def main(): logger = setup_logging() db.initialize(conf) if not dry_run: server = SimpleXMLRPCServer((conf['host'], conf['port']), logRequests=False, allow_none=True) server.register_introspection_functions() server.register_instance(SiEDRPCHandler(conf)) logger.info('XMLRPCServer setup, starting...') server.serve_forever() else: s = SiEDRPCHandler(conf) ctext = util.encrypt(hashlib.sha512('jemoeder').digest(), 'bla') s.testcrypto(ctext)
def main(): (options, conf, args) = config.parse_opts() try: # the database_path is usually the show_path, but can be defined in conf if ConfKeys.DB_PATH in conf: database_path = os.path.join(conf[ConfKeys.DB_PATH], u".next.db") else: database_path = os.path.join(conf[ConfKeys.SHOW_PATH], u".next.db") database_path = os.path.expanduser(os.path.expandvars(database_path)) except KeyError: print (u"No show_path or database_path defined in configuration, aborting!") sys.exit(-1) # initialize the sqlite database try: if os.path.exists(database_path) or os.access(os.path.dirname(database_path), os.W_OK | os.R_OK): conf[ConfKeys.DB_CONN] = db.initialize(database_path) else: print ( u'Could not access shows database, path "{0}" does not exist or we don\'t have write access!'.format( database_path ) ) sys.exit(-1) except sqlite3.OperationalError: print (u'Could not access shows database, are the permissions correct for "{0}"?'.format(database_path)) sys.exit(-1) # first check for commandline options if options.func: try: options.func() except UserCancelled: print "User cancelled!" except KeyboardInterrupt: print "\nUser pressed ^C!" sys.exit(0) # couple of usecases: # 1. there is an argument provided. this is probably a show that the user wants # us to start, so let's start it. # 2. there are no arguments provided. provide the user with a query what he wants if len(args): # 1. user provided a showname, find it in the db, then play it. s = db.find_show(conf, u" ".join(args)) if s: player.play_next(conf, s) else: print u'Show "{0}" could not be found!'.format(u" ".join(args)) else: # 2. user provided nothing, popup a list of options ui = TUI(conf) try: ui.cmdloop() except KeyboardInterrupt: print "\nUser pressed ^C, exitting!"
my_wishes(bot, update) @atexit.register def goodbye(): global my_scheduler scraper.active = False my_scheduler.clear() if __name__ == '__main__': uses_netloc.append('postgres') url = urlparse(os.environ['DATABASE_URL']) db.initialize( PostgresqlDatabase(database=url.path[1:], user=url.username, password=url.password, host=url.hostname, port=url.port)) # Connect to our database. db.connect() # Create the tabactive les. db.create_tables([User, Wish, Room]) # Enable logging logging.basicConfig( format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) logger = logging.getLogger(__name__)
def clear_db(self): db.initialize(self.conf)