1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

- make 'results' output less noisy

- add parseargs() to simplify argument handling
- clean up some unused code
This commit is contained in:
Dr. Peter Poeml 2006-05-11 07:27:50 +00:00
parent 81deb97562
commit 03ca18dbb8
2 changed files with 26 additions and 44 deletions

View File

@ -61,7 +61,7 @@ def main():
print ''.join(d)
elif cmd == 'co':
elif cmd == 'co' or cmd == 'checkout':
try:
project = sys.argv[2]
@ -84,11 +84,7 @@ def main():
elif cmd == 'st' or cmd == 'status':
if len(sys.argv) > 2:
args = sys.argv[2:]
else:
args = [ os.curdir ]
#print args
args = parseargs()
for arg in args:
@ -118,7 +114,12 @@ def main():
elif cmd == 'add':
filenames = sys.argv[2:]
if len(sys.argv) < 3:
print '%s requires at least one argument' % cmd
sys.exit(1)
filenames = parseargs()
for filename in filenames:
if not os.path.exists(filename):
print "file '%s' does not exist" % filename
@ -128,10 +129,7 @@ def main():
print 'A ', filename
elif cmd == 'addremove':
if len(sys.argv) > 2:
args = sys.argv[2:]
else:
args = [ os.curdir ]
args = parseargs()
for arg in args:
@ -164,11 +162,7 @@ def main():
elif cmd == 'ci' or cmd == 'checkin':
if len(sys.argv) > 2:
args = sys.argv[2:]
else:
args = [ os.curdir ]
#print args
args = parseargs()
for arg in args:
@ -216,11 +210,7 @@ def main():
elif cmd == 'up' or cmd == 'update':
if len(sys.argv) > 2:
args = sys.argv[2:]
else:
args = [ os.curdir ]
#print args
args = parseargs()
for arg in args:
@ -289,12 +279,12 @@ def main():
elif cmd == 'rm' or cmd == 'delete':
if len(sys.argv) > 2:
args = sys.argv[2:]
else:
if len(sys.argv) < 3:
print '%s requires at least one argument' % cmd
sys.exit(1)
args = parseargs()
for arg in args:
olddir = os.getcwd()

View File

@ -31,6 +31,14 @@ store = '.osc'
exclude_stuff = [store, '.svn', 'CVS']
def parseargs():
if len(sys.argv) > 2:
args = sys.argv[2:]
else:
args = [ os.curdir ]
return args
def makeurl(l):
"""given a list of path compoments, construct a complete URL"""
return urlunsplit((scheme, netloc, '/'.join(l), '', ''))
@ -106,6 +114,7 @@ def check_store_version():
sys.exit(1)
def meta_get_packagelist(prj):
u = makeurl(['source', prj, '_meta'])
@ -310,16 +319,6 @@ def get_source_file_diff(prj, package, filename):
return ''.join(d)
#def put_source_file_and_meta(prj, package, filename):
# if filename == '_meta':
# put_source_file(prj, package, filename)
# return
#
# get_source_file(prj, package, '_meta')
# localmeta_addfile(os.path.basename(filename))
# put_source_file(prj, package, filename)
# put_source_file(prj, package, '_meta')
def put_source_file(prj, package, filename):
import othermethods
@ -327,11 +326,7 @@ def put_source_file(prj, package, filename):
sys.stdout.write('.')
u = makeurl(['source', prj, package, os.path.basename(filename)])
othermethods.putfile(u, filename, username, password)
#f = urllib2.urlopen(u)
#o = open(filename, 'w')
#o.write(f.read())
#o.close()
def del_source_file(prj, package, filename):
import othermethods
@ -405,7 +400,7 @@ def get_results(prj, package, platform):
r = []
#result_line_templ = '%(prj)-15s %(pac)-15s %(rep)-15s %(arch)-10s %(status)s'
result_line_templ = '%(rep)-15s %(arch)-10s %(status)s %(hint)s'
result_line_templ = '%(rep)-15s %(arch)-10s %(status)s'
f = show_results_meta(prj, package, platform)
tree = ET.parse(StringIO(''.join(f)))
@ -413,7 +408,6 @@ def get_results(prj, package, platform):
root = tree.getroot()
rmap = {}
rmap['hint'] = ''
rmap['prj'] = root.get('project')
rmap['pac'] = root.get('package')
rmap['rep'] = root.get('repository')
@ -428,10 +422,8 @@ def get_results(prj, package, platform):
rmap['status'] += ': ' + statusnode.find('summary').text
if rmap['status'] == 'failed':
rmap['status'] += ':'
rmap['hint'] = '\'osc log %(rep)s %(arch)s\' -> ' % rmap + \
'(%s://%s' % (scheme, netloc) + \
'/result/%(prj)s/%(rep)s/%(pac)s/%(arch)s/log)' % rmap
rmap['status'] += ': %s://%s' % (scheme, netloc) + \
'/result/%(prj)s/%(rep)s/%(pac)s/%(arch)s/log' % rmap
r.append(result_line_templ % rmap)
return r