Commit 6334743d authored by Jason Frisvold's avatar Jason Frisvold
Browse files

- Python 2 to 3 compatibility changes

parent 3d663f5a
......@@ -20,7 +20,11 @@
# Import libraries
import sys
import getopt
import ConfigParser
# Try/Except to handle Python 3 renaming of configparser
try:
import configparser
except ImportError:
import ConfigParser as configparser
import time
import sqlite3
import logging
......@@ -56,8 +60,8 @@ def main(argv):
"dhvVs:c:",
["debug", "help", "verbose", "config",
"version", "license"])
except getopt.GetoptError, err:
print str(err)
except getopt.GetoptError as err:
print(str(err))
usage()
sys.exit(2)
......@@ -71,7 +75,7 @@ def main(argv):
# TODO : This should be validated
configfile = o
elif o in ("-V", "--version"):
print '{0} {1}'.format(programname, version)
print('{0} {1}'.format(programname, version))
sys.exit()
elif o in ("-h", "--help"):
usage()
......@@ -118,7 +122,7 @@ def main(argv):
def loadconfig():
logger.info('Loading spawner configuration')
config = ConfigParser.SafeConfigParser()
config = configparser.SafeConfigParser()
config.read(defaultconfigfile)
......@@ -275,7 +279,7 @@ def spawn_process(spawnlist):
if pid > 0:
# The parent process should jump to the next loop iteration
continue
except OSError, e:
except OSError as e:
sys.stderr.write('fork #1 failed: ({0}) {1}'.format(e.errno,
e.strerror))
sys.exit(1)
......@@ -291,7 +295,7 @@ def spawn_process(spawnlist):
pid = os.fork()
if pid > 0:
sys.exit(0)
except OSError, e:
except OSError as e:
sys.stderr.write('fork #2 failed: ({0}) {1}'.format(e.errno,
e.strerror))
sys.exit(1)
......@@ -428,9 +432,9 @@ def open_timing_database():
# Usage
###
def usage():
print ('Usage: ' + sys.argv[0] + ' [OPTION]... ');
print '{0}'.format(programname)
print
print(('Usage: ' + sys.argv[0] + ' [OPTION]... '));
print('{0}'.format(programname))
print()
print ('Mandatory arguments to long options are mandatory for short ' \
'options too.')
print (' -c <file> configuration file')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment