def beta_3_12_1_to_beta_3_13_0(self, dummy_progress):
        was_audio_hdmi = False

        # Get the currently set audio output channel.
        try:
            from kano_settings.system.audio import is_HDMI
            was_audio_hdmi = is_HDMI()
        except:
            logger.error("beta_3_12_1_to_beta_3_13_0: Failed to get audio output channel")

        # Replace the config.txt after numerous changes there (see kano-settings).
        try:
            import shutil
            shutil.copyfile(
                '/boot/config.txt',
                '/boot/beta_3_12_1_to_beta_3_13_0_bck_config.txt'
            )
            shutil.copyfile(
                '/usr/share/kano-settings/boot_default/config.txt',
                '/boot/config.txt'
            )
        except:
            logger.error("beta_3_12_1_to_beta_3_13_0: Failed to replace config.txt")

        # Set the audio output channel back to HDMI if it was set.
        try:
            from kano_settings.system.audio import set_to_HDMI
            if was_audio_hdmi:
                set_to_HDMI(True, force=True)
        except:
            logger.error("beta_3_12_1_to_beta_3_13_0: Failed to set HDMI audio back")

        # Remove the orphan udhcpc client, it is now obsoleted by dhcpcd5
        run_cmd_log('apt-get -y purge udhcpc')
Exemple #2
0
    def beta_3_12_1_to_beta_3_13_0(self):
        was_audio_hdmi = False

        # Get the currently set audio output channel.
        try:
            from kano_settings.system.audio import is_HDMI
            was_audio_hdmi = is_HDMI()
        except:
            logger.error(
                "beta_3_12_1_to_beta_3_13_0: Failed to get audio output channel"
            )

        # Replace the config.txt after numerous changes there (see kano-settings).
        try:
            import shutil
            shutil.copyfile('/boot/config.txt',
                            '/boot/beta_3_12_1_to_beta_3_13_0_bck_config.txt')
            shutil.copyfile('/usr/share/kano-settings/boot_default/config.txt',
                            '/boot/config.txt')
        except:
            logger.error(
                "beta_3_12_1_to_beta_3_13_0: Failed to replace config.txt")

        # Set the audio output channel back to HDMI if it was set.
        try:
            from kano_settings.system.audio import set_to_HDMI
            if was_audio_hdmi:
                set_to_HDMI(True, force=True)
        except:
            logger.error(
                "beta_3_12_1_to_beta_3_13_0: Failed to set HDMI audio back")

        # Remove the orphan udhcpc client, it is now obsoleted by dhcpcd5
        run_cmd_log('apt-get -y purge udhcpc')
Exemple #3
0
 def current_setting(self):
     if not is_hdmi_audio_supported():
         self.hdmi_button.set_active(False)
         self.hdmi_button.set_sensitive(False)
         self.analog_button.set_active(True)
     else:
         hdmi = is_HDMI()
         self.hdmi_button.set_active(hdmi)
         self.analog_button.set_active(not hdmi)
Exemple #4
0
        def _trigger_tracking_event(self):
            """ Generate a tracker event with some hardware settings.

                This will send a track_date event called 'user-settings'
                with the audio setting, parental lock level and display
                configuration.
            """

            track_data('user-settings', {
                'audio': 'hdmi' if is_HDMI() else 'analog',
                'parental-lock-level': get_setting('Parental-level'),
                'display': get_status()
            })
        def _trigger_tracking_event(self):
            """ Generate a tracker event with some hardware settings.

                This will send a track_date event called 'user-settings'
                with the audio setting, parental lock level and display
                configuration.
            """

            track_data('user-settings', {
                'audio': 'hdmi' if is_HDMI() else 'analog',
                'parental-lock-level': get_setting('Parental-level'),
                'display': get_status()
            })
def main():
    track_data(
        'safe-mode-boot',
        {
            'os-version-stamp': _get_kano_os_version_stamp(),
            'config-txt': _get_config_txt(),
            'display-name': _get_display_name(),
            'display-status': _get_display_status(),
            'display-modes-cea': _get_display_modes('cea'),
            'display-modes-dmt': _get_display_modes('dmt'),
            'hdmi-audio-output': is_HDMI(),
            'disk-space-usage': _get_disk_space_usage()
        }
    )
    os.system('kano-sync --skip-kdesk --upload-tracking-data --silent')
Exemple #7
0
def play_sound(audio_file, background=False, delay=0):
    from kano.logging import logger

    # Check if file exists
    if not os.path.isfile(audio_file):
        logger.error('audio file not found: {}'.format(audio_file))
        return False

    _, extension = os.path.splitext(audio_file)

    if extension in ['.wav', '.voc', '.raw', '.au']:
        cmd = 'aplay -q {}'.format(audio_file)
    else:
        volume_percent = get_volume()
        volume_str = '--vol {}'.format(
            percent_to_millibel(volume_percent, raspberry_mod=True))

        # Set the audio output between HDMI or Jack. Default is HDMI since it's the
        # safest route given the PiHat lib getting destabilised if Jack is used.
        audio_out = 'hdmi'
        try:
            from kano_settings.system.audio import is_HDMI
            if not is_HDMI():
                audio_out = 'local'
        except Exception:
            pass

        cmd = 'omxplayer -o {audio_out} {volume} {link}'.format(
            audio_out=audio_out,
            volume=volume_str,
            link=audio_file
        )

    logger.debug('cmd: {}'.format(cmd))

    # Delay the sound playback if specified
    if delay:
        cmd = '/bin/sleep {} ; {}'.format(delay, cmd)

    if background:
        run_bg(cmd)
        rc = 0
    else:
        dummy, dummy, rc = run_cmd_log(cmd)

    return rc == 0
Exemple #8
0
def play_sound(audio_file, background=False, delay=0):
    from kano.logging import logger

    # Check if file exists
    if not os.path.isfile(audio_file):
        logger.error('audio file not found: {}'.format(audio_file))
        return False

    _, extension = os.path.splitext(audio_file)

    if extension in ['.wav', '.voc', '.raw', '.au']:
        cmd = 'aplay -q {}'.format(audio_file)
    else:
        volume_percent = get_volume()
        volume_str = '--vol {}'.format(
            percent_to_millibel(volume_percent, raspberry_mod=True))

        # Set the audio output between HDMI or Jack. Default is HDMI since it's the
        # safest route given the PiHat lib getting destabilised if Jack is used.
        audio_out = 'hdmi'
        try:
            from kano_settings.system.audio import is_HDMI
            if not is_HDMI():
                audio_out = 'local'
        except Exception:
            pass

        cmd = 'omxplayer -o {audio_out} {volume} {link}'.format(
            audio_out=audio_out, volume=volume_str, link=audio_file)

    logger.debug('cmd: {}'.format(cmd))

    # Delay the sound playback if specified
    if delay:
        cmd = '/bin/sleep {} ; {}'.format(delay, cmd)

    if background:
        run_bg(cmd)
        rc = 0
    else:
        dummy, dummy, rc = run_cmd_log(cmd)

    return rc == 0
Exemple #9
0
    def current_setting(self):
        hdmi_supported = is_hdmi_audio_supported()
        analogue_supported = is_analogue_audio_supported()
        hdmi_selected = is_HDMI()

        if not hdmi_supported:
            self.disabled_hdmi_label.get_style_context().add_class(
                'normal_label')

        if not analogue_supported:
            self.disabled_analogue_label.get_style_context().add_class(
                'normal_label')

        # Disable radio buttons based on available features.
        self.hdmi_button.set_sensitive(hdmi_supported)
        self.analog_button.set_sensitive(analogue_supported)

        # Tick the radio button based on what is set on the system.
        self.hdmi_button.set_active(hdmi_selected)
        self.analog_button.set_active(not hdmi_selected)
    def fix_sound(self, _, event):
        """
        Launches the appropriate screen for resolving the problem
        of not hearing any sound.
        """

        # If enter key is pressed or mouse button is clicked
        if not hasattr(event, 'keyval') or event.keyval == 65293:
            self.win.clear_win()

            if AudioScreen.number_tries == 1:
                # check if current settings is configured for HDMI or analogue
                if not is_HDMI():
                    SeeTheLightScreen(self.win)
                else:
                    AnalogueScreen(self.win)
            else:
                if hdmi_supported:
                    TvSpeakersScreen(self.win)
                else:
                    DisplayScreen(self.win)
    def current_setting(self):
        hdmi_supported = is_hdmi_audio_supported()
        analogue_supported = is_analogue_audio_supported()
        hdmi_selected = is_HDMI()

        if not hdmi_supported:
            self.disabled_hdmi_label.get_style_context().add_class('normal_label')

        if not analogue_supported:
            self.disabled_analogue_label.get_style_context().add_class('normal_label')

        # Disable radio buttons based on available features.
        self.hdmi_button.set_sensitive(hdmi_supported)
        self.analog_button.set_sensitive(analogue_supported)

        # Tick the radio button based on what is set on the system.
        self.hdmi_button.set_active(hdmi_selected)
        self.analog_button.set_active(not hdmi_selected)

        # Set the initial tick state of for the audio overdrive button.
        self.initial_audio_overdrive = self._is_audio_overdrive()
        self.audio_overdrive_checkbutton.set_active(self.initial_audio_overdrive)
Exemple #12
0
def play_video(_button=None, video_url=None, localfile=None, subtitles=None,
               init_threads=True, keyboard_engulfer=True):
    """
    Plays a local or remote video using the optimal video player found.
    Handles sound settings and subtitles.
    """

    if video_url:
        logger.info('Getting video url: {}'.format(video_url))
        success, data = get_video_file_url(video_url)
        if not success:
            logger.error('Error with getting YouTube url: {}'.format(data))
            if _button:
                _button.set_sensitive(True)
            return
        link = data

    elif localfile:
        link = localfile
    else:
        if _button:
            _button.set_sensitive(True)
        return

    logger.info('Launching player...')

    if omxplayer_present:

        volume_percent = get_volume()
        volume_str = '--vol {}'.format(
            percent_to_millibel(volume_percent, raspberry_mod=True))

        if not subtitles or not os.path.isfile(subtitles):
            subtitles = None

            if localfile:
                filename = os.path.basename(localfile)
                filename = os.path.splitext(filename)[0]
                fullpath = os.path.join(subtitles_dir, filename + '.srt')
                if os.path.exists(fullpath):
                    subtitles = fullpath

            if not subtitles:
                subtitles = os.path.join(subtitles_dir, 'controls.srt')

        subtitles_str = ''
        try:
            from kano_settings.system.display import is_overscan
            if not is_overscan():
                subtitles_str = '--subtitle "{subtitles}" ' \
                    '--font "/usr/share/fonts/kano/bariol/Bariol_Regular.otf" --font-size 35 ' \
                    '--align center'.format(subtitles=subtitles)
        except Exception:
            pass

        # Set the audio output between HDMI or Jack. Default is HDMI since it's the
        # safest route given the PiHat lib getting destabilised if Jack is used.
        audio_out = 'hdmi'
        try:
            from kano_settings.system.audio import is_HDMI
            if not is_HDMI():
                audio_out = 'local'
        except Exception:
            pass

        player_cmd = 'omxplayer -o {audio_out} {volume_str} {subtitles} -b "{link}"' \
                     ''.format(
                         audio_out=audio_out,
                         link=link,
                         volume_str=volume_str,
                         subtitles=subtitles_str
                     )
    else:
        player_cmd = 'vlc -f --no-video-title-show ' \
            '"{link}"'.format(link=link)

    # Play with keyboard interaction coming from udev directly
    # so that we do not lose focus and capture all key presses
    playudev.run_player(player_cmd, init_threads=init_threads,
                        keyboard_engulfer=keyboard_engulfer)

    # finally, enable the button back again
    if _button:
        _button.set_sensitive(True)
Exemple #13
0
def play_video(_button=None,
               video_url=None,
               localfile=None,
               subtitles=None,
               init_threads=True,
               keyboard_engulfer=True):
    """
    Plays a local or remote video using the optimal video player found.
    Handles sound settings and subtitles.
    """

    if video_url:
        logger.info('Getting video url: {}'.format(video_url))
        success, data = get_video_file_url(video_url)
        if not success:
            logger.error('Error with getting YouTube url: {}'.format(data))
            if _button:
                _button.set_sensitive(True)
            return
        link = data

    elif localfile:
        link = localfile
    else:
        if _button:
            _button.set_sensitive(True)
        return

    logger.info('Launching player...')

    if omxplayer_present:

        volume_percent = get_volume()
        volume_str = '--vol {}'.format(
            percent_to_millibel(volume_percent, raspberry_mod=True))

        if not subtitles or not os.path.isfile(subtitles):
            subtitles = None

            if localfile:
                filename = os.path.basename(localfile)
                filename = os.path.splitext(filename)[0]
                fullpath = os.path.join(subtitles_dir, filename + '.srt')
                if os.path.exists(fullpath):
                    subtitles = fullpath

            if not subtitles:
                subtitles = os.path.join(subtitles_dir, 'controls.srt')

        subtitles_str = ''
        try:
            from kano_settings.system.display import is_overscan
            if not is_overscan():
                subtitles_str = '--subtitle "{subtitles}" ' \
                    '--font "/usr/share/fonts/kano/bariol/Bariol_Regular.otf" --font-size 35 ' \
                    '--align center'.format(subtitles=subtitles)
        except Exception:
            pass

        # Set the audio output between HDMI or Jack. Default is HDMI since it's the
        # safest route given the PiHat lib getting destabilised if Jack is used.
        audio_out = 'hdmi'
        try:
            from kano_settings.system.audio import is_HDMI
            if not is_HDMI():
                audio_out = 'local'
        except Exception:
            pass

        player_cmd = 'omxplayer -o {audio_out} {volume_str} {subtitles} -b "{link}"' \
                     ''.format(
                         audio_out=audio_out,
                         link=link,
                         volume_str=volume_str,
                         subtitles=subtitles_str
                     )
    else:
        player_cmd = 'vlc -f --no-video-title-show ' \
            '"{link}"'.format(link=link)

    # Play with keyboard interaction coming from udev directly
    # so that we do not lose focus and capture all key presses
    playudev.run_player(player_cmd,
                        init_threads=init_threads,
                        keyboard_engulfer=keyboard_engulfer)

    # finally, enable the button back again
    if _button:
        _button.set_sensitive(True)