def system_info(): viewlog = None try: viewlog = [ line.decode('utf-8') for line in check_output([ 'sudo', 'systemctl', 'status', 'screenly-viewer.service', '-n', '20' ]).split('\n') ] except: pass loadavg = diagnostics.get_load_avg()['15 min'] display_info = diagnostics.get_monitor_status() display_power = diagnostics.get_display_power() # Calculate disk space slash = statvfs("/") free_space = size(slash.f_bavail * slash.f_frsize) # Get uptime uptime_in_seconds = diagnostics.get_uptime() system_uptime = timedelta(seconds=uptime_in_seconds) # Player name for title player_name = settings['player_name'] raspberry_model = '%s Revision: %s Ram: %s %s' % ( diagnostics.get_raspberry_model(), diagnostics.get_raspberry_revision(), diagnostics.get_raspberry_ram(), diagnostics.get_raspberry_manufacturer()) branch = 'development' if diagnostics.get_git_branch( ) == 'master' else diagnostics.get_git_branch() screenly_version = '%s@%s' % (branch, diagnostics.get_git_short_hash()) return template('system-info.html', player_name=player_name, viewlog=viewlog, loadavg=loadavg, free_space=free_space, uptime=system_uptime, display_info=display_info, display_power=display_power, raspberry_model=raspberry_model, screenly_version=screenly_version, mac_address=get_node_mac_address())
def is_up_to_date(): """ Primitive update check. Checks local hash against GitHub hash for branch. Returns True if the player is up to date. """ latest_sha, retrieved_update = fetch_remote_hash() git_branch = get_git_branch() git_hash = get_git_hash() git_short_hash = get_git_short_hash() get_device_id = r.get('device_id') if not latest_sha: logging.error('Unable to get latest version from GitHub') return True if not get_device_id: device_id = ''.join( random.choice(string.ascii_lowercase + string.digits) for _ in range(15)) r.set('device_id', device_id) else: device_id = get_device_id if retrieved_update: 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_short_hash), 'NOOBS': os.path.isfile('/boot/os_config.json'), 'Balena': is_balena_app(), 'Docker': is_docker(), 'Pi_Version': get_raspberry_model(parse_cpu_info()['revision']) }) except MixpanelException: pass except AttributeError: pass return latest_sha == git_hash
def system_info(): viewlog = None try: viewlog = [line.decode('utf-8') for line in check_output(['sudo', 'systemctl', 'status', 'screenly-viewer.service', '-n', '20']).split('\n')] except: pass loadavg = diagnostics.get_load_avg()['15 min'] display_info = diagnostics.get_monitor_status() display_power = diagnostics.get_display_power() # Calculate disk space slash = statvfs("/") free_space = size(slash.f_bavail * slash.f_frsize) # Get uptime uptime_in_seconds = diagnostics.get_uptime() system_uptime = timedelta(seconds=uptime_in_seconds) # Player name for title player_name = settings['player_name'] raspberry_model = '%s Revision: %s Ram: %s %s' % (diagnostics.get_raspberry_model(), diagnostics.get_raspberry_revision(), diagnostics.get_raspberry_ram(), diagnostics.get_raspberry_manufacturer()) branch = 'development' if diagnostics.get_git_branch() == 'master' else diagnostics.get_git_branch() screenly_version = '%s@%s' % (branch, diagnostics.get_git_short_hash()) return template( 'system_info.html', player_name=player_name, viewlog=viewlog, loadavg=loadavg, free_space=free_space, uptime=system_uptime, display_info=display_info, display_power=display_power, raspberry_model=raspberry_model, screenly_version=screenly_version, mac_address=get_node_mac_address() )
EMPTY_PL_DELAY = 5 # secs INITIALIZED_FILE = '/.screenly/initialized' WATCHDOG_PATH = '/tmp/screenly.watchdog' LOAD_SCREEN = 'http://{}:{}/{}'.format(LISTEN, PORT, 'static/img/loading.png') current_browser_url = None browser = None loop_is_stopped = False browser_bus = None r = connect_to_redis() try: media_player = VLCMediaPlayer() if get_raspberry_model(get_raspberry_code()) == 'Model 4B' else OMXMediaPlayer() except sh.ErrorReturnCode_1: media_player = OMXMediaPlayer() HOME = None db_conn = None scheduler = None def sigalrm(signum, frame): """ Signal just throw an SigalrmException """ raise SigalrmException("SigalrmException")