From b3c5204b59d34541e37c0a412e6c42d897389e89 Mon Sep 17 00:00:00 2001 From: Danny Kukawka Date: Mon, 26 Jul 2010 16:46:21 +0200 Subject: [PATCH] fixed serveral warnings from pychecker.py Fixed serveral warnings from pychecker.py like such: - Parameter ($) not used - Local variable ($) not used Including fixes like: - remove not needed imports - don't read apiurl in core.py from config if already available via function parameter - delPerson(): check for user as e.g. in addPerson() --- osc/cmdln.py | 4 ++-- osc/commandline.py | 14 +++++--------- osc/core.py | 19 +++++++------------ setup.py | 2 +- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/osc/cmdln.py b/osc/cmdln.py index 27375ac9..cfce1efb 100644 --- a/osc/cmdln.py +++ b/osc/cmdln.py @@ -429,7 +429,7 @@ class RawCmdln(cmd.Cmd): cmdln.py). """ import sys - type, exc, traceback = sys.exc_info() + exc_type, exc, traceback = sys.exc_info() if isinstance(exc, CmdlnUserError): msg = "%s %s: %s\nTry '%s help %s' for info.\n"\ % (self.name, argv[0], exc, self.name, argv[0]) @@ -558,7 +558,7 @@ class RawCmdln(cmd.Cmd): do_help.aliases = ["?"] - def do_man(self, argv): + def do_man(self): """${cmd_name}: generates a man page usage: diff --git a/osc/commandline.py b/osc/commandline.py index 321ca18b..7131ca4b 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -8,7 +8,6 @@ from core import * import cmdln import conf import oscerr -import urlgrabber.progress from optparse import SUPPRESS_HELP MAN_HEADER = r""".TH %(ucname)s "1" "%(date)s" "%(name)s %(version)s" "User Commands" @@ -955,8 +954,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. 'superseded by %s' % result, result) if opts.supersede: - r = change_request_state(conf.config['apiurl'], - opts.supersede, 'superseded', opts.message or '', result) + change_request_state(conf.config['apiurl'], opts.supersede, 'superseded', + opts.message or '', result) print 'created request id', result @@ -985,7 +984,6 @@ Please submit there instead, or use --nodevelproject to force direct submission. actionxml="" apiurl = self.get_api_url() if len(args) == 0 and is_project_dir(os.getcwd()): - import cgi # submit requests for multiple packages are currently handled via multiple requests # They could be also one request with multiple actions, but that avoids to accepts parts of it. project = store_read_project(os.curdir) @@ -1140,8 +1138,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. 'superseded by %s' % result, result) if opts.supersede: - r = change_request_state(apiurl, - opts.supersede, 'superseded', '', result) + change_request_state(apiurl, opts.supersede, 'superseded', '', result) #print 'created request id', result return actionxml @@ -1702,7 +1699,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. if subcmd == 'review': if cmd in ['accept', 'decline', 'new']: r = change_review_state(conf.config['apiurl'], - reqid, state_map[cmd], conf.config['user'], '', opts.message or '') + reqid, state_map[cmd], conf.config['user'], opts.message or '') print r # Change state of entire request elif cmd in ['reopen', 'accept', 'decline', 'wipe', 'revoke']: @@ -4196,7 +4193,6 @@ Please submit there instead, or use --nodevelproject to force direct submission. args = slash_split(args) apiurl = self.get_api_url() - meta = None if len(args) == 0: wd = os.curdir @@ -5621,7 +5617,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. ${cmd_option_list} """ - from subprocess import Popen, PIPE + from subprocess import Popen if not os.path.exists('/usr/lib/build/vc'): print >>sys.stderr, 'Error: you need build.rpm with version 2009.04.17 or newer' diff --git a/osc/core.py b/osc/core.py index b748ba35..3121ad95 100644 --- a/osc/core.py +++ b/osc/core.py @@ -2126,9 +2126,9 @@ def init_project_dir(apiurl, dir, project): store_write_initial_packages(dir, project, []) def init_package_dir(apiurl, project, package, dir, revision=None, files=True, limit_size=None, meta=False): - if not os.path.isdir(store): - os.mkdir(store) - os.chdir(store) + if not os.path.isdir(dir): + os.mkdir(dir) + os.chdir(dir) f = open('_project', 'w') f.write(project + '\n') f.close() @@ -2798,7 +2798,7 @@ def get_request(apiurl, reqid): return r -def change_review_state(apiurl, reqid, newstate, by_user='', by_group='', message='', supersed=''): +def change_review_state(apiurl, reqid, newstate, by_user='', message='', supersed=''): u = makeurl(apiurl, ['request', reqid], query={'cmd': 'changereviewstate', 'newstate': newstate, 'by_user': by_user, 'superseded_by': supersed}) @@ -2885,7 +2885,7 @@ def get_user_projpkgs_request_list(apiurl, user, req_state=('new',), req_type=No return result def get_request_log(apiurl, reqid): - r = get_request(conf.config['apiurl'], reqid) + r = get_request(apiurl, reqid) data = [] frmt = '-' * 76 + '\n%s | %s | %s\n\n%s' # the description of the request is used for the initial log entry @@ -4062,17 +4062,13 @@ def print_jobhistory(apiurl, prj, current_package, repository, arch, format = 't reason = node.get('reason') if not reason: reason = "unknown" - bcnt = node.get('bcnt') code = node.get('code') - rev = int(node.get('rev')) - srcmd5 = node.get('srcmd5') rt = int(node.get('readytime')) readyt = time.localtime(rt) readyt = time.strftime('%Y-%m-%d %H:%M:%S', readyt) st = int(node.get('starttime')) et = int(node.get('endtime')) endtime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(et)) - waitstart = time.strftime('%H:%M:%S', time.gmtime(st-rt)) waittm = time.gmtime(et-st) if waittm.tm_hour: waitbuild = "%2dh %2dm %2ds" % (waittm.tm_hour, waittm.tm_min, waittm.tm_sec) @@ -4591,7 +4587,7 @@ def delPerson(apiurl, prj, pac, user, role="maintainer"): path_args=path, template_args=None, create_new=False) - if data: + if data and get_user_meta(apiurl, user) != None: root = ET.fromstring(''.join(data)) found = False for person in root.getiterator('person'): @@ -4883,7 +4879,6 @@ def get_commit_message_template(pac): def parse_diff_for_commit_message(diff, template = []): date_re = re.compile(r'\+(Mon|Tue|Wed|Thu|Fri|Sat|Sun) ([A-Z][a-z]{2}) ( ?[0-9]|[0-3][0-9]) .*') - index = 0 diff = diff.split('\n') # The first four lines contains a header of diff @@ -4946,7 +4941,7 @@ def print_request_list(apiurl, project, package = None, states = ('new', ), forc def request_interactive_review(apiurl, request): """review the request interactively""" - import tempfile, subprocess, re + import tempfile, re tmpfile = None diff --git a/setup.py b/setup.py index e4ef8d8e..f994cbb4 100755 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ class build_osc(distutils.command.build.build, object): # (this would break builds in environments like the obs) #osccli.main(argv = ['osc','man']) osccli.optparser = osccli.get_optparser() - osccli.do_man(None) + osccli.do_man() outfile.close() def run(self):