Skip to content

Commit

Permalink
Merge pull request #4043 from BOINC/dpa_python3_2
Browse files Browse the repository at this point in the history
Change python scripts to use python3.
  • Loading branch information
TheAspens authored Oct 23, 2020
2 parents 16d1061 + 697aebb commit 2ffd661
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 119 deletions.
5 changes: 2 additions & 3 deletions py/Boinc/add_util.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env python

# $Id$

# add_util.py - code shared between add and xadd
# add_util.py - used in make_project

from __future__ import print_function
from Boinc import database, tools
import time, pprint
import MySQLdb
Expand Down
7 changes: 3 additions & 4 deletions py/Boinc/boincxml.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env python

# $Id$

# boincxml.py - xml utilities for boinc
# boincxml.py - XML utilities for boinc

from __future__ import print_function
import sys, os
import xml.dom.minidom

Expand Down Expand Up @@ -130,7 +129,7 @@ def read(self, failopen_ok=False):
except:
if not failopen_ok:
raise Exception("Couldn't parse XML config\n")
print("Warning: couldn't parse XML file", sys.stderr)
print("Warning: couldn't parse XML file", file=sys.stderr)
self._init_empty_xml()
try:
self._get_elements()
Expand Down
3 changes: 1 addition & 2 deletions py/Boinc/configxml.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env python

# $Id$

# configxml.py - module to read and parse config.xml, run_state.xml

'''
Expand All @@ -21,6 +19,7 @@
'''

from __future__ import print_function
import sys
from Boinc import boinc_project_path
from Boinc.boincxml import *
Expand Down
5 changes: 0 additions & 5 deletions py/Boinc/db_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
## $Id$

# quarl 2003-10-16 initial version based on conglomeration of
# coursesurvey/database.py and boinc/database.py

Expand All @@ -11,12 +9,9 @@
# will do a database.Results.find1(id=wu.resultid) the first time

from __future__ import generators

import MySQLdb, MySQLdb.cursors
import sys, os, weakref

ID = '$Id$'

dbconnection = None

def list2dict(list):
Expand Down
2 changes: 1 addition & 1 deletion py/Boinc/projectxml.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# $Id$

# projectxml.py - module to read and parse project.xml

'''
Expand Down
3 changes: 1 addition & 2 deletions py/Boinc/setup_project.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
## $Id$

# module for setting up a new project (either a real project or a test project
# see tools/makeproject, test/testbase.py).

# TODO: make sure things work if build_dir != src_dir

from __future__ import print_function
import boinc_path_config
from Boinc import database, db_mid, configxml, tools
from Boinc.boinc_db import *
Expand Down
18 changes: 14 additions & 4 deletions py/Boinc/tools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## $Id$

from __future__ import print_function
from Boinc import configxml

try:
# use new hashlib if available
from hashlib import md5
Expand Down Expand Up @@ -62,15 +64,23 @@ def file_size(path):
f.seek(0,2)
return f.tell()

# workaround for dubious function change in python3
#
from sys import version_info
def input_aux():
if version_info.major == 2:
return raw_input()
return input()

def query_yesno(str):
'''Query user; default Yes'''
print str, "[Y/n] ",
return not raw_input().strip().lower().startswith('n')
print (str, "[Y/n] ", end="")
return not input_aux().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] ", end="")
return input_aux().strip().lower().startswith('y')

def get_output_file_path(filename):
""" Return the filename's path in the upload directory
Expand Down
2 changes: 1 addition & 1 deletion sched/pymw_assimilator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _copy_to_output(self, result, error_mask=0):
else:
shutil.copy2(resultFullPath, dest)
self.logNormal("Result copied [%s]\n", resultName)
except Exception,msg:
except (Exception, msg):
self.logCritical("Error copying output\n" + \
" - Source: %s\n" + \
" - Dest: %s\n" +
Expand Down
Loading

0 comments on commit 2ffd661

Please sign in to comment.