• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python settings.load函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中settings.settings.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了load函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: initialize

def initialize():
    # 加载配置文件
    settings.load(os.path.join(HOME_DIR, ARGS.settings))
    
    loglevel = logging._checkLevel(ARGS.loglevel)
    
    # 日志配置
    log_format = '[%(asctime)-15s %(levelname)s:%(name)s:%(module)s] %(message)s'
    logging.basicConfig(level=loglevel, format=log_format)
开发者ID:rlcjj,项目名称:spider-blog,代码行数:9,代码来源:__main__.py


示例2: reload_settings

def reload_settings():
    """
    Reload settings if the timestamp of the
    settings file is newer than the settings
    file loaded in memory.
    """

    settings_file = path.join(getenv('HOME'), '.screenly', 'screenly.conf')
    settings_file_mtime = path.getmtime(settings_file)
    settings_file_timestamp = datetime.fromtimestamp(settings_file_mtime)

    if not last_settings_refresh or settings_file_timestamp > last_settings_refresh:
        settings.load()

    global last_setting_refresh
    last_setting_refresh = datetime.utcnow()
开发者ID:07jetta,项目名称:screenly-ose,代码行数:16,代码来源:viewer.py


示例3: reload_settings

def reload_settings():
    """
    Reload settings if the timestamp of the
    settings file is newer than the settings
    file loaded in memory.
    """

    settings_file = path.join(getenv('HOME'), '.screenly', 'screenly.conf')
    settings_file_mtime = path.getmtime(settings_file)
    settings_file_timestamp = datetime.fromtimestamp(settings_file_mtime)

    if not last_settings_refresh or settings_file_timestamp > last_settings_refresh:
        settings.load()

    logging.getLogger().setLevel(logging.DEBUG if settings['debug_logging'] else logging.INFO)

    global last_setting_refresh
    last_setting_refresh = datetime.utcnow()
开发者ID:phobozad,项目名称:screenly-ose,代码行数:18,代码来源:viewer.py


示例4: create_window

    def create_window(self):
        log.debug("Creating main window...")
        self.app = hildon.Program()
        self.window = hildon.StackableWindow()
        self.app.add_window(self.window)

        self.window.set_title("jamaendo")

        self.window.connect("destroy", self.destroy)

        self.CONFDIR = os.path.expanduser('~/MyDocs/.jamaendo')
        jamaendo.set_cache_dir(self.CONFDIR)
        settings.set_filename(os.path.join(self.CONFDIR, 'ui_settings'))
        settings.load()

        postoffice.connect('request-album-cover', self, self.on_request_cover)
        postoffice.connect('request-images', self, self.on_request_images)
        log.debug("Created main window.")
开发者ID:krig,项目名称:jamaendo,代码行数:18,代码来源:ui.py


示例5: run

def run():
    from spider import BlogSpider
    
    while True:
        settings.load(os.path.join(HOME_DIR, ARGS.settings))  # reload settings
        optionses = settings['BLOGS']
        
        blog_spiders = []
        
        for options in optionses:
            bs = BlogSpider(**options)
            bs.start()
            blog_spiders.append(bs)
    
        gevent.joinall(blog_spiders)
        
        logger.info('spider over, wait next')
        
        gevent.sleep(3600 * 24)  # 一天爬一次
开发者ID:rlcjj,项目名称:spider-blog,代码行数:19,代码来源:__main__.py


示例6: settings_page

def settings_page():

    context = {'flash': None}

    if request.method == "POST":
        for field, default in DEFAULTS['viewer'].items():
            value = request.POST.get(field, default)
            if isinstance(default, bool):
                value = value == 'on'
            settings[field] = value
        try:
            settings.save()
            context['flash'] = {'class': "success", 'message': "Settings were successfully saved."}
        except IOError as e:
            context['flash'] = {'class': "error", 'message': e}
    else:
        settings.load()
    for field, default in DEFAULTS['viewer'].items():
        context[field] = settings[field]

    return template('settings', **context)
开发者ID:Geo-Joy,项目名称:sync-pi-ose,代码行数:21,代码来源:server.py


示例7: main

def main():
	# Initiates the PyGame module.
	pygame.init()

	# Instantiates a PyGame Clock.
	main_clock = gameclock.GameClock()

	# Load the settings.
	settings.load()
	graphics.load()

	# Display modes, these are by standard double buffering (for performance reasons) and hardware acceleration (works if fullscreen is enabled).
	if graphics.FULLSCREEN:
		display_modes = DOUBLEBUF | HWSURFACE | FULLSCREEN
	else:
		display_modes = DOUBLEBUF | HWSURFACE

	# Setup the window surface to be used.
	window_surface = pygame.display.set_mode((settings.SCREEN_WIDTH, settings.SCREEN_HEIGHT), display_modes)

	# Initialize the camera.
	camera.create_camera(0, 0, settings.SCREEN_WIDTH, settings.SCREEN_HEIGHT)

	# Initialize the joystick module.
	pygame.joystick.init()

	# Initialize the available joysticks.
	for joystick in ([pygame.joystick.Joystick(x) for x in range(pygame.joystick.get_count())]):
		joystick.init()
	
	# Set the allowed events so we don't have to check for events that we don't listen to anyway.
	pygame.event.set_allowed([QUIT, KEYDOWN, KEYUP, JOYAXISMOTION, JOYBUTTONDOWN, JOYBUTTONUP])

	# Set the window caption.
	pygame.display.set_caption(settings.WINDOW_CAPTION)

	# Start the splash screen.
	splash.Splash(window_surface, main_clock)
开发者ID:Pigmassacre,项目名称:mBreak,代码行数:38,代码来源:mBreak.py


示例8: settings_page

def settings_page():

    context = {'flash': None}

    if request.method == "POST":
        for field, default in CONFIGURABLE_SETTINGS.items():
            value = request.POST.get(field, default)
            if isinstance(default, bool):
                value = value == 'on'
            settings[field] = value
        try:
            settings.save()
            sh.sudo('systemctl', 'kill', '--signal=SIGUSR2', 'screenly-viewer.service')
            context['flash'] = {'class': "success", 'message': "Settings were successfully saved."}
        except IOError as e:
            context['flash'] = {'class': "error", 'message': e}
        except sh.ErrorReturnCode_1 as e:
            context['flash'] = {'class': "error", 'message': e}
    else:
        settings.load()
    for field, default in DEFAULTS['viewer'].items():
        context[field] = settings[field]

    return template('settings', **context)
开发者ID:pcarass,项目名称:screenly-ose,代码行数:24,代码来源:server.py


示例9: load_settings

def load_settings():
    """Load settings and set the log level."""
    settings.load()
    logging.getLogger().setLevel(logging.DEBUG if settings['debug_logging'] else logging.INFO)
开发者ID:banglardamal,项目名称:lynda-ose,代码行数:4,代码来源:viewer.py


示例10: settings_page

def settings_page():
    context = {'flash': None}

    if request.method == "POST":
        try:
            # put some request variables in local variables to make easier to read
            current_pass = request.form.get('curpassword', '')
            new_pass = request.form.get('password', '')
            new_pass2 = request.form.get('password2', '')
            current_pass = '' if current_pass == '' else hashlib.sha256(current_pass).hexdigest()
            new_pass = '' if new_pass == '' else hashlib.sha256(new_pass).hexdigest()
            new_pass2 = '' if new_pass2 == '' else hashlib.sha256(new_pass2).hexdigest()

            new_user = request.form.get('user', '')
            use_auth = request.form.get('use_auth', '') == 'on'

            # Handle auth components
            if settings['password'] != '':  # if password currently set,
                if new_user != settings['user']:  # trying to change user
                    # should have current password set. Optionally may change password.
                    if current_pass == '':
                        if not use_auth:
                            raise ValueError("Must supply current password to disable authentication")
                        raise ValueError("Must supply current password to change username")
                    if current_pass != settings['password']:
                        raise ValueError("Incorrect current password.")

                    settings['user'] = new_user

                if new_pass != '' and use_auth:
                    if current_pass == '':
                        raise ValueError("Must supply current password to change password")
                    if current_pass != settings['password']:
                        raise ValueError("Incorrect current password.")

                    if new_pass2 != new_pass:  # changing password
                        raise ValueError("New passwords do not match!")

                    settings['password'] = new_pass

                if new_pass == '' and not use_auth and new_pass2 == '':
                    # trying to disable authentication
                    if current_pass == '':
                        raise ValueError("Must supply current password to disable authentication")
                    settings['password'] = ''

            else:  # no current password
                if new_user != '':  # setting username and password
                    if new_pass != '' and new_pass != new_pass2:
                        raise ValueError("New passwords do not match!")
                    if new_pass == '':
                        raise ValueError("Must provide password")
                    settings['user'] = new_user
                    settings['password'] = new_pass

            for field, default in CONFIGURABLE_SETTINGS.items():
                value = request.form.get(field, default)

                # skip user and password as they should be handled already.
                if field == "user" or field == "password":
                    continue

                if not value and field in ['default_duration', 'default_streaming_duration']:
                    value = str(0)

                if isinstance(default, bool):
                    value = value == 'on'
                settings[field] = value

            settings.save()
            publisher = ZmqPublisher.get_instance()
            publisher.send_to_viewer('reload')
            context['flash'] = {'class': "success", 'message': "Settings were successfully saved."}
        except ValueError as e:
            context['flash'] = {'class': "danger", 'message': e}
        except IOError as e:
            context['flash'] = {'class': "danger", 'message': e}
        except OSError as e:
            context['flash'] = {'class': "danger", 'message': e}
    else:
        settings.load()
    for field, default in DEFAULTS['viewer'].items():
        context[field] = settings[field]

    context['user'] = settings['user']
    context['password'] = "password" if settings['password'] != "" else ""

    context['is_balena_app'] = is_balena_app()

    if not settings['user'] or not settings['password']:
        context['use_auth'] = False
    else:
        context['use_auth'] = True

    return template('settings.html', **context)
开发者ID:vpetersson,项目名称:screenly-ose,代码行数:95,代码来源:server.py


示例11: main

def main():
    """Usage: %prog [options] command

Available commands:
  add    \t\tsearches, prompts for project, activity and alias, adds to .tksrc
  commit \t\tcommits the changes to the server
  edit   \t\topens your zebra file in your favourite editor
  help   \t\tprints this help or the one of the given command
  search \t\tsearches for a project
  show   \t\tshows the activities and other details of a project
  start  \t\tstarts the counter on a given activity
  status \t\tshows the status of your entries file
  stop   \t\tstops the counter and record the elapsed time
  update \t\tupdates your project database with the one on the server
  autofill \t\tautofills the current timesheet with all the days of the month"""

    usage = main.__doc__
    locale.setlocale(locale.LC_ALL, '')

    opt = OptionParser(usage=usage, version='%prog ' + taxi.__version__)
    opt.add_option('-c', '--config', dest='config', help='use CONFIG file instead of ~/.tksrc', default=os.path.join(os.path.expanduser('~'), '.tksrc'))
    opt.add_option('-v', '--verbose', dest='verbose', action='store_true', help='make taxi verbose', default=False)
    opt.add_option('-f', '--file', dest='file', help='parse FILE instead of the '\
            'one defined in your CONFIG file')
    opt.add_option('-d', '--date', dest='date', help='only process entries for date '\
            'DATE (eg. 31.01.2011, 31.01.2011-05.02.2011)')
    opt.add_option('--ignore-date-error',
            dest='ignore_date_error', help='suppresses the error if'\
            ' you\'re trying to commit a date that\'s on a week-end or on another'\
            ' day than the current day or the day before', action='store_true', default=False)
    (options, args) = opt.parse_args()

    args = [term_unicode(arg) for arg in args]

    actions = [
            (['stat', 'status'], status),
            (['ci', 'commit'], commit),
            (['up', 'update'], update),
            (['search'], search),
            (['show'], show),
            (['start'], start),
            (['stop'], stop),
            (['edit'], edit),
            (['add'], add),
            (['autofill'], autofill),
    ]

    if len(args) == 0 or (len(args) == 1 and args[0] == 'help'):
        opt.print_help()
        exit()

    settings.load(options.config)
    if not os.path.exists(settings.TAXI_PATH):
        os.mkdir(settings.TAXI_PATH)

    if options.file is None:
        try:
            options.file = settings.get('default', 'file')
        except ConfigParser.NoOptionError:
            raise Exception("""Error: no file to parse. You must either define \
one in your config file with the 'file' setting, or use the -f option""")

    options.unparsed_file = options.file
    options.file = datetime.date.today().strftime(os.path.expanduser(options.file))

    if options.date is not None:
        date_format = '%d.%m.%Y'

        try:
            if '-' in options.date:
                splitted_date = options.date.split('-', 1)

                options.date = (datetime.datetime.strptime(splitted_date[0],\
                        date_format).date(),
                        datetime.datetime.strptime(splitted_date[1],
                            date_format).date())
            else:
                options.date = datetime.datetime.strptime(options.date,\
                        date_format).date()
        except ValueError:
            opt.print_help()
            exit()

    try:
        call_action(actions, options, args)
    except ProjectNotFoundError as e:
        if options.verbose:
            raise

        print e.description
        print suggest_project_names(e.project_name)
    except Exception as e:
        if options.verbose:
            raise

        print e
开发者ID:waldvogel,项目名称:taxi,代码行数:96,代码来源:app.py


示例12: load_settings

def load_settings():
    """Load settings and set the log level."""
    settings.load()
开发者ID:jinkanban,项目名称:showtime-client,代码行数:3,代码来源:viewer.py


示例13: Copyright

from tangiblePattern	import tangibles


# clear screen and print program info
os.system('cls' if os.name=='nt' else 'clear')

print "Vega - TUIO proxy Copyright (C) 2012 Thomas Becker"
print "This program comes with ABSOLUTELY NO WARRANTY."
print "This is free software, and you are welcome to redistribute it"
print "under certain conditions."
print ""

print "TUIO proxy started"

# load settings from files
settings.load()

# load tangibles from disk
tangibles.loadTangiblesFromDisk()

# start the tuio proxy
tuioServer.start()

# start remote control for this programm
remote.start()

print "TUIO proxy up and running..."

try :
	while 1 :
		pass
开发者ID:hoshijirushi,项目名称:Vega,代码行数:31,代码来源:PROXY.py



注:本文中的settings.settings.load函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python settings_base.SettingsBase类代码示例发布时间:2022-05-27
下一篇:
Python settings.get_theming_attribute函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap