Ejemplo n.º 1
0
    def __init__(self, controller=None, temp_path="", packages_path="", filename=""):
        """
            Constructor
        """
        self.controller = controller
        self.glade = gui.get_glade(constants.RESTORE_GUI, WINDOW_NAME)

        self.temp_path = temp_path
        self.cd_path = ""
        self.root_shell = None
        if self.temp_path == "" or self.temp_path == None:
            self.temp_path = constants.TEMP_FOLDER
        else:
            self.temp_path = temp_path

        self.packages_path = packages_path
        self.isoFileName = filename
        self.restoretype = constants.RESTORE_TYPE.RESTORE_FROM_NONE

        self.window = gui.get_widget(self.glade, WINDOW_NAME)
        if self.controller:
            self.window.set_decorated(False)
            self.content = gui.set_parent_widget_from_glade(self.glade, WINDOW_NAME, self.controller.restoreContainer)
            self.window.destroy()
            gui.setCursorToBusy(self.controller.get_main_window(), True)
        else:
            # Window Widgets
            self.window.show()
            gui.setCursorToBusy(self.window, True)

        self.ListContainer = gui.get_widget(self.glade, "ListContainer")

        self.lblPkgDesc = gui.get_widget(self.glade, "lblPkgDesc")
        self.pkgImg = gui.get_widget(self.glade, "pkgImg")

        self.btnRestorePackages = gui.get_widget(self.glade, "restorePackages")
        self.btnLoadFrom = gui.get_widget(self.glade, "btnLoadFrom")
        self.btnRestorePackages.set_sensitive(False)

        self.packageList = PackageList.PackageView(self)
        self.ListContainer.add(self.packageList)

        self.ListContainer.show_all()
        gui.processEvents()

        if self.controller:
            self.controller.show_status_message(constants.MESSAGE_0001)

        # self.packageList.load_package_folder(self.packages_path)

        self.bind_signals()

        if self.isoFileName != "":
            self.restoreFromIso(self.isoFileName, self.temp_path)
Ejemplo n.º 2
0
    def copy_files(self):
        gui.setCursorToBusy(self.get_parent_widget(), True)
        self.controller.get_main_window().set_sensitive(False)

        progress = self.get_parent().progressbar
        progress.show()

        self.controller.show_status_message("preparing to copy files")
        script_file = os.path.join(constants.TEMP_FOLDER, "aoc.sc")
        ifile = open(script_file, "w")
        indx = 1
        self.file_count = 1
        f_len = len(self.packageList.store)
        for nItens in self.packageList.store:
            if nItens[0]:
                pkg = nItens[PackageList.COL_PACKAGE]
                source = pkg.deb_full_filename
                destination = utils.join_path(constants.LOCAL_APT_FOLDER, pkg.deb_filename)
                if not utils.fileExist(destination):
                    ifile.write("%s|%s\n" % (source, destination))
                    self.file_count += 1
            percent = float(indx) / f_len
            progress.set_fraction(percent)
            progress.set_text(str(int(percent * 100)) + "%")
            gui.processEvents()
            indx += 1
        ifile.close()

        self.controller.show_status_message("Wait while your system is being restored.")
        progress.hide()
        gui.processEvents()

        parentwd = self.controller.get_main_window()
        winid = parentwd.window.xid

        file_exec = constants.COPY_SCRIPT
        command = "gksu --desktop " + constants.DESKTOP_FILE + " 'python %s %s %s'" % (file_exec, winid, script_file)
        os.system(command)

        gui.processEvents()
        self.packageList.update_parent_count()
        self.controller.get_main_window().set_sensitive(True)
        gui.setCursorToBusy(self.get_parent_widget())
Ejemplo n.º 3
0
    def toggled_item(self, data, row):
        """Set a function to be called when the value of a row is toggled.
        The  function will be called with two arguments, the clicked item
        in the row and a string for which row was clicked."""
        gui.setCursorToBusy(self, True)
        iter = self.store.get_iter((int(row),))

        pkg = self.store.get_value(iter, COL_PACKAGE)

        if not pkg.selected:
            self.store.check(pkg)
        else:
            self.store.uncheck(pkg)

        try:
            self.controller.btnBurn.set_sensitive( self.store.get_count()['selected'] > 0)
        except:
            self.controller.btnRestorePackages.set_sensitive( self.store.get_count()['selected'] > 0)

        gui.setCursorToNormal(self)
        return
Ejemplo n.º 4
0
 def check_uncheck_all(self, check_type = 0):
     gui.setCursorToBusy(self, True)
     tmp = self.autoselect_dependents
     self.autoselect_dependents = False
     for n in range(len(self.store)):
         pkg = self.store.get_value(self.store.get_iter((n,)),COL_PACKAGE)
         if check_type == 0 :
             self.store.check(pkg)
         elif check_type == 1:
             self.store.uncheck(pkg)
         elif check_type == 2:
             if not pkg.selected:
                 self.store.check(pkg)
             else:
                 self.store.uncheck(pkg)
     self.autoselect_dependents = tmp
     self.update_parent_count()
     gui.setCursorToNormal(self)
     try:
         self.controller.btnBurn.set_sensitive( self.store.get_count()['selected'] > 0)
     except:
         self.controller.btnRestorePackages.set_sensitive( self.store.get_count()['selected'] > 0)
Ejemplo n.º 5
0
    def __init__(self, controller = None, missing_list = []):
        """
            Constructor.
        """

        self.controller = controller
        self.glade = gui.get_glade(constants.CREATE_GUI, WINDOW_NAME)
        gui.setCursorToBusy(self.controller.get_parent_widget(),True)
        #main widget
        self.window = gui.get_widget(self.glade, WINDOW_NAME)
        self.window.set_icon_name(constants.APP_ICON_NAME)
        self.window.set_transient_for(self.controller.get_main_window())
        self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        #get work widgets
        self.tvwNotInstalled = gui.get_widget(self.glade, 'tvwNotInstalled')
        self.store = gtk.ListStore(gobject.TYPE_BOOLEAN, str)

        self.__create_ui()
        if len(missing_list)>0:
            for n in missing_list:
                self.store.append([False, n])
        gui.setCursorToNormal(self.controller.get_parent_widget())
Ejemplo n.º 6
0
    def load_package_folder(self, path_to_scan, custom = False, recursive = False):
        """
            Loads all packages files from a given path in to the list.
        """
        gui.setCursorToBusy(self.controller.get_parent_widget(),True)
        self.controller.get_main_window().set_sensitive(False)
        processEvents()
        self.store._load_cache()

        list_bad = []
        not_added = []

        progress = self.controller.get_parent().progressbar
        progress.show()

        processEvents()

        # now get all packages in cache
        packages_files = utils.get_deb_from_folder(path_to_scan, recursive)
        f_len = len(packages_files)
        for index, pkg in enumerate(packages_files):
            #add the package to the list
            index+=1
            percent = (float(index) / f_len)
            iter = self.store.add_item(pkg,path_to_scan, custom)
            if iter == None:
                not_added.append(os.path.basename(pkg))
            else:
                if self.store.get_value(iter, COL_PACKAGE).bad:
                    list_bad.append(self.store.get_value(iter, COL_PACKAGE).deb_filename)
            progress.set_fraction(percent)
            progress.set_text(str(int(percent * 100)) + '%' )
            #process pending events / update the window
            if index % 2 == 0:
                processEvents()

        processEvents()
        
        progress.set_fraction(0)
        progress.hide()
        progress.set_text('0%')
        progress.set_fraction(0)
        
        self.controller.controller.show_status_message('Checking versions...')
        processEvents()
        self.store.uncheck_minor_version()
        #self.count_packages()
        self.not_in_cache = []
        self.controller.controller.show_status_message('Checking uncached packages...')
        processEvents()
        for n in self.store.installed:
            if not self.store.get_package(n,self.store.installed[n]):
                self.not_in_cache.append(n)
        
        #print len(self.not_in_cache)
        
        #update the parent count labels
        self.update_parent_count()
        self.controller.get_main_window().set_sensitive(True)
        self.set_model(self.store)
        self.get_selection().select_path((0,0))
        self.grab_focus()
        gui.setCursorToNormal(self.controller.get_parent_widget())

        #show packages not inserted due to already exist in list
        if len(not_added)>0:
            self.__load_dialog_skip(not_added)

        if len(list_bad)>0:
            self.__load_dialog_skip(list_bad)
Ejemplo n.º 7
0
    def add_from_file_list(self, packages_names):
        """
            Loads all packages files from a given path in to the list.
        """
        gui.setCursorToBusy(self.controller.get_parent_widget(),True)
        self.controller.get_main_window().set_sensitive(False)
        #self.clear()

        list_bad = []
        not_added = []

        f_len = len(packages_names)
        pbar_shown = False
        #only show progressbar if user selects more than 5 packages
        if len(packages_names) > 5:

            if self.controller.get_parent():
                progress = self.controller.get_parent().progressbar
                progress.show()
                pbar_shown = True
            else:
                pbar_shown = False
            processEvents()

        indx = 1
        # now get all packages in cache
        for index in range(f_len):
            percent = (float(index) / f_len)
            filename = os.path.basename(packages_names[index])
            pathname = os.path.dirname(packages_names[index])
            iter = self.store.add_item(filename,pathname, True)
            if iter == None:
                not_added.append(filename)
            else:
                #self.get_selection().select_iter(iter)
                if self.store.get_value(iter, COL_PACKAGE).bad:
                    list_bad.append(self.store.get_value(iter, COL_PACKAGE).deb_filename) 

            #process pending events / update the window
            if pbar_shown:
                progress.set_fraction(percent)
                progress.set_text(str(int(percent * 100)) + '%' )
                processEvents()

        if pbar_shown:
            progress.set_fraction(0)
            progress.hide()
            progress.set_text('0%')
            progress.set_fraction(0)

        #update the parent count labels
        #update the parent count labels
        self.update_parent_count()
        self.controller.get_main_window().set_sensitive(True)
        self.set_model(self.store)
        self.get_selection().select_path((0,0))
        self.grab_focus()
        gui.setCursorToNormal(self.controller.get_parent_widget())

        #show packages not inserted due to already exist in list
        if len(not_added)>0:
            self.__load_dialog_skip(not_added, constants.MESSAGE_0017)

        if len(list_bad)>0:
            self.__load_dialog_skip(list_bad, constants.MESSAGE_0016)
Ejemplo n.º 8
0
    def __init__(self, controller = None, temp_path = '', packages_path = '', packages_file_list='', non_interactive = False):
        """
            Constructor
        """
        self.freespaceneeded = 0
        self.controller = controller
        self.glade = gui.get_glade(constants.CREATE_GUI, WINDOW_NAME)
        
        self.non_interactive = non_interactive
        if temp_path == '':
            self.temp_path = constants.TEMP_FOLDER
        else:
            self.temp_path = temp_path
        self.packages_path = packages_path
        
        self.window = gui.get_widget(self.glade, WINDOW_NAME)
        #self.window.set_icon(get_icon('aptoncd'))
        #if is inside a container
        if self.controller:
            self.window.set_decorated(False)
            self.content = gui.set_parent_widget_from_glade(self.glade, WINDOW_NAME, self.controller.createContainer)
            self.window.destroy()
            gui.setCursorToBusy(self.get_main_window(), True)
        else:
            #Window Widgets
            if packages_file_list =='' or self.non_interactive == False:
                self.window.show()
            gui.setCursorToBusy(self.window, True)
        
        self.tipBox = gui.get_widget(self.glade, 'tipbox')
        self.btnCloseTipBox = gui.get_widget(self.glade, 'btnCloseTipBox')
        self.btnMoreMissing = gui.get_widget(self.glade, 'btnMoreMissing')
        
        self.ListContainer = gui.get_widget(self.glade,'ListContainer')       
        self.lblPkgDesc = gui.get_widget(self.glade, 'lblPkgDesc')
        self.pkgImg = gui.get_widget(self.glade, 'pkgImg')

        self.btnAdd = gui.get_widget(self.glade, 'btnAdd')
        self.btnBurn = gui.get_widget(self.glade, 'createBurn')

        self.packageList = PackageList.PackageView(self)
        self.ListContainer.add(self.packageList)
        self.ListContainer.show_all()
        self.bind_signals()
        #gui.connect(self.tgBtnCreate, 'toggled',self.on_BtnCreate_toggle)
        self.values = {
                        'media_type': 'CD',
                        'media_size': constants.CD,
                        'destination': utils.get_home_folder(),
                        'isoname': '',
                        'createmeta': False
                        }
        if packages_file_list =='':
            #self.packageList.can_select_old = self.ckbtnOldVersions.get_active()
            #self.packageList.auto_select_packages = self.ckbtnAutoSelectDepends.get_active()
        
            gui.processEvents()
        
            if self.controller:
                self.controller.show_status_message(constants.MESSAGE_0001)
        else:
            self.process_list(packages_file_list)