mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-12 08:56:13 +01:00
code cleanup
This commit is contained in:
parent
ce0c2a5ad2
commit
661d927d38
@ -3,10 +3,9 @@
|
|||||||
# this wrapper exists so it can be put into /usr/bin, but still allows the
|
# this wrapper exists so it can be put into /usr/bin, but still allows the
|
||||||
# python module to be called within the source directory during development
|
# python module to be called within the source directory during development
|
||||||
|
|
||||||
|
|
||||||
import sys, locale
|
import sys, locale
|
||||||
# this is a hack to make osc work as expected with utf-8 characters, no matter
|
# this is a hack to make osc work as expected with utf-8 characters,
|
||||||
# how site.py is set...
|
# no matter how site.py is set...
|
||||||
reload(sys)
|
reload(sys)
|
||||||
loc = locale.getdefaultlocale()[1]
|
loc = locale.getdefaultlocale()[1]
|
||||||
if not loc:
|
if not loc:
|
||||||
@ -21,6 +20,3 @@ osccli = commandline.Osc()
|
|||||||
|
|
||||||
r = babysitter.run(osccli)
|
r = babysitter.run(osccli)
|
||||||
sys.exit(r)
|
sys.exit(r)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -616,9 +616,9 @@ Warning: failed to fetch meta data for '%s' package '%s' (new package?) """ \
|
|||||||
% (dst_project, dst_package)
|
% (dst_project, dst_package)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if devloc \
|
if devloc and \
|
||||||
and dst_project != devloc \
|
dst_project != devloc and \
|
||||||
and src_project != devloc:
|
src_project != devloc:
|
||||||
print """\
|
print """\
|
||||||
Sorry, but a different project, %s, is defined as the place where development
|
Sorry, but a different project, %s, is defined as the place where development
|
||||||
of the package %s primarily takes place.
|
of the package %s primarily takes place.
|
||||||
@ -1092,7 +1092,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
if opts.current:
|
if opts.current:
|
||||||
rev = show_upstream_rev(conf.config['apiurl'], src_project, src_package);
|
rev = show_upstream_rev(conf.config['apiurl'], src_project, src_package)
|
||||||
|
|
||||||
if rev and not checkRevision(src_project, src_package, rev):
|
if rev and not checkRevision(src_project, src_package, rev):
|
||||||
print >>sys.stderr, 'Revision \'%s\' does not exist' % rev
|
print >>sys.stderr, 'Revision \'%s\' does not exist' % rev
|
||||||
@ -1218,7 +1218,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
comment = opts.message
|
comment = opts.message
|
||||||
else:
|
else:
|
||||||
if not rev:
|
if not rev:
|
||||||
rev = show_upstream_rev(src_apiurl, src_project, src_package);
|
rev = show_upstream_rev(src_apiurl, src_project, src_package)
|
||||||
comment = 'osc copypac from project:%s package:%s revision:%s' % ( src_project, src_package, rev )
|
comment = 'osc copypac from project:%s package:%s revision:%s' % ( src_project, src_package, rev )
|
||||||
|
|
||||||
r = copy_pac(src_apiurl, src_project, src_package,
|
r = copy_pac(src_apiurl, src_project, src_package,
|
||||||
@ -3019,8 +3019,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
if not args:
|
if not args:
|
||||||
raise oscerr.WrongArgs('Please specify one of projects/packages/requests')
|
raise oscerr.WrongArgs('Please specify one of projects/packages/requests')
|
||||||
|
|
||||||
if args[0] in ('requests', 'request', 'req', 'rq',
|
if args[0] in ('requests', 'request', 'req', 'rq', 'submitrequest', 'submitreq', 'submit', 'sr'):
|
||||||
'submitrequest', 'submitreq', 'submit', 'sr'):
|
|
||||||
## FIXME: involvement bugowner is not reported here.
|
## FIXME: involvement bugowner is not reported here.
|
||||||
## this only reports usernames found in request history.
|
## this only reports usernames found in request history.
|
||||||
opts.state = 'all'
|
opts.state = 'all'
|
||||||
@ -3656,8 +3655,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
os.chdir(destdir)
|
os.chdir(destdir)
|
||||||
init_package_dir(apiurl, target_prj, target_package, destdir, files=False)
|
init_package_dir(apiurl, target_prj, target_package, destdir, files=False)
|
||||||
os.chdir(olddir)
|
os.chdir(olddir)
|
||||||
store_write_string(destdir, '_files', ''.join(meta));
|
store_write_string(destdir, '_files', ''.join(meta))
|
||||||
store_write_string(destdir, '_linkrepair', '');
|
store_write_string(destdir, '_linkrepair', '')
|
||||||
pac = Package(destdir)
|
pac = Package(destdir)
|
||||||
|
|
||||||
storedir = os.path.join(destdir, store)
|
storedir = os.path.join(destdir, store)
|
||||||
|
@ -361,7 +361,7 @@ def init_basicauth(config):
|
|||||||
if ctx.load_verify_locations(capath=capath, cafile=cafile) != 1: raise Exception('No CA certificates found')
|
if ctx.load_verify_locations(capath=capath, cafile=cafile) != 1: raise Exception('No CA certificates found')
|
||||||
opener = m2urllib2.build_opener(ctx, urllib2.HTTPCookieProcessor(cookiejar), authhandler)
|
opener = m2urllib2.build_opener(ctx, urllib2.HTTPCookieProcessor(cookiejar), authhandler)
|
||||||
else:
|
else:
|
||||||
import sys;
|
import sys
|
||||||
print >>sys.stderr, "WARNING: SSL certificate checks disabled. Connection is insecure!\n"
|
print >>sys.stderr, "WARNING: SSL certificate checks disabled. Connection is insecure!\n"
|
||||||
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar), authhandler)
|
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar), authhandler)
|
||||||
|
|
||||||
@ -581,7 +581,7 @@ def get_config(override_conffile = None,
|
|||||||
passwordx = cp.get(url, 'passx', raw=True) # especially on password!
|
passwordx = cp.get(url, 'passx', raw=True) # especially on password!
|
||||||
if password is None or password == 'your_password':
|
if password is None or password == 'your_password':
|
||||||
try:
|
try:
|
||||||
password = passwordx.decode('base64').decode('bz2');
|
password = passwordx.decode('base64').decode('bz2')
|
||||||
except:
|
except:
|
||||||
print "%s: no credentials known" % url
|
print "%s: no credentials known" % url
|
||||||
password = 'your_password'
|
password = 'your_password'
|
||||||
@ -640,7 +640,8 @@ def get_config(override_conffile = None,
|
|||||||
# override values which we were called with
|
# override values which we were called with
|
||||||
if override_verbose:
|
if override_verbose:
|
||||||
config['verbose'] = override_verbose + 1
|
config['verbose'] = override_verbose + 1
|
||||||
if not config.has_key('verbose') : config['verbose'] = 1;
|
if not config.has_key('verbose'):
|
||||||
|
config['verbose'] = 1
|
||||||
|
|
||||||
if override_debug:
|
if override_debug:
|
||||||
config['debug'] = override_debug
|
config['debug'] = override_debug
|
||||||
|
@ -511,7 +511,7 @@ class Project:
|
|||||||
rev = p.linkinfo.lsrcmd5
|
rev = p.linkinfo.lsrcmd5
|
||||||
print 'Unexpanding to rev', rev
|
print 'Unexpanding to rev', rev
|
||||||
elif p.islink() and p.isexpanded():
|
elif p.islink() and p.isexpanded():
|
||||||
rev = p.latest_rev();
|
rev = p.latest_rev()
|
||||||
print 'Updating %s' % p.name
|
print 'Updating %s' % p.name
|
||||||
p.update(rev, service_files)
|
p.update(rev, service_files)
|
||||||
elif state == 'D':
|
elif state == 'D':
|
||||||
@ -792,7 +792,7 @@ class Package:
|
|||||||
|
|
||||||
def commit(self, msg=''):
|
def commit(self, msg=''):
|
||||||
# commit only if the upstream revision is the same as the working copy's
|
# commit only if the upstream revision is the same as the working copy's
|
||||||
upstream_rev = self.latest_rev();
|
upstream_rev = self.latest_rev()
|
||||||
if self.rev != upstream_rev:
|
if self.rev != upstream_rev:
|
||||||
raise oscerr.WorkingCopyOutdated((self.absdir, self.rev, upstream_rev))
|
raise oscerr.WorkingCopyOutdated((self.absdir, self.rev, upstream_rev))
|
||||||
|
|
||||||
@ -3872,7 +3872,7 @@ def set_link_rev(apiurl, project, package, revision = None):
|
|||||||
if not revision:
|
if not revision:
|
||||||
src_project = root.attrib['project']
|
src_project = root.attrib['project']
|
||||||
src_package = root.attrib['package']
|
src_package = root.attrib['package']
|
||||||
root.attrib['rev'] = show_upstream_rev(apiurl, src_project, src_package);
|
root.attrib['rev'] = show_upstream_rev(apiurl, src_project, src_package)
|
||||||
elif revision == -1:
|
elif revision == -1:
|
||||||
del root.attrib['rev']
|
del root.attrib['rev']
|
||||||
else:
|
else:
|
||||||
|
@ -109,7 +109,7 @@ class Fetcher:
|
|||||||
pac.filename = canonname
|
pac.filename = canonname
|
||||||
pac.fullfilename = os.path.join(pac.localdir, canonname)
|
pac.fullfilename = os.path.join(pac.localdir, canonname)
|
||||||
|
|
||||||
os.rename(pac.fullpartname, pac.fullfilename);
|
os.rename(pac.fullpartname, pac.fullfilename)
|
||||||
|
|
||||||
def dirSetup(self, pac):
|
def dirSetup(self, pac):
|
||||||
dir = os.path.join(self.cachedir, pac.localdir)
|
dir = os.path.join(self.cachedir, pac.localdir)
|
||||||
@ -166,7 +166,7 @@ def verify_pacs(pac_list):
|
|||||||
stderr=subprocess.STDOUT, close_fds=True).stdout
|
stderr=subprocess.STDOUT, close_fds=True).stdout
|
||||||
|
|
||||||
# restore locale
|
# restore locale
|
||||||
if saved_LC_ALL: os.environ['LC_ALL'] = saved_LC_ALL;
|
if saved_LC_ALL: os.environ['LC_ALL'] = saved_LC_ALL
|
||||||
else: os.environ.pop('LC_ALL')
|
else: os.environ.pop('LC_ALL')
|
||||||
|
|
||||||
for line in o.readlines():
|
for line in o.readlines():
|
||||||
|
@ -17,15 +17,15 @@ class UserAbort(OscBaseError):
|
|||||||
|
|
||||||
class ConfigError(OscBaseError):
|
class ConfigError(OscBaseError):
|
||||||
"""Exception raised when there is an error in the config file"""
|
"""Exception raised when there is an error in the config file"""
|
||||||
def __init__(self, msg, file):
|
def __init__(self, msg, fname):
|
||||||
OscBaseError.__init__(self)
|
OscBaseError.__init__(self)
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
self.file = file
|
self.file = fname
|
||||||
|
|
||||||
class ConfigMissingApiurl(ConfigError):
|
class ConfigMissingApiurl(ConfigError):
|
||||||
"""Exception raised when a apiurl does not exist in the config file"""
|
"""Exception raised when a apiurl does not exist in the config file"""
|
||||||
def __init__(self, msg, file, url):
|
def __init__(self, msg, fname, url):
|
||||||
ConfigError.__init__(self, msg, file)
|
ConfigError.__init__(self, msg, fname)
|
||||||
self.url = url
|
self.url = url
|
||||||
|
|
||||||
class APIError(OscBaseError):
|
class APIError(OscBaseError):
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
# 2008-03-25, jw, v0.3 -- go via api using iChains and ~/.oscrc
|
# 2008-03-25, jw, v0.3 -- go via api using iChains and ~/.oscrc
|
||||||
# 2008-03-26, jw, v0.4 -- added linked file retrieval and usage.
|
# 2008-03-26, jw, v0.4 -- added linked file retrieval and usage.
|
||||||
|
|
||||||
|
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use LWP::UserAgent;
|
use LWP::UserAgent;
|
||||||
use HTTP::Status;
|
use HTTP::Status;
|
||||||
@ -382,7 +381,6 @@ sub scalar_cdata
|
|||||||
delete $hash->{$selftag};
|
delete $hash->{$selftag};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
## find_tags -- a brute force tag finder.
|
## find_tags -- a brute force tag finder.
|
||||||
## This code is robust enough to parse the weirdest HTML.
|
## This code is robust enough to parse the weirdest HTML.
|
||||||
@ -487,5 +485,3 @@ sub xml_add_attr
|
|||||||
}
|
}
|
||||||
die "xml_expand_attr: unknown method '$how'\n";
|
die "xml_expand_attr: unknown method '$how'\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#################################################################
|
|
||||||
|
Loading…
Reference in New Issue
Block a user