precache.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:precache_dev 作者: carlashley 项目源码 文件源码
def cache_server(self):
        '''Gets the Caching/Tetherator server address, by checking
        Caching/Tetherator configurations.'''
        # Two places a config file can exist depending on whether this is
        # Caching Server in Server.app or a tetherator machine.
        config_plists = [self.configuration['tetheratorConfigPlist'],
                         self.configuration['cacheServerConfigPlist']]
        try:
            plist = [x for x in config_plists if os.path.exists(x)][0]
            self.log.debug('Found caching server plist: %s' % plist)
        except:
            plist = False
            self.log.debug('No caching server plist found.')

        if plist:
            # Fall back to testing if Caching Server/Server.app or tetherator
            try:
                port = readPlist(plist)['LastPort']
            except:
                try:
                    port = readPlist(plist)['Port']
                except:
                    self.log.debug('No port for caching server found in %s' % plist)  # NOQA
                    raise Exception('No port found.')
            if port:
                return 'http://localhost:%s' % port
            else:
                return self.cache_locator()
        else:
            return self.cache_locator()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号