# The database setup commands if sys.argv[1] == 'setupdb': logger.debug('Preparing to do database setup') DB.setup() logger.info('Database succesfully setup') print ' * Setup of database `%s` complete' % db.database sys.exit(0) # The start of hogar as a daemon. Debug is used # to keep the controlling terminal attached elif sys.argv[1] == 'start' or sys.argv[1] == 'debug': qprint(' * Loading plugins...') command_map = PluginLoader.prepare_plugins() if not command_map: qprint(' * No plugins found. Aborting.') sys.exit(1) qprint(' * Loaded plugins for {number} message types: {commands}'. format(number=len(command_map.keys()), commands='; '.join(command_map.keys()))) # Pass the checked command map to the instance # of Hogar app.set_command_map(command_map) # Decide if we should daemonize or stay attached if sys.argv[1] == 'start':
banner() # prepare a db setup command if len(sys.argv) > 1 : if sys.argv[1] == 'setupdb': logger.debug('Preparing to do database setup') DB.setup() logger.info('Database succesfully setup') print ' * Setup of database `%s` complete' % db.database sys.exit(0) else: print ' * Supported arguments are: setupdb' sys.exit(0) print ' * Loading plugins...' command_map = PluginLoader.prepare_plugins() if not command_map: print ' * No plugins found. Aborting.' sys.exit(1) print ' * Loaded plugins for {number} message types: {commands}'.format( number = len(command_map.keys()), commands = '; '.join(command_map.keys()) ) main()