1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-03-03 14:42:11 +01:00

Complete rewrite of the internal commandline handling, using cmdln.py.

Bump version to 0.95.

New features:
- implement "rebuild all failed packages", via --failed option in rebuildpac
  subcommand (new api route)
- status -v shows all files, including unmodified ones
- suppress the legend in prjresults by default (show with -l)
- add global options to override config
- can use arbitrary api server via global -A option
- -H enables HTTP traffic debugging
- --version

Bugfixes:
- fix typo in delete_project() (the line building up the URL got lost)
- fix the commit subcommand's arguments. This works correctly now: 
    osc ci ../test/onlyinwc `pwd` fstab ../test/f2 
- fix buildinfo subcommand, if no specfile is posted. Broke with the recent URL
  handling rewrite, but didn't seem to bother because the build subcommand
  always sends the specfile.
- try to fix buildhistory route, but it might be gone actually (need to pursue)
- add --clean/--noinit to osc build help output
This commit is contained in:
Dr. Peter Poeml 2007-04-24 23:00:12 +00:00
parent 637dec8e83
commit 2f5b52e92c
6 changed files with 2545 additions and 1000 deletions

10
TODO
View File

@ -14,8 +14,6 @@
- prefer-rpms support for osc build - prefer-rpms support for osc build
- plugin-ize subcommand implementation - plugin-ize subcommand implementation
- look at Susannes extensions - look at Susannes extensions
- add --clean/--noinit to osc build help output
- https://api.opensuse.org/build/GNOME:UNSTABLE?cmd=rebuild&code=failed
- Allow the package owners/users to signal an abort build. - Allow the package owners/users to signal an abort build.
Message-ID: <20070214120205.GA9629@suse.de> Message-ID: <20070214120205.GA9629@suse.de>
- implement wipe command - implement wipe command
@ -165,8 +163,6 @@ put the current release number into the spec file before sending it
show request body of 400 responses (bad request) show request body of 400 responses (bad request)
geht print self.USAGE % self.__dict__ ?
a merge issues: a merge issues:
if I mark a file as "to be added" ("A"), and someone else alread adds (and if I mark a file as "to be added" ("A"), and someone else alread adds (and
@ -175,10 +171,6 @@ D apr_dbd_mysql.c
M libapr-util1.spec M libapr-util1.spec
build command:
> "You need to call the command inside a package directory, which should be a
> buildsystem checkout. (Local modifications are fine.)"
in the unusual event that a log file should be there (due to status "building"), but there is none, fail gracefully. in the unusual event that a log file should be there (due to status "building"), but there is none, fail gracefully.
% osc log openSUSE_10.2 i586 % osc log openSUSE_10.2 i586
@ -199,8 +191,6 @@ Traceback (most recent call last):
for node in root.find('packstatuslist'): for node in root.find('packstatuslist'):
TypeError: 'NoneType' object is not iterable TypeError: 'NoneType' object is not iterable
put the prjresults Legend into the help text instead of showing it each time?
also, we could add the option to configure it away
19:08 < Beineri> DuDE: can you add an option to "up" which moves instead overwriting a file if it has changed in the repository? 19:08 < Beineri> DuDE: can you add an option to "up" which moves instead overwriting a file if it has changed in the repository?

View File

@ -3,6 +3,10 @@
# 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
from osc import commandline from osc import commandline
commandline.main()
osc = commandline.Osc()
sys.exit( osc.main() )

1461
osc/cmdln.py Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -63,6 +63,7 @@ DEFAULTS = { 'apisrv': 'api.opensuse.org',
# switched off for now (testing) # switched off for now (testing)
'do_commits': '0', 'do_commits': '0',
} }
boolean_opts = ['http_debug', 'do_commits']
new_conf_template = """ new_conf_template = """
[general] [general]
@ -120,7 +121,7 @@ def init_basicauth(config):
global cookiejar global cookiejar
if config['http_debug'] == '1': if config['http_debug']:
# brute force # brute force
def urllib2_debug_init(self, debuglevel=0): def urllib2_debug_init(self, debuglevel=0):
self._debuglevel = 1 self._debuglevel = 1
@ -215,6 +216,15 @@ def get_config():
config = dict(cp.items('general', raw=1)) config = dict(cp.items('general', raw=1))
for i in boolean_opts:
try:
if int(config.get(i)):
config[i] = True
else:
config[i] = False
except:
sys.exit('option %s requires an integer value' % i)
# transform 'url1, url2, url3' form into a list # transform 'url1, url2, url3' form into a list
if type(config['urllist']) == str: if type(config['urllist']) == str:
config['urllist'] = [ i.strip() for i in config['urllist'].split(',') ] config['urllist'] = [ i.strip() for i in config['urllist'].split(',') ]
@ -226,6 +236,4 @@ def get_config():
config['user'] = config['auth_dict'][config['apisrv']]['user'] config['user'] = config['auth_dict'][config['apisrv']]['user']
config['pass'] = config['auth_dict'][config['apisrv']]['pass'] config['pass'] = config['auth_dict'][config['apisrv']]['pass']
# finally, initialize urllib2 for to use the credentials for Basic Authentication
init_basicauth(config)

View File

@ -5,7 +5,7 @@
# and distributed under the terms of the GNU General Public Licence, # and distributed under the terms of the GNU General Public Licence,
# either version 2, or (at your option) any later version. # either version 2, or (at your option) any later version.
__version__ = '0.9' __version__ = '0.95'
import os import os
import sys import sys
@ -605,25 +605,12 @@ def filedir_to_pac(f):
wd = f wd = f
p = Package(wd) p = Package(wd)
elif os.path.isfile(f):
wd = os.path.dirname(f)
if wd == '':
wd = os.curdir
p = Package(wd)
p.todo = [ os.path.basename(f) ]
else: else:
wd = os.path.dirname(f) wd = os.path.dirname(f)
if wd == '': if wd == '':
wd = os.curdir wd = os.curdir
p = Package(wd) p = Package(wd)
p.todo = [ os.path.basename(f) ] p.todo = [ os.path.basename(f) ]
#else:
# print
# print 'error: %s is neither a valid file or directory' % f
# sys.exit(1)
return p return p
@ -651,7 +638,7 @@ def http_request(method, url, data=None, file=None):
filefd = None filefd = None
if conf.config['http_debug'] == '1': if conf.config['http_debug']:
print print
print print
print '--', method, url print '--', method, url
@ -743,7 +730,7 @@ def check_store_version(dir):
sys.exit(1) sys.exit(1)
if v != __version__: if v != __version__:
if v in ['0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8']: if v in ['0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9']:
# version is fine, no migration needed # version is fine, no migration needed
f = open(versionfile, 'w') f = open(versionfile, 'w')
f.write(__version__ + '\n') f.write(__version__ + '\n')
@ -1141,6 +1128,7 @@ def delete_package(prj, pac):
def delete_project(prj): def delete_project(prj):
u = makeurl(['source', prj])
http_DELETE(u) http_DELETE(u)
@ -1212,7 +1200,7 @@ def get_results(prj, package):
r.append(result_line_templ % rmap) r.append(result_line_templ % rmap)
return r return r
def get_prj_results(prj): def get_prj_results(prj, show_legend=False):
#print '----------------------------------------' #print '----------------------------------------'
r = [] r = []
@ -1261,9 +1249,10 @@ def get_prj_results(prj):
r.append('') r.append('')
r.append(' Legend:') if show_legend:
for i, j in buildstatus_symbols.items(): r.append(' Legend:')
r.append(' %s %s' % (j, i)) for i, j in buildstatus_symbols.items():
r.append(' %s %s' % (j, i))
return r return r
@ -1277,7 +1266,10 @@ def get_log(prj, package, platform, arch, offset):
def get_buildinfo(prj, package, platform, arch, specfile=None): def get_buildinfo(prj, package, platform, arch, specfile=None):
# http://api.opensuse.org/rpm/Subversion/Apache_SuSE_Linux_10.1/i586/subversion/buildinfo # http://api.opensuse.org/rpm/Subversion/Apache_SuSE_Linux_10.1/i586/subversion/buildinfo
u = makeurl(['rpm', prj, platform, arch, package, 'buildinfo']) u = makeurl(['rpm', prj, platform, arch, package, 'buildinfo'])
f = http_POST(u, data=specfile) if specfile:
f = http_POST(u, data=specfile)
else:
f = http_GET(u)
return f.read() return f.read()
@ -1311,15 +1303,20 @@ def get_buildhistory(prj, package, platform, arch):
return r return r
def cmd_rebuild(prj, package, repo, arch): def cmd_rebuild(prj, package, repo, arch, code=None):
cmd = '?cmd=rebuild' cmd = prj
cmd += '?cmd=rebuild'
if package:
cmd += '&package=%s' % package
if repo: if repo:
cmd += '&repo=%s' % repo cmd += '&repo=%s' % repo
if arch: if arch:
cmd += '&arch=%s' % arch cmd += '&arch=%s' % arch
u = makeurl(['source', prj, package, cmd]) if code:
cmd += '&code=%s' % code
u = makeurl(['build', cmd])
try: try:
# adding data to the request makes it a POST
f = http_POST(u) f = http_POST(u)
except urllib2.HTTPError, e: except urllib2.HTTPError, e:
print >>sys.stderr, 'could not trigger rebuild for project \'%s\' package \'%s\'' % (prj, package) print >>sys.stderr, 'could not trigger rebuild for project \'%s\' package \'%s\'' % (prj, package)
@ -1328,8 +1325,7 @@ def cmd_rebuild(prj, package, repo, arch):
sys.exit(1) sys.exit(1)
root = ET.parse(f).getroot() root = ET.parse(f).getroot()
#code = root.get('code') return root.get('code')
return root.find('summary').text
def store_read_project(dir): def store_read_project(dir):