mirror of https://github.com/BOINC/boinc.git
More progress on this, but it looks like we can use 2to3 instead
This commit is contained in:
parent
7c094689e2
commit
4e0c3018e6
|
@ -4,7 +4,7 @@
|
|||
|
||||
# add_util.py - code shared between add and xadd
|
||||
|
||||
import database, tools
|
||||
from Boinc import database, tools
|
||||
import time, pprint
|
||||
import MySQLdb
|
||||
|
||||
|
@ -128,9 +128,9 @@ def translate_database_arg(database_table, arg, value):
|
|||
if len(results) == 0:
|
||||
raise SystemExit('No %s "%s" found' %(arg,value))
|
||||
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:
|
||||
print >>sys.stderr, ' ', result.name
|
||||
print (' '+result.name, sys.stderr)
|
||||
raise SystemExit
|
||||
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)
|
||||
check_required_arguments(add_object, args_dict)
|
||||
dbobject = add_object.DatabaseObject(**args_dict)
|
||||
print "Processing", dbobject, "..."
|
||||
print("Processing"+dbobject+"...")
|
||||
# print "Commiting", dbobject, "with args:"
|
||||
# pprint.pprint(dbobject.__dict__)
|
||||
try:
|
||||
dbobject.commit()
|
||||
except MySQLdb.MySQLError, e:
|
||||
except MySQLdb.MySQLError as e:
|
||||
if skip_old and exception_is_duplicate_entry(e):
|
||||
print " Skipped existing", dbobject
|
||||
print(" Skipped existing"+dbobject)
|
||||
return
|
||||
else:
|
||||
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
|
||||
del dbobject
|
||||
dbobject = add_object.DatabaseObject._table[id]
|
||||
print " Committed", dbobject, "; values:"
|
||||
print(" Committed"+dbobject+"; values:")
|
||||
pprint.pprint(dbobject.__dict__)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
##
|
||||
## will look prettier if you import this module.
|
||||
|
||||
import database
|
||||
from Boinc import database
|
||||
|
||||
def MixIn(pyClass, mixInClass):
|
||||
pyClass.__bases__ = (mixInClass,) + pyClass.__bases__
|
||||
|
|
|
@ -10,9 +10,9 @@ USAGE: from Boinc import projectxml
|
|||
'''
|
||||
|
||||
import sys
|
||||
import boinc_project_path
|
||||
from boincxml import *
|
||||
from add_util import *
|
||||
from Boinc import boinc_project_path
|
||||
from Boinc.boincxml import *
|
||||
from Boinc.add_util import *
|
||||
|
||||
default_project_file = None
|
||||
|
||||
|
@ -27,7 +27,7 @@ class ProjectFile(XMLConfig):
|
|||
default_project_file = self
|
||||
def _get_elements(self):
|
||||
self.xml_boinc = get_element(self.xml, 'boinc', optional=False)
|
||||
self.elements = ConfigDictList(self.xml_boinc)
|
||||
self.elements = ConfigDictList(self.xml_boinc)
|
||||
self.add_objects_and_args = []
|
||||
for node in self.xml_boinc.childNodes:
|
||||
add_object = add_objects.get(node.nodeName)
|
||||
|
@ -35,13 +35,13 @@ class ProjectFile(XMLConfig):
|
|||
raise SystemExit("Error in %s: No such object '%s' to add." %(self.filename,node.nodeName))
|
||||
self.add_objects_and_args.append((add_object, get_elements_as_dict(node)))
|
||||
def _set_elements(self):
|
||||
self.elements.save()
|
||||
self.elements.save()
|
||||
def commit_all(self):
|
||||
'''Commits all new data to the BOINC project database.'''
|
||||
for add_object, untranslated_args_dict in self.add_objects_and_args:
|
||||
try:
|
||||
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))
|
||||
default_xml = '<boinc></boinc>'
|
||||
|
||||
|
|
|
@ -168,10 +168,10 @@ def account_file_name(url):
|
|||
return 'account_' + _url_to_filename(url) + '.xml'
|
||||
|
||||
def srcdir(*dirs):
|
||||
return apply(os.path.join,(options.srcdir,)+dirs)
|
||||
return os.path.join(options.srcdir, 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):
|
||||
verbose_shell_call(builddir('tools', cmd))
|
||||
|
@ -244,7 +244,7 @@ def build_command_line(cmd, **kwargs):
|
|||
|
||||
def create_project_dirs(dest_dir):
|
||||
def dir(*d):
|
||||
return apply(os.path.join,(dest_dir,)+d)
|
||||
return os.path.join(dest_dir, d)
|
||||
def mkdir2(d):
|
||||
try:
|
||||
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."""
|
||||
|
||||
def dir(*dirs):
|
||||
return apply(os.path.join,(dest_dir,)+dirs)
|
||||
return os.path.join(dest_dir, dirs)
|
||||
|
||||
create_project_dirs(dest_dir);
|
||||
|
||||
|
@ -511,10 +511,10 @@ class Project:
|
|||
self.scheduler_url = os.path.join(cgi_url , 'cgi')
|
||||
|
||||
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):
|
||||
return apply(os.path.join,(self.config.config.key_dir,)+dirs)
|
||||
return os.path.join(self.config.config.key_dir, dirs)
|
||||
|
||||
def logdir(self):
|
||||
return os.path.join(self.project_dir, "log_"+self.config.config.host)
|
||||
|
@ -648,7 +648,7 @@ class Project:
|
|||
each_app = True
|
||||
else:
|
||||
raise SystemExit("test script error: invalid progname '%s'"%progname)
|
||||
cmdline = apply(build_command_line, [''], kwargs)
|
||||
cmdline = build_command_line([''], kwargs)
|
||||
if each_app:
|
||||
return map(lambda av: '-app %s %s'%(av.app.name,cmdline), self.app_versions)
|
||||
else:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
## $Id$
|
||||
|
||||
import configxml
|
||||
from Boinc import configxml
|
||||
try:
|
||||
# use new hashlib if available
|
||||
from hashlib import md5
|
||||
|
@ -64,13 +64,13 @@ def file_size(path):
|
|||
|
||||
def query_yesno(str):
|
||||
'''Query user; default Yes'''
|
||||
print str, "[Y/n] ",
|
||||
return not raw_input().strip().lower().startswith('n')
|
||||
print(str+"[Y/n] ")
|
||||
return not input().strip().lower().startswith('n')
|
||||
|
||||
def query_noyes(str):
|
||||
'''Query user; default No'''
|
||||
print str, "[y/N] ",
|
||||
return raw_input().strip().lower().startswith('y')
|
||||
print(str+"[y/N] ")
|
||||
return input().strip().lower().startswith('y')
|
||||
|
||||
def get_output_file_path(filename):
|
||||
""" Return the filename's path in the upload directory
|
||||
|
|
Loading…
Reference in New Issue