def wait_for_node_ip(seconds): for _ in range(seconds): try: get_node_ip() break except Exception: sleep(1)
def viewIndex(): player_name = settings['player_name'] my_ip = get_node_ip() # If we bind on 127.0.0.1, `enable_ssl.sh` has most likely been executed if settings.get_listen_ip() == '127.0.0.1': ws_address = 'wss://' + my_ip + '/ws/' else: ws_address = 'ws://' + my_ip + ':' + settings['websocket_port'] return template('index.html', ws_address=ws_address, player_name=player_name)
def splash_page(): my_ip = get_node_ip() if my_ip: ip_lookup = True # If we bind on 127.0.0.1, `enable_ssl.sh` has most likely been # executed and we should access over SSL. if settings.get_listen_ip() == '127.0.0.1': url = 'https://{}'.format(my_ip) else: url = "http://{}:{}".format(my_ip, settings.get_listen_port()) else: ip_lookup = False url = "Unable to look up your installation's IP address." return template('splash_page', ip_lookup=ip_lookup, url=url)
def viewIndex(): player_name = settings['player_name'] my_ip = get_node_ip() resin_uuid = getenv("RESIN_UUID", None) ws_addresses = [] if settings['use_ssl']: ws_addresses.append('wss://' + my_ip + '/ws/') else: ws_addresses.append('ws://' + my_ip + ':' + settings['websocket_port']) if resin_uuid: ws_addresses.append('wss://{}.resindevice.io/ws/'.format(resin_uuid)) return template('index.html', ws_addresses=ws_addresses, player_name=player_name)
def viewIndex(): player_name = settings['player_name'] my_ip = get_node_ip() resin_uuid = getenv("RESIN_UUID", None) ws_addresses = [] # If we bind on 127.0.0.1, `enable_ssl.sh` has most likely been executed if settings.get_listen_ip() == '127.0.0.1': ws_addresses.append('wss://' + my_ip + '/ws/') else: ws_addresses.append('ws://' + my_ip + ':' + settings['websocket_port']) if resin_uuid: ws_addresses.append('wss://{}.resindevice.io/ws/'.format(resin_uuid)) return template('index.html', ws_addresses=ws_addresses, player_name=player_name)
def template(template_name, **context): """Screenly template response generator. Shares the same function signature as Bottle's template() method but also injects some global context.""" # Add global contexts context['up_to_date'] = is_up_to_date() context['default_duration'] = settings['default_duration'] context['default_streaming_duration'] = settings[ 'default_streaming_duration'] context['use_24_hour_clock'] = settings['use_24_hour_clock'] context['listen_ip'] = get_node_ip() context['template_settings'] = { 'imports': ['from lib.utils import template_handle_unicode'], 'default_filters': ['template_handle_unicode'], } return haml_template(template_name, **context)
def splash_page(): try: my_ip = get_node_ip() except Exception as e: ip_lookup = False error_msg = e else: ip_lookup = True # If we bind on 127.0.0.1, `enable_ssl.sh` has most likely been # executed and we should access over SSL. if settings.get_listen_ip() == '127.0.0.1': url = 'https://{}'.format(my_ip) else: url = "http://{}:{}".format(my_ip, settings.get_listen_port()) msg = url if url else error_msg return template('splash_page', ip_lookup=ip_lookup, msg=msg)
def splash_page(): url = None try: my_ip = get_node_ip() except Exception as e: ip_lookup = False error_msg = e else: ip_lookup = True if settings['use_ssl']: url = 'https://{}'.format(my_ip) elif LISTEN == '127.0.0.1': url = "http://{}".format(my_ip) else: url = "http://{}:{}".format(my_ip, PORT) msg = url if url else error_msg return template('splash_page.html', ip_lookup=ip_lookup, msg=msg)
api.add_resource(Asset, '/api/v1/assets/<asset_id>') api.add_resource(AssetsV1_1, '/api/v1.1/assets') api.add_resource(AssetV1_1, '/api/v1.1/assets/<asset_id>') api.add_resource(AssetsV1_2, '/api/v1.2/assets') api.add_resource(AssetV1_2, '/api/v1.2/assets/<asset_id>') api.add_resource(AssetContent, '/api/v1/assets/<asset_id>/content') api.add_resource(FileAsset, '/api/v1/file_asset') api.add_resource(PlaylistOrder, '/api/v1/assets/order') api.add_resource(Backup, '/api/v1/backup') api.add_resource(Recover, '/api/v1/recover') api.add_resource(AssetsControl, '/api/v1/assets/control/<command>') api.add_resource(Info, '/api/v1/info') api.add_resource(ResetWifiConfig, '/api/v1/reset_wifi') try: my_ip = get_node_ip() except: pass else: SWAGGER_URL = '/api/docs' swagger_address = getenv("SWAGGER_HOST", my_ip) if settings['use_ssl']: API_URL = 'https://{}/api/swagger.json'.format(swagger_address) elif LISTEN == '127.0.0.1' or swagger_address != my_ip: API_URL = "http://{}/api/swagger.json".format(swagger_address) else: API_URL = "http://{}:{}/api/swagger.json".format(swagger_address, PORT) swaggerui_blueprint = get_swaggerui_blueprint( SWAGGER_URL, API_URL, config={'app_name': "Screenly API"})
api.add_resource(AssetsV1_1, '/api/v1.1/assets') api.add_resource(AssetV1_1, '/api/v1.1/assets/<asset_id>') api.add_resource(AssetsV1_2, '/api/v1.2/assets') api.add_resource(AssetV1_2, '/api/v1.2/assets/<asset_id>') api.add_resource(AssetContent, '/api/v1/assets/<asset_id>/content') api.add_resource(FileAsset, '/api/v1/file_asset') api.add_resource(PlaylistOrder, '/api/v1/assets/order') api.add_resource(Backup, '/api/v1/backup') api.add_resource(Recover, '/api/v1/recover') api.add_resource(AssetsControl, '/api/v1/assets/control/<command>') api.add_resource(Info, '/api/v1/info') api.add_resource(ResetWifiConfig, '/api/v1/reset_wifi') api.add_resource(ViewerCurrentAsset, '/api/v1/viewer_current_asset') try: my_ip = get_node_ip() except: pass else: SWAGGER_URL = '/api/docs' swagger_address = getenv("SWAGGER_HOST", my_ip) if settings['use_ssl']: API_URL = 'https://{}/api/swagger.json'.format(swagger_address) elif LISTEN == '127.0.0.1' or swagger_address != my_ip: API_URL = "http://{}/api/swagger.json".format(swagger_address) else: API_URL = "http://{}:{}/api/swagger.json".format(swagger_address, PORT) swaggerui_blueprint = get_swaggerui_blueprint( SWAGGER_URL,
def viewIndex(): player_name = settings['player_name'] listen_ip = get_node_ip() return template('index', listen_ip=listen_ip, player_name=player_name)