示例#1
0
    def get_lspci_info(self, manufacturerId, filterString=''):
        deviceArray = []
        output = []

        # Check for Optimus
        if manufacturerId == '10de':
            output = getoutput("lspci -vnn | grep '\[030[02]\]'")

            if self.test_optimus:
                output = ['00:02.0 VGA compatible controller [0300]: Intel Corporation Haswell-ULT Integrated Graphics Controller [8086:0a16] (rev 09) (prog-if 00 [VGA controller])', \
                          '01:00.0 3D controller [0302]: NVIDIA Corporation GK107M [GeForce GT 750M] [10de:0fe4] (rev a1)']

        # Optimus will return 2 devices
        # If there are less than 2 devices, do regular check
        if len(output) < 2:
            if filterString != '':
                filterString = " | grep {}".format(filterString)
            output = getoutput("lspci -nn -d {}:{}".format(manufacturerId, filterString))

        if output:
            self.log.write("lspci output = {}".format(output), 'get_lspci_info')

        for line in output:
            matchObj = re.search(':\W(.*)\W\[(.+):(.+)\]', line)
            if matchObj:
                deviceArray.append([matchObj.group(1), matchObj.group(2), matchObj.group(3)])
        return deviceArray
示例#2
0
    def get_lspci_info(self, manufacturerId, filterString=''):
        deviceArray = []
        output = []

        # Check for Optimus
        if manufacturerId == '10de':
            output = getoutput("lspci -vnn | grep '\[030[02]\]'")

            if self.test_optimus:
                output = ['00:02.0 VGA compatible controller [0300]: Intel Corporation Haswell-ULT Integrated Graphics Controller [8086:0a16] (rev 09) (prog-if 00 [VGA controller])', \
                          '01:00.0 3D controller [0302]: NVIDIA Corporation GK107M [GeForce GT 750M] [10de:0fe4] (rev a1)']

        # Optimus will return 2 devices
        # If there are less than 2 devices, do regular check
        if len(output) < 2:
            if filterString != '':
                filterString = " | grep {}".format(filterString)
            output = getoutput("lspci -nn -d {}:{}".format(
                manufacturerId, filterString))

        if output:
            self.log.write("lspci output = {}".format(output),
                           'get_lspci_info')

        for line in output:
            matchObj = re.search(':\W(.*)\W\[(.+):(.+)\]', line)
            if matchObj:
                deviceArray.append(
                    [matchObj.group(1),
                     matchObj.group(2),
                     matchObj.group(3)])
        return deviceArray
示例#3
0
        def _get_attached_disks():
            disks = []
            exclude_devices = ['/dev/sr0', '/dev/sr1', '/dev/cdrom', '/dev/dvd']
            live_device = getoutput("findmnt -n -o source /lib/live/mount/findiso").split('\n')[0]
            live_device = re.sub('[0-9]+$', '', live_device) # remove partition numbers if any
            if live_device is not None and live_device.startswith('/dev/'):
                exclude_devices.append(live_device)
                print("Excluding %s (detected as the live device)" % live_device)
            lsblk = getoutput('LC_ALL=en_US.UTF-8 lsblk -rindo TYPE,NAME,RM,SIZE,MODEL | sort -k3,2')
            for line in lsblk:
                try:
                    type, dev, removable, size, model = line.split(" ", 4)
                    device = "/dev/" + dev
                    if type == "disk" and device not in exclude_devices:
                        # convert size to manufacturer's size for show, e.g. in GB, not GiB!
                        size = str(int(float(size[:-1]) * (1024/1000)**'BkMGTPEZY'.index(size[-1]))) + size[-1]
                        model = model.replace("\\x20", " ")
                        description = '{} ({}B)'.format(model.strip(), size)
                        if int(removable):
                            description = _('Removable:') + ' ' + description

                        # Is this device a SSD or pen drive?
                        ssd = is_ssd(device)
                        detachable = is_detachable(device)
                        disks.append((device, description, ssd, detachable))
                except:
                    pass
            return disks
示例#4
0
    def get_pae(self):
        machine = getoutput('uname -m')[0]
        release = getoutput('uname -r')[0]

        if self.test:
            machine = 'i686'
            release = '3.16.0-4-586'

        self.log.write(
            "PAE check: machine={} / release={}".format(machine, release),
            'get_pae')

        if machine == 'i686':
            # Check if PAE is installed and running
            selected = False
            if 'pae' in release:
                self.paeBooted = True
                selected = True
            else:
                if getPackageVersion('linux-image-686-pae') != '':
                    selected = True

            # Get the logo
            logo = join(self.mediaDir, 'images/pae.png')

            # Fill self.hardware
            paeDescription = _("PAE capable system")
            self.hardware.append(
                [selected, logo, paeDescription, '', 'pae', ''])
示例#5
0
    def __init__(self, locales, timezone, queue=None):
        threading.Thread.__init__(self)
        
        self.locales = locales
        self.default_locale = ''
        for loc in locales:
            if loc[3]:
                self.default_locale = loc[1]
                break
        if self.default_locale == '':
            self.default_locale = DEFAULTLOCALE
        self.timezone = timezone.strip()
        self.queue = queue
        self.user = getoutput("logname")[0]
        self.user_dir = "/home/%s" % self.user
        self.current_default = getoutput("awk -F'[=.]' '/UTF-8/{ print $2 }' /etc/default/locale")[0]
        self.scriptDir = abspath(dirname(__file__))
        self.edition = 'all'

        # Get configuration settings
        self.debian_version = get_debian_version()
        config = get_config_dict(join(self.scriptDir, "solydxk-system.conf"))
        self.debian_frontend = "DEBIAN_FRONTEND=%s" % config.get('DEBIAN_FRONTEND', 'noninteractive')
        self.apt_options = config.get('APT_OPTIONS_8', '')
        if self.debian_version == 0 or self.debian_version >= 9:
            self.apt_options = config.get('APT_OPTIONS_9', '')
        self.info = config.get('INFO', '/usr/share/solydxk/info')
        if exists(self.info):
            config = get_config_dict(self.info)
            self.edition = config.get('EDITION', 'all').replace(' ', '').lower()

        # Steps
        self.max_steps = 10
        self.current_step = 0
示例#6
0
    def set_locale(self):
        print((" --> Set locale %s" % self.default_locale))
        self.queue_progress()
#        minus_list = []
        # First, comment all languages
        shell_exec("sed -i -e '/^[a-z]/ s/^#*/# /' /etc/locale.gen")
        # Loop through all locales
        for loc in self.locales:
            if loc[0]:
#                if not loc[3]:
#                    minus_list.append(loc[1].replace('_', '-'))
                if has_string_in_file(loc[1], '/etc/locale.gen'):
                    # Uncomment the first occurence of the locale
                    shell_exec("sed -i '0,/^# *%(lan)s.UTF-8/{s/^# *%(lan)s.UTF-8/%(lan)s.UTF-8/}' /etc/locale.gen" % {'lan': loc[1].replace('.', '\.')})
                else:
                    # Add the locale
                    shell_exec("echo \"%s.UTF-8 UTF-8\" >> /etc/locale.gen" % loc[1])

            # Save new default locale
            if loc[3]:
                self.default_locale = loc[1]

        # Check if at least one locale is set
        locales = getoutput("awk -F'[@. ]' '{print $1}' < /etc/locale.gen | grep -v -E '^#|^$'")
        if locales[0] == '':
            shell_exec("echo \"%s.UTF-8 UTF-8\" >> /etc/locale.gen" % self.default_locale)
            
        cmd = "echo '{0}' > /etc/timezone && " \
              "rm /etc/localtime; ln -sf /usr/share/zoneinfo/{0} /etc/localtime && " \
              "echo 'LANG={1}.UTF-8' > /etc/default/locale && " \
              "dpkg-reconfigure --frontend=noninteractive locales && " \
              "update-locale LANG={1}.UTF-8".format(self.timezone, self.default_locale)
        shell_exec(cmd)
        
        # Copy mo files for Grub if needed
        cmd = "mkdir -p /boot/grub/locale && " \
              "for F in $(find /usr/share/locale -name 'grub.mo'); do " \
              "MO=/boot/grub/locale/$(echo $F | cut -d'/' -f 5).mo; " \
              "cp -afuv $F $MO; done"
        shell_exec(cmd)
        
        # Cleanup old default grub settings
        default_grub = '/etc/default/grub'
        shell_exec("sed -i '/^# Set locale$/d' {0} && " \
                   "sed -i '/^LANG=/d' {0} && " \
                   "sed -i '/^LANGUAGE=/d' {0} && " \
                   "sed -i '/^GRUB_LANG=/d' {0}".format(default_grub))
        
        # Update Grub and make sure it uses the new locale
        shell_exec('LANG={0}.UTF-8 update-grub'.format(self.default_locale))
            
        # Change user settings
        if exists(self.user_dir):
            shell_exec("sudo -H -u %s bash -c \"sed -i 's/Language=.*/Language=%s\.utf8/' %s/.dmrc\"" % (self.user, self.default_locale, self.user_dir))
            shell_exec("sudo -H -u %s bash -c \"printf %s > %s/.config/user-dirs.locale\"" % (self.user, self.default_locale, self.user_dir))
            prefs = getoutput("find %s -type f -name \"prefs.js\" -not -path \"*/extensions/*\"" % self.user_dir)
            for pref in prefs:
                self.localizePref(pref)

        self.current_default = self.default_locale
示例#7
0
    def get_pae(self):
        machine = getoutput('uname -m')[0]
        release = getoutput('uname -r')[0]

        if self.test:
            machine = 'i686'
            release = '3.16.0-4-586'

        self.log.write("PAE check: machine={} / release={}".format(machine, release), 'get_pae')

        if machine == 'i686':
            # Check if PAE is installed and running
            selected = False
            if 'pae' in release:
                self.paeBooted = True
                selected = True
            else:
                if getPackageVersion('linux-image-686-pae') != '':
                    selected = True

            # Get the logo
            logo = join(self.mediaDir, 'images/pae.png')

            # Fill self.hardware
            paeDescription = _("PAE capable system")
            self.hardware.append([selected, logo, paeDescription, '', 'pae', ''])
示例#8
0
    def on_cmbDevice_changed(self, widget=None):
        device = self.cmbDeviceHandler.getValue()
        if device is not None:
            mount = ''
            size = 0
            available = 0

            # Get the size of the USB
            usb_size = getoutput("env LANG=C udisks --show-info {} | grep size".format(device))
            if usb_size:
                # udisks returns bytes, while df returns kbs
                size = int(int(usb_size[0].split(":")[1].strip()) / 1024)

            # Assume that the USB is empty (will check later)
            available = size

            # Get free size on USB
            has_partition = self.device_has_partition(device)
            if has_partition:
                mount = self.get_device_mount(device)
                # This function can be called from on_chkFormatDevice_toggled
                if widget != self.chkFormatDevice:
                    self.chkFormatDevice.set_sensitive(True)
                    self.chkFormatDevice.set_active(False)
                    free_size = getoutput("df --output=avail {}1 | awk 'NR==2'".format(device))
                    if free_size:
                        available = int(free_size[0])
            else:
                self.chkFormatDevice.set_active(True)
                self.chkFormatDevice.set_sensitive(False)

            self.chkRepairDevice.set_active(False)
            self.fill_treeview_usbcreator(mount)
            self.lblAvailable.set_label("{}: {} MB".format(self.available_text, int(available / 1024)))

            # Save the info
            self.device['path'] = device
            self.device['size'] = size
            self.device['has_partition'] = has_partition
            self.device['mount'] = mount
            self.device['available'] = available
            self.log.write("Selected device info: {}".format(self.device))

            # Update info
            iso_path = self.txtIso.get_text().strip()
            if iso_path != "" and exists(iso_path):
                self.on_txtIso_changed()
        else:
            self.fill_treeview_usbcreator()
            self.lblAvailable.set_label('')
            self.lblRequired.set_label('')
            self.txtIso.set_text('')
            self.device['path'] = ''
            self.device['size'] = 0
            self.device['has_partition'] = False
            self.device['mount'] = ''
            self.device['available'] = 0
            self.device["new_iso"] = ''
            self.device["new_iso_required"] = 0
示例#9
0
 def get_readable_language(self, locale):
     lan = ''
     lan_list = join(self.scriptDir, 'languages.list')
     if exists(lan_list):
         lan = getoutput("grep '^%s' \"%s\" | awk -F'=' '{print $2}'" % (locale, lan_list))[0]
         if lan == '':
             lan = getoutput("grep '^%s' \"%s\" | awk -F'[= ]' '{print $2}' | uniq" % (locale.split('_')[0], lan_list))[0]
     return lan
示例#10
0
 def refresh(self):
     self.locales = getoutput("awk -F'[@. ]' '/UTF-8/{ print $1 }' /usr/share/i18n/SUPPORTED | uniq")
     self.default_locale = getoutput("awk -F'[=.]' '/UTF-8/{ print $2 }' /etc/default/locale")[0]
     self.available_locales = getoutput("locale -a | grep '_' | awk -F'[@ .]' '{print $1}'")
     self.timezone_continents = self.list_timezones()
     tz = getoutput("cat /etc/timezone 2>/dev/null")[0]
     self.current_timezone_continent = dirname(tz)
     self.current_timezone = basename(tz)
示例#11
0
 def on_btnHelp_clicked(self, widget):
     # Open the help file as the real user (not root)
     logname = getoutput('logname')[0]
     try:
         ff = getoutput('which firefox')[0]
         os.system("su {} -c \"{} {}\" &".format(logname, ff, self.helpFile))
     except:
         # If Firefox was removed, this might work
         os.system("su {} -c \"xdg-open {}\" &".format(logname, self.helpFile))
示例#12
0
def get_release_name(mount_point=''):
    # Get the name of the live OS
    try:
        lsb_release = "{}/etc/lsb-release".format(mount_point)
        if path_exists(lsb_release):
            name = getoutput(". %s; echo $DISTRIB_DESCRIPTION" % lsb_release)
        if name == '':
            os_release = "{}etc/os-release".format(mount_point)
            if path_exists(os_release):
                name = getoutput(". %s; echo PRETTY_NAME" % os_release)
        return name.strip()
    except:
        return ''
示例#13
0
 def get_luks_info(self, partition_path):
     mapper_path = ''
     mount_points = []
     mapper = '/dev/mapper'
     mapper_name = getoutput("ls %s | grep %s$" % (mapper, basename(partition_path)))[0]
     if not mapper_name:
         uuid = get_uuid(partition_path)
         if uuid:
             mapper_name = getoutput("ls %s | grep %s$" % (mapper, uuid))[0]
     if mapper_name:
         mapper_path = join(mapper, mapper_name)
     if mapper_path:
         mount_points = get_mount_points(mapper_path)
     return (mapper_path, mount_points[0])
示例#14
0
def has_grub(path):
    cmd = "dd bs=512 count=1 if={} 2>/dev/null | strings".format(path)
    out = ' '.join(getoutput(cmd)).upper()
    if "GRUB" in out:
        print(("Grub installed on {}".format(path)))
        return True
    return False
示例#15
0
 def set_progress(self):
     if exists(self.log_file):
         msg = ''
         last_line = getoutput("tail -50 {} | grep -v DEBUG | grep -v ==".format(self.log_file))
         for line in reversed(last_line):
             # Check for session start line: that is the last line to check
             if ">>>>>" in line and "<<<<<" in line:
                 break
             for chk_line in self.log_lines:
                 if chk_line[0] in line.lower():
                     #print((line))
                     word = ''
                     if chk_line[1] == 0:
                         self.pbUsbCreator.pulse()
                         words = line.split(' ')
                         for word in reversed(words):
                             if word.strip() != '':
                                 break
                     else:
                         self.pbUsbCreator.set_fraction(float(chk_line[1] / 100))
                     msg = "{} {}".format(chk_line[2], word)
                     break
             if msg != '':
                 break
         self.set_statusbar_message(msg)
示例#16
0
def is_detachable(path):
    udisks_detachable = getoutput(
        "env LANG=C udisks --show-info %s | grep detachable | awk '{print $2}'"
        % path)
    if udisks_detachable == "1":
        return True
    return False
示例#17
0
def handle_command(command, chart):
    """
    Fires off ``command`` and sends the collected result to given ``chart``.

    """
    result = getoutput(command).strip()
    send_result(result, chart)
示例#18
0
def has_grub(path):
    cmd = "dd bs=512 count=1 if={} 2>/dev/null | strings".format(path)
    out = ' '.join(getoutput(cmd)).upper()
    if "GRUB" in out:
        print(("Grub installed on {}".format(path)))
        return True
    return False
示例#19
0
def handle_command(command, chart):
    """
    Fires off ``command`` and sends the collected result to given ``chart``.

    """
    result = getoutput(command).strip()
    send_result(result, chart)
示例#20
0
 def set_progress(self):
     if exists(self.log_file):
         msg = ''
         last_line = getoutput(
             "tail -50 {} | grep -v DEBUG | grep -v ==".format(
                 self.log_file))
         for line in reversed(last_line):
             # Check for session start line: that is the last line to check
             if ">>>>>" in line and "<<<<<" in line:
                 break
             for chk_line in self.log_lines:
                 if chk_line[0] in line.lower():
                     #print((line))
                     word = ''
                     if chk_line[1] == 0:
                         self.pbUsbCreator.pulse()
                         words = line.split(' ')
                         for word in reversed(words):
                             if word.strip() != '':
                                 break
                     else:
                         self.pbUsbCreator.set_fraction(
                             float(chk_line[1] / 100))
                     msg = "{} {}".format(chk_line[2], word)
                     break
             if msg != '':
                 break
         self.set_statusbar_message(msg)
示例#21
0
def get_status(device):
    status_dict = {
        'offset': '',
        'mode': '',
        'device': '',
        'cipher': '',
        'keysize': '',
        'filesystem': '',
        'active': '',
        'type': '',
        'size': ''
    }
    mapped_name = basename(device)
    status_info = getoutput(
        "env LANG=C cryptsetup status {}".format(mapped_name))
    for line in status_info:
        parts = line.split(':')
        if len(parts) == 2:
            status_dict[parts[0].strip()] = parts[1].strip()
        elif " active" in line:
            parts = line.split(' ')
            status_dict['active'] = parts[0]
            status_dict['filesystem'] = get_filesystem(parts[0])

    # No info has been retrieved: save minimum
    if status_dict['device'] == '':
        status_dict['device'] = device
    if status_dict['active'] == '' and is_encrypted(device):
        mapped_name = basename(device)
        status_dict['active'] = "/dev/mapper/{}".format(mapped_name)

    return status_dict
示例#22
0
 def is_plymouth_booted(self):
     cmdline = getoutput("cat /proc/cmdline")[0]
     if ' splash' in cmdline:
         return True
     else:
         # It could be that the user manually removed splash in Grub when booting
         # Check grub.cfg
         matchObj = re.search('\/.*=[0-9a-z\-]+', cmdline)
         if matchObj:
             if exists(self.grubcfg):
                 grubcfg_splash = getoutput(
                     'grep "{}" "{}" | grep " splash"'.format(
                         matchObj.group(0), self.grubcfg))[0]
                 if grubcfg_splash:
                     return True
     return False
示例#23
0
 def do_configure_grub(self, our_total, our_current):
     self.update_progress(pulse=True, total=our_total, current=our_current, message=_("Configuring bootloader"))
     print " --> Running grub-mkconfig"
     chroot_exec("grub-mkconfig -o /boot/grub/grub.cfg")
     grub_output = getoutput("chroot /target/ /bin/sh -c \"grub-mkconfig -o /boot/grub/grub.cfg\"")
     grubfh = open("/var/log/live-installer-grub-output.log", "w")
     grubfh.writelines(grub_output)
     grubfh.close()
示例#24
0
def get_release_name(mount_point=''):
    # Get the name of the live OS
    try:
        lsb_release = "{}/etc/lsb-release".format(mount_point)
        if path_exists(lsb_release):
            name = getoutput(
                "grep DISTRIB_DESCRIPTION %s | awk -F'=' '{print $2}' | sed 's#\"##g'"
                % lsb_release)
        if name == '':
            os_release = "{}etc/os-release".format(mount_point)
            if path_exists(os_release):
                name = getoutput(
                    "grep PRETTY_NAME %s | awk -F'=' '{print $2}' | sed 's#\"##g'"
                    % os_release)
        return name.strip()
    except:
        return ''
示例#25
0
 def get_devices(self):
     devices = []
     my_devices = getoutput("udisks --enumerate-device-files | egrep '/dev/sd[a-z]$'")
     for device in my_devices:
         info = getoutput("env LANG=C udisks --show-info {}".format(device))
         detachable = False
         has_partition = False
         for line in info:
             if "detachable" in line and "1" in line:
                 detachable = True
             elif "partition" in line:
                 has_partition = True
             if detachable and has_partition:
                 devices.append(device)
                 break
     devices.sort()
     return devices
示例#26
0
def unmount_partition(device):
    shell_exec("umount -f {}".format(device))
    if is_connected(device):
        shell_exec("cryptsetup close {} 2>/dev/null".format(device))
    ret = getoutput("grep '%s ' /proc/mounts" % device)[0]
    if not device in ret:
        return True
    return False
示例#27
0
 def get_broadcom_ids(self, driver_name):
     driver_name = driver_name.upper()
     ids = getoutput(
         "cat /usr/bin/ddm | grep '{}=' | cut -d'=' -f 2".format(
             driver_name))
     if len(ids) > 0:
         return ids[0].split('|')
     return []
示例#28
0
 def device_has_partition(self, device):
     part_count = getoutput(
         "udisks --show-info {} | grep count | grep -v block".format(
             device))
     if part_count:
         if "1" in part_count[0]:
             return True
     return False
示例#29
0
 def get_device_mount(self, device):
     shell_exec("udisks --mount {}1".format(device))
     mount = getoutput(
         "grep %s1 /etc/mtab | awk '{print $2}' | sed 's/\\040/ /g'" %
         device)
     if mount:
         return mount[0]
     return ''
示例#30
0
 def need_drivers(self):
     if exists('/usr/bin/ddm'):
         hw_list = ['amd', 'nvidia', 'broadcom', 'pae']
         for hw in hw_list:
             drivers = getoutput("ddm -i %s -s" % hw)
             if drivers[0]:
                 return True
     return False
示例#31
0
 def getCurrentTheme(self):
     try:
         if isfile(self.setThemePath) and \
            self.is_plymouth_booted():
             return getoutput(self.setThemePath)[0]
     except:
         pass
     return ''
示例#32
0
    def __init__(self, test=False):
        # Testing
        self.test = test
        # Set to true for testing Optimus
        self.test_optimus = False

        # Load window and widgets
        self.scriptName = basename(__file__)
        self.scriptDir = abspath(dirname(__file__))
        self.mediaDir = join(self.scriptDir, '../../share/ddm')
        self.builder = Gtk.Builder()
        self.builder.add_from_file(join(self.mediaDir, 'ddm.glade'))

        # Main window objects
        go = self.builder.get_object
        self.window = go("ddmWindow")
        self.tvDDM = go("tvDDM")
        self.btnSave = go("btnSave")
        self.btnHelp = go("btnHelp")
        self.btnQuit = go("btnQuit")
        self.pbDDM = go("pbDDM")
        self.chkBackports = go("chkBackports")

        self.window.set_title(_("Device Driver Manager"))
        self.btnSave.set_label(_("Install"))
        self.btnHelp.set_label(_("Help"))
        self.btnQuit.set_label(_("Quit"))
        self.chkBackports.set_label(_("Use Backports"))

        # Initiate variables
        self.queue = Queue(-1)
        self.threads = {}
        self.hardware = []
        self.loadedDrivers = []
        self.notSupported = []
        self.paeBooted = False
        self.htmlDir = join(self.mediaDir, "html")
        self.helpFile = join(self.get_language_dir(), "help.html")
        log = getoutput("cat /usr/bin/ddm | grep 'LOG=' | cut -d'=' -f 2")
        self.logFile = log[0]
        self.log = Logger(self.logFile, addLogTime=False, maxSizeKB=5120)
        self.tvDDMHandler = TreeViewHandler(self.tvDDM)
        self.tvDDMHandler.connect('checkbox-toggled', self.tv_checkbox_toggled)

        # Connect builder signals and show window
        self.builder.connect_signals(self)
        self.window.show_all()

        # Fill treeview
        self.fill_treeview_ddm()

        # Check backports
        if len(self.hardware) < 2 or not has_backports():
            self.chkBackports.hide()

        self.get_loaded_graphical_driver()
        self.get_loaded_wireless_driver()
示例#33
0
 def getInstalledThemes(self):
     instThemes = []
     try:
         if isfile(self.setThemePath):
             cmd = '%s --list' % self.setThemePath
             instThemes = getoutput(cmd)
     except:
         pass
     return instThemes
示例#34
0
 def get_devices(self):
     devices = []
     my_devices = getoutput(
         "udisks --enumerate-device-files | egrep '/dev/sd[a-z]$'")
     for device in my_devices:
         info = getoutput("env LANG=C udisks --show-info {}".format(device))
         detachable = False
         has_partition = False
         for line in info:
             if "detachable" in line and "1" in line:
                 detachable = True
             elif "partition" in line:
                 has_partition = True
             if detachable and has_partition:
                 devices.append(device)
                 break
     devices.sort()
     return devices
示例#35
0
    def __init__(self, test=False):
        # Testing
        self.test = test
        # Set to true for testing Optimus
        self.test_optimus = False

        # Load window and widgets
        self.scriptName = basename(__file__)
        self.scriptDir = abspath(dirname(__file__))
        self.mediaDir = join(self.scriptDir, '../../share/ddm')
        self.builder = Gtk.Builder()
        self.builder.add_from_file(join(self.mediaDir, 'ddm.glade'))

        # Main window objects
        go = self.builder.get_object
        self.window = go("ddmWindow")
        self.tvDDM = go("tvDDM")
        self.btnSave = go("btnSave")
        self.btnHelp = go("btnHelp")
        self.btnQuit = go("btnQuit")
        self.pbDDM = go("pbDDM")
        self.chkBackports = go("chkBackports")

        self.window.set_title(_("Device Driver Manager"))
        self.btnSave.set_label(_("Install"))
        self.btnHelp.set_label(_("Help"))
        self.btnQuit.set_label(_("Quit"))
        self.chkBackports.set_label(_("Use Backports"))

        # Initiate variables
        self.queue = Queue(-1)
        self.threads = {}
        self.hardware = []
        self.loadedDrivers = []
        self.notSupported = []
        self.paeBooted = False
        self.htmlDir = join(self.mediaDir, "html")
        self.helpFile = join(self.get_language_dir(), "help.html")
        log = getoutput("cat /usr/bin/ddm | grep 'LOG=' | cut -d'=' -f 2")
        self.logFile = log[0]
        self.log = Logger(self.logFile, addLogTime=False, maxSizeKB=5120)
        self.tvDDMHandler = TreeViewHandler(self.tvDDM)
        self.tvDDMHandler.connect('checkbox-toggled', self.tv_checkbox_toggled)

        # Connect builder signals and show window
        self.builder.connect_signals(self)
        self.window.show_all()

        # Fill treeview
        self.fill_treeview_ddm()

        # Check backports
        if len(self.hardware) < 2 or not has_backports():
            self.chkBackports.hide()

        self.get_loaded_graphical_driver()
        self.get_loaded_wireless_driver()
示例#36
0
def get_partition_path_from_string(partition_string):
    if '/' in partition_string:
        if path_exists(partition_string):
            return partition_string
        return ''
    cmd = "blkid | grep {} | cut -d':' -f 1".format(partition_string)
    try:
        return getoutput(cmd).strip()
    except:
        return ''
示例#37
0
def get_partition_path_from_string(partition_string):
    if '/' in partition_string:
        if path_exists(partition_string):
            return partition_string
        return ''
    cmd = "blkid | grep {} | cut -d':' -f 1".format(partition_string)
    try:
        return getoutput(cmd).strip()
    except:
        return ''
示例#38
0
def get_mount_point(device, mountpoint=None):
    mountpoint = " | grep \"%s \"" % mountpoint if mountpoint else ''
    cmd = "mount | grep \"%s \"%s" % (device, mountpoint)
    #print((">> cmd = %s" % cmd))
    try:
        out = getoutput(cmd).strip()
        mount = re.search("\s+on\s+([\S]+)", out).group(1)
        #print((">> mount = %s" % mount))
        return mount
    except:
        return ''
示例#39
0
def build_timezones(_installer):
    global installer, time_label, time_label_box, timezone
    installer = _installer
    # Add the label displaying current time
    time_label = installer.go("label_time")
    time_label_box = time_label.get_parent()
    time_label_box.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('#000'))
    time_label.modify_fg(Gtk.StateType.NORMAL, Gdk.color_parse('#fff'))
    GObject.timeout_add(200, update_local_time_label)
    # Populate timezones model
    installer.go("image_timezones").set_from_file(TIMEZONE_RESOURCES +
                                                  'bg.png')

    def autovivified():
        return defaultdict(autovivified)

    hierarchy = autovivified()

    for line in getoutput(
            "awk '/^[^#]/{ print $1,$2,$3 }' /usr/share/zoneinfo/zone.tab | sort -k3",
            always_as_list=True):
        ccode, coords, name = line.split()
        lat, lon = TZ_SPLIT_COORDS.search(coords).groups()
        x, y = pixel_position(to_float(lat, 2), to_float(lon, 3))
        if x < 0:
            x = MAP_SIZE[0] + x
        tup = Timezone(name, ccode, x, y)
        submenu = hierarchy
        parts = name.split('/')
        for i, part in enumerate(parts, 1):
            if i != len(parts):
                submenu = submenu[part]
            else:
                submenu[part] = tup
        timezones.append(tup)

    def _build_menu(d):
        menu = Gtk.Menu()
        for k in sorted(d):
            v = d[k]
            item = Gtk.MenuItem(k)
            item.show()
            if isinstance(v, dict):
                item.set_submenu(_build_menu(v))
            else:
                item.connect('activate', cb_menu_selected, v)
            menu.append(item)
        menu.show()
        return menu

    tz_menu = _build_menu(hierarchy)
    tz_menu.show()
    installer.go('button_timezones').connect('event', cb_button_timezoens,
                                             tz_menu)
示例#40
0
def get_mount_point(device, mountpoint=None):
    mountpoint = " | grep \"%s \"" % mountpoint if mountpoint else ''
    cmd = "mount | grep \"%s \"%s" % (device, mountpoint)
    #print((">> cmd = %s" % cmd))
    try:
        out = getoutput(cmd).strip()
        mount = re.search("\s+on\s+([\S]+)", out).group(1)
        #print((">> mount = %s" % mount))
        return mount
    except:
        return ''
示例#41
0
 def _get_attached_disks():
     disks = []
     exclude_devices = 'sr0 sr1 cdrom dvd'.split()
     lsblk = getoutput('lsblk -dinro TYPE,NAME,RM,SIZE,MODEL | sort -k3,2')
     for line in lsblk:
         # Don't do a full parse until we know this line describes a disk.
         type, device = line.split(" ", 1)
         if type == "disk" and device not in exclude_devices:
             type, device, removable, size, model = line.split(" ", 4)
             device = "/dev/" + device
             # [XK] Exclude live boot device
             boot_partition = getoutput("mount | grep -v loop | egrep 'medium|findiso' | awk '{print $1}'")
             if device not in boot_partition:
                 # convert size to manufacturer's size for show, e.g. in GB, not GiB!
                 print ">>> size = '{}'".format(size)
                 size = str(int(float(size[:-1]) * (1024/1000)**'BkMGTPEZY'.index(size[-1]))) + size[-1]
                 description = '{} ({}B)'.format(model.strip(), size)
                 if int(removable):
                     description = _('Removable:') + ' ' + description
                 disks.append((device, description))
     return disks
示例#42
0
    def run(self):
        httpCode = -1
        dlSpeed = 0
        mirror_index = 0
        for mirrorData in self.mirrors:
            mirror_index += 1
            try:
                mirror = mirrorData[3].strip()
                if mirror == "URL":
                    continue
                if mirror.endswith('/'):
                    mirror = mirror[:-1]

                # Only check Debian repository: SolydXK is on the same server
                httpCode = -1
                dlSpeed = 0
                config = get_config_dict(
                    join(self.scriptDir, "solydxk-system.conf"))
                dl_file = config.get('DLTEST', 'dltest')
                url = os.path.join(mirror, dl_file)
                http = "http://"
                if url[0:4] == "http":
                    http = ""
                cmd = "curl --connect-timeout 5 -m 5 -w '%%{http_code}\n%%{speed_download}\n' -o /dev/null -s --location %s%s" % (
                    http, url)

                lst = getoutput(cmd)
                if len(lst) == 2:
                    httpCode = int(lst[0])
                    dlSpeed = lst[1]
                    # Download speed returns as string with decimal separator
                    # On non-US systems converting to float throws an error
                    # Split on the separator, and use the left part only
                    if ',' in dlSpeed:
                        dlSpeed = dlSpeed.split(',')[0]
                    elif '.' in dlSpeed:
                        dlSpeed = dlSpeed.split('.')[0]
                    dlSpeed = int(dlSpeed) / 1024

                    self.queue.put([
                        mirror,
                        "%d kb/s" % dlSpeed, mirror_index,
                        len(self.mirrors)
                    ])
                    print(("Server {0} - {1} kb/s ({2})".format(
                        mirror, dlSpeed,
                        self.get_human_readable_http_code(httpCode))))

            except Exception as detail:
                # This is a best-effort attempt, fail graciously
                print(("Error: http code = {} / error = {}".format(
                    self.get_human_readable_http_code(httpCode), detail)))
示例#43
0
    def getRemovablePackageName(self, theme):
        cmd = 'dpkg -S %s.plymouth' % theme
        package = None
        packageNames = getoutput(cmd)

        for line in packageNames:
            if self.avlThemesSearchstr in line:
                matchObj = re.search('(^.*):', line)
                if matchObj:
                    package = matchObj.group(1)
                    break
        self.write_log("Package found %(pck)s" % {"pck": package})
        return package
示例#44
0
    def getAvailableThemes(self):
        cmd = 'aptitude search %s | grep ^p' % self.avlThemesSearchstr
        availableThemes = utils.getoutput(cmd)
        avlThemes = []

        for line in availableThemes:
            matchObj = re.search('%s-([a-zA-Z0-9-]*)' % self.avlThemesSearchstr, line)
            if matchObj:
                theme = matchObj.group(1)
                if not 'all' in theme:
                    avlThemes.append(theme)

        return avlThemes
示例#45
0
    def getRemovablePackageName(self, theme):
        cmd = 'dpkg -S %s.plymouth' % theme
        package = None
        packageNames = utils.getoutput(cmd)

        for line in packageNames:
            if self.avlThemesSearchstr in line:
                matchObj = re.search('(^.*):', line)
                if matchObj:
                    package = matchObj.group(1)
                    break
        self.log.write("Package found %(pck)s" % { "pck": package }, 'plymouth.getRemovablePackageName', 'debug')
        return package
示例#46
0
        def _get_attached_disks():
            disks = []
            exclude_devices = [
                '/dev/sr0', '/dev/sr1', '/dev/cdrom', '/dev/dvd'
            ]
            live_device = getoutput(
                "findmnt -n -o source /lib/live/mount/findiso").split('\n')[0]
            live_device = re.sub(
                '[0-9]+$', '', live_device)  # remove partition numbers if any
            if live_device is not None and live_device.startswith('/dev/'):
                exclude_devices.append(live_device)
                print("Excluding %s (detected as the live device)" %
                      live_device)
            lsblk = getoutput(
                'LC_ALL=en_US.UTF-8 lsblk -rindo TYPE,NAME,RM,SIZE,MODEL | sort -k3,2'
            )
            for line in lsblk:
                try:
                    type, dev, removable, size, model = line.split(" ", 4)
                    device = "/dev/" + dev
                    if type == "disk" and device not in exclude_devices:
                        # convert size to manufacturer's size for show, e.g. in GB, not GiB!
                        size = str(
                            int(
                                float(size[:-1]) * (1024 / 1000)**
                                'BkMGTPEZY'.index(size[-1]))) + size[-1]
                        model = model.replace("\\x20", " ")
                        description = '{} ({}B)'.format(model.strip(), size)
                        if int(removable):
                            description = _('Removable:') + ' ' + description

                        # Is this device a SSD or pen drive?
                        ssd = is_ssd(device)
                        detachable = is_detachable(device)
                        disks.append((device, description, ssd, detachable))
                except:
                    pass
            return disks
示例#47
0
    def getAvailableThemes(self):
        cmd = 'aptitude search %s | grep ^p' % self.avlThemesSearchstr
        availableThemes = utils.getoutput(cmd)
        avlThemes = []

        for line in availableThemes:
            matchObj = re.search(
                '%s-([a-zA-Z0-9-]*)' % self.avlThemesSearchstr, line)
            if matchObj:
                theme = matchObj.group(1)
                if not 'all' in theme:
                    avlThemes.append(theme)

        return avlThemes
示例#48
0
 def getCurrentTheme(self):
     curTheme = None
     if os.path.isfile(self.setThemePath):
         if self.boot is not None:
             grubCont = ""
             with open(self.boot, 'r') as f:
                 grubCont = f.read()
             matchObj = re.search('GRUB_CMDLINE_LINUX_DEFAULT="(.*)"', grubCont)
             if matchObj:
                 if ' splash' in matchObj.group(1):
                     curThemeList = utils.getoutput(self.setThemePath)
                     if curThemeList:
                         curTheme = curThemeList[0]
     return curTheme
示例#49
0
    def __init__(self):
        self.scriptDir = abspath(dirname(__file__))
        self.timezones = getoutput("awk '/^[^#]/{print $3}' /usr/share/zoneinfo/zone.tab | sort -k3")
        self.refresh()

        # Genereate locale files with the default locale if they do not exist
        if not exists('/etc/locale.gen'):
            shell_exec("echo \"%s.UTF-8 UTF-8\" >> /etc/locale.gen" % DEFAULTLOCALE)
            shell_exec("locale-gen")
        if self.default_locale == '':
            self.default_locale = DEFAULTLOCALE
            shell_exec("echo \"\" > /etc/default/locale")
            shell_exec("update-locale LANG=\"%s.UTF-8\"" % self.default_locale)
            shell_exec("update-locale LANG=%s.UTF-8" % self.default_locale)
示例#50
0
def build_timezones(_installer):
    global installer, time_label, time_label_box, timezone
    installer = _installer
    # Add the label displaying current time
    time_label = installer.go("label_time")
    time_label_box = time_label.get_parent()
    time_label_box.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('#000'))
    time_label.modify_fg(Gtk.StateType.NORMAL, Gdk.color_parse('#fff'))
    GObject.timeout_add(200, update_local_time_label)
    # Populate timezones model
    installer.go("image_timezones").set_from_file(TIMEZONE_RESOURCES + 'bg.png')

    def autovivified():
        return defaultdict(autovivified)

    hierarchy = autovivified()

    for line in getoutput("awk '/^[^#]/{ print $1,$2,$3 }' /usr/share/zoneinfo/zone.tab | sort -k3", always_as_list=True):
        ccode, coords, name = line.split()
        lat, lon = TZ_SPLIT_COORDS.search(coords).groups()
        x, y = pixel_position(to_float(lat, 2), to_float(lon, 3))
        if x < 0:
            x = MAP_SIZE[0] + x
        tup = Timezone(name, ccode, x, y)
        submenu = hierarchy
        parts = name.split('/')
        for i, part in enumerate(parts, 1):
            if i != len(parts):
                submenu = submenu[part]
            else:
                submenu[part] = tup
        timezones.append(tup)

    def _build_menu(d):
        menu = Gtk.Menu()
        for k in sorted(d):
            v = d[k]
            item = Gtk.MenuItem(k)
            item.show()
            if isinstance(v, dict):
                item.set_submenu(_build_menu(v))
            else:
                item.connect('activate', cb_menu_selected, v)
            menu.append(item)
        menu.show()
        return menu
    tz_menu = _build_menu(hierarchy)
    tz_menu.show()
    installer.go('button_timezones').connect('event', cb_button_timezoens, tz_menu)
示例#51
0
 def build_kb_lists(self):
     ''' Do some xml kung-fu and load the keyboard stuffs '''
     # Determine the layouts in use
     (keyboard_geom,
      self.setup.keyboard_layout) = getoutput("setxkbmap -query | awk '/^(model|layout)/{print $2}'").split()
     # Build the models
     from collections import defaultdict
     def _ListStore_factory():
         model = gtk.ListStore(str, str)
         model.set_sort_column_id(0, gtk.SORT_ASCENDING)
         return model
     models = _ListStore_factory()
     layouts = _ListStore_factory()
     variants = defaultdict(_ListStore_factory)
     try:
         import xml.etree.cElementTree as ET
     except ImportError:
         import xml.etree.ElementTree as ET
     xml = ET.parse('/usr/share/X11/xkb/rules/xorg.xml')
     for node in xml.iterfind('.//modelList/model/configItem'):
         name, desc = node.find('name').text, node.find('description').text
         iterator = models.append((desc, name))
         if name == keyboard_geom:
             set_keyboard_model = iterator
     for node in xml.iterfind('.//layoutList/layout'):
         name, desc = node.find('configItem/name').text, node.find('configItem/description').text
         variants[name].append((desc, None))
         for variant in node.iterfind('variantList/variant/configItem'):
             var_name, var_desc = variant.find('name').text, variant.find('description').text
             var_desc = var_desc if var_desc.startswith(desc) else '{} - {}'.format(desc, var_desc)
             variants[name].append((var_desc, var_name))
         iterator = layouts.append((desc, name))
         if name == self.setup.keyboard_layout:
             set_keyboard_layout = iterator
     # Set the models
     self.wTree.get_widget("combobox_kb_model").set_model(models)
     self.wTree.get_widget("treeview_layouts").set_model(layouts)
     self.layout_variants = variants
     # Preselect currently active keyboard info
     try:
         self.wTree.get_widget("combobox_kb_model").set_active_iter(set_keyboard_model)
     except NameError: pass  # set_keyboard_model not set
     try:
         treeview = self.wTree.get_widget("treeview_layouts")
         path = layouts.get_path(set_keyboard_layout)
         treeview.set_cursor(path)
         treeview.scroll_to_cell(path)
     except NameError: pass  # set_keyboard_layout not set
示例#52
0
 def run(self):
     try:
         lst = utils.getoutput(self.command)
         print((str(lst)))
         # Check if an error occured
         for line in lst:
             if line[:2] == 'E:':
                 self.log.write(_("Error returned: %(err)s") % { "err": line }, 'execapt.run', 'error')
                 self.queue.put(line)
                 break
     except Exception as detail:
         self.queue.put(detail)
     finally:
         # If no error occurred, be sure to put None in the queue or get an error on task_done
         self.queue.put(None)
         self.queue.task_done()
示例#53
0
    def full_disk_format(self, device):
        # Create a default partition set up
        disk_label = ('gpt' if device.getLength('B') > 2**32*.9 * device.sectorSize  # size of disk > ~2TB
                               or installer.setup.gptonefi
                            else 'msdos')
        separate_home_partition = device.getLength('GB') > 61

        # [XK] Only the first drive gets a swap, root, and/or home partition
        if self.full_disk_format_runonce:
            mkpart = (
                # (condition, mount_as, format_as, size_mb)
                # root
                (True, '', 'ext4', 0),
            )
        else:
            mkpart = (
                # (condition, mount_as, format_as, size_mb)
                # EFI
                (installer.setup.gptonefi, EFI_MOUNT_POINT, 'vfat', 300),
                # swap - equal to RAM for hibernate to work well (but capped at ~8GB)
                (True, SWAP_MOUNT_POINT, 'swap', min(8800, int(round(1.1/1024 * int(getoutput("awk '/^MemTotal/{ print $2 }' /proc/meminfo")), -2)))),
                # root
                (True, '/', 'ext4', 30000 if separate_home_partition else 0),
                # home
                (separate_home_partition, '/home', 'ext4', 0),
            )
        run_parted = lambda cmd: os.system('parted --script --align optimal {} {} ; sync'.format(device.path, cmd))
        run_parted('mklabel ' + disk_label)
        start_mb = 1
        for size_mb in map(lambda x: x[-1], filter(lambda x: x[0], mkpart)):
            end = '{}MB'.format(start_mb + size_mb) if size_mb else '100%'
            run_parted('mkpart primary {}MB {}'.format(start_mb, end))
            start_mb += size_mb
        if installer.setup.gptonefi:
            run_parted('set 1 boot on')
        elif not self.full_disk_format_runonce:
            # [XK] Set the boot flag for the root partition
            run_parted('set 2 boot on')
        # [XK] Save that the first drive has been configured
        self.full_disk_format_runonce = True
        return ((i[1], i[2]) for i in mkpart if i[0])
示例#54
0
def get_status(partitionPath):
    status_dict = {'offset': '', 'mode': '', 'device': '', 'cipher': '', 'keysize': '', 'filesystem': '', 'active': '', 'type': '', 'size': ''}
    mapped_name = os.path.basename(partitionPath)
    status_info = getoutput("env LANG=C cryptsetup status {}".format(mapped_name))
    for line in status_info:
        parts = line.split(':')
        if len(parts) == 2:
            status_dict[parts[0].strip()] = parts[1].strip()
        elif " active" in line:
            parts = line.split(' ')
            status_dict['active'] = parts[0]
            status_dict['filesystem'] = get_filesystem(parts[0])

    # No info has been retrieved: save minimum
    if status_dict['device'] == '':
        status_dict['device'] = partitionPath
    if status_dict['active'] == '' and is_encrypted(partitionPath):
        mapped_name = os.path.basename(partitionPath)
        status_dict['active'] = "/dev/mapper/{}".format(mapped_name)

    if status_dict['type'] != '':
        print(("Encryption: mapped drive status = {}".format(status_dict)))
    return status_dict
示例#55
0
 def __init__(self, path, mount_as, format_as, type):
     self.glade = RESOURCE_DIR + 'interface.glade'
     self.dTree = gtk.glade.XML(self.glade, 'dialog')
     self.window = self.dTree.get_widget("dialog")
     self.window.set_title(_("Edit partition"))
     self.dTree.get_widget("label_partition").set_markup("<b>%s</b>" % _("Device:"))
     self.dTree.get_widget("label_partition_value").set_label(path)
     self.dTree.get_widget("label_use_as").set_markup(_("Format as:"))
     self.dTree.get_widget("label_mount_point").set_markup(_("Mount point:"))
     # Build supported filesystems list
     filesystems = sorted(['', 'swap'] +
                          [fs[11:] for fs in getoutput('echo /sbin/mkfs.*').split()],
                          key=lambda x: 0 if x in ('', 'ext4') else 1 if x == 'swap' else 2)
     model = gtk.ListStore(str)
     for i in filesystems: model.append([i])
     self.dTree.get_widget("combobox_use_as").set_model(model)
     self.dTree.get_widget("combobox_use_as").set_active(filesystems.index(format_as))
     # Build list of pre-provided mountpoints
     model = gtk.ListStore(str)
     for i in " / /home /boot /boot/efi /srv /tmp swap".split(' '):
         model.append([i])
     self.dTree.get_widget("comboboxentry_mount_point").set_model(model)
     self.dTree.get_widget("comboboxentry_mount_point").child.set_text(mount_as)
示例#56
0
def get_filesystem(partitionPath):
    return getoutput("blkid -o value -s TYPE {}".format(partitionPath))
示例#57
0
 def get_iso_size(self, iso):
     iso_size = getoutput("du -Lk \"%s\" | awk '{print $1}'" % iso)
     if iso_size:
         return int(iso_size[0])
     return 0
示例#58
0
 def get_device_mount(self, device):
     shell_exec("udisks --mount {}1".format(device))
     mount = getoutput("grep %s1 /etc/mtab | awk '{print $2}' | sed 's/\\040/ /g'" % device)
     if mount:
         return mount[0]
     return ''
示例#59
0
 def device_has_partition(self, device):
     part_count = getoutput("udisks --show-info {} | grep count | grep -v block".format(device))
     if part_count:
         if "1" in part_count[0]:
             return True
     return False
示例#60
0
    def __init__(self):

        # Load window and widgets
        self.scriptName = basename(__file__)
        self.scriptDir = abspath(dirname(__file__))
        self.mediaDir = join(self.scriptDir, '../../share/usb-creator')
        self.builder = Gtk.Builder()
        self.builder.add_from_file(join(self.mediaDir, 'usb-creator.glade'))

        # Main window objects
        go = self.builder.get_object
        self.window = go("usb-creator")
        self.lblDevice = go("lblDevice")
        self.lblIso = go("lblIso")
        self.lblAvailable = go("lblAvailable")
        self.lblRequired = go("lblRequired")
        self.cmbDevice = go("cmbDevice")
        self.cmbDeviceHandler = ComboBoxHandler(self.cmbDevice)
        self.txtIso = go("txtIso")
        self.btnRefresh = go("btnRefresh")
        self.btnUnmount = go("btnUnmount")
        self.btnBrowseIso = go("btnBrowseIso")
        self.btnClear = go("btnClear")
        self.chkFormatDevice = go("chkFormatDevice")
        self.chkRepairDevice = go("chkRepairDevice")
        self.btnExecute = go("btnExecute")
        self.lblUsb = go("lblUsb")
        self.tvUsbIsos = go("tvUsbIsos")
        self.btnDelete = go("btnDelete")
        self.pbUsbCreator = go("pbUsbCreator")
        self.statusbar = go("statusbar")

        # Translations
        self.window.set_title(_("USB Creator"))
        self.lblDevice.set_label(_("Device"))
        self.lblUsb.set_label(_("USB"))
        self.available_text = _("Available")
        self.required_text = _("Required")
        self.chkFormatDevice.set_label(_("Format device"))
        self.chkFormatDevice.set_tooltip_text(_("Warning: all data will be lost"))
        self.chkRepairDevice.set_label(_("Repair device"))
        self.chkRepairDevice.set_tooltip_text(_("Tries to repair an unbootable USB"))
        self.btnExecute.set_label("_{}".format(_("Execute")))
        self.lblIso.set_label(_("ISO"))
        self.btnDelete.set_label("_{}".format(_("Delete")))
        self.btnRefresh.set_tooltip_text(_("Refresh device list"))
        self.btnUnmount.set_tooltip_text(_("Unmount device"))
        self.btnBrowseIso.set_tooltip_text(_("Browse for ISO file"))
        self.btnClear.set_tooltip_text(_("Clear the ISO field"))

        # Log lines to show: check string, percent done (0=pulse, appends last word in log line), show line (translatable)
        self.log_lines = []
        self.log_lines.append(["partitioning usb", 5, _("Partitioning USB...")])
        self.log_lines.append(["searching for bad blocks", 0, _("Searching for bad block")])
        self.log_lines.append(["installing", 15, _("Installing Grub...")])
        self.log_lines.append(["rsync", 25, _("Start copying ISO...")])
        self.log_lines.append(["left to copy", 0, _("kB left to copy:")])
        self.log_lines.append(["check hash", 85, _("Check hash of ISO...")])

        # Initiate variables
        self.devices = []
        self.device = {}
        self.device['path'] = ''
        self.device['size'] = 0
        self.device['has_partition'] = False
        self.device['mount'] = ''
        self.device['available'] = 0
        self.device["new_iso"] = ''
        self.device["new_iso_required"] = 0
        self.logos = self.get_logos()
        self.queue = Queue(-1)
        self.threads = {}
        self.htmlDir = join(self.mediaDir, "html")
        self.helpFile = join(self.get_language_dir(), "help.html")
        log = getoutput("cat /usr/bin/usb-creator | grep 'LOG=' | cut -d'=' -f 2")
        self.log_file = log[0]
        self.log = Logger(self.log_file, addLogTime=False, maxSizeKB=5120)
        self.tvUsbIsosHandler = TreeViewHandler(self.tvUsbIsos)

        self.lblAvailable.set_label('')
        self.lblRequired.set_label('')

        # Connect builder signals and show window
        self.builder.connect_signals(self)
        self.window.show_all()

        # Get attached devices
        self.on_btnRefresh_clicked()

        # Init log
        init_log = ">>> Start USB Creator: {} <<<".format(datetime.now())
        self.log.write(init_log)

        # Version information
        self.version_text = _("Version")
        self.pck_version = getPackageVersion('usb-creator')
        self.set_statusbar_message("{}: {}".format(self.version_text, self.pck_version))