def read_line_retry(self, timeout=60, ping=False, stale_sleep=1.0): line = None stale_since = None while not line: line = self.read_line() if line: stale_since = None time.sleep(0.05) break if stale_since is None: stale_since = time.time() time.sleep(stale_sleep) continue elif (time.time() - stale_since) > timeout: return None elif (time.time() - stale_since) > timeout / 2: # Nothing returned for 5 seconds if self.file.get_path() != self.path: log.debug("Log file moved (probably rotated), closing") self.close() elif ping: # Ping server to see if server is still active Plex.detail() ping = False time.sleep(stale_sleep) return line
def test_booleans(): responses.add( responses.GET, 'http://mock:32400', body=read('fixtures/detail_a.xml'), status=200, content_type='application/xml' ) detail = Plex.detail() assert detail is not None assert detail.multiuser is True assert detail.sync is False
def init_raven(cls): # Retrieve server details server = Plex.detail() if not server: return # Set client name to a hash of `machine_identifier` RAVEN.name = md5(server.machine_identifier) RAVEN.tags.update({ 'server.version': server.version })
def test_detail(): responses.add( responses.GET, 'http://mock:32400', body=read('fixtures/detail_malformed.xml'), status=200, content_type='application/xml' ) detail = Plex.detail() if PARSER == 'etree.HTMLParser': assert detail is not None assert detail.platform_version == six.u('6.2 (Build 9200)\xff\xff') else: assert detail is None
def test_detail(): responses.add(responses.GET, 'http://mock:32400', body=read('fixtures/detail_a.xml'), status=200, content_type='application/xml') detail = Plex.detail() assert detail is not None assert detail.friendly_name == "Mock Server" assert detail.platform == "Windows" assert detail.platform_version == "6.2 (Build 9200)"
def test_detail(): responses.add( responses.GET, 'http://mock:32400', body=read('fixtures/detail_a.xml'), status=200, content_type='application/xml' ) detail = Plex.detail() assert detail is not None assert detail.friendly_name == "Mock Server" assert detail.platform == "Windows" assert detail.platform_version == "6.2 (Build 9200)"
def test_detail(): responses.add(responses.GET, 'http://mock:32400', body=read('fixtures/detail_malformed.xml'), status=200, content_type='application/xml') detail = Plex.detail() if PARSER == 'etree.HTMLParser': assert detail is not None assert detail.platform_version == six.u('6.2 (Build 9200)\xff\xff') else: assert detail is None
def test(cls): if Plex['status'].sessions() is None: log.info("Error while retrieving sessions, assuming WebSocket method isn't available") return False detail = Plex.detail() if detail is None: log.info('Error while retrieving server info for testing') return False if not detail.multiuser: log.info("Server info indicates multi-user support isn't available, WebSocket method not available") return False return True
def process_server_state(cls): # Check startup state server = Plex.detail() if server is None: log.info('Unable to check startup state, detail request failed') return # Check server startup state if server.start_state is None: return if server.start_state == 'startingPlugins': return cls.on_starting_plugins() log.error('Unhandled server start state %r', server.start_state)
def test(cls): if Plex['status'].sessions() is None: log.info( "Error while retrieving sessions, assuming WebSocket method isn't available" ) return False detail = Plex.detail() if detail is None: log.info('Error while retrieving server info for testing') return False if not detail.multiuser: log.info( "Server info indicates multi-user support isn't available, WebSocket method not available" ) return False return True