我们从Python开源项目中,提取了以下24个代码示例,用于说明如何使用settings.settings()。
def add_new_gif(visible_gifs, gif): """Add new gif to visible gifs, this might push the oldest away from visible! """ new_gif = { 'id': gif['id'], 'position': {'bottom': 40, 'left': 50}, 'height': gif['height'], 'added': int(time.time()) } if len(visible_gifs) >= settings['maxVisible']: oldest = visible_gifs.pop(0) logger.info('Popped oldest %s' % oldest['id']) # Take position from the oldest new_gif['position'] = oldest['position'] new_gif['height'] = oldest['height'] visible_gifs.append(new_gif)
def get_serial_list(): baselist=[] baselist = baselist \ + glob.glob("/dev/ttyUSB*") \ + glob.glob("/dev/ttyACM*") \ + glob.glob("/dev/tty.usb*") \ + glob.glob("/dev/cu.*") \ + glob.glob("/dev/rfcomm*") additionalPorts = WebConfig.settings().get(["serial", "additionalPorts"]) for additional in additionalPorts: baselist += glob.glob(additional) if "AUTO" not in baselist: baselist.insert(0, "AUTO") prev = WebConfig.settings().get(["serial", "port"]) if prev in baselist: baselist.remove(prev) baselist.insert(0, prev) if WebConfig.settings().getBoolean(["devel", "virtualPrinter", "enabled"]): baselist.append("VIRTUAL") return baselist
def __init__(self): handlers = [ URLSpec(r'/', IndexHandler), URLSpec(r'/cat/(\d{1,2})', CatHandler, name="cat"), URLSpec(r'/detail/(\w+)', DetailHandler), URLSpec(r'/login', LoginHandler), ] tornado.web.Application.__init__(self, handlers, **settings.settings) self.db = torndb.Connection(host=settings.DBHOST, database=settings.DATABASE, user=settings.DBUSER, password=settings.DBPWD)
def __init__(self): logging.info("init MainApplication with settings: %s" % str(settings)) tornado.web.Application.__init__(self, url_patterns, **settings)
def get_settings(env, start_response): start_response('200 OK', [('Content-Type', 'application/json')]) return [json.dumps(settings)] # Functions for responding to file requests etc.
def __init__(self): tornado.web.Application.__init__(self, url_patterns, **settings)
def set_local_control(self,status): print("Setting local control to "+str(status)) self.usr_local_control = int(status) self.local_control = self.usr_local_control #fix into persistent memory settings[2] = self.usr_local_control f = open(self.cwd+'/../thermostat/settings.py','w') f.write('settings = ' + str(settings)) f.close()
def read_temp(self): temp = self.instance.read_temp() return str(temp),str(settings[1])
def set_mode(self,mode): self.user_mode =str(mode) #fix into persistent memory settings[0] = self.user_mode f = open(self.cwd+'/../thermostat/settings.py','w') f.write('settings = ' + str(settings)) f.close()
def set_setpoint(self,setpoint): self.instance.set_setpoint(float(setpoint)) #fix into persistent memory settings[1] = float(setpoint) f = open(self.cwd+'/../thermostat/settings.py','w') f.write('settings = ' + str(settings)) f.close()
def __init__(self, config_path, **kwargs): super(LocalControl_Agent, self).__init__(**kwargs) self.Config = utils.load_config(config_path) self.zonenum = self.Config["zonenum"] self.deadband = settings[2] self.min_switch_time = settings[1] self.setpoint = settings[0] self.last_switch_time = time.time() self.usr_mode = 0
def get_baudrate_list(): ret = [115200, 250000, 230400, 57600, 38400, 19200, 9600] prev = WebConfig.settings().get(["serial", "baudrate"]) if prev == "AUTO": ret.insert(0, "AUTO") elif prev in ret: ret.remove(prev) ret.insert(0, prev) else: pass return ret
def __init__(self): tornado.web.Application.__init__(self, url_patterns, **settings) self._redis = _db.redis_client self._motor = get_mongodb(CONFIG.MONGO.DATABASE, client='motor') connect(CONFIG.MONGO.DATABASE, host=CONFIG.MONGO.HOST, port=CONFIG.MONGO.PORT, io_loop=tornado.ioloop.IOLoop.current()) # motorengine
def app_settings(cls): dirname = os.path.dirname(os.path.abspath(__file__)) return { "debug": options.debug, "cookie_secret": options.cookie_secret, "xsrf_cookies": options.xsrf_cookies, "twitter_consumer_key": options.twitter_consumer_key, "twitter_consumer_secret": options.twitter_consumer_secret, # invariant settings "login_url": "/sign-in", "static_path": os.path.join(dirname, "static"), "template_path": os.path.join(dirname, "templates"), "ui_modules": lib.uimodules, }
def __init__(self, *args, **settings): self.db = register_connection(host=options.database_host, name=options.database_name, user=options.database_user, password=options.database_password, charset="utf8mb4") if options.use_query_cache: lib.flyingcow.cache.use_query_cache = True if options.stripe_secret_key: stripe.api_key = options.stripe_secret_key super(MltshpApplication, self).__init__(*args, **settings)
def main(): db_path = "{root_path}/{db}".format(root_path=settings['sqlite'], db=settings['db']) if not db_init(db_path): print "Init DB Failed" sys.exit(999) print "Init DB Success" app = LittleFSApp() http_server = tornado.httpserver.HTTPServer(app, max_buffer_size=1024 * 1024 * 1024) http_server.listen(options.port) print "Start PyWeedFS Success" tornado.ioloop.IOLoop.instance().start()
def __init__(self): print '\ninside Application __init__()' tornado.web.Application.__init__(self, urls, **settings) print 'Aapplication __init__ caleed with web.Application()' print 'returning from Application __init__'
def __init__(self): tornado.web.Application.__init__(self, urls, **settings)
def main_app(env, start_response): """Provides following features: - Serves static files - /debug route for mobile debugging - /command route for interacting with computer """ request_path = env['PATH_INFO'] if request_path == '/debug': return debug(env, start_response) elif request_path == '/settings': return get_settings(env, start_response) elif request_path == '/get_gif': ret, stdout, stderr = run_command(settings['gifScriptCommand']) print('STDOUT') print('------') print(stdout) print('STDERR') print('------') print(stderr) if ret != 0: response = 'Error' start_response('500 OK', HEADERS) return [json.dumps(response)] preview_path = path.get_resource('static/img/preview.gif') if not os.path.isfile(preview_path): response = 'Error' start_response('500 OK', HEADERS) return [json.dumps(response)] response = 'OK' start_response('200 OK', HEADERS) return [json.dumps(response)] elif request_path == '/save_gif': directory = os.path.abspath(settings['gifsDirectory']) new_name = str(int(time.time())) + '.gif' os.rename(path.get_resource('static/img/preview.gif'), path.get_resource('static/img/%s' % new_name)) shutil.move(path.get_resource('static/img/%s' % new_name), directory) response = 'OK' start_response('200 OK', HEADERS) return [json.dumps(response)] # Serve a file if it's found. else: if request_path == '/': request_path = '/static/index.html' return file_response(request_path, start_response)