Skip to content
Snippets Groups Projects
Commit 59d52264 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

LSMR-20: made module python3 compliant

parent 0dd5fa99
No related branches found
No related tags found
1 merge request!87Lsmr epic
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
from glob import glob from glob import glob
import os import os
import pwd import pwd
from ConfigParser import SafeConfigParser, NoSectionError, DuplicateSectionError from configparser import SafeConfigParser, NoSectionError, DuplicateSectionError
from optparse import OptionGroup from optparse import OptionGroup
from os import stat, path, chmod from os import stat, path, chmod
import logging import logging
...@@ -159,10 +159,10 @@ class DBCredentials: ...@@ -159,10 +159,10 @@ class DBCredentials:
# make sure the files are mode 600 to hide passwords # make sure the files are mode 600 to hide passwords
for file in self.files: for file in self.files:
if oct(stat(file).st_mode & 0777) != '0600': if oct(stat(file).st_mode & 0o777) != '0o600':
logger.info('Changing permissions of %s to 600' % file) logger.info('Changing permissions of %s to 600' % file)
try: try:
chmod(file, 0600) chmod(file, 0o600)
except Exception as e: except Exception as e:
logger.error('Error: Could not change permissions on %s: %s' % (file, str(e))) logger.error('Error: Could not change permissions on %s: %s' % (file, str(e)))
...@@ -293,7 +293,7 @@ if __name__ == "__main__": ...@@ -293,7 +293,7 @@ if __name__ == "__main__":
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if not options.database and not options.list and not options.files: if not options.database and not options.list and not options.files:
print "Missing database name" logger.error("Missing database name")
parser.print_help() parser.print_help()
sys.exit(1) sys.exit(1)
...@@ -302,16 +302,16 @@ if __name__ == "__main__": ...@@ -302,16 +302,16 @@ if __name__ == "__main__":
if options.files: if options.files:
""" Print list of configuration files that we've read. """ """ Print list of configuration files that we've read. """
if dbc.files: if dbc.files:
print "\n".join(dbc.files) logger.info("\n".join(dbc.files))
sys.exit(0) sys.exit(0)
if options.list: if options.list:
""" Print list of databases. """ """ Print list of databases. """
databases = dbc.list() databases = dbc.list()
if databases: if databases:
print "\n".join(databases) logger.info("\n".join(databases))
sys.exit(0) sys.exit(0)
""" Print credentials of a specific database. """ """ Print credentials of a specific database. """
print str(dbc.get(options.database)) logger.info(str(dbc.get(options.database)))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment