1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-27 15:06:15 +01:00

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()
This commit is contained in:
Danny Kukawka 2010-07-26 16:46:21 +02:00
parent 14376dd2b6
commit b3c5204b59
4 changed files with 15 additions and 24 deletions

View File

@ -429,7 +429,7 @@ class RawCmdln(cmd.Cmd):
cmdln.py). cmdln.py).
""" """
import sys import sys
type, exc, traceback = sys.exc_info() exc_type, exc, traceback = sys.exc_info()
if isinstance(exc, CmdlnUserError): if isinstance(exc, CmdlnUserError):
msg = "%s %s: %s\nTry '%s help %s' for info.\n"\ msg = "%s %s: %s\nTry '%s help %s' for info.\n"\
% (self.name, argv[0], exc, self.name, argv[0]) % (self.name, argv[0], exc, self.name, argv[0])
@ -558,7 +558,7 @@ class RawCmdln(cmd.Cmd):
do_help.aliases = ["?"] do_help.aliases = ["?"]
def do_man(self, argv): def do_man(self):
"""${cmd_name}: generates a man page """${cmd_name}: generates a man page
usage: usage:

View File

@ -8,7 +8,6 @@ from core import *
import cmdln import cmdln
import conf import conf
import oscerr import oscerr
import urlgrabber.progress
from optparse import SUPPRESS_HELP from optparse import SUPPRESS_HELP
MAN_HEADER = r""".TH %(ucname)s "1" "%(date)s" "%(name)s %(version)s" "User Commands" 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) 'superseded by %s' % result, result)
if opts.supersede: if opts.supersede:
r = change_request_state(conf.config['apiurl'], change_request_state(conf.config['apiurl'], opts.supersede, 'superseded',
opts.supersede, 'superseded', opts.message or '', result) opts.message or '', result)
print 'created request id', result print 'created request id', result
@ -985,7 +984,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
actionxml="" actionxml=""
apiurl = self.get_api_url() apiurl = self.get_api_url()
if len(args) == 0 and is_project_dir(os.getcwd()): if len(args) == 0 and is_project_dir(os.getcwd()):
import cgi
# submit requests for multiple packages are currently handled via multiple requests # 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. # They could be also one request with multiple actions, but that avoids to accepts parts of it.
project = store_read_project(os.curdir) 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) 'superseded by %s' % result, result)
if opts.supersede: if opts.supersede:
r = change_request_state(apiurl, change_request_state(apiurl, opts.supersede, 'superseded', '', result)
opts.supersede, 'superseded', '', result)
#print 'created request id', result #print 'created request id', result
return actionxml return actionxml
@ -1702,7 +1699,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if subcmd == 'review': if subcmd == 'review':
if cmd in ['accept', 'decline', 'new']: if cmd in ['accept', 'decline', 'new']:
r = change_review_state(conf.config['apiurl'], 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 print r
# Change state of entire request # Change state of entire request
elif cmd in ['reopen', 'accept', 'decline', 'wipe', 'revoke']: 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) args = slash_split(args)
apiurl = self.get_api_url() apiurl = self.get_api_url()
meta = None
if len(args) == 0: if len(args) == 0:
wd = os.curdir wd = os.curdir
@ -5621,7 +5617,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
${cmd_option_list} ${cmd_option_list}
""" """
from subprocess import Popen, PIPE from subprocess import Popen
if not os.path.exists('/usr/lib/build/vc'): if not os.path.exists('/usr/lib/build/vc'):
print >>sys.stderr, 'Error: you need build.rpm with version 2009.04.17 or newer' print >>sys.stderr, 'Error: you need build.rpm with version 2009.04.17 or newer'

View File

@ -2126,9 +2126,9 @@ def init_project_dir(apiurl, dir, project):
store_write_initial_packages(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): def init_package_dir(apiurl, project, package, dir, revision=None, files=True, limit_size=None, meta=False):
if not os.path.isdir(store): if not os.path.isdir(dir):
os.mkdir(store) os.mkdir(dir)
os.chdir(store) os.chdir(dir)
f = open('_project', 'w') f = open('_project', 'w')
f.write(project + '\n') f.write(project + '\n')
f.close() f.close()
@ -2798,7 +2798,7 @@ def get_request(apiurl, reqid):
return r 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, u = makeurl(apiurl,
['request', reqid], ['request', reqid],
query={'cmd': 'changereviewstate', 'newstate': newstate, 'by_user': by_user, 'superseded_by': supersed}) 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 return result
def get_request_log(apiurl, reqid): def get_request_log(apiurl, reqid):
r = get_request(conf.config['apiurl'], reqid) r = get_request(apiurl, reqid)
data = [] data = []
frmt = '-' * 76 + '\n%s | %s | %s\n\n%s' frmt = '-' * 76 + '\n%s | %s | %s\n\n%s'
# the description of the request is used for the initial log entry # 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') reason = node.get('reason')
if not reason: if not reason:
reason = "unknown" reason = "unknown"
bcnt = node.get('bcnt')
code = node.get('code') code = node.get('code')
rev = int(node.get('rev'))
srcmd5 = node.get('srcmd5')
rt = int(node.get('readytime')) rt = int(node.get('readytime'))
readyt = time.localtime(rt) readyt = time.localtime(rt)
readyt = time.strftime('%Y-%m-%d %H:%M:%S', readyt) readyt = time.strftime('%Y-%m-%d %H:%M:%S', readyt)
st = int(node.get('starttime')) st = int(node.get('starttime'))
et = int(node.get('endtime')) et = int(node.get('endtime'))
endtime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(et)) 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) waittm = time.gmtime(et-st)
if waittm.tm_hour: if waittm.tm_hour:
waitbuild = "%2dh %2dm %2ds" % (waittm.tm_hour, waittm.tm_min, waittm.tm_sec) 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, path_args=path,
template_args=None, template_args=None,
create_new=False) create_new=False)
if data: if data and get_user_meta(apiurl, user) != None:
root = ET.fromstring(''.join(data)) root = ET.fromstring(''.join(data))
found = False found = False
for person in root.getiterator('person'): for person in root.getiterator('person'):
@ -4883,7 +4879,6 @@ def get_commit_message_template(pac):
def parse_diff_for_commit_message(diff, template = []): 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]) .*') 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') diff = diff.split('\n')
# The first four lines contains a header of diff # 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): def request_interactive_review(apiurl, request):
"""review the request interactively""" """review the request interactively"""
import tempfile, subprocess, re import tempfile, re
tmpfile = None tmpfile = None

View File

@ -32,7 +32,7 @@ class build_osc(distutils.command.build.build, object):
# (this would break builds in environments like the obs) # (this would break builds in environments like the obs)
#osccli.main(argv = ['osc','man']) #osccli.main(argv = ['osc','man'])
osccli.optparser = osccli.get_optparser() osccli.optparser = osccli.get_optparser()
osccli.do_man(None) osccli.do_man()
outfile.close() outfile.close()
def run(self): def run(self):