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

Python utils.url_fails函数代码示例

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

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



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

示例1: asset_loop

def asset_loop(scheduler):
    check_update()
    asset = scheduler.get_next_asset()

    if asset is None:
        logging.info('Playlist is empty. Sleeping for %s seconds', EMPTY_PL_DELAY)
        view_image(HOME + LOAD_SCREEN)
        sleep(EMPTY_PL_DELAY)

    elif path.isfile(asset['uri']) or not url_fails(asset['uri']):
        name, mime, uri = asset['name'], asset['mimetype'], asset['uri']
        logging.info('Showing asset %s (%s)', name, mime)
        logging.debug('Asset URI %s', uri)
        watchdog()

        if 'image' in mime:
            view_image(uri)
        elif 'web' in mime:
            # FIXME If we want to force periodic reloads of repeated web assets, force=True could be used here.
            # See e38e6fef3a70906e7f8739294ffd523af6ce66be.
            browser_url(uri)
        elif 'video' in mime:
            view_video(uri, asset['duration'])
        else:
            logging.error('Unknown MimeType %s', mime)

        if 'image' in mime or 'web' in mime:
            duration = int(asset['duration'])
            logging.info('Sleeping for %s', duration)
            sleep(duration)
    else:
        logging.info('Asset %s at %s is not available, skipping.', asset['name'], asset['uri'])
        sleep(0.5)
开发者ID:banglardamal,项目名称:lynda-ose,代码行数:33,代码来源: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')

    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


示例3: check_update

def check_update():
    """
    Check if there is a later version of RIDS
    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('/home/pi/rids_files/', 'latest_rids_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 get_ip() != '0.0.0.0' and not url_fails("http://www.google.com"):
            Popen(["/home/pi/ridsc/misc/run_upgrade.sh"],shell=True)
            with open(sha_file, 'w') as f:
                f.write(VERSION)
            return True    
        else:
            logging.debug('Unable to retreive latest RIDS')
            return
    else:
        return False
开发者ID:amit1870,项目名称:ridsc,代码行数:31,代码来源:viewer.py


示例4: try_connectivity

def try_connectivity():
    urls = [
        'http://www.google.com',
        'http://www.bbc.co.uk',
        'https://www.google.com',
        'https://www.bbc.co.uk',
    ]
    result = []
    for url in urls:
        if utils.url_fails(url):
            result.append('{}: Error'.format(url))
        else:
            result.append('{}: OK'.format(url))
    return result
开发者ID:viaict,项目名称:screenly-ose,代码行数:14,代码来源:diagnostics.py


示例5: asset_loop

def asset_loop(scheduler):
    check_update()
    asset = scheduler.get_next_asset()

    if asset is None:
        logging.info('Playlist is empty. Sleeping for %s seconds', EMPTY_PL_DELAY)
        view_image(HOME + LOAD_SCREEN)
        sleep(EMPTY_PL_DELAY)

    elif path.isfile(asset['uri']) or not url_fails(asset['uri']):
        name, mime, uri = asset['name'], asset['mimetype'], asset['uri']
        logging.info('Showing asset %s (%s)', name, mime)
        logging.debug('Asset URI %s', uri)
        watchdog()
        # Procedure om loop stop te zetten
        if scheduler.get_n_assets() > 1:
            if scheduler.get_inLoop() == True:
                run = sh.killall('omxplayer')
                scheduler.set_inLoop(False)
        if 'image' in mime:
            view_image(uri)
        elif 'web' in mime:
            browser_url(uri)
        elif 'video' in mime:
            
            # Als er juist 1 videoasset is: checken of ie al in loop staat, anders gewoon doen!
            if scheduler.get_n_assets() == 1:
                if scheduler.get_inLoop() == False:
                    logging.info('Playing video in loop')
                    scheduler.set_inLoop(True)
                    
            else:
                logging.info('Playing video')
                scheduler.set_inLoop(False)
            # schedulerobject toegevoegd
            view_video(uri, asset['duration'],scheduler)    
                
        
        else:
            logging.error('Unknown MimeType %s', mime)

        if 'image' in mime or 'web' in mime:
            duration = int(asset['duration'])
            logging.info('Sleeping for %s', duration)
            sleep(duration)
    else:
        logging.info('Asset %s at %s is not available, skipping.', asset['name'], asset['uri'])
        sleep(0.5)
开发者ID:KunstencentrumVooruit,项目名称:screenly_patch,代码行数:48,代码来源:viewer.py


示例6: asset_loop

def asset_loop(scheduler):
    logging.debug("")
    logging.debug("")
    logging.debug("New Loop")
    asset = scheduler.get_next_asset()
    logging.info("Active Playlist: {0}".format(get_active_playlist()))
    logging.info("Asset: {}".format(asset))
    
    if asset is None:
        logging.info(('Playlist is empty. Sleeping for %s seconds', EMPTY_PL_DELAY))
        view_url(SPLASH_PAGE)
        sleep(EMPTY_PL_DELAY)

    elif path.isfile(asset['uri']) or not url_fails(asset['uri']):
        name, mime, uri = asset['name'], asset['mimetype'], asset['uri']
        logging.info('Showing asset %s (%s)', name, mime)
        logging.info('Asset URI %s', uri)
        watchdog()
        
        if 'image' in mime:
            logging.debug("VIEWING IMAGE")
            view_image("file://{0}/{1}".format(ASSET_PATH, uri))
        elif 'webpage' in mime:
            logging.debug("VIEWING WEB")
            browser_url(uri)
        elif 'video' in mime:
            logging.debug("VIEWING VIDEO")
            view_video("{0}/{1}".format(ASSET_PATH, uri), asset['duration'])
        elif 'rtmp' in mime:
            logging.debug("VIEWING RTMP")
            view_video(uri, asset['duration'], '--live')
        elif 'livestream' in mime:
            logging.debug("VIEWING LIVESTREAM")
            view_livestream(uri, asset['duration'])
        else:
            logging.error('Unknown MimeType %s', mime)

        if 'image' in mime or 'web' in mime:
            duration = int(asset['duration'])
            logging.debug('Sleeping for %s', duration)
            sleep(duration)
    else:
        logging.warning('Asset %s at %s is not available, skipping.', asset['name'], asset['uri'])
        sleep(0.5)
开发者ID:jinkanban,项目名称:showtime-client,代码行数:44,代码来源:viewer.py


示例7: add_asset

def add_asset():
    asset = prepare_asset(request)
    if url_fails(asset['uri']):
        raise Exception("Could not retrieve file. Check the asset URL.")
    return assets_helper.create(db_conn, asset)
开发者ID:Geo-Joy,项目名称:sync-pi-ose,代码行数:5,代码来源:server.py


示例8: toggle_load_screen

    toggle_load_screen(False)

    # Infinite loop.
    logging.debug('Entering infinite loop.')
    while True:
        asset = scheduler.get_next_asset()
        logging.debug('got asset' + str(asset))

        is_up_to_date = check_update()
        logging.debug('Check update: %s' % str(is_up_to_date))

        if asset is None:
            # The playlist is empty, go to sleep.
            logging.info('Playlist is empty. Going to sleep.')
            sleep(5)
        elif not url_fails(asset['uri']):
            logging.info('Showing asset %s.' % asset["name"])

            watchdog()

            if "image" in asset["mimetype"]:
                view_image(asset['uri'], asset["duration"])
            elif "video" in asset["mimetype"]:
                view_video(asset["uri"])
            elif "web" in asset["mimetype"]:
                view_web(asset["uri"], asset["duration"])
            else:
                print "Unknown MimeType, or MimeType missing"
        else:
            logging.info('Asset {0} is not available, skipping.'.format(asset['uri']))
开发者ID:phobozad,项目名称:screenly-ose,代码行数:30,代码来源:viewer.py


示例9: asset_loop

def asset_loop(scheduler):
    check_update()
    global run, video_lock
    SLEEP_DELAY = 1

    if scheduler.assets[0] is None and scheduler.assets[1] is None and scheduler.assets[2] is None :
        logging.info('All Playlist are empty. Sleeping for %s seconds', 1)
    
    split_map = ["P","S","T"]

    mylist = range(int(settings['split_screen']))

    logging.info('Status for Playlist %s: index %s,  nassets %s, go_next %s', str(mylist), str(scheduler.index), str(scheduler.nassets), str(scheduler.go_next))
    frame = ""
    for i in mylist:

        skip = False      
        if video_lock and split_map[i] == settings["video_split_screen"]:
            if run.process.alive:
                watchdog()
                # Skip next loop only if go_next time logic says, not on video_lock logic
                if scheduler.go_next[i]>int(time()):
                    skip = True
            else:
                video_lock = False
                # scheduler.go_next[i] = int(time())

                scheduler.go_next[i] = int(time()) + int(scheduler.assets[i][((scheduler.index[i]-1)%scheduler.nassets[i])]['duration'])   
            
            # if scheduler.assets[i][((scheduler.index[i-1])%scheduler.nassets[i])]['mimetype'] == 'video':
            #     frame =  scheduler.assets[i][((scheduler.index[i-1])%scheduler.nassets[i])]['filename']
            #     frame = frame.split(".")[0]+".jpeg"

        if scheduler.go_next[i]> int(time()): #0
            logging.debug('Playlist %s: Asset id %s is still running.', i,scheduler.index[i])
        elif not skip:
            asset = scheduler.get_next_asset(i)

            while asset is not None and (scheduler.counter[i]+1) % int(asset['modulo']) != 0 :
                asset = scheduler.get_next_asset(i)

            if asset is None:
                logging.info('Playlist %s is empty', i)
                view_image(HOME + LOAD_SCREEN,i)
                scheduler.go_next[i] = int(time()) + 1

            elif path.isfile(asset['uri']) or not url_fails(asset['uri']):
                name, mime, uri = asset['name'], asset['mimetype'], asset['uri']
                logging.info('Playlist %s: Showing asset %s (%s)', i, name, mime)
                # logging.debug('Asset URI %s', uri)
                watchdog()
                dur = int(asset['duration'])
                if 'image' in mime:
                    view_image(uri,i)
                elif 'Html' in mime:
                    set_iframe(uri,i)
                elif 'video' in mime:
                    frame = asset['filename'].split(".")[0]+".jpeg"
                    view_video(uri, asset['duration'],i,frame)
                    video_lock = True             
                    dur = int(dur*1-1)
                elif 'web' in mime:
                    frame = asset['filename'].split(".")[0]+".jpeg"
                    view_video(uri, asset['duration'],i,frame)
                    video_lock = True
                    dur = int(dur)
                else:
                    logging.error('Unknown MimeType %s', mime)

                #Should be below the above code
                scheduler.go_next[i] =  int(time()) + dur
                    
            else:
                # scheduler.go_next[i] =  int(asset['duration'])
                logging.info('Asset %s at %s is not available, skipping.', asset['name'], asset['uri'])
                sleep(0.5)
    
    if video_lock:
        SLEEP_DELAY = 1
    else:  
        # SLEEP_DELAY = int(min(scheduler.go_next))
        SLEEP_DELAY = max(1,int(min([ x - int(time()) for x in scheduler.go_next])))

    logging.info('Sleeping for %s, go_next - %s, current_time - %s', SLEEP_DELAY,str(scheduler.go_next),str(int(time())))
    sleep(SLEEP_DELAY)  
开发者ID:amit1870,项目名称:ridsc,代码行数:85,代码来源:viewer.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.urljoin函数代码示例发布时间:2022-05-26
下一篇:
Python utils.unzip函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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