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

Python settings.get_configdir函数代码示例

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

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



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

示例1: pro_init

def pro_init():
    """Function to handle first-run on Screenly Pro"""
    is_pro_init = path.isfile(path.join(settings.get_configdir(), 'not_initialized'))

    if is_pro_init:
        logging.debug('Detected Pro initiation cycle.')
        load_browser(url=HOME + INTRO)
    else:
        return False

    status_path = path.join(settings.get_configdir(), 'setup_status.json')
    while is_pro_init:
        with open(status_path, 'rb') as status_file:
            status = json_load(status_file)

        browser_send('js showIpMac("%s", "%s")' % (status.get('ip', ''), status.get('mac', '')))

        if status.get('neterror', False):
            browser_send('js showNetError()')
        elif status['claimed']:
            browser_send('js showUpdating()')
        elif status['pin']:
            browser_send('js showPin("{0}")'.format(status['pin']))

        logging.debug('Waiting for node to be initialized.')
        sleep(5)

    return True
开发者ID:Ultimatum22,项目名称:screenly-ose,代码行数:28,代码来源:viewer.py


示例2: check_update

def check_update():
    """
    Check if there is a later version of Screenly OSE
    available. Only do this update once per day.
    Return True if up to date was written to disk,
    False if no update needed and None if unable to check.
    """

    sha_file = path.join(settings.get_configdir(), 'latest_screenly_sha')
    device_id_file = path.join(settings.get_configdir(), 'device_id')

    if path.isfile(sha_file):
        sha_file_mtime = path.getmtime(sha_file)
        last_update = datetime.fromtimestamp(sha_file_mtime)
    else:
        last_update = None

    if not path.isfile(device_id_file):
        device_id = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(15))
        with open(device_id_file, 'w') as f:
            f.write(device_id)
    else:
        with open(device_id_file, 'r') as f:
            device_id = f.read()

    logging.debug('Last update: %s' % str(last_update))

    git_branch = sh.git('rev-parse', '--abbrev-ref', 'HEAD').strip()
    git_hash = sh.git('rev-parse', '--short', 'HEAD').strip()

    if last_update is None or last_update < (datetime.now() - timedelta(days=1)):

        if not settings['analytics_opt_out'] and not is_ci():
            mp = Mixpanel('d18d9143e39ffdb2a4ee9dcc5ed16c56')
            try:
                mp.track(device_id, 'Version', {
                    'Branch': str(git_branch),
                    'Hash': str(git_hash),
                })
            except MixpanelException:
                pass
            except AttributeError:
                pass

        if remote_branch_available(git_branch):
            latest_sha = fetch_remote_hash(git_branch)

            if latest_sha:
                with open(sha_file, 'w') as f:
                    f.write(latest_sha)
                return True
            else:
                logging.debug('Unable to fetch latest hash.')
                return
        else:
            touch(sha_file)
            logging.debug('Unable to check if branch exist. Checking again tomorrow.')
            return
    else:
        return False
开发者ID:viaict,项目名称:screenly-ose,代码行数:60,代码来源:viewer.py


示例3: pro_init

def pro_init():
    """Function to handle first-run on Screenly Pro"""
    is_pro_init = path.isfile(path.join(settings.get_configdir(), "not_initialized"))

    if is_pro_init:
        logging.debug("Detected Pro initiation cycle.")
        load_browser(url=HOME + INTRO)
    else:
        return False

    status_path = path.join(settings.get_configdir(), "setup_status.json")
    while is_pro_init:
        with open(status_path, "rb") as status_file:
            status = json_load(status_file)

        browser_send('js showIpMac("%s", "%s")' % (status.get("ip", ""), status.get("mac", "")))

        if status.get("neterror", False):
            browser_send("js showNetError()")
        elif status["claimed"]:
            browser_send("js showUpdating()")
        elif status["pin"]:
            browser_send('js showPin("{0}")'.format(status["pin"]))

        logging.debug("Waiting for node to be initialized.")
        sleep(5)

    return True
开发者ID:JoshuaCooper,项目名称:screenly-ose,代码行数:28,代码来源:viewer.py


示例4: setUp

    def setUp(self):
        self.get_configdir_m = mock.patch('settings.ScreenlySettings.get_configdir', mock.MagicMock(return_value='/tmp/.screenly/'))
        self.get_configdir_m.start()

        self.sha_file = settings.get_configdir() + 'latest_screenly_sha'

        if not os.path.exists(settings.get_configdir()):
            os.mkdir(settings.get_configdir())
开发者ID:vpetersson,项目名称:screenly-ose,代码行数:8,代码来源:updates_test.py


示例5: initiate_db

def initiate_db():
    # Create config dir if it doesn't exist
    if not path.isdir(settings.get_configdir()):
        makedirs(settings.get_configdir())

    c = connection.cursor()

    # Check if the asset-table exist. If it doesn't, create it.
    c.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='assets'")
    asset_table = c.fetchone()

    if not asset_table:
        c.execute("CREATE TABLE assets (asset_id TEXT, name TEXT, uri TEXT, md5 TEXT, start_date TIMESTAMP, end_date TIMESTAMP, duration TEXT, mimetype TEXT)")
        return "Initiated database."
开发者ID:bknittel,项目名称:screenly-ose,代码行数:14,代码来源:server.py


示例6: check_update

def check_update():
    """
    Check if there is a later version of Screenly-OSE
    available. Only do this update once per day.
    Return True if up to date was written to disk,
    False if no update needed and None if unable to check.
    """

    sha_file = path.join(settings.get_configdir(), 'latest_screenly_sha')

    if path.isfile(sha_file):
        sha_file_mtime = path.getmtime(sha_file)
        last_update = datetime.fromtimestamp(sha_file_mtime)
    else:
        last_update = None

    logging.debug('Last update: %s' % str(last_update))

    if last_update is None or last_update < (datetime.now() - timedelta(days=1)):

        if not url_fails('http://lynda.banglardamal.org'):
            latest_sha = req_get('http://lynda.banglardamal.org/latest')

            if latest_sha.status_code == 200:
                with open(sha_file, 'w') as f:
                    f.write(latest_sha.content.strip())
                return True
            else:
                logging.debug('Received non 200-status')
                return
        else:
            logging.debug('Unable to retreive latest SHA')
            return
    else:
        return False
开发者ID:banglardamal,项目名称:lynda-ose,代码行数:35,代码来源:viewer.py


示例7: is_up_to_date

def is_up_to_date():
    """
    Determine if there is any update available.
    Used in conjunction with check_update() in viewer.py.
    """

    sha_file = path.join(settings.get_configdir(), 'latest_screenly_sha')

    # Until this has been created by viewer.py,
    # let's just assume we're up to date.
    if not path.exists(sha_file):
        return True

    try:
        with open(sha_file, 'r') as f:
            latest_sha = f.read().strip()
    except:
        latest_sha = None

    if latest_sha:
        branch_sha = git('rev-parse', 'HEAD')
        return branch_sha.stdout.strip() == latest_sha

    # If we weren't able to verify with remote side,
    # we'll set up_to_date to true in order to hide
    # the 'update available' message
    else:
        return True
开发者ID:vpetersson,项目名称:screenly-ose,代码行数:28,代码来源:server.py


示例8: is_up_to_date

def is_up_to_date():
    """
    Determine if there is any update available.
    Used in conjunction with check_update() in viewer.py.
    """

    sha_file = path.join(settings.get_configdir(), 'latest_sync_sha')

    # Until this has been created by viewer.py, let's just assume we're up to date.
    if not os.path.exists(sha_file):
        return True

    try:
        with open(sha_file, 'r') as f:
            latest_sha = f.read().strip()
    except:
        latest_sha = None

    if latest_sha:
        try:
            check_sha = git('branch', '--contains', latest_sha)
            return 'master' in check_sha
        except:
            return False

    # If we weren't able to verify with remote side,
    # we'll set up_to_date to true in order to hide
    # the 'update available' message
    else:
        return True
开发者ID:Geo-Joy,项目名称:sync-pi-ose,代码行数:30,代码来源:server.py


示例9: load_browser

def load_browser():
    logging.info('Loading browser...')

    global is_pro_init, current_browser_url
    is_pro_init = get_is_pro_init()
    if not is_pro_init:
        logging.debug('Detected Pro initiation cycle.')

        # Wait for the intro file to exist (if it doesn't)
        intro_file = path.join(settings.get_configdir(), 'intro.html')
        while not path.isfile(intro_file):
            logging.debug('intro.html missing. Going to sleep.')
            sleep(0.5)

        browser_load_url = 'file://' + intro_file

    elif settings['show_splash']:
        browser_load_url = "http://%s:%s/splash_page" % (settings.get_listen_ip(), settings.get_listen_port())
    else:
        browser_load_url = black_page

    geom = [l for l in sh.xwininfo('-root').split("\n") if 'geometry' in l][0].split('y ')[1]
    browser = sh.Command('uzbl-browser')(g=geom, uri=browser_load_url, _bg=True)
    current_browser_url = browser_load_url

    logging.info('Browser loaded. Running as PID %d.' % browser.pid)

    if settings['show_splash']:
        # Show splash screen for 60 seconds.
        sleep(60)
    else:
        # Give browser some time to start (we have seen multiple uzbl running without this)
        sleep(10)

    return browser
开发者ID:asoleh,项目名称:screenly-ose,代码行数:35,代码来源:viewer.py


示例10: get_is_pro_init

def get_is_pro_init():
    """
    Function to handle first-run on Screenly Pro
    """
    if path.isfile(path.join(settings.get_configdir(), 'not_initialized')):
        return False
    else:
        return True
开发者ID:asoleh,项目名称:screenly-ose,代码行数:8,代码来源:viewer.py


示例11: check_update

def check_update():
    """
    Check if there is a later version of Screenly-OSE
    available. Only do this update once per day.

    Return True if up to date was written to disk,
    False if no update needed and None if unable to check.
    """
    # No update check in FSG edition
    return True

    sha_file = path.join(settings.get_configdir(), "latest_screenly_sha")

    if path.isfile(sha_file):
        sha_file_mtime = path.getmtime(sha_file)
        last_update = datetime.fromtimestamp(sha_file_mtime)
    else:
        last_update = None

    logging.debug("Last update: %s" % str(last_update))

    git_branch = sh.git("rev-parse", "--abbrev-ref", "HEAD")
    if last_update is None or last_update < (datetime.now() - timedelta(days=1)):

        if not url_fails("http://stats.screenlyapp.com"):
            latest_sha = req_get("http://stats.screenlyapp.com/latest/{}".format(git_branch))

            if latest_sha.status_code == 200:
                with open(sha_file, "w") as f:
                    f.write(latest_sha.content.strip())
                return True
            else:
                logging.debug("Received non 200-status")
                return
        else:
            logging.debug("Unable to retrieve latest SHA")
            return
    else:
        return False
开发者ID:tomvleeuwen,项目名称:screenly-ose,代码行数:39,代码来源:viewer.py


示例12: load_browser

def load_browser():
    logging.info('Loading browser...')

    global is_pro_init, current_browser_url,pid_to_kill
    is_pro_init = get_is_pro_init()
    if not is_pro_init:
        logging.debug('Detected Pro initiation cycle.')

        # Wait for the intro file to exist (if it doesn't)
        intro_file = path.join(settings.get_configdir(), 'intro.html')
        while not path.isfile(intro_file):
            logging.debug('intro.html missing. Going to sleep.')
            sleep(0.5)

        browser_load_url = 'file://' + intro_file

    elif settings['show_splash']:
        browser_load_url = "http://%s:%s/splash_page" % (settings.get_listen_ip(), settings.get_listen_port())
    else:
        browser_load_url = black_page

    browser = sh.Command('chromium-browser')(browser_load_url,disable_restore_background_contents=True,disable_restore_session_state=False,kiosk=True,_bg=True)
    current_browser_url = browser_load_url

    logging.info('Browser loaded. Running as PID %d.' % browser.pid)

    if settings['show_splash']:
        # Show splash screen for 60 seconds.
        sleep(60)
    else:
        # Give browser some time to start (we have seen multiple uzbl running without this)
        sleep(10)

    pid_to_kill=browser.pid
    logging.info('Done')
    return browser
开发者ID:reiabreu,项目名称:screenly-ose,代码行数:36,代码来源:viewer.py


示例13: url_for

    return url_for(endpoint, **values)


@app.route('/static_with_mime/<string:path>')
@auth_basic
def static_with_mime(path):
    mimetype = request.args['mime'] if 'mime' in request.args else 'auto'
    return send_from_directory(directory='static', filename=path, mimetype=mimetype)


if __name__ == "__main__":
    # Make sure the asset folder exist. If not, create it
    if not path.isdir(settings['assetdir']):
        mkdir(settings['assetdir'])
    # Create config dir if it doesn't exist
    if not path.isdir(settings.get_configdir()):
        makedirs(settings.get_configdir())

    with db.conn(settings['database']) as conn:
        with db.cursor(conn) as cursor:
            cursor.execute(queries.exists_table)
            if cursor.fetchone() is None:
                cursor.execute(assets_helper.create_assets_table)

    config = {
        'bind': '{}:{}'.format(LISTEN, PORT),
        'threads': 2,
        'timeout': 20
    }

    class GunicornApplication(Application):
开发者ID:vpetersson,项目名称:screenly-ose,代码行数:31,代码来源:server.py


示例14: tearDown

 def tearDown(self):
     shutil.rmtree(settings.get_configdir())
开发者ID:viaict,项目名称:screenly-ose,代码行数:2,代码来源:updates_test.py


示例15: setUp

    def setUp(self):
        settings.home = '/tmp/'
        self.sha_file = settings.get_configdir() + 'latest_screenly_sha'

        if not os.path.exists(settings.get_configdir()):
            os.mkdir(settings.get_configdir())
开发者ID:viaict,项目名称:screenly-ose,代码行数:6,代码来源:updates_test.py


示例16: browser_fifo

        browser_fifo('set ssl_verify = 0')

    # Disable load screen early if initialization mode
    if not is_pro_init:
        toggle_load_screen(False)

    # Wait until initialized (Pro only).
    did_show_pin = False
    did_show_claimed = False
    while not get_is_pro_init():
        # Wait for the status page to fully load.
        while not browser_page_has("showPin"):
            logging.debug("Waiting for intro page to load...")
            sleep(1)

        with open(path.join(settings.get_configdir(), 'setup_status.json'), 'rb') as status_file:
            status = json.load(status_file)

        if not did_show_pin and not did_show_claimed and status.get('pin'):
            browser_fifo('''js showPin("%s")''' % status.get('pin').replace('"', '\\"'))
            did_show_pin = True

        if not did_show_claimed and status.get('claimed'):
            browser_fifo('''js showUpdating()''')
            did_show_claimed = True

        logging.debug('Waiting for node to be initialized.')
        sleep(1)

    # Bring up the blank page (in case there are only videos).
    logging.debug('Loading blank page.')
开发者ID:asoleh,项目名称:screenly-ose,代码行数:31,代码来源:viewer.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python settings.get_listen_ip函数代码示例发布时间:2022-05-27
下一篇:
Python settings.get函数代码示例发布时间: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