More progress on this, but it looks like we can use 2to3 instead

This commit is contained in:
David Anderson 2018-04-22 23:51:44 -07:00
parent 7c094689e2
commit 4e0c3018e6
5 changed files with 26 additions and 26 deletions

View File

@ -4,7 +4,7 @@
# add_util.py - code shared between add and xadd # add_util.py - code shared between add and xadd
import database, tools from Boinc import database, tools
import time, pprint import time, pprint
import MySQLdb import MySQLdb
@ -128,9 +128,9 @@ def translate_database_arg(database_table, arg, value):
if len(results) == 0: if len(results) == 0:
raise SystemExit('No %s "%s" found' %(arg,value)) raise SystemExit('No %s "%s" found' %(arg,value))
if len(results) > 1: if len(results) > 1:
print >>sys.stderr, 'Too many %ss match "%s": '%(arg,value) print('Too many %ss match "%s": '%(arg,value), sys.stderr)
for result in results: for result in results:
print >>sys.stderr, ' ', result.name print (' '+result.name, sys.stderr)
raise SystemExit raise SystemExit
return results[0] return results[0]
@ -158,14 +158,14 @@ def do_add_object(add_object, untranslated_args_dict, skip_old=False):
args_dict = translate_args_dict(add_object, untranslated_args_dict) args_dict = translate_args_dict(add_object, untranslated_args_dict)
check_required_arguments(add_object, args_dict) check_required_arguments(add_object, args_dict)
dbobject = add_object.DatabaseObject(**args_dict) dbobject = add_object.DatabaseObject(**args_dict)
print "Processing", dbobject, "..." print("Processing"+dbobject+"...")
# print "Commiting", dbobject, "with args:" # print "Commiting", dbobject, "with args:"
# pprint.pprint(dbobject.__dict__) # pprint.pprint(dbobject.__dict__)
try: try:
dbobject.commit() dbobject.commit()
except MySQLdb.MySQLError, e: except MySQLdb.MySQLError as e:
if skip_old and exception_is_duplicate_entry(e): if skip_old and exception_is_duplicate_entry(e):
print " Skipped existing", dbobject print(" Skipped existing"+dbobject)
return return
else: else:
raise SystemExit('Error committing %s: %s' %(dbobject, e)) raise SystemExit('Error committing %s: %s' %(dbobject, e))
@ -175,5 +175,5 @@ def do_add_object(add_object, untranslated_args_dict, skip_old=False):
id = dbobject.id id = dbobject.id
del dbobject del dbobject
dbobject = add_object.DatabaseObject._table[id] dbobject = add_object.DatabaseObject._table[id]
print " Committed", dbobject, "; values:" print(" Committed"+dbobject+"; values:")
pprint.pprint(dbobject.__dict__) pprint.pprint(dbobject.__dict__)

View File

@ -7,7 +7,7 @@
## ##
## will look prettier if you import this module. ## will look prettier if you import this module.
import database from Boinc import database
def MixIn(pyClass, mixInClass): def MixIn(pyClass, mixInClass):
pyClass.__bases__ = (mixInClass,) + pyClass.__bases__ pyClass.__bases__ = (mixInClass,) + pyClass.__bases__

View File

@ -10,9 +10,9 @@ USAGE: from Boinc import projectxml
''' '''
import sys import sys
import boinc_project_path from Boinc import boinc_project_path
from boincxml import * from Boinc.boincxml import *
from add_util import * from Boinc.add_util import *
default_project_file = None default_project_file = None
@ -41,7 +41,7 @@ class ProjectFile(XMLConfig):
for add_object, untranslated_args_dict in self.add_objects_and_args: for add_object, untranslated_args_dict in self.add_objects_and_args:
try: try:
do_add_object(add_object, untranslated_args_dict, skip_old=True) do_add_object(add_object, untranslated_args_dict, skip_old=True)
except AddObjectException, e: except AddObjectException as e:
raise SystemExit('Error in %s: %s' %(self.filename,e)) raise SystemExit('Error in %s: %s' %(self.filename,e))
default_xml = '<boinc></boinc>' default_xml = '<boinc></boinc>'

View File

@ -168,10 +168,10 @@ def account_file_name(url):
return 'account_' + _url_to_filename(url) + '.xml' return 'account_' + _url_to_filename(url) + '.xml'
def srcdir(*dirs): def srcdir(*dirs):
return apply(os.path.join,(options.srcdir,)+dirs) return os.path.join(options.srcdir, dirs)
def builddir(*dirs): def builddir(*dirs):
return apply(os.path.join,(boinc_path_config.TOP_BUILD_DIR,)+dirs) return os.path.join(boinc_path_config.TOP_BUILD_DIR, dirs)
def run_tool(cmd): def run_tool(cmd):
verbose_shell_call(builddir('tools', cmd)) verbose_shell_call(builddir('tools', cmd))
@ -244,7 +244,7 @@ def build_command_line(cmd, **kwargs):
def create_project_dirs(dest_dir): def create_project_dirs(dest_dir):
def dir(*d): def dir(*d):
return apply(os.path.join,(dest_dir,)+d) return os.path.join(dest_dir, d)
def mkdir2(d): def mkdir2(d):
try: try:
os.makedirs(d) os.makedirs(d)
@ -303,7 +303,7 @@ def install_boinc_files(dest_dir, install_web_files, install_server_files):
Used by the upgrade script, so don't copy sample files to real name.""" Used by the upgrade script, so don't copy sample files to real name."""
def dir(*dirs): def dir(*dirs):
return apply(os.path.join,(dest_dir,)+dirs) return os.path.join(dest_dir, dirs)
create_project_dirs(dest_dir); create_project_dirs(dest_dir);
@ -511,10 +511,10 @@ class Project:
self.scheduler_url = os.path.join(cgi_url , 'cgi') self.scheduler_url = os.path.join(cgi_url , 'cgi')
def dir(self, *dirs): def dir(self, *dirs):
return apply(os.path.join,(self.project_dir,)+dirs) return os.path.join(self.project_dir, dirs)
def keydir(self, *dirs): def keydir(self, *dirs):
return apply(os.path.join,(self.config.config.key_dir,)+dirs) return os.path.join(self.config.config.key_dir, dirs)
def logdir(self): def logdir(self):
return os.path.join(self.project_dir, "log_"+self.config.config.host) return os.path.join(self.project_dir, "log_"+self.config.config.host)
@ -648,7 +648,7 @@ class Project:
each_app = True each_app = True
else: else:
raise SystemExit("test script error: invalid progname '%s'"%progname) raise SystemExit("test script error: invalid progname '%s'"%progname)
cmdline = apply(build_command_line, [''], kwargs) cmdline = build_command_line([''], kwargs)
if each_app: if each_app:
return map(lambda av: '-app %s %s'%(av.app.name,cmdline), self.app_versions) return map(lambda av: '-app %s %s'%(av.app.name,cmdline), self.app_versions)
else: else:

View File

@ -1,6 +1,6 @@
## $Id$ ## $Id$
import configxml from Boinc import configxml
try: try:
# use new hashlib if available # use new hashlib if available
from hashlib import md5 from hashlib import md5
@ -64,13 +64,13 @@ def file_size(path):
def query_yesno(str): def query_yesno(str):
'''Query user; default Yes''' '''Query user; default Yes'''
print str, "[Y/n] ", print(str+"[Y/n] ")
return not raw_input().strip().lower().startswith('n') return not input().strip().lower().startswith('n')
def query_noyes(str): def query_noyes(str):
'''Query user; default No''' '''Query user; default No'''
print str, "[y/N] ", print(str+"[y/N] ")
return raw_input().strip().lower().startswith('y') return input().strip().lower().startswith('y')
def get_output_file_path(filename): def get_output_file_path(filename):
""" Return the filename's path in the upload directory """ Return the filename's path in the upload directory