diff --git a/osc/build.py b/osc/build.py index 973e0f2c..ecd72276 100644 --- a/osc/build.py +++ b/osc/build.py @@ -47,8 +47,8 @@ class Buildinfo: try: tree = ET.parse(filename) except: - print 'could not parse the buildconfig:' - print open(filename).read() + print >>sys.stderr, 'could not parse the buildconfig:' + print >>sys.stderr, open(filename).read() sys.exit(1) root = tree.getroot() diff --git a/osc/commandline.py b/osc/commandline.py index 5ae6726b..b7fd1eeb 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -73,7 +73,8 @@ class Osc(cmdln.Cmdln): ${cmd_option_list} """ if len(args) != 2: - sys.exit('Must provide project and package name.') + print >>sys.stderr, 'Must provide project and package name.' + return 2 project = args[0] package = args[1] @@ -118,7 +119,7 @@ class Osc(cmdln.Cmdln): """ if not args: - print 'Missing argument.' + print >>sys.stderr, 'Missing argument.' self.do_help(['foo', 'meta']) return 2 @@ -173,7 +174,7 @@ class Osc(cmdln.Cmdln): """ if not args: - print 'Missing argument.' + print >>sys.stderr, 'Missing argument.' self.do_help(['foo', 'editmeta']) return 2 @@ -225,7 +226,7 @@ class Osc(cmdln.Cmdln): """ if not args or len(args) < 3: - print 'Incorrect number of argument.' + print >>sys.stderr, 'Incorrect number of argument.' self.do_help(['foo', 'linkpac']) return 2 @@ -238,7 +239,8 @@ class Osc(cmdln.Cmdln): dst_package = src_package if src_project == dst_project and src_package == dst_package: - sys.exit('osc: error: source and destination are the same') + print >>sys.stderr, 'Error: source and destination are the same.' + return 1 link_pac(src_project, src_package, dst_project, dst_package) @@ -256,7 +258,7 @@ class Osc(cmdln.Cmdln): """ if not args or len(args) < 3: - print 'Incorrect number of argument.' + print >>sys.stderr, 'Incorrect number of argument.' self.do_help(['foo', 'copypac']) return 2 @@ -269,7 +271,8 @@ class Osc(cmdln.Cmdln): dst_package = src_package if src_project == dst_project and src_package == dst_package: - sys.exit('osc: error: source and destination are the same') + print >>sys.stderr, 'Error: source and destination are the same.' + return 1 copy_pac(src_project, src_package, dst_project, dst_package) @@ -297,7 +300,8 @@ class Osc(cmdln.Cmdln): """ if meta_get_packagelist(project) != []: - sys.exit('Project contains packages. It must be empty before deleting it.') + print >>sys.stderr, 'Project contains packages. It must be empty before deleting it.' + return 1 delete_project(project) @@ -353,7 +357,7 @@ class Osc(cmdln.Cmdln): difference_found = True if difference_found: - sys.exit(1) + return 1 @@ -416,7 +420,7 @@ class Osc(cmdln.Cmdln): for package in meta_get_packagelist(project): checkout_package(project, package) else: - print 'Missing argument.' + print >>sys.stderr, 'Missing argument.' self.do_help(['foo', 'checkout']) return 2 @@ -464,7 +468,8 @@ class Osc(cmdln.Cmdln): elif os.path.isfile(arg): pacpaths.append(arg) else: - sys.exit('osc: error: %s is neither a project or a package directory' % arg) + print >>sys.stderr, 'osc: error: %s is neither a project or a package directory' % arg + return 1 pacs = findpacs(pacpaths) @@ -503,7 +508,7 @@ class Osc(cmdln.Cmdln): """ if not args: - print 'Missing argument.' + print >>sys.stderr, 'Missing argument.' self.do_help(['foo', 'add']) return 2 @@ -511,8 +516,8 @@ class Osc(cmdln.Cmdln): for filename in filenames: if not os.path.exists(filename): - print "file '%s' does not exist" % filename - sys.exit(1) + print >>sys.stderr, "file '%s' does not exist" % filename + return 1 pacs = findpacs(filenames) @@ -521,7 +526,7 @@ class Osc(cmdln.Cmdln): if filename in pac.excluded: continue if filename in pac.filenamelist: - print 'osc: warning: \'%s\' is already under version control' % filename + print >>sys.stderr, 'osc: warning: \'%s\' is already under version control' % filename continue pac.addfile(filename) @@ -585,9 +590,10 @@ class Osc(cmdln.Cmdln): # commit only if the upstream revision is the same as the working copy's upstream_rev = show_upstream_rev(p.prjname, p.name) if p.rev != upstream_rev: - print 'Working copy \'%s\' is out of date (rev %s vs rev %s).' % (p.absdir, p.rev, upstream_rev) - print 'Looks as if you need to update it first.' - sys.exit(1) + print >>sys.stderr, 'Working copy \'%s\' is out of date (rev %s vs rev %s).' \ + % (p.absdir, p.rev, upstream_rev) + print >>sys.stderr, 'Looks as if you need to update it first.' + return 1 if not p.todo: p.todo = p.filenamelist_unvers + p.filenamelist @@ -728,7 +734,7 @@ class Osc(cmdln.Cmdln): """ if not args: - print 'Missing argument.' + print >>sys.stderr, 'Missing argument.' self.do_help(['foo', 'delete']) return 2 @@ -768,7 +774,7 @@ class Osc(cmdln.Cmdln): """ if not args: - print 'Missing argument.' + print >>sys.stderr, 'Missing argument.' self.do_help(['foo', 'resolved']) return 2 @@ -843,7 +849,7 @@ class Osc(cmdln.Cmdln): """ if args and len(args) > 1: - print 'getting results for more than one package is not supported' + print >>sys.stderr, 'getting results for more than one package is not supported' self.do_help(['foo', 'results']) return 2 @@ -856,7 +862,8 @@ class Osc(cmdln.Cmdln): package = store_read_package(wd) project = store_read_project(wd) except: - sys.exit('\'%s\' is not an osc package directory' % wd) + print >>sys.stderr, '\'%s\' is not an osc package directory' % wd + return 1 print '\n'.join(get_results(project, package)) @@ -879,7 +886,7 @@ class Osc(cmdln.Cmdln): """ if args and len(args) > 1: - print 'getting results for more than one project is not supported' + print >>sys.stderr, 'getting results for more than one project is not supported' return 2 if args: @@ -890,7 +897,7 @@ class Osc(cmdln.Cmdln): try: project = store_read_project(wd) except: - print '\'%s\' is neither an osc project or package directory' % wd + print >>sys.stderr, '\'%s\' is neither an osc project or package directory' % wd return 1 print '\n'.join(get_prj_results(project, show_legend=opts.legend)) @@ -955,7 +962,8 @@ class Osc(cmdln.Cmdln): project = store_read_project(wd) if args is None or len(args) < 2: - print 'Missing argument. Valid arguments for this package are:' + print >>sys.stderr, 'Missing argument.' + print 'Valid arguments for this package are:' print self.do_repos(None, None) print @@ -970,7 +978,8 @@ class Osc(cmdln.Cmdln): except IndexError: spec = None except IOError, e: - sys.exit(e) + print >>sys.stderr, e + return 1 print ''.join(get_buildinfo(project, package, platform, arch, specfile=spec)) @@ -1066,17 +1075,18 @@ class Osc(cmdln.Cmdln): builddist = os.getenv('BUILD_DIST') if builddist: - #sys.argv[4] = sys.argv[1] + #args[3] = args[0] hyphen = builddist.rfind('-') - sys.argv.insert(2, builddist[hyphen+1:]) - sys.argv.insert(2, builddist[:hyphen]) + args.insert(1, builddist[hyphen+1:]) + args.insert(1, builddist[:hyphen]) print sys.argv elif len(args) >= 2 and len(args) < 3: - print 'Missing argument: build description (spec of dsc file)' + print >>sys.stderr, 'Missing argument: build description (spec of dsc file)' return 2 elif len(args) < 2: print + print >>sys.stderr, 'Missing argument.' print 'Valid arguments are:' print 'you have to choose a repo to build on' print 'possible repositories on this machine are:' @@ -1142,7 +1152,7 @@ class Osc(cmdln.Cmdln): """ if len(args) < 1: - print 'Missing argument.' + print >>sys.stderr, 'Missing argument.' #self.do_help(['foo', 'rebuildpac']) return 2 diff --git a/osc/core.py b/osc/core.py index 17ee3136..7d35905e 100755 --- a/osc/core.py +++ b/osc/core.py @@ -448,8 +448,8 @@ class Package: elif not exists and exists_in_store and not known_by_meta: state = 'D' elif not exists and not exists_in_store and not known_by_meta: - print '%s: not exists and not exists_in_store and not nown_by_meta' % n - print 'this code path should never be reached!' + print >>sys.stderr, '%s: not exists and not exists_in_store and not nown_by_meta' % n + print >>sys.stderr, 'this code path should never be reached!' sys.exit(1) return state @@ -481,7 +481,7 @@ rev: %s name, summary, descr = read_meta_from_spec(specfile) if name != self.name: - print 'name from spec does not match name of package... this is probably a problem' + print >>sys.stderr, 'name from spec does not match name of package... this is probably a problem' sys.exit(1) self.summary = summary self.descr = descr @@ -500,8 +500,8 @@ rev: %s print 'package does not exist yet... creating it' m = template % (pac, conf.config['user']) else: - print 'error getting package meta for project \'%s\' package \'%s\':' % (prj, pac) - print e + print >>sys.stderr, 'error getting package meta for project \'%s\' package \'%s\':' % (prj, pac) + print >>sys.stderr, e sys.exit(1) f = os.fdopen(fd, 'w') @@ -726,7 +726,7 @@ def check_store_version(dir): v = '' if v == '': - print 'error: "%s" is not an osc working copy' % dir + print >>sys.stderr, 'error: "%s" is not an osc working copy' % dir sys.exit(1) if v != __version__: @@ -736,11 +736,11 @@ def check_store_version(dir): f.write(__version__ + '\n') f.close() return - print - print 'the osc metadata of your working copy "%s"' % dir - print 'has the wrong version (%s), should be %s' % (v, __version__) - print 'please do a fresh checkout' - print + print >>sys.stderr + print >>sys.stderr, 'the osc metadata of your working copy "%s"' % dir + print >>sys.stderr, 'has the wrong version (%s), should be %s' % (v, __version__) + print >>sys.stderr, 'please do a fresh checkout' + print >>sys.stderr sys.exit(1) @@ -804,8 +804,8 @@ class metafile: if e.code == 404: m = template % (pac, conf.config['user']) else: - print 'error getting package meta for project \'%s\' package \'%s\':' % (prj, pac) - print e + print >>sys.stderr, 'error getting package meta for project \'%s\' package \'%s\':' % (prj, pac) + print >>sys.stderr, e sys.exit(1) else: @@ -820,8 +820,8 @@ class metafile: if e.code == 404: m = new_project_templ % (prj, conf.config['user']) else: - print 'error getting package meta for project \'%s\':' % prj - print e + print >>sys.stderr, 'error getting package meta for project \'%s\':' % prj + print >>sys.stderr, e sys.exit(1) f = os.fdopen(fd, 'w') @@ -861,8 +861,8 @@ def edit_user_meta(user, change_is_required=True): if e.code == 404: m = new_user_template % { 'user': user } else: - print 'error getting metadata for user \'%s\':' % user - print e + print >>sys.stderr, 'error getting metadata for user \'%s\':' % user + print >>sys.stderr, e sys.exit(1) (fd, filename) = tempfile.mkstemp(prefix = 'osc_edituser.', suffix = '.xml', dir = '/tmp') @@ -1063,8 +1063,8 @@ def link_pac(src_project, src_package, dst_project, dst_package): # create the _link file # but first, make sure not to overwrite an existing one if '_link' in meta_get_filelist(dst_project, dst_package): - print - print '_link file already exists...! Aborting' + print >>sys.stderr + print >>sys.stderr, '_link file already exists...! Aborting' sys.exit(1) print 'Creating _link...', diff --git a/osc/fetch.py b/osc/fetch.py index fd7c0eae..38ebd072 100644 --- a/osc/fetch.py +++ b/osc/fetch.py @@ -88,8 +88,8 @@ class Fetcher: try: os.makedirs(dir, mode=0755) except OSError, e: - print 'packagecachedir is not writable for you?' - print e + print >>sys.stderr, 'packagecachedir is not writable for you?' + print >>sys.stderr, e sys.exit(1)