def main(): log.start_logging() log.info("Starting RFLocus server") app = flask.Flask(__name__) flask_cors.CORS(app, resources={r"/*": {"origins": "*"}}) api = flask_restful.Api(app) log.info("RFLocus resource URI is %s", RFLOCUS_URI) api.add_resource(RFLResource, RFLOCUS_URI) app.run(host=HOST, port=PORT, debug=DEBUG)
async def on_start(client): global ONE_TIME_DONE if ONE_TIME_DONE: return ONE_TIME_DONE = True cors = [start_logging()] if variables.DISCOIN_TOKEN: variables.DISCOIN_CLIENT = Discoin(f"{variables.DISCOIN_TOKEN}", variables.DISCOIN_SELF_CURRENCY, loop=loop) cors.append(discoin_watcher(client)) if variables.NOFLYLIST_TOKEN: cors.append(blacklist_updater()) await asyncio.gather(*cors)
def main(): # check '~/.pyraxshell' and config files exist, create them if missing if not check_dir_home(): print ("This is the first time 'pyraxshell' runs, please, configure " "'%s' according to your needs" % CONFIG_FILE) #create db DB() Sessions.Instance().create_table_sessions() # @UndefinedVariable Sessions.Instance().create_table_commands() # @UndefinedVariable # create default configuration file Configuration.Instance() # @UndefinedVariable sys.exit(0) # ######################################## # VERSION CHECK if not version.check_version_file(): sys.exit(1) # ######################################## # LOGGING start_logging() logging.debug('starting') # from baseconfigfile import BaseConfigFile # bcf = BaseConfigFile() # ######################################## # ACCOUNTS accounts = Account.Instance() # @UnusedVariable @UndefinedVariable # config file is read by 'BaseConfigFile' constructor # ######################################## # CONFIGURATION cfg = Configuration.Instance() # @UndefinedVariable # override settings with CLI params cfg.parse_cli(sys.argv) logging.debug("configuration: %s" % cfg) # set user's log level if specified if not Configuration.Instance().log_level == None: # @UndefinedVariable l = logging.getLogger() for h in l.handlers: h.setLevel(cfg.log_level) # ######################################## # START SESSION Sessions.Instance().start_session() # @UndefinedVariable # Sessions.Instance().insert_table_commands('IN', 'OUT') # @UndefinedVariable # ######################################## # DO STUFF # handle configuration if cfg.pyrax_http_debug == True: pyrax.set_http_debug(True) if cfg.pyrax_no_verify_ssl == True: # see: https://github.com/rackspace/pyrax/issues/187 pyrax.set_setting("verify_ssl", False) # start notifier Notifier().start() # main loop Cmd_Pyraxshell().cmdloop()
def main(): # check '~/.pyraxshell' and config files exist, create them if missing if not check_dir_home(): print("This is the first time 'pyraxshell' runs, please, configure " "'%s' according to your needs" % CONFIG_FILE) #create db DB() Sessions.Instance().create_table_sessions() # @UndefinedVariable Sessions.Instance().create_table_commands() # @UndefinedVariable # create default configuration file Configuration.Instance() # @UndefinedVariable sys.exit(0) # ######################################## # VERSION CHECK if not version.check_version_file(): sys.exit(1) # ######################################## # LOGGING start_logging() logging.debug('starting') # from baseconfigfile import BaseConfigFile # bcf = BaseConfigFile() # ######################################## # ACCOUNTS accounts = Account.Instance() # @UnusedVariable @UndefinedVariable # config file is read by 'BaseConfigFile' constructor # ######################################## # CONFIGURATION cfg = Configuration.Instance() # @UndefinedVariable # override settings with CLI params cfg.parse_cli(sys.argv) logging.debug("configuration: %s" % cfg) # set user's log level if specified if not Configuration.Instance().log_level == None: # @UndefinedVariable l = logging.getLogger() for h in l.handlers: h.setLevel(cfg.log_level) # ######################################## # START SESSION Sessions.Instance().start_session() # @UndefinedVariable # Sessions.Instance().insert_table_commands('IN', 'OUT') # @UndefinedVariable # ######################################## # DO STUFF # handle configuration if cfg.pyrax_http_debug == True: pyrax.set_http_debug(True) if cfg.pyrax_no_verify_ssl == True: # see: https://github.com/rackspace/pyrax/issues/187 pyrax.set_setting("verify_ssl", False) # start notifier Notifier().start() # main loop Cmd_Pyraxshell().cmdloop()
def main(argv=None): if not argv: argv = sys.argv from optparse import OptionParser parser = OptionParser("%prog [options]") parser.add_option("--debug", "-d", help="spam with debug messages", action="store_true", default=False) parser.add_option("-b", "--browser", help="start web browser", dest="browser", default=0, action="store_true") parser.add_option("--config", help="dump JSON of configuration and exit", dest="config", action="store_true", default=0) opts, args = parser.parse_args(argv[1:]) if args: parser.error("wrong number of arguments") # Will exit if opts.config: dump_config() raise SystemExit ensure_user_config() ensure_user_config(USER_BROWSERS_FILE, BROWSERS_FILE) root = root_dir() chdir(root) start_logging() log("Sauce RC", "Sauce RC version %s started" % VERSION) daemon_thread(current_mode.start) daemon_thread(version_thread) daemon_thread(check_ondemand) daemon_thread(get_browsers) atexit.register(cleanup) config = { "/images" : { "tools.staticdir.on" : 1, "tools.staticdir.dir" : join(root, "images"), }, "/css" : { "tools.staticdir.on" : 1, "tools.staticdir.dir" : join(root, "css"), }, "/js" : { "tools.staticdir.on" : 1, "tools.staticdir.dir" : join(root, "js"), }, "/static" : { "tools.staticdir.on" : 1, "tools.staticdir.dir" : join(root, "static"), }, } if opts.browser: daemon_thread(open_browser_when_ready) cherrypy.config.update({"server.socket_host" : "0.0.0.0", "server.socket_port" : SERVER_PORT, "checker.check_skipped_app_config" : False, "log.screen" : False, }) cherrypy.engine.reexec_retry = 20 quickstart(WebServer(), config=config)
# -*- coding: utf-8 -*- from log import start_logging import gevent start_logging("./test.log", "%Y-%d-%m %X", level="=", bollback=("D", 15)) print "!", "abcdef", "12345" print "+ghighk", "34343" print "-hahaha", "67676" print "=", "ooxxx", "88989" print "xyzufo", "88989" print "!", {"a":2} gevent.wait()