Browse Source

Making sure we're ready for python3

Adds py37 to the env list and switches pep8 python to
python3, including necessary changes to make pylint
and pep8 checks happy in python3:

* Unpins pylint, as 1.4.5 explodes (exception) when trying
  to check our code.

* Unpins flake8-import-order from an old version.

* Stops making use of the builtin cmp function, and replaces
  it with the recommended (a > b) - (a < b).

* Disables one py3 specific warning, since it's still necessary
  for python2 (useless-object-inheritance)

* Removes a non existing argument in netprobe parser (version).

* Inserts an additional blank line between __future__ imports
  and stdlib imports.

Change-Id: If4a45108fe93080f9967e2ac26d681b8dd5c7fc2
Miguel Angel Ajo 6 months ago
parent
commit
20645e4f9a
5 changed files with 14 additions and 7 deletions
  1. 2
    1
      .pylintrc
  2. 7
    1
      oslogmerger/oslogmerger.py
  3. 1
    1
      oslogmerger/probes/netprobe.py
  4. 2
    2
      test-requirements.txt
  5. 2
    2
      tox.ini

+ 2
- 1
.pylintrc View File

@@ -82,7 +82,8 @@ disable=
82 82
  too-many-nested-blocks,
83 83
  too-many-public-methods,
84 84
  too-many-return-statements,
85
- too-many-statements
85
+ too-many-statements,
86
+ useless-object-inheritance
86 87
 
87 88
 [BASIC]
88 89
 # Variable names can be 1 to 31 characters long, with lowercase and underscores

+ 7
- 1
oslogmerger/oslogmerger.py View File

@@ -14,6 +14,7 @@
14 14
 #    under the License.
15 15
 
16 16
 from __future__ import print_function
17
+
17 18
 import argparse
18 19
 from datetime import datetime, timedelta
19 20
 import hashlib
@@ -110,7 +111,8 @@ class LogEntry(object):
110 111
         self.data += EXTRALINES_PADDING + line
111 112
 
112 113
     def __cmp__(self, other):
113
-        return cmp(self.dt, other.dt) * 2 + cmp(self.alias, other.alias)
114
+        return (self._cmp(self.dt, other.dt) * 2 +
115
+                self._cmp(self.alias, other.alias))
114 116
 
115 117
     def __lt__(self, other):
116 118
         return self.dt < other.dt or (self.dt == other.dt and
@@ -119,6 +121,10 @@ class LogEntry(object):
119 121
     def __str__(self):
120 122
         return '%s [%s] %s' % (self.dt_str, self.alias, self.data.rstrip('\n'))
121 123
 
124
+    @staticmethod
125
+    def _cmp(a, b):
126
+        return (a > b) - (a < b)
127
+
122 128
 
123 129
 class LogParser(object):
124 130
     def __init__(self, filename, cfg):

+ 1
- 1
oslogmerger/probes/netprobe.py View File

@@ -135,7 +135,7 @@ the tcpdumps goes in a single openstack-like log.
135 135
 
136 136
     general_epilog = ""
137 137
 
138
-    parser = MyParser(description=general_description, version=__version__,
138
+    parser = MyParser(description=general_description,
139 139
                       epilog=general_epilog, argument_default='',
140 140
                       formatter_class=argparse.RawTextHelpFormatter)
141 141
     parser.add_argument('--netns-re', '-n', dest='netns_regex',

+ 2
- 2
test-requirements.txt View File

@@ -2,10 +2,10 @@
2 2
 # of appearance. Changing the order has an impact on the overall integration
3 3
 # process, which may cause wedges in the gate later.
4 4
 flake8
5
-flake8-import-order==0.12 # LGPLv3
5
+flake8-import-order # LGPLv3
6 6
 mock>=2.0.0 # BSD
7 7
 python-subunit>=0.0.18 # Apache-2.0/BSD
8 8
 testtools>=1.4.0 # MIT
9 9
 oslotest>=1.10.0 # Apache-2.0
10 10
 os-testr>=1.0.0 # Apache-2.0
11
-pylint==1.4.5 # GPLv2
11
+pylint # GPLv2

+ 2
- 2
tox.ini View File

@@ -1,5 +1,5 @@
1 1
 [tox]
2
-envlist = py35,py36,py27,pep8
2
+envlist = py35,py36,py37,py27,pep8
3 3
 minversion = 2.3.2
4 4
 skipsdist = True
5 5
 
@@ -24,7 +24,7 @@ setenv = OS_TEST_TIMEOUT={env:OS_TEST_TIMEOUT:180}
24 24
 commands = false
25 25
 
26 26
 [testenv:pep8]
27
-basepython = python2.7
27
+basepython = python3
28 28
 deps =
29 29
   {[testenv]deps}
30 30
 commands=

Loading…
Cancel
Save