git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
2to3 on the sfa-config* scripts
[sfa.git]
/
config
/
sfa-config
diff --git
a/config/sfa-config
b/config/sfa-config
index
ab59fe8
..
346356b
100755
(executable)
--- a/
config/sfa-config
+++ b/
config/sfa-config
@@
-1,20
+1,20
@@
-#!/usr/bin/env python
2
+#!/usr/bin/env python
3
#
# Script for basic access to the SFA configuration file store.
#
import sys
import os
#
# Script for basic access to the SFA configuration file store.
#
import sys
import os
-import fcntl
+
#
import fcntl
import getopt
import getopt
-import signal
+
#
import signal
from sfa.util.config import Config
def usage():
from sfa.util.config import Config
def usage():
- print
"""
+ print
(
"""
Script to access the SFA configuration file store.
Script to access the SFA configuration file store.
-
+
Usage: %s [OPTION]... [FILES]
Conversion:
Usage: %s [OPTION]... [FILES]
Conversion:
@@
-44,13
+44,13
@@
Usage: %s [OPTION]... [FILES]
-h, --help This message
-s, --save Save changes to first configuration file
-h, --help This message
-s, --save Save changes to first configuration file
-""".lstrip() % sys.argv[0]
+""".lstrip() % sys.argv[0]
)
sys.exit(1)
def deprecated(message):
sys.exit(1)
def deprecated(message):
- print
"%s: deprecated usage" % sys.argv[0]
- print
message
+ print
("%s: deprecated usage" % sys.argv[0])
+ print
(message)
sys.exit(1)
sys.exit(1)
@@
-80,7
+80,7
@@
def main():
try:
(opts, argv) = getopt.gnu_getopt(sys.argv[1:], shortopts, longopts)
try:
(opts, argv) = getopt.gnu_getopt(sys.argv[1:], shortopts, longopts)
- except Exception
,
err:
+ except Exception
as
err:
sys.stderr.write("Error: " + str(err) + os.linesep)
sys.exit(1)
sys.stderr.write("Error: " + str(err) + os.linesep)
sys.exit(1)
@@
-119,7
+119,7
@@
def main():
elif opt == '-s' or opt == "--save":
if not optval:
usage()
elif opt == '-s' or opt == "--save":
if not optval:
usage()
- print
'parsed save option', optval
+ print
('parsed save option', optval)
save = optval
elif opt == '-h' or opt == "--help":
usage()
save = optval
elif opt == '-h' or opt == "--help":
usage()
@@
-134,17
+134,17
@@
def main():
config.load(file)
except IOError:
pass
config.load(file)
except IOError:
pass
- except Exception
,
err:
+ except Exception
as
err:
sys.stderr.write("Error: %s: %s" % (file, str(err)) + os.linesep)
sys.exit(1)
# --category, --variable, --value
sys.stderr.write("Error: %s: %s" % (file, str(err)) + os.linesep)
sys.exit(1)
# --category, --variable, --value
- if
category.has_key('id') and variable.has_key('id')
:
- if
variable.has_key('value')
:
+ if
'id' in category and 'id' in variable
:
+ if
'value' in variable
:
config.set(category['id'], variable['id'], variable['value'])
else:
value = config.get(category['id'], variable['id'])
config.set(category['id'], variable['id'], variable['value'])
else:
value = config.get(category['id'], variable['id'])
- print
value
+ print
(value)
# --shell, --php, --xml
if output is not None:
# --shell, --php, --xml
if output is not None:
@@
-156,9
+156,9
@@
def main():
# so that plc.d/{api,postgres} can create configs/site.xml
dirname = os.path.dirname(save)
if (not os.path.exists(dirname)):
# so that plc.d/{api,postgres} can create configs/site.xml
dirname = os.path.dirname(save)
if (not os.path.exists(dirname)):
- os.makedirs(dirname, 0755)
+ os.makedirs(dirname, 0
o
755)
if (not os.path.exists(dirname)):
if (not os.path.exists(dirname)):
- print
"Cannot create dir %s - exiting" % dirname
+ print
("Cannot create dir %s - exiting" % dirname)
sys.exit(1)
config.save(save)
sys.exit(1)
config.save(save)