Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def check_auth(username, password):
# Load from local settings file in configs, or if not, from system settings in etc.
(auth_settings,path) = pybit.load_settings("web/web.conf")
if not auth_settings:
# Cant load settings
return False
# Check credentials
if auth_settings['web']['username'] == username and auth_settings['web']['password'] == password:
return True
else:
return False
if __name__ == '__main__':
parser = optparse.OptionParser()
#options we can override in the config file.
groupConfigFile = optparse.OptionGroup(parser,
"Config File Defaults","All the options which have defaults read from a config file.")
parser.add_option_group(groupConfigFile)
parser.add_option_group(groupConfigFile)
parser.add_option("--config", dest="config", default="web/web.conf",
help="Config file to read settings from, defaults to web.conf which will be read from configs/ and /etc/pybit/ in turn.",
metavar=META + "CONF_FILE")
parser.add_option("-v", dest="verbose", action="store_true", default=False,
help="Turn on verbose messages.", metavar=META+"VERBOSE")
(options, args) = parser.parse_args()
(settings, opened_file) = pybit.load_settings(options.config)
settings = pybit.merge_options(settings, groupConfigFile, options)
FORMAT = '%(asctime)s %(filename)s:%(lineno)d %(msg)s'
logging.basicConfig( stream=sys.stderr, level=logging.WARN)
logging.basicConfig( format=FORMAT )
myDb = Database(settings['db']) # singleton instance
buildController = Controller(settings, myDb) # singleton instance - Needs access to both controller and web settings
# try:
app = pybitweb.get_app(settings, myDb, buildController)
bottle.debug(options.verbose)
bottle.run(app=app,
server=settings['web']['app'],
host=settings['web']['interface'],
port=settings['web']['port'],
reloader=settings['web']['reloader'])