diff --git a/modules/graphite/files/graphite-init-db.py b/modules/graphite/files/graphite-init-db.py index 1a83632b4b..45e01d557a 100644 --- a/modules/graphite/files/graphite-init-db.py +++ b/modules/graphite/files/graphite-init-db.py @@ -33,8 +33,8 @@ PASS = config.get('admin', 'password') management.call_command('syncdb', interactive=False) try: - auth_models.User.objects.get(username=USER) - print 'Admin user already exists.' + auth_models.User.objects.get(username=USER) + print 'Admin user already exists.' except auth_models.User.DoesNotExist: - print 'Creating admin user' - auth_models.User.objects.create_superuser(USER, EMAIL, PASS) + print 'Creating admin user' + auth_models.User.objects.create_superuser(USER, EMAIL, PASS) diff --git a/modules/jenkins/files/slave_scripts/subunit2html.py b/modules/jenkins/files/slave_scripts/subunit2html.py index e33df3bba7..96c289f4c8 100755 --- a/modules/jenkins/files/slave_scripts/subunit2html.py +++ b/modules/jenkins/files/slave_scripts/subunit2html.py @@ -93,10 +93,10 @@ class TemplateData(object): """ STATUS = { - 0: 'pass', - 1: 'fail', - 2: 'error', - 3: 'skip', + 0: 'pass', + 1: 'fail', + 2: 'error', + 3: 'skip', } DEFAULT_TITLE = 'Unit Test Report' @@ -536,9 +536,9 @@ class HtmlOutput(testtools.TestResult): a_lines = [] for name, value in report_attrs: line = TemplateData.HEADING_ATTRIBUTE_TMPL % dict( - name=saxutils.escape(name), - value=saxutils.escape(value), - ) + name=saxutils.escape(name), + value=saxutils.escape(value), + ) a_lines.append(line) heading = TemplateData.HEADING_TMPL % dict( title=saxutils.escape(TemplateData.DEFAULT_TITLE), @@ -590,7 +590,7 @@ class HtmlOutput(testtools.TestResult): report = TemplateData.REPORT_TMPL % dict( test_list=''.join(rows), count=str(self.success_count + self.failure_count + - self.error_count + self.skip_count), + self.error_count + self.skip_count), Pass=str(self.success_count), fail=str(self.failure_count), error=str(self.error_count), diff --git a/modules/jenkins/files/slave_scripts/tardiff.py b/modules/jenkins/files/slave_scripts/tardiff.py index 6faaee015c..8a66f6d21c 100755 --- a/modules/jenkins/files/slave_scripts/tardiff.py +++ b/modules/jenkins/files/slave_scripts/tardiff.py @@ -25,8 +25,9 @@ class OpenStackTarDiff: def check_env(self): """ exit if dist/ directory already exists """ if not self.package and os.path.exists(self.dist_dir): - self.error("dist directory '%s' exist. Please remove it before " \ - "running this script" % self.dist_dir) + self.error( + "dist directory '%s' exist. Please remove it before " + "running this script" % self.dist_dir) def validate_args(self): try: @@ -108,8 +109,8 @@ class OpenStackTarDiff: """ read file list from git archive """ git_tar = os.path.join(os.getcwd(), '%s.tar' % self.project_name) try: - a_cmd = "git archive -o %s HEAD --prefix=%s" % \ - (git_tar, self.prefix) + a_cmd = ("git archive -o %s HEAD --prefix=%s" % + (git_tar, self.prefix)) self.debug("executing command '%s'" % a_cmd) (status, out) = commands.getstatusoutput(a_cmd) if status != 0: @@ -118,7 +119,7 @@ class OpenStackTarDiff: if os.path.exists(git_tar): os.unlink(git_tar) self.error('git archive failed: %s' % out) - except Exception, err: + except Exception as err: if os.path.exists(git_tar): os.unlink(git_tar) self.error('git archive failed: %s' % err) @@ -132,7 +133,7 @@ class OpenStackTarDiff: self.git_files = out.split('\n') self.debug("Removing git archive ... %s ..." % git_tar) os.remove(git_tar) - except Exception, err: + except Exception as err: self.error('unable to read tar: %s' % err) def get_sdist_files(self): @@ -144,7 +145,7 @@ class OpenStackTarDiff: (status, out) = commands.getstatusoutput(sdist_cmd) if status != 0: self.error("command '%s' failed" % sdist_cmd) - except Exception, err: + except Exception as err: self.error("command '%s' failed" % (sdist_cmd, err)) self.package = os.listdir(self.dist_dir)[0] @@ -157,7 +158,7 @@ class OpenStackTarDiff: self.error("command '%s' failed" % tar_cmd) #self.debug(out) self.sdist_files = out.split('\n') - except Exception, err: + except Exception as err: self.error("command '%s' failed: %s" % (tar_cmd, err)) def debug(self, msg): @@ -175,8 +176,7 @@ class OpenStackTarDiff: stream = sys.stdout stream.write("usage: %s [--help|h] [-v] " "[-p|--package=sdist_package.tar.gz] " - "-e|--exclude=filename\n" \ - % os.path.basename(sys.argv[0])) + "-e|--exclude=filename\n" % os.path.basename(sys.argv[0])) if msg: stream.write("\nERROR: " + msg + "\n") exitCode = 1 diff --git a/modules/openstack_project/files/logs/htmlify-screen-log.py b/modules/openstack_project/files/logs/htmlify-screen-log.py index c59fcc946d..d92f33da2e 100755 --- a/modules/openstack_project/files/logs/htmlify-screen-log.py +++ b/modules/openstack_project/files/logs/htmlify-screen-log.py @@ -35,7 +35,7 @@ SEVS = { 'TRACE': 4, 'WARN': 5, 'ERROR': 6 - } +} def _html_close(): @@ -96,13 +96,15 @@ def escape_html(line): def link_timestamp(line): m = re.match( - '([^\']+)\'>)?(?P%s)(?P.*)' % DATEFMT, - line) + '([^\']+)\'>)?(?P%s)(?P.*)' + % DATEFMT, line) if m: date = "_" + re.sub('[\s\:\.]', '_', m.group('date')) - return "%s%s\n" % ( - m.group('class'), date, date, date, m.group('date'), m.group('rest')) + return ("" + "%s%s\n" % ( + m.group('class'), date, date, date, + m.group('date'), m.group('rest'))) else: return line diff --git a/modules/openstack_project/files/logstash/log-gearman-client.py b/modules/openstack_project/files/logstash/log-gearman-client.py index 33bf208ab0..d0a360bc10 100644 --- a/modules/openstack_project/files/logstash/log-gearman-client.py +++ b/modules/openstack_project/files/logstash/log-gearman-client.py @@ -103,7 +103,7 @@ class EventProcessor(threading.Thread): fields = self._parse_fields(event, fileopts['name']) log_dir = self._get_log_dir(event) source_url = fileopts.get('source-url', self.source_url) + '/' + \ - os.path.join(log_dir, fileopts['name']) + os.path.join(log_dir, fileopts['name']) fields["log_url"] = source_url out_event = {} out_event["fields"] = fields @@ -134,8 +134,9 @@ class Server(object): gearclient = gear.Client() gearclient.addServer('localhost') gearclient.waitForServer() - processor = EventProcessor(publisher, gearclient, - self.config['source-files'], self.source_url) + processor = EventProcessor( + publisher, gearclient, + self.config['source-files'], self.source_url) self.processors.append(processor) def main(self): diff --git a/modules/openstack_project/files/logstash/log-gearman-worker.py b/modules/openstack_project/files/logstash/log-gearman-worker.py index 297c29ba68..39f3d4b2c6 100644 --- a/modules/openstack_project/files/logstash/log-gearman-worker.py +++ b/modules/openstack_project/files/logstash/log-gearman-worker.py @@ -161,7 +161,7 @@ class LogRetriever(threading.Thread): try: logging.debug(str(backoff) + " Retrying fetch of: " + source_url + "?level=INFO") - logging.debug("Fetching bytes=" + str(content_len) + '-') + logging.debug("Fetching bytes=" + str(content_len) + '-') req = urllib2.Request(source_url + "?level=INFO") req.add_header('Range', 'bytes=' + str(content_len) + '-') r = urllib2.urlopen(req) diff --git a/modules/openstack_project/files/nodepool/scripts/devstack-cache.py b/modules/openstack_project/files/nodepool/scripts/devstack-cache.py index 1cb3e14ab1..ec298f6efb 100755 --- a/modules/openstack_project/files/nodepool/scripts/devstack-cache.py +++ b/modules/openstack_project/files/nodepool/scripts/devstack-cache.py @@ -20,8 +20,9 @@ import os import sys import subprocess -DEVSTACK=os.path.expanduser('~/workspace-cache/devstack') -CACHEDIR=os.path.expanduser('~/cache/files') +DEVSTACK = os.path.expanduser('~/workspace-cache/devstack') +CACHEDIR = os.path.expanduser('~/cache/files') + def run_local(cmd, status=False, cwd='.', env={}): print "Running:", cmd diff --git a/modules/openstack_project/files/zuul/layout.yaml b/modules/openstack_project/files/zuul/layout.yaml index 957d33fbe5..a71162004d 100644 --- a/modules/openstack_project/files/zuul/layout.yaml +++ b/modules/openstack_project/files/zuul/layout.yaml @@ -501,11 +501,13 @@ projects: check: - config-compare-xml - gate-config-layout + - gate-config-pep8 - gate-config-puppet-lint - gate-config-puppet-syntax - gate-ci-docs gate: - gate-config-layout + - gate-config-pep8 - gate-config-puppet-lint - gate-config-puppet-syntax post: diff --git a/modules/openstack_project/files/zuul/openstack_functions.py b/modules/openstack_project/files/zuul/openstack_functions.py index 15275dbeaa..1ef5205288 100644 --- a/modules/openstack_project/files/zuul/openstack_functions.py +++ b/modules/openstack_project/files/zuul/openstack_functions.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. + def set_log_url(item, job, params): if hasattr(item.change, 'refspec'): path = "%s/%s/%s/%s" % ( diff --git a/tools/atc/diff.py b/tools/atc/diff.py index 7949285d50..3ab24fbe60 100755 --- a/tools/atc/diff.py +++ b/tools/atc/diff.py @@ -13,4 +13,3 @@ writer = csv.writer(open(sys.argv[3], 'w')) for row in csv.reader(open(sys.argv[2])): if row[0] not in old: writer.writerow(row) - diff --git a/tools/atc/email-stats.py b/tools/atc/email-stats.py index f332e2b01b..a8b805b723 100755 --- a/tools/atc/email-stats.py +++ b/tools/atc/email-stats.py @@ -19,13 +19,10 @@ # Soren Hansen wrote the original version of this script. # James Blair hacked it up to include email addresses from gerrit. -import calendar import datetime import json import optparse import paramiko -from pprint import pprint -import sys import csv import re @@ -33,6 +30,7 @@ MAILTO_RE = re.compile('mailto:(.*)') USERNAME_RE = re.compile('username:(.*)') accounts = {} + class Account(object): def __init__(self, num): self.num = num @@ -40,6 +38,7 @@ class Account(object): self.emails = [] self.username = None + def get_account(num): a = accounts.get(num) if not a: @@ -78,8 +77,10 @@ for a in accounts.values(): atcs = [] optparser = optparse.OptionParser() -optparser.add_option('-p', '--project', default='nova', help='Project to generate stats for') -optparser.add_option('-o', '--output', default='out.csv', help='Output file') +optparser.add_option( + '-p', '--project', default='nova', help='Project to generate stats for') +optparser.add_option( + '-o', '--output', default='out.csv', help='Output file') options, args = optparser.parse_args() QUERY = "project:%s status:merged" % options.project @@ -87,9 +88,11 @@ QUERY = "project:%s status:merged" % options.project client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.load_system_host_keys() -client.connect('review.openstack.org', port=29418, key_filename='/home/corvus/.ssh/id_rsa', username='CHANGME') -stdin, stdout, stderr = client.exec_command('gerrit query %s --all-approvals --format JSON' % - QUERY) +client.connect( + 'review.openstack.org', port=29418, + key_filename='/home/corvus/.ssh/id_rsa', username='CHANGME') +stdin, stdout, stderr = client.exec_command( + 'gerrit query %s --all-approvals --format JSON' % QUERY) changes = [] done = False @@ -130,7 +133,9 @@ while not done: if approved and account not in atcs: atcs.append(account) if not done: - stdin, stdout, stderr = client.exec_command('gerrit query %s resume_sortkey:%s --all-approvals --format JSON' % (QUERY, last_sortkey)) + stdin, stdout, stderr = client.exec_command( + 'gerrit query %s resume_sortkey:%s --all-approvals' + ' --format JSON' % (QUERY, last_sortkey)) print 'project: %s' % options.project print 'examined %s changes' % count diff --git a/tools/invite2summit/send.py b/tools/invite2summit/send.py index 0e30159291..567c6a8561 100644 --- a/tools/invite2summit/send.py +++ b/tools/invite2summit/send.py @@ -53,7 +53,8 @@ if __name__ == '__main__': for committer, code in zip(committers, codes): if settings.EMAIL_USE_SSL: - session = smtplib.SMTP_SSL(settings.EMAIL_HOST, settings.EMAIL_PORT) + session = smtplib.SMTP_SSL( + settings.EMAIL_HOST, settings.EMAIL_PORT) else: session = smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT) if settings.EMAIL_USE_TLS: @@ -66,10 +67,8 @@ if __name__ == '__main__': code=code, signature=settings.EMAIL_SIGNATURE) msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s" % ( - settings.EMAIL_FROM, - ','.join(committer.emails), - settings.EMAIL_SUBJECT, - content) + settings.EMAIL_FROM, ','.join(committer.emails), + settings.EMAIL_SUBJECT, content) session.sendmail(settings.EMAIL_FROM, committer.emails, msg) print "%s,ATC,%s" % (code, committer.name) diff --git a/tox.ini b/tox.ini index f8a44cdfb1..e137686c5a 100644 --- a/tox.ini +++ b/tox.ini @@ -16,5 +16,5 @@ commands = {posargs} [flake8] show-source = True -exclude = .tox,modules +exclude = .tox ignore = E125,H