Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Godshell
Skynet
Commits
6334743d
Commit
6334743d
authored
May 01, 2016
by
Jason Frisvold
Browse files
- Python 2 to 3 compatibility changes
parent
3d663f5a
Changes
1
Hide whitespace changes
Inline
Side-by-side
client/spawner.py
View file @
6334743d
...
...
@@ -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
=
C
onfig
P
arser
.
SafeConfigParser
()
config
=
c
onfig
p
arser
.
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'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment