Example #1
0
 def rm_rpms_cb(self, b):
     cmd = '/bin/rm -f'
     dlg = wait(self.ccw)
     dlg.show_all()
     p = self.get_ls()
     if not p:
         dlg.hide()
         info(_("There are no repeated RPM files!"), self.ccw)
         return
     s = self.get_size(p)[1]
     dlg.hide()
     if not sure(
             _("Delete %d RPM Files, will save %s!\nAre you sure?" %
               (len(p), s)), self.ccw):
         return
     cmd = '%s %s' % (cmd, ' '.join(p))
     dlg.show_all()
     r = self.ccw.mechanism('run', 'system', cmd)
     dlg.hide()
     if r == 'NotAuth': return
     if r:
         info(
             _("%d RPM files has been deleted, TO save %s!") % (len(p), s),
             self.ccw)
     else:
         info(
             _("We can't complete this action at this time, due unknown error, you can try again!"
               ), self.ccw)
Example #2
0
 def apply_cb(self, w):
     if not sure(_('Are you sure you want to apply changes?'), self.ccw): return
     dlg=wait(self.ccw)
     self.convert_img(self.bg_fn, self.bg_nm)
     self.conf[0]['GRUB_TIMEOUT'] = int(self.Time_Out.get_value())
     self.conf[0]['GRUB_DISTRIBUTOR'] = self.conf[0]['GRUB_DISTRIBUTOR']
     self.conf[0]['GRUB_DISABLE_RECOVERY'] = str(not self.recovery_c.get_active()).lower()
     self.conf[0]['GRUB_DEFAULT'] = self.conf[0]['GRUB_DEFAULT']
     self.conf[0]['GRUB_CMDLINE_LINUX'] = '"' + self.Kernel_Opt.get_text() + '"'
     self.conf[0]['GRUB_GFXMODE'] = self.gfxmode
     self.conf[0]['GRUB_GFXPAYLOAD_LINUX'] = "keep"
     self.conf[0]['GRUB_BACKGROUND'] = '/boot/grub2/oj.grub2.png'
     self.conf[1]['BACKGROUND'] = self.bg_fn
     self.conf[1]['FONT_FILE'] = self.font_fn
     self.conf[1]['FONT_NAME'] = self.font_nm
     font=self.font_fn
     if not self.theme_c.get_active(): font=''
     cfg = '\n'.join(map(lambda k: "%s=%s" % (k,str(self.conf[0][k])), self.conf[0].keys()))
     cfg +='\n'
     usr_cfg = '\n'.join(map(lambda k: "%s=%s" % (k,str(self.conf[1][k])), self.conf[1].keys()))
     try: open(self.user_conf, 'w+').write(usr_cfg)
     except IOError: pass
     #print usr_cfg, '\n\n',cfg,font, self.bg_fn,self.bg_nm
     r = self.ccw.mechanism('grub2', 'apply_cfg', self.conf_fn, cfg, font, self.bg_nm)
     dlg.destroy()
     if r == 'NotAuth': return 
     if r.startswith("Error"): return error('%s: %s' %(_('Error!'),r),self.ccw)
     info(_('Done!'),self.ccw)
Example #3
0
 def apply_cb(self, w):
     if not sure(_('Are you sure you want to detect and add other operating systems?'), self.ccw): return
     dlg=wait(self.ccw)
     dlg.show_all()
     r=self.ccw.mechanism('grub2','os_prober_cb')
     dlg.hide()
     if r == 'NotAuth': return 
     if r.startswith("Error"): return info('%s: %s'%(_('Error'),r[6:]))
     info(_('Operating systems found:\n%s') % r,self.ccw)
Example #4
0
    def execute(self, *args):
        f = "/usr/bin/livecd-iso-to-disk"
        if not os.path.exists(f): f = "/mnt/live/LiveOS/livecd-iso-to-disk"
        if not os.path.exists(f):
            error(_("The package 'livecd-tools' is not installed."), self.ccw)
            if sure(_("Would you like to install 'livecd-tools'?"), self.ccw):
                self.ccw.install_packages(['livecd-tools'])
                info(_("Please try again."), self.ccw)
            return
        ov = self.overlay_size.get_value()
        opt = "--noverify"
        dst, s, l = self.dst_parse(self.target_dev_ls.get_active_text())
        if not dst:
            error(_('Please choose valid target device.'), self.ccw)
            return

        if self.format.get_active():
            opt += " --format"
            if not sure(
                    _("Are you sure you want to format target device (labeled %s)?"
                      ) % l, self.ccw):
                return
        if self.reset_mbr.get_active(): opt += " --reset-mbr"
        if ov > 0: opt += " --overlay-size-mb %i" % ov

        if self.src_iso_file.get_active():
            src = self.iso_file_b.get_filename()
            if not src or not os.path.exists(src) or not src.lower().endswith(
                    '.iso'):
                error(_('Please choose a valid iso file'), self.ccw)
                return
        else:
            src = self.iso_dev_ls.get_active_text()
            if not src:
                error(_('Please choose a source device.'), self.ccw)
                return
        os.system("umount '%s'" % dst)
        cmd = '''%s %s "%s" "%s"''' % (f, opt, src, dst)
        print cmd
        dlg = wait(self.ccw)
        p = self.__dev_re.findall(dst)[0]
        dst0 = self.__dev_re.sub('', dst)
        self.ccw.mechanism('run', 'system',
                           '''echo ",,,*" | sfdisk %s -N%s''' % (dst0, p))
        while (Gtk.main_iteration_do()):
            pass
        r = self.ccw.mechanism('run', 'system', cmd, on_fail='0')
        if r != '0' and r != 'NotAuth':
            error(
                _("An error occurred while creating the live system.\nYou may run the following command in terminal to see the error:\n%s"
                  ) % cmd, self.ccw)
        while (Gtk.main_iteration_do()):
            pass
        dlg.hide()
        if dlg: dlg.destroy()
Example #5
0
 def apply_cb(self, w):
     if not sure(
             _('Are you sure you want to detect and add other operating systems?'
               ), self.ccw):
         return
     dlg = wait(self.ccw)
     dlg.show_all()
     r = self.ccw.mechanism('grub2', 'os_prober_cb')
     dlg.hide()
     if r == 'NotAuth': return
     if r.startswith("Error"): return info('%s: %s' % (_('Error'), r[6:]))
     info(_('Operating systems found:\n%s') % r, self.ccw)
Example #6
0
 def apply_cb(self, w):
     if not sure(
             _('Make sure all disks are mounted. Are you sure you want to detect and add other operating systems?'
               ), self.ccw):
         return
     dlg = wait()
     dlg.show_all()
     r = self.ccw.mechanism('grub', 'set_grub_items')
     dlg.hide()
     if r == 'NotAuth': return
     if not r: return info(_('No operating systems were found'))
     info(_('Operating systems found:\n%s') % r, self.ccw)
Example #7
0
 def cp_rpms_cb(self, b):
     tdir_dlg=sel_dir_dlg(self.ccw)
     if (tdir_dlg.run()==Gtk.ResponseType.ACCEPT):
         tdir = tdir_dlg.get_filename()
         tdir_dlg.hide()
     else:
         tdir_dlg.hide()
         return
     #tdir = '/media/DATA/project/yumarchive/sss'
     dlg=wait(self.ccw)
     dlg.show_all()
     c,r = self.cp(tdir)
     dlg.hide()
     info(_("%d RPM files has been copied\nTo:%s\n%d Repeated RPMS removed!") %(len(c), tdir, len(r)), self.ccw) 
Example #8
0
 def apply_cb(self, *b):
     if not os.path.isdir(self.tdir):
         return error(_("Select repository directory frist!"), self.ccw)
     dlg=wait(self.ccw)
     dlg.show_all()
     ret=False
     if self.gen_info_c.get_active():
         s=self.create_repo_cb(self.tdir)
         if s: dlg.hide(); return error(s, self.ccw)
         ret=True
     if self.write_config_c.get_active():
         if self.write_repo_cb(self.tdir) == '0': ret=True
         else: self.write_config_c.set_active(False)
     dlg.hide()
     if ret:info(_("Done!"), self.ccw)
     self.ch_rm_repo_b_sens()
Example #9
0
 def cp_rpms_cb(self, b):
     tdir_dlg = sel_dir_dlg(self.ccw)
     if (tdir_dlg.run() == Gtk.ResponseType.ACCEPT):
         tdir = tdir_dlg.get_filename()
         tdir_dlg.hide()
     else:
         tdir_dlg.hide()
         return
     #tdir = '/media/DATA/project/yumarchive/sss'
     dlg = wait(self.ccw)
     dlg.show_all()
     c, r = self.cp(tdir)
     dlg.hide()
     info(
         _("%d RPM files has been copied\nTo:%s\n%d Repeated RPMS removed!")
         % (len(c), tdir, len(r)), self.ccw)
Example #10
0
 def inst_opera(self, b):
     dlg=wait(self.ccw)
     dlg.show()
     opera_url=self.get_latest_opera_url()
     if not opera_url:
         dlg.hide()
         return error(_("Can not get latest opera url, make sure that you are online!"), self.ccw)
     print opera_url
     if which_exe('opera'):
         dlg.hide()
         return info(_('already installed'), self.ccw)
     r=self.ccw.mechanism('run','system','rpm -Uvh "%s"' % opera_url, on_fail='-1')
     dlg.hide()
     if r == 'NotAuth': return
     if dlg: dlg.destroy()
     info(_("You can wait about 5-15 minutes while downloading opera browser."), self.ccw)
Example #11
0
 def rm_rpms_cb(self, b):
     cmd = '/bin/rm -f'
     dlg=wait(self.ccw)
     dlg.show_all()
     p = self.get_ls()
     if not p:
         dlg.hide()
         info(_("There are no repeated RPM files!"), self.ccw)
         return
     s = self.get_size(p)[1]
     dlg.hide()
     if not sure(_("Delete %d RPM Files, will save %s!\nAre you sure?"%(len(p), s)), self.ccw): return
     cmd = '%s %s'%(cmd, ' '.join(p))
     dlg.show_all()
     r = self.ccw.mechanism('run', 'system', cmd)
     dlg.hide()
     if r == 'NotAuth': return
     if r: info(_("%d RPM files has been deleted, TO save %s!") %(len(p), s), self.ccw)
     else: info(_("We can't complete this action at this time, due unknown error, you can try again!"), self.ccw)
Example #12
0
    def execute(self, *args):
        f="/usr/bin/livecd-iso-to-disk"
        if not os.path.exists(f): f="/mnt/live/LiveOS/livecd-iso-to-disk"
        if not os.path.exists(f):
            error(_("The package 'livecd-tools' is not installed."), self.ccw)
            if sure(_("Would you like to install 'livecd-tools'?"), self.ccw):
                self.ccw.install_packages(['livecd-tools'])
                info(_("Please try again."), self.ccw)
            return
        ov=self.overlay_size.get_value()
        opt="--noverify"
        dst,s,l=self.dst_parse(self.target_dev_ls.get_active_text())
        if not dst: error(_('Please choose valid target device.'), self.ccw); return

        if self.format.get_active():
            opt+=" --format"
            if not sure(_("Are you sure you want to format target device (labeled %s)?") % l, self.ccw): return
        if self.reset_mbr.get_active(): opt+=" --reset-mbr"
        if ov>0: opt+=" --overlay-size-mb %i" % ov
        
        if self.src_iso_file.get_active():
            src=self.iso_file_b.get_filename()
            if not src or not os.path.exists(src) or not src.lower().endswith('.iso'):
                error(_('Please choose a valid iso file'), self.ccw); return
        else:
            src=self.iso_dev_ls.get_active_text()
            if not src:
                error(_('Please choose a source device.'), self.ccw); return
        os.system("umount '%s'" % dst)
        cmd='''%s %s "%s" "%s"''' % (f, opt,src,dst)
        print cmd
        dlg=wait(self.ccw)
        p=self.__dev_re.findall(dst)[0]
        dst0=self.__dev_re.sub('',dst)
        self.ccw.mechanism('run','system','''echo ",,,*" | sfdisk %s -N%s''' % (dst0, p))
        while(Gtk.main_iteration_do()): pass
        r=self.ccw.mechanism('run','system',cmd, on_fail='0')
        if r!='0' and r!='NotAuth': error(_("An error occurred while creating the live system.\nYou may run the following command in terminal to see the error:\n%s") % cmd, self.ccw)
        while(Gtk.main_iteration_do()): pass
        dlg.hide()
        if dlg: dlg.destroy()
Example #13
0
 def inst_opera(self, b):
     dlg = wait(self.ccw)
     dlg.show()
     opera_url = self.get_latest_opera_url()
     if not opera_url:
         dlg.hide()
         return error(
             _("Can not get latest opera url, make sure that you are online!"
               ), self.ccw)
     print opera_url
     if which_exe('opera'):
         dlg.hide()
         return info(_('already installed'), self.ccw)
     r = self.ccw.mechanism('run',
                            'system',
                            'rpm -Uvh "%s"' % opera_url,
                            on_fail='-1')
     dlg.hide()
     if r == 'NotAuth': return
     if dlg: dlg.destroy()
     info(
         _("You can wait about 5-15 minutes while downloading opera browser."
           ), self.ccw)