Ejemplo n.º 1
0
    def load_menu_data(self):
        """Loads menu data and sets up the UI. Returns false if
        something fails."""

        try:
            self.menudata = menudata.Menudata()

            self.menudata.load(
                self.__settings.language, self.__settings.menu_dir,
                utils.puavo_conf('puavo.puavomenu.tags', 'default'),
                self.__icons)

        except Exception as exception:
            logging.fatal('Could not load menu data!')
            logging.error(exception, exc_info=True)

            if self.__settings.prod_mode:
                # Log for later examination
                syslog.syslog(syslog.LOG_CRIT, 'Could not load menu data!')
                syslog.syslog(syslog.LOG_CRIT, traceback.format_exc())

            self.menudata = None
            return False

        # Prepare the user interface
        for index in self.menudata.category_index:
            cat = self.menudata.categories[index]

            if cat.hidden:
                continue

            frame = Gtk.Frame()
            label = Gtk.Label(cat.name)
            frame.show()
            label.show()
            self.__category_buttons.append_page(frame, label)

        if len(self.menudata.category_index) > 0:
            self.__category_buttons.show()

        self.__create_current_menu()
        self.__programs_container.show()

        if self.__settings.enable_faves_saving:
            faves.load_use_counts(self.menudata.programs,
                                  self.__settings.user_dir)

        self.__faves.update(self.menudata.programs, self.__settings)
        self.__faves_sep.show()
        self.__faves.show()

        self.__search.show()
        self.__search.grab_focus()

        return True
Ejemplo n.º 2
0
def get_changelog_url():
    """Generates the full URL to the current image's changelog."""

    series = utils.get_file_contents('/etc/puavo-image/class', 'opinsys')
    version = utils.get_file_contents('/etc/puavo-image/name', '')

    logging.info('The current image series is "%s"', series)
    logging.info('The current image version is "%s"', version)

    if len(version) > 4:
        # strip the extension from the image file name
        version = version[:-4]

    url = utils.puavo_conf('puavo.support.image_changelog_url',
                           'http://changelog.opinsys.fi')

    url = url.replace('%%IMAGESERIES%%', series)
    url = url.replace('%%IMAGEVERSION%%', version)

    logging.info('The final changelog URL is "%s"', url)

    return url
Ejemplo n.º 3
0
            'width': 1000,
            'height': 650,
            'enable_js': True,
        },
    },
}

SB_SUPPORT = {
    'name': 'support',
    'title': STRINGS['sb_support'],
    'icon': '/usr/share/icons/Faenza/status/96/dialog-question.png',
    'command': {
        'type':
        'url',
        'args':
        utils.puavo_conf('puavo.support.new_bugreport_url',
                         'https://tuki.opinsys.fi')
    },
}

SB_LAPTOP_SETTINGS = {
    'name': 'laptop-settings',
    'title': STRINGS['sb_laptop_setup'],
    'icon': '/usr/share/icons/Faenza/devices/96/drive-harddisk-system.png',
    'command': {
        'type': 'command',
        'args': 'puavo-laptop-setup',
    },
}

SB_PUAVOPKG_INSTALLER = {
    'name': 'puavopkg-installer',
Ejemplo n.º 4
0
    def detect_environment(self):
        """Detects the runtime-environment for this session. Call once
        at startup."""

        import os
        import os.path
        import configparser
        import subprocess
        import logging
        import utils

        # Detect the session and device types
        if 'GUEST_SESSION' in os.environ:
            logging.info('This is a guest user session')
            self.is_guest = True

        if utils.puavo_conf('puavo.hosttype', 'laptop') == 'fatclient':
            logging.info('This is a fatclient device')
            self.is_fatclient = True

        if utils.puavo_conf('puavo.webmenu.webkiosk', '') == 'true':
            # I don't know if this actually works!
            logging.info('This is a webkiosk session')
            self.is_webkiosk = True

        if self.is_guest or self.is_webkiosk:
            # No point in saving faves when they get blown away upon logout.
            # No point in loading them, either.
            logging.info('Faves loading/saving is disabled for this session')
            self.enable_faves_saving = False

        if utils.puavo_conf('puavo.admin.personally_administered',
                            'false') == 'true':
            self.is_personally_administered = True

            try:
                import pwd

                configured_primary_user = \
                    utils.puavo_conf('puavo.admin.primary_user', None)
                current_user = pwd.getpwuid(os.getuid()).pw_name

                if configured_primary_user == current_user:
                    # The current user is this personally administered
                    # device's configured primary user
                    self.is_user_primary_user = True
            except Exception as e:
                logging.error("Cannot determine if the current user is this " \
                              "device's configured primary user:"******"%s" exists, '
                'trying to load it...', conf_file)

            try:
                config = configparser.ConfigParser()
                config.read(conf_file)

                self.reset_view_after_start = \
                    config.getboolean('puavomenu',
                                      'reset_view_after_start',
                                      fallback=True)
            except Exception as exception:
                logging.error(str(exception))

        # Determine the location of the desktop directory
        try:
            # There are some XDG modules available for Python
            # that probably can do this for us, but right now
            # I don't want to install any more dependencies.
            proc = subprocess.Popen(['xdg-user-dir', 'DESKTOP'],
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)

            proc.wait()
            self.desktop_dir = proc.stdout.read().decode('utf-8').strip()
        except Exception as exception:
            # Keep as None to signal that we don't know where to put desktop
            # files, this makes desktop link creation always fail
            logging.error("Could not determine the location of user's "
                          "desktop directory")
            logging.error(str(exception))
            self.desktop_dir = None