Fix flake8 warnings

This fixes all the warnings emitted by flake8, mostly involving
qualified imports, import grouping, and indentation.

Change-Id: Ia45839f3e65e15a34e2a2793fd21b83e4fc891d7
Needed-By: I158ea10f104549dd4f0f3ff777b39feb5886642e
This commit is contained in:
Clint Adams 2015-10-25 19:34:27 +09:00
parent d123189bf8
commit 49d560de11
17 changed files with 83 additions and 84 deletions

View File

@ -14,16 +14,15 @@
# under the License.
from __future__ import print_function
from argparse import ArgumentParser
from datetime import datetime
from datetime import timedelta
from launchpadlib.launchpad import Launchpad
import pytz
import argparse
import datetime
import sys
import launchpadlib.launchpad
import pytz
# Parameters
parser = ArgumentParser(description="Update BPs on milestone closure")
parser = argparse.ArgumentParser(description="Update BPs on milestone closure")
parser.add_argument('project', help='The project to act on')
parser.add_argument('milestone', help='The milestone to set')
parser.add_argument("--target", action='store_true',
@ -36,8 +35,8 @@ args = parser.parse_args()
# Connect to Launchpad
print("Connecting to Launchpad...")
launchpad = Launchpad.login_with('openstack-releasing', args.test,
version='devel')
launchpad = launchpadlib.launchpad.Launchpad.login_with('openstack-releasing',
args.test, version='devel')
project = launchpad.projects[args.project]
milestone = project.getMilestone(name=args.milestone)
@ -47,7 +46,7 @@ series = milestone.series_target
# Get the blueprints
print("Retrieving blueprints...")
now = datetime.now(tz=pytz.utc)
now = datetime.datetime.now(tz=pytz.utc)
to_clear = []
to_series = []
to_target = []
@ -65,7 +64,7 @@ for bp in bps:
sys.stdout.write("\r%d%%" % int(count * 100 / numbps))
sys.stdout.flush()
if ((bp.implementation_status == 'Implemented') and
((now - bp.date_completed) < timedelta(days=92)) and
((now - bp.date_completed) < datetime.timedelta(days=92)) and
(not bp.milestone or not bp.milestone.date_targeted or
bp.milestone.date_targeted >= milestone.date_targeted)):
if bp not in seriesbps:

View File

@ -19,13 +19,13 @@
# under the License.
from __future__ import print_function
from argparse import ArgumentParser
from launchpadlib.launchpad import Launchpad
import argparse
import sys
import launchpadlib.launchpad
# Parse arguments
parser = ArgumentParser(description="Adjust blueprint series goal/milestones")
parser = argparse.ArgumentParser(description="Adjust blueprint series goal/milestones")
parser.add_argument('projectname', help='Project or projectgroup to act on')
parser.add_argument('seriesname', help='Series to act on')
parser.add_argument('--nokick', action='store_true',
@ -34,11 +34,11 @@ parser.add_argument('--dryrun', action='store_true',
help='Just show what would be done')
args = parser.parse_args()
kickmessage = "You should not set a milestone target unless the blueprint" \
" has been properly prioritized by the project drivers."
kickmessage = ("You should not set a milestone target unless the blueprint"
" has been properly prioritized by the project drivers.")
# Log into LP
lp = Launchpad.login_with('adjust-series-goal', 'production', version='devel')
lp = launchpadlib.launchpad.Launchpad.login_with('adjust-series-goal', 'production', version='devel')
try:
projectgroup = lp.project_groups[args.projectname]

View File

@ -31,14 +31,14 @@
# One bug_task is specific to one project
from argparse import ArgumentParser
from launchpadlib.launchpad import Launchpad
import argparse
import logging
import os
import launchpadlib.launchpad
# Parameters
parser = ArgumentParser(description="Cleanup Launchpad (LP) Bugs")
parser = argparse.ArgumentParser(description="Cleanup Launchpad (LP) Bugs")
parser.add_argument('projectname', help='The project to act on')
parser.add_argument("--test", action='store_const', const='staging',
default='production', help='Use LP staging server to test')
@ -53,7 +53,7 @@ args = parser.parse_args()
class LaunchpadCleanup(object):
"""Triggers specific cleanups in Launchpad"""
"""Triggers specific cleanups in Launchpad."""
def __init__(self, project_name, server="staging", dryrun=True,
ignoreable_bug_ids=[]):
@ -69,14 +69,14 @@ class LaunchpadCleanup(object):
cachedir = os.path.expanduser("~/.launchpadlib/cache/")
if not os.path.exists(cachedir):
os.makedirs(cachedir, 0o0700)
return Launchpad.login_with('openstack-cleanup', server, cachedir)
return launchpadlib.launchpad.Launchpad.login_with('openstack-cleanup', server, cachedir)
def cleanup_new_bugs_with_assignee(self):
"""A new bug with an assignee is in progress"""
"""A new bug with an assignee is in progress."""
logger.info("Cleanup new bugs with an assignee")
message = "@%s:\n\nSince you are set as assignee, I switch the " \
"status to 'In Progress'."
message = ("@%s:\n\nSince you are set as assignee, I switch the "
"status to 'In Progress'.")
subject = "Cleanup"
project = self.client.projects[self.project_name]

View File

@ -19,11 +19,11 @@
from __future__ import print_function
import argparse
from launchpadlib.launchpad import Launchpad
from lazr.restfulclient.errors import BadRequest
from lazr.restfulclient.errors import ServerError
import sys
import launchpadlib.launchpad
import lazr.restfulclient.errors
# Parameters
parser = argparse.ArgumentParser(description="Consolidate milestone pages"
" at release time")
@ -47,8 +47,8 @@ statuses = ['New', 'Incomplete', 'Confirmed', 'Triaged', 'In Progress',
# Connect to Launchpad
print("Connecting to Launchpad...")
launchpad = Launchpad.login_with('openstack-releasing', args.test,
version='devel')
launchpad = launchpadlib.launchpad.Launchpad.login_with('openstack-releasing',
args.test, version='devel')
# Retrieve FixCommitted bugs
print("Retrieving %s project..." % args.project)
@ -128,14 +128,14 @@ for milestone in milestones:
newbt.lp_save()
print(" - copytasked")
bugsleft = True
except BadRequest:
except lazr.restfulclient.errors.BadRequest:
print(" - task already exists, skipping")
else:
bt.milestone = release
try:
bt.lp_save()
print(" - released")
except ServerError as e:
except lazr.restfulclient.errors.ServerError as e:
print(" - TIMEOUT during save !",)
failed.add(bug.id)
bugsleft = True

View File

@ -22,7 +22,7 @@ import argparse
import string
import sys
from launchpadlib.launchpad import Launchpad
import launchpadlib.launchpad
def abort(code, errmsg):
@ -42,8 +42,8 @@ args = parser.parse_args()
# Connect to LP
try:
launchpad = Launchpad.login_anonymously('openstack-releasing',
'production')
launchpad = launchpadlib.launchpad.Launchpad.login_anonymously('openstack-releasing',
'production')
except Exception as error:
abort(2, 'Could not connect to Launchpad: ' + str(error))

View File

@ -18,12 +18,13 @@
# under the License.
from __future__ import print_function
from argparse import ArgumentParser
from launchpadlib.launchpad import Launchpad
from lazr.restfulclient.errors import ServerError
import argparse
import launchpadlib.launchpad
import lazr.restfulclient.errors
# Parameters
parser = ArgumentParser(description="Change Launchpad bugs in bulk")
parser = argparse.ArgumentParser(description="Change Launchpad bugs in bulk")
parser.add_argument('projectname', help='The project to act on')
bugsfrom = parser.add_mutually_exclusive_group()
bugsfrom.add_argument('--status', default='Fix Committed',
@ -41,7 +42,7 @@ args = parser.parse_args()
# Connect to Launchpad
print("Connecting to Launchpad...")
launchpad = Launchpad.login_with('openstack-releasing', args.test)
launchpad = launchpadlib.launchpad.Launchpad.login_with('openstack-releasing', args.test)
# Retrieve bugs
print("Retrieving project...")
@ -95,7 +96,7 @@ while changes:
b.lp_save()
if (args.settarget and not b.milestone) or args.fixrelease:
changes = True
except ServerError as e:
except lazr.restfulclient.errors.ServerError as e:
print(" - TIMEOUT during save !", end='')
failed.add(bug.id)
except Exception as e:

View File

@ -21,7 +21,7 @@ from __future__ import unicode_literals
import sys
from launchpadlib.launchpad import Launchpad
import launchpadlib.launchpad
def abort(code, errmsg):
@ -33,6 +33,6 @@ def main():
# Connect to LP
print("connecting to launchpad")
try:
Launchpad.login_with('openstack-releasing', 'production')
launchpadlib.launchpad.Launchpad.login_with('openstack-releasing', 'production')
except Exception as error:
abort(2, 'Could not connect to Launchpad: ' + str(error))

View File

@ -19,7 +19,7 @@ import argparse
import datetime
import sys
from launchpadlib.launchpad import Launchpad
import launchpadlib.launchpad
def abort(code, errmsg):
@ -40,7 +40,7 @@ def main():
# Connect to LP
print("Connecting to Launchpad...")
try:
launchpad = Launchpad.login_with('openstack-releasing', args.test)
launchpad = launchpadlib.launchpad.Launchpad.login_with('openstack-releasing', args.test)
except Exception as error:
abort(2, 'Could not connect to Launchpad: ' + str(error))
@ -59,9 +59,9 @@ def main():
# Mark milestone released
print("Marking %s released..." % milestone)
rel_notes = "This is another milestone (%s) on the road to %s %s." \
% (milestone, args.project.capitalize(),
lp_milestone.series_target.name)
rel_notes = ("This is another milestone (%s) on the road to %s %s." %
(milestone, args.project.capitalize(),
lp_milestone.series_target.name))
if not lp_milestone.release:
lp_milestone.createProductRelease(

View File

@ -22,7 +22,7 @@ from __future__ import unicode_literals
import argparse
import sys
from launchpadlib.launchpad import Launchpad
import launchpadlib.launchpad
def abort(code, errmsg):
@ -41,7 +41,7 @@ def main():
# Connect to LP
print("connecting to launchpad")
try:
launchpad = Launchpad.login_with('openstack-releasing', 'production')
launchpad = launchpadlib.launchpad.Launchpad.login_with('openstack-releasing', 'production')
except Exception as error:
abort(2, 'Could not connect to Launchpad: ' + str(error))

View File

@ -21,7 +21,7 @@ from __future__ import print_function
import argparse
import sys
from launchpadlib.launchpad import Launchpad
import launchpadlib.launchpad
def abort(code, errmsg):
@ -42,7 +42,7 @@ def main():
# Connect to Launchpad
print("Connecting to Launchpad...")
try:
launchpad = Launchpad.login_with('openstack-releasing', args.test)
launchpad = launchpadlib.launchpad.Launchpad.login_with('openstack-releasing', args.test)
except Exception as error:
abort(2, 'Could not connect to Launchpad: ' + str(error))

View File

@ -20,9 +20,9 @@
from __future__ import print_function
import argparse
import sys
import yaml
from launchpadlib.launchpad import Launchpad
import launchpadlib.launchpad
import yaml
def abort(code, errmsg):
@ -43,7 +43,7 @@ with open(args.configfile) as f:
# Connect to LP
print("Connecting to Launchpad...")
try:
launchpad = Launchpad.login_with('openstack-releasing', 'production')
launchpad = launchpadlib.launchpad.Launchpad.login_with('openstack-releasing', 'production')
except Exception as error:
abort(2, 'Could not connect to Launchpad: ' + str(error))

View File

@ -87,8 +87,8 @@ class Repository(object):
@property
def code_related(self):
return not (self.name.endswith('-specs')
or 'cookiecutter' in self.name)
return not (self.name.endswith('-specs') or
'cookiecutter' in self.name)
def get_repositories(team_data, team_name=None, deliverable_name=None,

View File

@ -14,7 +14,6 @@
import textwrap
from oslotest import base
import yaml
from releasetools import governance

View File

@ -18,8 +18,9 @@
# under the License.
import argparse
from launchpadlib.launchpad import Launchpad
import re
import launchpadlib.launchpad
import requests
# Parameters
@ -42,8 +43,8 @@ args = parser.parse_args()
# Log into Launchpad
launchpad = Launchpad.login_with('openstack-releasing', args.test,
version='devel')
launchpad = launchpadlib.launchpad.Launchpad.login_with('openstack-releasing',
args.test, version='devel')
# Validate project
project = launchpad.projects[args.project]

View File

@ -20,10 +20,9 @@ import json
import logging
import optparse
import os
import subprocess
import sys
from subprocess import check_output
GERRIT_USER = None
GERRIT_HOST = None
DRY_RUN = False
@ -63,7 +62,7 @@ def run_command(cmd):
if 'query' in _cmd:
_cmd += ['--format', 'json']
res = check_output(_cmd)
res = subprocess.check_output(_cmd)
if 'query' not in cmd:
return res

View File

@ -27,7 +27,7 @@ import tempfile
import time
import urllib
from launchpadlib.launchpad import Launchpad
import launchpadlib.launchpad
def abort(code, errmsg):
@ -62,7 +62,7 @@ if args.deliverable is None:
# Connect to LP
print("Connecting to Launchpad...")
try:
launchpad = Launchpad.login_with('openstack-releasing', args.test)
launchpad = launchpadlib.launchpad.Launchpad.login_with('openstack-releasing', args.test)
except Exception as error:
abort(2, 'Could not connect to Launchpad: ' + str(error))
@ -99,13 +99,13 @@ if not args.nop:
print("Downloading tarball...")
tmpdir = tempfile.mkdtemp()
if args.tarball is None:
base_tgz = "%s-%s%s.tar.gz" % \
(args.deliverable, args.version, preversion)
base_tgz = ("%s-%s%s.tar.gz" %
(args.deliverable, args.version, preversion))
else:
base_tgz = "%s-%s.tar.gz" % \
(args.deliverable, args.tarball)
url_tgz = "http://tarballs.openstack.org/%s/%s" % \
(args.deliverable, base_tgz)
base_tgz = ("%s-%s.tar.gz" %
(args.deliverable, args.tarball))
url_tgz = ("http://tarballs.openstack.org/%s/%s" %
(args.deliverable, base_tgz))
tgz = os.path.join(tmpdir, base_tgz)
(tgz, message) = urllib.urlretrieve(url_tgz, filename=tgz)
@ -137,11 +137,11 @@ if args.nop:
rel_notes = ""
else:
if args.milestone:
rel_notes = "This is another milestone (%s) on the road to %s %s." \
% (args.milestone, args.project.capitalize(), args.version)
rel_notes = ("This is another milestone (%s) on the road to %s %s." %
(args.milestone, args.project.capitalize(), args.version))
else:
rel_notes = "This is %s %s release." \
% (args.project.capitalize(), args.version)
rel_notes = ("This is %s %s release." %
(args.project.capitalize(), args.version))
if lp_milestone.release:
lp_release = lp_milestone.release
@ -158,14 +158,14 @@ lp_milestone.lp_save()
if not args.nop:
# Upload file
print("Uploading release files...")
final_tgz = "%s-%s%s.tar.gz" % \
(args.deliverable, args.version, preversion)
final_tgz = ("%s-%s%s.tar.gz" %
(args.deliverable, args.version, preversion))
if args.milestone:
description = '%s "%s" milestone' % \
(args.deliverable.capitalize(), args.milestone)
description = ('%s "%s" milestone' %
(args.deliverable.capitalize(), args.milestone))
else:
description = '%s %s release' % \
(args.deliverable.capitalize(), args.version)
description = ('%s %s release' %
(args.deliverable.capitalize(), args.version))
lp_file = lp_release.add_file(file_type='Code Release Tarball',
description=description,
@ -179,8 +179,8 @@ if not args.nop:
# Check LP-reported MD5
print("Checking MD5s...")
time.sleep(2)
result_md5_url = "http://launchpad.net/%s/+download/%s/+md5" % \
(lp_release.self_link[30:], final_tgz)
result_md5_url = ("http://launchpad.net/%s/+download/%s/+md5" %
(lp_release.self_link[30:], final_tgz))
result_md5_file = urllib.urlopen(result_md5_url)
result_md5 = result_md5_file.read().split()[0]
result_md5_file.close()

View File

@ -20,9 +20,9 @@
from __future__ import print_function
import argparse
import re
import requests
import time
import requests
# Turn off warnings for insecure sites, since we'll be talking to
# cloud instances anyway.