def _add_led_speaker_checkbox(self): self.cpu_monitor_checkbox = Gtk.CheckButton() is_led_speaker_plugged = False is_pi_hat_plugged = False try: from kano_peripherals.speaker_leds.driver.high_level import \ get_speakerleds_interface from kano_peripherals.pi_hat.driver.high_level import \ get_pihat_interface speaker_led_api = get_speakerleds_interface(retry_count=0) if speaker_led_api: # can be None is_led_speaker_plugged = speaker_led_api.detect() pi_hat_api = get_pihat_interface(retry_count=0) if pi_hat_api: # can be None is_pi_hat_plugged = pi_hat_api.detect() except Exception as e: logger.error( "Something unexpected occured in _add_led_speaker_checkbox" " - [{}]".format(e)) if has_min_performance(RPI_2_B_SCORE) and (is_led_speaker_plugged or is_pi_hat_plugged): self.buttons.append(self.cpu_monitor_checkbox) self.label_button_and_pack(self.cpu_monitor_checkbox, _("Enable LED ring CPU Animation"), '')
def _add_led_speaker_checkbox(self): self.cpu_monitor_checkbox = Gtk.CheckButton() is_led_speaker_plugged = False is_pi_hat_plugged = False try: from kano_peripherals.speaker_leds.driver.high_level import \ get_speakerleds_interface from kano_peripherals.pi_hat.driver.high_level import \ get_pihat_interface speaker_led_api = get_speakerleds_interface(retry_count=0) if speaker_led_api: # can be None is_led_speaker_plugged = speaker_led_api.detect() pi_hat_api = get_pihat_interface(retry_count=0) if pi_hat_api: # can be None is_pi_hat_plugged = pi_hat_api.detect() except Exception as e: logger.error("Something unexpected occured in _add_led_speaker_checkbox" " - [{}]".format(e)) if has_min_performance(RPI_2_B_SCORE) and (is_led_speaker_plugged or is_pi_hat_plugged): self.buttons.append(self.cpu_monitor_checkbox) self.label_button_and_pack( self.cpu_monitor_checkbox, _("Enable LED ring CPU Animation"), '' )
def __init__(self): Gtk.Overlay.__init__(self, hexpand=True, vexpand=True) self.percent_completed_label = None self.progress_subphase_label = None self.play_game_label = None self.is_at_least_rpi2 = has_min_performance(RPI_2_B_SCORE) self.is_game_first_launch = True self.game_allowed_states = ['downloading', 'init', 'installing-urgent'] self.get_style_context().add_class('install') self.add(self._create_progress_grid()) self.add_overlay(self._create_warning_icon()) self.add_overlay(self._create_warning_label())
def __init__(self): Gtk.Overlay.__init__(self, hexpand=True, vexpand=True) self.percent_completed_label = None self.progress_subphase_label = None self.play_game_label = None self.is_at_least_rpi2 = has_min_performance(RPI_2_B_SCORE) self.game_launch_timestamp = 0 self.game_allowed_states = [ 'downloading', 'init', 'installing-urgent' ] self.get_style_context().add_class('install') self.add(self._create_progress_grid()) self.add_overlay(self._create_warning_icon()) self.add_overlay(self._create_warning_label())
def download_app(app_id_or_slug): data = query_for_app(app_id_or_slug) # download the icon icon_file_type = data['icon_url'].split(".")[-1] icon_path = '/tmp/{}.{}'.format(app_id_or_slug, icon_file_type) rv, err = download_url(data['icon_url'], icon_path) if not rv: msg = _("Unable to download the application ({})").format(err) raise AppDownloadError(msg) # Check if the app is going to run well on the hardware if 'min_performance_score' in data and \ has_min_performance(data['min_performance_score']): msg = _( "{} won't be downloaded " "because the hardware is not performant enough" ).format(data['title']) raise AppDownloadError(msg) # Cleanup the JSON file data['icon'] = data['slug'] del data['icon_url'] del data['likes'] del data['comments_count'] data['time_installed'] = int(time.time()) data['categories'] = map(lambda c: c.lower(), data['categories']) data['removable'] = True # FIXME: This should all be done in the API if 'priority' not in data: data['priority'] = get_prio(data['slug']) if data['slug'] == 'powerup': data['title'] = 'Make Light' # write out the data data_path = '/tmp/{}.app'.format(app_id_or_slug) with open(data_path, 'w') as f: f.write(json.dumps(data)) return [data_path, icon_path]
def update_progress(self, percent, phase_name, msg, sub_msg=''): # enabling flappy-judoka launch only after these phases (when a reboot is iminent) if phase_name in ['downloading', 'downloading-pip-pkgs', 'init', 'installing-urgent']: if has_min_performance(RPI_2_B_SCORE): self.get_toplevel().connect('key-release-event', self._launch_game) self._pgl.show() percent_fraction = percent / 100. self._progress_bar.set_fraction(percent_fraction) idx = percent_fraction * (len(STAGE_TEXT) - 1) current_text = STAGE_TEXT[int(idx)] self._psa.set_markup(current_text) if self._progress_phase.get_text() != msg: self._progress_phase.set_text(msg) self._progress_subphase.set_text(sub_msg) self._percent_display.set_text( _("Time flies - {}% already!").format(percent))
def update_progress(self, percent, phase_name, msg, sub_msg=''): # enabling flappy-judoka launch only after these phases (when a reboot is iminent) if phase_name in [ 'downloading', 'downloading-pip-pkgs', 'init', 'installing-urgent' ]: if has_min_performance(RPI_2_B_SCORE): self.get_toplevel().connect('key-release-event', self._launch_game) self._pgl.show() percent_fraction = percent / 100. self._progress_bar.set_fraction(percent_fraction) idx = percent_fraction * (len(STAGE_TEXT) - 1) current_text = STAGE_TEXT[int(idx)] self._psa.set_markup(current_text) if self._progress_phase.get_text() != msg: self._progress_phase.set_text(msg) self._progress_subphase.set_text(sub_msg) self._percent_display.set_text( _("Time flies - {}% already!").format(percent))
# Copyright (C) 2014-2016 Kano Computing Ltd. # License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2 # import time import string as s import os from gi.repository import Gtk, Pango, Gdk from kano.utils import has_min_performance, RPI_2_B_SCORE from linux_story.sound_manager import SoundManager from linux_story.helper_functions import get_ascii_art if has_min_performance(RPI_2_B_SCORE): NEWLINE_SLEEP = 0.15 OTHER_SLEEP = 0.025 else: NEWLINE_SLEEP = 0.07 OTHER_SLEEP = 0.007 class Storybook(Gtk.TextView): ''' This class displays all the hints and description text for the user on the left side of the application. ''' def __init__(self, width, height): Gtk.TextView.__init__(self) self.__generate_tags()
# import time import string as s import os from gi.repository import Gtk, Pango, Gdk from kano.utils import has_min_performance, RPI_2_B_SCORE from linux_story.sound_manager import SoundManager from linux_story.helper_functions import get_ascii_art if has_min_performance(RPI_2_B_SCORE): NEWLINE_SLEEP = 0.15 OTHER_SLEEP = 0.025 else: NEWLINE_SLEEP = 0.07 OTHER_SLEEP = 0.007 class Storybook(Gtk.TextView): ''' This class displays all the hints and description text for the user on the left side of the application. ''' def __init__(self, width, height): Gtk.TextView.__init__(self)