Exemplo n.º 1
0
    def store_values(self):
        # remove timer
        self.remove_timer = True

        logging.info(_("We have Internet connection."))
        logging.info(_("We're connected to a power source."))
        logging.info(_("We have enough disk space."))

        # Enable forward button
        self.forward_button.set_sensitive(True)

        if not self.testing:
            ## Launch rankmirrors script to determine the 5 fastest mirrors
            self.thread = AutoRankmirrorsThread()
            self.thread.start()

        return True
Exemplo n.º 2
0
    def store_values(self):
        """ Continue """
        # Remove timer
        self.remove_timer = True
        has_internet = misc.has_connection()

        if has_internet:
            logging.info(_("We have Internet connection."))
        logging.info(_("We're connected to a power source."))
        logging.info(_("We have enough disk space."))

        # Enable forward button
        self.forward_button.set_sensitive(True)

        if not self.testing and has_internet:
            # Launch reflector script to determine the 10 fastest mirrors
            self.thread = AutoRankmirrorsThread()
            self.thread.start()

        return True
Exemplo n.º 3
0
    def store_values(self):
        # remove timer
        self.remove_timer = True

        log.debug(_("We have Internet connection."))
        log.debug(_("We're connected to a power source."))
        log.debug(_("We have enough space in disk."))
          
        # Enable forward button
        self.forward_button.set_sensitive(True)
        
        ## Launch rankmirrors script to determine the 5 fastest mirrors
        self.thread = None
        self.thread = AutoRankmirrorsThread()
        self.thread.start()
        return True
Exemplo n.º 4
0
Arquivo: check.py Projeto: pahau/Cnchi
    def store_values(self):
        # remove timer
        self.remove_timer = True

        logging.info(_("We have Internet connection."))
        logging.info(_("We're connected to a power source."))
        logging.info(_("We have enough disk space."))

        # Enable forward button
        self.forward_button.set_sensitive(True)

        if not self.testing:
            # Launch reflector script to determine the 10 fastest mirrors
            self.thread = AutoRankmirrorsThread()
            self.thread.start()

        return True
Exemplo n.º 5
0
class Check(GtkBaseBox):
    """ Check class """

    def __init__(self, params, prev_page="language", next_page="location"):
        """ Init class ui """
        super().__init__(self, params, "check", prev_page, next_page)

        self.remove_timer = False

        self.thread = None

        self.prepare_power_source = None
        self.prepare_network_connection = None
        self.prepare_enough_space = None
        self.timeout_id = None
        self.prepare_best_results = None

        # Boolean variable to check if reflector has been run once or not
        self.reflector_launched = False

        self.label_space = self.ui.get_object("label_space")

        if 'checks_are_optional' in params:
            self.checks_are_optional = params['checks_are_optional']
        else:
            self.checks_are_optional = False

        '''
        data_dir = self.settings.get('data')
        image1 = self.ui.get_object('image1')
        image1_path = os.path.join(data_dir, "images/apricity/apricity-for-everyone-white1.png")
        image1.set_from_file(image1_path)
        '''

    def translate_ui(self):
        """ Translates all ui elements """
        txt = _("System Check")
        self.header.set_subtitle(txt)

        self.prepare_enough_space = self.ui.get_object("prepare_enough_space")
        txt = _("has at least {0}GB available storage space").format(MIN_ROOT_SIZE / 1000000000)
        self.prepare_enough_space.props.label = txt

        txt = _("")
        txt = "<i>{0}</i>".format(txt)
        self.label_space.set_markup(txt)

        self.prepare_power_source = self.ui.get_object("prepare_power_source")
        txt = _("is plugged into a power source")
        self.prepare_power_source.props.label = txt

        self.prepare_network_connection = self.ui.get_object("prepare_network_connection")
        txt = _("is connected to the Internet")
        self.prepare_network_connection.props.label = txt

        self.prepare_best_results = self.ui.get_object("prepare_best_results")
        txt = _("For best results, please ensure that this computer:")
        txt = '<span weight="bold" size="large">{0}</span>'.format(txt)
        self.prepare_best_results.set_markup(txt)

    def check_all(self):
        """ Check that all requirements are meet """
        has_internet = misc.has_connection()
        self.prepare_network_connection.set_state(has_internet)

        on_power = not self.on_battery()
        self.prepare_power_source.set_state(on_power)

        space = self.has_enough_space()
        self.prepare_enough_space.set_state(space)

        if self.checks_are_optional:
            return True

        if has_internet and space:
            return True

        return False

    def on_battery(self):
        """ Checks if we are on battery power """
        import dbus

        if self.has_battery():
            bus = dbus.SystemBus()
            upower = bus.get_object(UPOWER, UPOWER_PATH)
            return misc.get_prop(upower, UPOWER_PATH, 'OnBattery')

        return False

    def has_battery(self):
        # UPower doesn't seem to have an interface for this.
        path = '/sys/class/power_supply'
        if not os.path.exists(path):
            return False
        for folder in os.listdir(path):
            type_path = os.path.join(path, folder, 'type')
            if os.path.exists(type_path):
                with open(type_path) as power_file:
                    if power_file.read().startswith('Battery'):
                        self.settings.set('laptop', 'True')
                        return True
        return False

    @staticmethod
    def has_enough_space():
        """ Check that we have a disk or partition with enough space """
        lsblk = subprocess.Popen(["lsblk", "-lnb"], stdout=subprocess.PIPE)
        output = lsblk.communicate()[0].decode("utf-8").split("\n")

        max_size = 0

        for item in output:
            col = item.split()
            if len(col) >= 5:
                if col[5] == "disk" or col[5] == "part":
                    size = int(col[3])
                    if size > max_size:
                        max_size = size

        if max_size >= MIN_ROOT_SIZE:
            return True

        return False

    def on_timer(self):
        """ If all requirements are meet, enable forward button """
        if not self.remove_timer:
            self.forward_button.set_sensitive(self.check_all())
        return not self.remove_timer

    def store_values(self):
        """ Continue """
        # Remove timer
        self.remove_timer = True

        logging.info(_("We have Internet connection."))
        logging.info(_("We're connected to a power source."))
        logging.info(_("We have enough disk space."))

        # Enable forward button
        self.forward_button.set_sensitive(True)

        if not self.testing and not self.reflector_launched:
            # Launch reflector script to determine the 10 fastest mirrors
            self.thread = AutoRankmirrorsThread()
            self.thread.start()
            self.reflector_launched = True

        return True

    def prepare(self, direction):
        """ Load screen """
        self.translate_ui()
        self.show_all()

        self.forward_button.set_sensitive(self.check_all())

        # Set timer
        self.timeout_id = GLib.timeout_add(5000, self.on_timer)
Exemplo n.º 6
0
class Check(GtkBaseBox):
    """ Check class """

    def __init__(self, params, prev_page="keymap", next_page="installation_ask"):
        """ Init class ui """
        super().__init__(self, params, "check", prev_page, next_page)

        self.remove_timer = False

        self.thread = None

        self.prepare_power_source = None
        self.prepare_network_connection = None
        self.prepare_enough_space = None
        self.timeout_id = None
        self.prepare_best_results = None

        self.label_space = self.ui.get_object("label_space")

    def translate_ui(self):
        """ Translates all ui elements """
        txt = _("System Check")
        txt = '<span weight="bold" size="large">{0}</span>'.format(txt)
        self.title.set_markup(txt)

        self.prepare_enough_space = self.ui.get_object("prepare_enough_space")
        txt = _("has at least {0}GB available storage space. (*)").format(MIN_ROOT_SIZE / 1000000000)
        self.prepare_enough_space.props.label = txt

        txt = _("This highly depends on which desktop environment you choose, so you might need more space.")
        txt = "(*) <i>{0}</i>".format(txt)
        self.label_space.set_markup(txt)

        self.prepare_power_source = self.ui.get_object("prepare_power_source")
        txt = _("is plugged in to a power source")
        self.prepare_power_source.props.label = txt

        self.prepare_network_connection = self.ui.get_object("prepare_network_connection")
        txt = _("is connected to the Internet")
        self.prepare_network_connection.props.label = txt

        self.prepare_best_results = self.ui.get_object("prepare_best_results")
        txt = _("For best results, please ensure that this computer:")
        txt = '<span weight="bold" size="large">{0}</span>'.format(txt)
        self.prepare_best_results.set_markup(txt)

    def check_all(self):
        """ Check that all requirements are meet """
        has_internet = misc.has_connection()
        self.prepare_network_connection.set_state(has_internet)

        on_power = not self.on_battery()
        self.prepare_power_source.set_state(on_power)

        space = self.has_enough_space()
        self.prepare_enough_space.set_state(space)

        return space

    def on_battery(self):
        """ Checks if we are on battery power """
        import dbus

        if self.has_battery():
            bus = dbus.SystemBus()
            upower = bus.get_object(UPOWER, UPOWER_PATH)
            return misc.get_prop(upower, UPOWER_PATH, 'OnBattery')

        return False

    def has_battery(self):
        # UPower doesn't seem to have an interface for this.
        path = '/sys/class/power_supply'
        if os.path.exists(path):
            for folder in os.listdir(path):
                type_path = os.path.join(path, folder, 'type')
                if os.path.exists(type_path):
                    with open(type_path) as power_file:
                        if power_file.read().startswith('Battery'):
                            return True
        return False

    @staticmethod
    def has_enough_space():
        """ Check that we have a disk or partition with enough space """
        lsblk = subprocess.Popen(["lsblk", "-lnb"], stdout=subprocess.PIPE)
        output = lsblk.communicate()[0].decode("utf-8").split("\n")

        max_size = max(
            [int(col[3]) for col in [item.split() for item in output] if len(col) >= 5 and col[5] in ["disk", "part"]]
        )

        return max_size >= MIN_ROOT_SIZE

    def on_timer(self):
        """ If all requirements are meet, enable forward button """
        if not self.remove_timer:
            self.forward_button.set_sensitive(self.check_all())
        return not self.remove_timer

    def store_values(self):
        """ Continue """
        # Remove timer
        self.remove_timer = True
        has_internet = misc.has_connection()

        if has_internet:
            logging.info(_("We have Internet connection."))
        logging.info(_("We're connected to a power source."))
        logging.info(_("We have enough disk space."))

        # Enable forward button
        self.forward_button.set_sensitive(True)

        if not self.testing and has_internet:
            # Launch reflector script to determine the 10 fastest mirrors
            self.thread = AutoRankmirrorsThread()
            self.thread.start()

        return True

    def prepare(self, direction):
        """ Load screen """
        self.translate_ui()
        self.show_all()

        self.forward_button.set_sensitive(self.check_all())

        # Set timer
        self.timeout_id = GLib.timeout_add(5000, self.on_timer)
Exemplo n.º 7
0
class Check(Gtk.Box):
    """ Check class """
    def __init__(self, params):
        """ Init class ui """
        self.title = params['title']
        self.settings = params['settings']
        self.forward_button = params['forward_button']
        self.backwards_button = params['backwards_button']
        self.testing = params['testing']

        super().__init__()

        self.ui = Gtk.Builder()

        self.ui_dir = self.settings.get('ui')
        self.ui.add_from_file(os.path.join(self.ui_dir, "check.ui"))
        self.ui.connect_signals(self)

        self.remove_timer = False

        self.thread = None

        self.prepare_power_source = None
        self.prepare_network_connection = None
        self.prepare_enough_space = None
        self.timeout_id = None
        self.prepare_best_results = None

        super().add(self.ui.get_object("check"))

    def translate_ui(self):
        txt = _("System Check")
        txt = '<span weight="bold" size="large">%s</span>' % txt
        self.title.set_markup(txt)

        self.prepare_enough_space = self.ui.get_object("prepare_enough_space")
        txt = _("has at least %dGB available storage space") % int(MIN_ROOT_SIZE / 1000000000)
        txt += " (*)"
        self.prepare_enough_space.props.label = txt

        self.label_space = self.ui.get_object("label_space")
        txt = _("This highly depends on which desktop environment you choose, so you might need more space.")
        txt = "(*) <i>%s</i>" % txt
        self.label_space.set_markup(txt)

        self.prepare_power_source = self.ui.get_object("prepare_power_source")
        txt = _("is plugged in to a power source")
        self.prepare_power_source.props.label = txt

        self.prepare_network_connection = self.ui.get_object("prepare_network_connection")
        txt = _("is connected to the Internet")
        self.prepare_network_connection.props.label = txt

        self.prepare_best_results = self.ui.get_object("prepare_best_results")
        txt = _("For best results, please ensure that this computer:")
        txt = '<span weight="bold" size="large">%s</span>' % txt
        self.prepare_best_results.set_markup(txt)

    def check_all(self):
        has_internet = misc.has_connection()
        self.prepare_network_connection.set_state(has_internet)

        on_power = not self.on_battery()
        self.prepare_power_source.set_state(on_power)

        space = self.has_enough_space()
        self.prepare_enough_space.set_state(space)

        #if has_internet and space:
        if space:
            return True

        return False

    def on_battery(self):
        import dbus
        if self.has_battery():
            bus = dbus.SystemBus()
            upower = bus.get_object(UPOWER, UPOWER_PATH)
            return misc.get_prop(upower, UPOWER_PATH, 'OnBattery')

        return False

    def has_battery(self):
        # UPower doesn't seem to have an interface for this.
        path = '/sys/class/power_supply'
        if not os.path.exists(path):
            return False
        for folder in os.listdir(path):
            type_path = os.path.join(path, folder, 'type')
            if os.path.exists(type_path):
                with open(type_path) as power_file:
                    if power_file.read().startswith('Battery'):
                        return True
        return False

    def has_enough_space(self):
        lsblk = subprocess.Popen(["lsblk", "-lnb"], stdout=subprocess.PIPE)
        output = lsblk.communicate()[0].decode("utf-8").split("\n")

        max_size = 0

        for item in output:
            col = item.split()
            if len(col) >= 5:
                if col[5] == "disk" or col[5] == "part":
                    size = int(col[3])
                    if size > max_size:
                        max_size = size
        # we need 5GB
        # 5000000000
        if max_size >= MIN_ROOT_SIZE:
            return True

        return False

    def on_timer(self, time):
        if not self.remove_timer:
            self.forward_button.set_sensitive(self.check_all())
        return not self.remove_timer

    def store_values(self):
        # remove timer
        self.remove_timer = True

        logging.info(_("We have Internet connection."))
        logging.info(_("We're connected to a power source."))
        logging.info(_("We have enough disk space."))

        # Enable forward button
        self.forward_button.set_sensitive(True)

        if not self.testing:
            ## Launch rankmirrors script to determine the 5 fastest mirrors
            self.thread = AutoRankmirrorsThread()
            self.thread.start()

        return True

    def get_prev_page(self):
        return _prev_page

    def get_next_page(self):
        return _next_page

    def prepare(self, direction):
        self.translate_ui()
        self.show_all()

        self.forward_button.set_sensitive(self.check_all())

        # set timer
        self.timeout_id = GObject.timeout_add(1000, self.on_timer, None)
Exemplo n.º 8
0
class Check(Gtk.Box):

    def __init__(self, params):

        self.title = params['title']
        self.ui_dir = params['ui_dir']
        self.settings = params['settings']
        self.forward_button = params['forward_button']
        self.backwards_button = params['backwards_button']

        super().__init__()

        self.ui = Gtk.Builder()

        self.ui.add_from_file(os.path.join(self.ui_dir, "check.ui"))
        self.ui.connect_signals(self)

        self.remove_timer = False

        super().add(self.ui.get_object("check"))

    def translate_ui(self):
        txt = _("System Check")
        txt = '<span weight="bold" size="large">%s</span>' % txt
        self.title.set_markup(txt)

        self.prepare_enough_space = self.ui.get_object("prepare_enough_space")
        txt = _("has at least 3GB available storage space")
        self.prepare_enough_space.props.label = txt

        self.prepare_power_source = self.ui.get_object("prepare_power_source")
        txt = _("is plugged in to a power source")
        self.prepare_power_source.props.label = txt

        self.prepare_network_connection = self.ui.get_object("prepare_network_connection")
        txt = _("is connected to the Internet")
        self.prepare_network_connection.props.label = txt

        self.prepare_best_results = self.ui.get_object("prepare_best_results")
        txt = _("For best results, please ensure that this computer:")
        txt = '<span weight="bold" size="large">%s</span>' % txt
        self.prepare_best_results.set_markup(txt)

        self.third_party_info = self.ui.get_object("third_party_info")
        txt = _("Lution installs third-party software to play Flash videos, MP3 " \
        "and other media." \
        " Some of this software is proprietary. Use of this " \
        "software is subject to license terms included with its " \
        "documentation.")
        self.third_party_info.set_label(txt)

        self.third_party_checkbutton = self.ui.get_object("third_party_checkbutton")
        txt = _("Install this third-party software")
        self.third_party_checkbutton.set_label(txt)

    def get_prop(self, obj, iface, prop):
        try:
            import dbus
            return obj.Get(iface, prop, dbus_interface=dbus.PROPERTIES_IFACE)
        except dbus.DBusException as e:
            if e.get_dbus_name() == 'org.freedesktop.DBus.Error.UnknownMethod':
                return None
            else:
                raise

    def has_connection(self):
        try:
            import dbus
            bus = dbus.SystemBus()
            manager = bus.get_object(NM, '/org/freedesktop/NetworkManager')
            state = self.get_prop(manager, NM, 'state')
        except dbus.exceptions.DBusException:
            logging.warning(_("Can't get network status"))
            return False
        return state == NM_STATE_CONNECTED_GLOBAL

    def check_all(self):
        has_internet = self.has_connection()
        self.prepare_network_connection.set_state(has_internet)       

        on_power = not self.on_battery()
        self.prepare_power_source.set_state(on_power)
        
        space = self.has_enough_space()
        self.prepare_enough_space.set_state(space)

        if has_internet and space:
            return True

        return False

    def on_battery(self):
        import dbus
        if self.has_battery():
            bus = dbus.SystemBus()
            upower = bus.get_object(UPOWER, UPOWER_PATH)
            return self.get_prop(upower, UPOWER_PATH, 'OnBattery')

        return False

    def has_battery(self):
        # UPower doesn't seem to have an interface for this.
        path = '/sys/class/power_supply'
        if not os.path.exists(path):
            return False
        for d in os.listdir(path):
            p = os.path.join(path, d, 'type')
            if os.path.exists(p):
                with open(p) as fp:
                    if fp.read().startswith('Battery'):
                        return True
        return False

    def has_enough_space(self):
        lsblk = subprocess.Popen(["lsblk", "-lnb"], stdout=subprocess.PIPE)
        output = lsblk.communicate()[0].decode("utf-8").split("\n")

        max_size = 0

        for item in output:
            col = item.split()
            if len(col) >= 5:
                if col[5] == "disk" or col[5] == "part":
                    size = int(col[3])
                    if size > max_size:
                        max_size = size
        # we need 3GB
        if max_size >= 3221225472:
            return True

        return False

    def on_third_party_checkbutton_toggled(self, button):
        current_value = self.settings.get("third_party_software")
        if current_value is False:
            self.settings.set("third_party_software", True)
        else:
            self.settings.set("third_party_software", False)

    def on_timer(self, time):
        if not self.remove_timer:
            self.forward_button.set_sensitive(self.check_all())
        return not self.remove_timer

    def store_values(self):
        # remove timer
        self.remove_timer = True

        logging.info(_("We have Internet connection."))
        logging.info(_("We're connected to a power source."))
        logging.info(_("We have enough disk space."))
          
        # Enable forward button
        self.forward_button.set_sensitive(True)

        ## Launch rankmirrors script to determine the 5 fastest mirrors
        self.thread = None
        self.thread = AutoRankmirrorsThread()
        self.thread.start()
        
        return True

    def get_prev_page(self):
        return _prev_page

    def get_next_page(self):
        return _next_page

    def prepare(self, direction):
        self.translate_ui()
        self.show_all()
        
        # We now have a features screen, so we don't need this here
        # Just hide it for now
        self.third_party_info.hide()
        self.third_party_checkbutton.hide()
        
        self.forward_button.set_sensitive(self.check_all())

        # set timer
        self.timeout_id = GObject.timeout_add(1000, self.on_timer, None)