diff --git a/LCS/PyCommon/dbcredentials.py b/LCS/PyCommon/dbcredentials.py index e68bed2e00119448480c242735155196b6a6ee18..7b941ac1a2ac118ce3c614c5d72ffb4941a3f9d4 100644 --- a/LCS/PyCommon/dbcredentials.py +++ b/LCS/PyCommon/dbcredentials.py @@ -22,7 +22,7 @@ from glob import glob import os import pwd -from ConfigParser import SafeConfigParser, NoSectionError, DuplicateSectionError +from configparser import SafeConfigParser, NoSectionError, DuplicateSectionError from optparse import OptionGroup from os import stat, path, chmod import logging @@ -159,10 +159,10 @@ class DBCredentials: # make sure the files are mode 600 to hide passwords 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) try: - chmod(file, 0600) + chmod(file, 0o600) except Exception as e: logger.error('Error: Could not change permissions on %s: %s' % (file, str(e))) @@ -293,7 +293,7 @@ if __name__ == "__main__": (options, args) = parser.parse_args() if not options.database and not options.list and not options.files: - print "Missing database name" + logger.error("Missing database name") parser.print_help() sys.exit(1) @@ -302,16 +302,16 @@ if __name__ == "__main__": if options.files: """ Print list of configuration files that we've read. """ if dbc.files: - print "\n".join(dbc.files) + logger.info("\n".join(dbc.files)) sys.exit(0) if options.list: """ Print list of databases. """ databases = dbc.list() if databases: - print "\n".join(databases) + logger.info("\n".join(databases)) sys.exit(0) """ Print credentials of a specific database. """ - print str(dbc.get(options.database)) + logger.info(str(dbc.get(options.database)))