Moises Henriquez avatar Moises Henriquez committed f8073d9

Cleaning up unnecessary code

Comments (0)

Files changed (3)

         the bonus disc over ANYTHING else
         """
         if self.cache.is_app_installed(pkgname):
-            pass
-            # Remove the package
-
+            # If package is installed, remove it first
+            r = self.remove_package(package = pkgname)
         # Now install the package again.
         return self.install_package(pkgname)
 
-
 class PackageCache(object):
     """ Cache of currently installed packages """
     def __init__(self, cachedir='/var/log/packages'):
                 configfile = slaptconfig.name)
 
     def change_cancel_button(self):
+        """ Change the cancel button to read close, 
+        and also change its icon.
+        This is to be triggered when the install process
+        is finished successful or not"""
         wid = self.btCancel
         wid.set_use_stock(False)
         img = gtk.Image()
         return
 
     def run(self):
+        """ Append our start_process() method to the dialog's
+        .run method"""
         self.start_process()
         return gtk.Dialog.run(self)
 
     def start_process(self, widget = None):
+        """ Start installation process"""
         self.stopbar = False
         self.monitor.start()
         ins = threading.Thread(target = self.installation, args=(self.pkglist,))
 
 
     def installation(self, pkgs):
+        """ Installation method. This method is not to be called
+        directly, but rather inside a thread"""
         # First, update the cache:
         self._icurrent = -1.0
         gtk.gdk.threads_enter()
             # output.
             time.sleep(3)
             self._icurrent += 1
-        
+
         # When done, stop the monitor thread
         self.stopbar = True
         # Change the cancel button to 'Close'
 
 
     def exit(self, widget=None):
+        """ Do a clean exit when closing the dialog
+        and returning to the main gui"""
         self.stopbar = True
         time.sleep(0.25)
         self.destroy()
-#        gtk.main_quit()
 
     def move(self):
+        """ Move the progressbar according to the progress made"""
         while not self.stopbar:
             while self._icurrent == -1.0:
                 gtk.gdk.threads_enter()
                 self.progress.pulse()
-#                time.sleep(0.25)
                 gtk.gdk.threads_leave()
                 time.sleep(0.25)
             val = float(float(self._icurrent) / float(len(self.pkglist)))
             valstr = str(int(val) * 100)
-#            print float(float(self._icurrent) / float(len(self.pkglist)))
-            #            print self._icurrent / len(self.pkglist)
             gtk.gdk.threads_enter()
             self.progress.set_fraction(val)
             self.progress.set_text('%i'% (val * 100) + ' %')
-            #   str(int(self._icurrent / len(self.pkglist)), '\%'))
             gtk.gdk.threads_leave()
             time.sleep(0.1)
         gtk.gdk.threads_enter()
         self.progress.set_fraction(1.0)
         self.progress.set_text('100 %')
         gtk.gdk.threads_leave()
-               
 
-    def process_package(self, package):
-        #        gtk.gdk.threads_enter()
-        self.status.set_property('label', 'Installing %s'%package)
-#        gtk.gdk.threads_leave()
-#        time.sleep(5)
-        return 0
-
     def refresh_view(self):
         sel = self.get_selection().get_selected_rows()[0][0][0]
         self.show_category(sel)
-#        print sel
+
     def click_event(self, column):
         row = column.get_selection().get_selected_rows()[1][0][0]
         sel = self.model[row][0]
                 if 'deps' not in app.location:
                     _overlay = cache.is_app_installed(app.name)
                     _sdesc = app.summary
-#                    _sdesc = repository.ShortDescribe(app)
-                    self.view.list_app(app_name = app.name,
+                   self.view.list_app(app_name = app.name,
                             app_short_description = _sdesc,
                             installed_indicator = _overlay)
         elif category == _('Audio'):
             for app in self.repo:
                 _overlay = cache.is_app_installed(app.name)
                 _sdesc = app.summary
-#                _sdesc = repository.ShortDescribe(app)
                 if 'Audio' in app.location:
                     self.view.list_app(
                             app_name = app.name,
             for app in self.repo:
                 _overlay = cache.is_app_installed(app.name)
                 _sdesc = app.summary
-#                _sdesc = repository.ShortDescribe(app)
-                if 'Video' in app.location:
+               if 'Video' in app.location:
                     self.view.list_app(
                             app_name = app.name,
                             app_short_description = _sdesc,
             for app in self.repo:
                 _overlay = cache.is_app_installed(app.name)
                 _sdesc = app.summary
-#                _sdesc = repository.ShortDescribe(app)
-                if app.location not in (
+               if app.location not in (
                         'Audio',
                         'Video',
                         'deps',
                 installed_indicator])
         return
 
-
-
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.