Ori.livneh has submitted this change and it was merged.

Change subject: rolematcher.py: Fix PEP8 violations
......................................................................


rolematcher.py: Fix PEP8 violations

* E265 block comment should start with '# '
* E501 line too long (n > 100 characters)
* F821 undefined name 'httplib'
* F841 local variable 'elements' is assigned to but never used

Change-Id: I1179884cbfa525d26599383243c6262b7d6d97af
---
M modules/udp2log/files/rolematcher.py
1 file changed, 14 insertions(+), 8 deletions(-)

Approvals:
  Ori.livneh: Verified; Looks good to me, approved



diff --git a/modules/udp2log/files/rolematcher.py 
b/modules/udp2log/files/rolematcher.py
index f77bd7d..ac02b86 100644
--- a/modules/udp2log/files/rolematcher.py
+++ b/modules/udp2log/files/rolematcher.py
@@ -1,5 +1,5 @@
-# -*- coding: utf-8 -*-
 #!/usr/bin/env python
+# -*- coding: utf-8 -*-
 
 '''
 This script parses the packet-loss.log file and for each server entry
@@ -15,10 +15,11 @@
 PacketLossLogTailer.py is the regular point of entry.
 '''
 
-import re
-import urllib2
+import httplib
 import json
+import re
 import sys
+import urllib2
 
 
 numbers = re.compile('([0-9]+)')
@@ -90,7 +91,8 @@
     for row in data:
         # pybal outputs python dictionaries but we are not going to use eval(),
         # hence make the dictionary JSON compatible.
-        row = row.strip().replace('"', '').replace("'", '"').replace('True', 
'true').replace('False', 'false')
+        row = row.strip().replace('"', '').replace("'", '"')
+        row = row.replace('True', 'true').replace('False', 'false')
         if row == '':
             sections.append(section)
             section = []
@@ -160,7 +162,6 @@
 
 def init():
     matchers = []
-    elements = {}
     for dc, roles in dcs.iteritems():
         for role in roles:
             url = '/'.join([base_url, dc, role])
@@ -172,20 +173,25 @@
                     start, end = determine_start_end_range(section, hostname)
                     prefix = determine_hostname_prefix(hostname)
                     suffix = determine_hostname_suffix(hostname)
-                    matcher = RoleMatcher('%s_%s_%s' % (dc, role, prefix), 
'%s([0-9]+)\.%s' % (prefix, suffix), start, end)
+                    matcher = RoleMatcher(
+                        '%s_%s_%s' % (dc, role, prefix),
+                        '%s([0-9]+)\.%s' % (prefix, suffix), start, end)
                     matchers.append(matcher)
     return matchers
 
 
 if __name__ == '__main__':
     if len(sys.argv) != 2:
-        print 'Please specify path to packetloss log file, call this file only 
for testing purposes.'
+        print ('Please specify path to packetloss log file, '
+               'call this file only for testing purposes.')
         sys.exit(-1)
     else:
         path = sys.argv[1]
 
     matchers = init()
-    line_matcher = re.compile('^\[(?P<date>[^]]+)\] (?P<server>[^ ]+) lost: 
\((?P<percentloss>[^ ]+) \+\/- (?P<margin>[^)]+)\)%')
+    line_matcher = re.compile(
+        r'^\[(?P<date>[^]]+)\] (?P<server>[^ ]+) '
+        r'lost: \((?P<percentloss>[^ ]+) \+\/- (?P<margin>[^)]+)\)%')
     fh = open(path, 'r')
     for line in fh:
         regMatch = line_matcher.match(line)

-- 
To view, visit https://gerrit.wikimedia.org/r/291177
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1179884cbfa525d26599383243c6262b7d6d97af
Gerrit-PatchSet: 4
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: BryanDavis <bda...@wikimedia.org>
Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to