diff options
author | 2010-07-14 14:58:55 -0300 | |
---|---|---|
committer | 2010-07-14 14:58:55 -0300 | |
commit | e97c273736b4d1f48b6627bcd415bb9e85432f5a (patch) | |
tree | 5a17826f9da7857f15009acb48fcfe30e60c720e /scripts | |
parent | ported the test suite to py3k (diff) | |
download | g-octave-e97c273736b4d1f48b6627bcd415bb9e85432f5a.tar.gz g-octave-e97c273736b4d1f48b6627bcd415bb9e85432f5a.tar.bz2 g-octave-e97c273736b4d1f48b6627bcd415bb9e85432f5a.zip |
ported a bunch of scripts to py3k
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/package_database.py | 6 | ||||
-rwxr-xr-x | scripts/package_sources.py | 15 | ||||
-rwxr-xr-x | scripts/requirements.py | 32 | ||||
-rwxr-xr-x | scripts/tinderbox.py | 23 |
4 files changed, 44 insertions, 32 deletions
diff --git a/scripts/package_database.py b/scripts/package_database.py index 9dffce6..9db45df 100755 --- a/scripts/package_database.py +++ b/scripts/package_database.py @@ -12,6 +12,8 @@ :license: GPL-2, see LICENSE for more details. """ +from __future__ import print_function + import os import sys @@ -30,7 +32,7 @@ from g_octave.svn import revisions, utils def main(argv): if len(argv) < 2: - print >> sys.stderr, 'You should provide the name of the generated tarball' + print('You should provide the name of the generated tarball', file=sys.stderr) return 1 conf = config.Config() json_file = os.path.join(conf.db, 'revisions.json') @@ -53,7 +55,7 @@ def main(argv): path = category_dir ) utils.create_tarball(temp_dir, argv[1], 'octave-forge') - except Exception, err: + except Exception as err: raise RuntimeError('An error was ocurred: %s' % err) finally: shutil.rmtree(temp_dir) diff --git a/scripts/package_sources.py b/scripts/package_sources.py index 750d87f..4196109 100755 --- a/scripts/package_sources.py +++ b/scripts/package_sources.py @@ -12,12 +12,13 @@ :license: GPL-2, see LICENSE for more details. """ +from __future__ import print_function + import datetime import os import shutil import sys import tempfile -import urllib2 current_dir = os.path.dirname(os.path.realpath(__file__)) if os.path.exists(os.path.join(current_dir, '..', 'g_octave')): @@ -39,15 +40,15 @@ def main(argv): for category, pkg in svn.update_revisions(): cur_checkout_dir = os.path.join(checkout_dir, pkg) os.makedirs(cur_checkout_dir) - print 'Checking out the package: %s/%s' % (category, pkg) + print('Checking out the package: %s/%s' % (category, pkg)) try: svn.checkout_package(category, pkg, cur_checkout_dir, stable=True) - except Exception, err: + except Exception as err: error.append('%s/%s' % (category, pkg)) - print 'An error was ocurred: %s' % err + print('An error was ocurred: %s' % err) continue - print 'Creating the tarball: %s/%s' % (category, pkg) + print('Creating the tarball: %s/%s' % (category, pkg)) desc = description.Description(os.path.join(cur_checkout_dir, 'DESCRIPTION')) new_checkout = os.path.join(temp_dir, '%s-%s' % (pkg, desc.version)) shutil.move(cur_checkout_dir, new_checkout) @@ -57,12 +58,12 @@ def main(argv): '%s/%s-%s.tar.gz' % (conf.pkg_cache, pkg, desc.version), '%s-%s' % (pkg, desc.version) ) - except Exception, err: + except Exception as err: raise RuntimeError('An error was ocurred: %s' % err) finally: shutil.rmtree(temp_dir) if len(error) > 0: - print 'Errors: %s' % ', '.join(error) + print('Errors: %s' % ', '.join(error)) if __name__ == '__main__': diff --git a/scripts/requirements.py b/scripts/requirements.py index 03b90b9..45d446f 100755 --- a/scripts/requirements.py +++ b/scripts/requirements.py @@ -13,6 +13,8 @@ :license: GPL-2, see LICENSE for more details. """ +from __future__ import print_function + import json import sys import os @@ -26,11 +28,12 @@ if os.path.exists(os.path.join(current_dir, '..', 'g_octave')): sys.path.insert(0, os.path.join(current_dir, '..')) from g_octave import description, description_tree, exception +from g_octave.compat import py3k, open def main(argv): if len(argv) <= 1: - print >> sys.stderr, 'one argument required: the json file.' + print('one argument required: the json file.', file=sys.stderr) return 1 # init portage stuff @@ -46,8 +49,8 @@ def main(argv): for pkg in desc_tree.packages(): try: desc = desc_tree[pkg] - except exception.DescriptionTreeException, err: - print >> sys.stderr, 'DescriptionTree error: %s' % err + except exception.DescriptionTreeException as err: + print('DescriptionTree error: %s' % err, file=sys.stderr) return 1 deps = [] @@ -78,17 +81,24 @@ def main(argv): for dep in dependencies: s.execute(dep) - print dep + print(dep) temp = [] for i in range(len(s.matches['pkg'])): - print ' %i: %s' % (i, s.matches['pkg'][i][0]) + print(' %i: %s' % (i, s.matches['pkg'][i][0])) temp.append(s.matches['pkg'][i][0]) if dependencies[dep][0] in json_dict['dependencies']: - select = raw_input('Select a package [%s]: ' % \ - json_dict['dependencies'][dependencies[dep][0]]) + if py3k: + select = input('Select a package [%s]: ' % \ + json_dict['dependencies'][dependencies[dep][0]]) + else: + select = raw_input('Select a package [%s]: ' % \ + json_dict['dependencies'][dependencies[dep][0]]) else: - select = raw_input('Select a package: ') + if py3k: + select = input('Select a package: ') + else: + select = raw_input('Select a package: ') try: for dep_name in dependencies[dep]: json_dict['dependencies'][dep_name] = temp[int(select)] @@ -96,14 +106,14 @@ def main(argv): if select != '' or dependencies[dep][0] not in json_dict['dependencies']: for dep_name in dependencies[dep]: json_dict['dependencies'][dep_name] = select - print 'Selected: %s' % json_dict['dependencies'][dependencies[dep][0]] - print + print('Selected: %s' % json_dict['dependencies'][dependencies[dep][0]]) + print() try: with open(argv[1], 'w') as fp: json.dump(json_dict, fp, sort_keys=True, indent=4) except: - print >> sys.stderr, 'failed to save the json file.' + print('failed to save the json file.', file=sys.stderr) return 1 return 0 diff --git a/scripts/tinderbox.py b/scripts/tinderbox.py index c3fd508..b01ba5c 100755 --- a/scripts/tinderbox.py +++ b/scripts/tinderbox.py @@ -12,6 +12,8 @@ :license: GPL-2, see LICENSE for more details. """ +from __future__ import print_function + import sys import os @@ -35,11 +37,8 @@ current_dir = os.path.dirname(os.path.realpath(__file__)) if os.path.exists(os.path.join(current_dir, '..', 'g_octave')): sys.path.insert(0, os.path.join(current_dir, '..')) -import csv import portage import subprocess -import urllib -import urllib2 from g_octave import config, description_tree, ebuild, fetch, overlay from g_octave.tinderbox.trac import Trac, TracError @@ -83,9 +82,9 @@ def bug_report(pkgatom): try: for row in trac.list_tickets('=g-octave/'+ pkgatom + ' fails to build. #tinderbox'): bug_id = row['id'] - except TracError, err: + except TracError as err: out.eend(1) - print >> sys.stderr, err + print(err, file=sys.stderr) else: out.eend(0) @@ -98,9 +97,9 @@ def bug_report(pkgatom): 'This is ticket was created by tinderbox.\nLook at the attachments.' ) bug_id = int(bug_id) - except TracError, err: + except TracError as err: out.eend(1) - print >> sys.stderr, err + print(err, file=sys.stderr) else: out.eend(0) @@ -120,13 +119,13 @@ def bug_report(pkgatom): out.ebegin('Attaching file %s to #%i' % (f, int(bug_id))) try: trac.attach_file(bug_id, '%s file.' % f, f_) - except TracError, err: + except TracError as err: out.eend(1) - print >> sys.stderr, err + print(err, file=sys.stderr) else: out.eend(0) else: - print >> sys.stderr, f_ + ' don\'t exists!' + print(f_ + ' don\'t exists!', file=sys.stderr) def main(argv): @@ -138,9 +137,9 @@ def main(argv): out.ebegin('Trac - user autentication') try: trac = Trac(conf.trac_user, conf.trac_passwd) - except TracError, err: + except TracError as err: out.eend(1) - print >> sys.stderr, err + print(err, file=sys.stderr) else: out.eend(0) |