Commits

Moises Henriquez committed c6b3fe8 Merge

Merged conflicts in bot.py

Comments (0)

Files changed (4)

 import time
 import os
 import sqlite3
-import urllib
+import urllib2
 
 
 __author__ = 'M0E-lnx'
             if desc.startswith('/'):
                 shutil.copy2(desc, 'slack-desc')
             else:
-                urllib.urlretrieve(desc, 'slack-desc')
+                self.parent._play_output('Downloading description from %s \n'% desc)
+                u = urllib2.urlopen(desc)
+                f = open('slack-desc', 'w')
+                f.write(u.read())
+                f.close()
+                u.close()
             job = srcob.buildSlackBuild()
             job.observer.add_callback(self.parent._play_output)
             job.run()
             self._refresh_views()
             if result == "Success" and toinstall == "1":
                 # install the package
+<<<<<<< local
                 print 'we should be installing this package here'
+=======
+                self.parent._play_output(
+                        '\nInstalling package \n')
+                try:
+                    proc = srcob.install_pkg()
+                    proc.observer.add_callback(self.parent._play_output)
+                    proc.run()
+                    while proc._popen_running:
+                        time.sleep(1)
+                    retval = proc.popen.returncode
+                except:
+                    print 'Error while installing package'
+                    pass
+>>>>>>> other
 
 class Tab(gtk.VBox):
     ''' Generic tab for use in the tabstrip '''
         self.mon_thread.start()
         self.jobDispatcher = Dispatcher(parent = self._parent)
 
+<<<<<<< local
+=======
+
+>>>>>>> other
     def __bot_monitor(self):
         while self._parent._bot_run:
             gtk.gdk.threads_enter()
             self.jobDispatcher.start()
         return
 
-
 class TabQueue(Tab):
     """ Job queue tab. Used to manage build jobs."""
     def __init__(self, *args, **kwargs):
         self.set_icon_from_file('data/vpackager.png')
         self.set_size_request(950, 500)
         self.body = gtk.VBox()
+        # make sure the db is ok
+        self._check_db_sanity()
         self.outputplayer = None
         self.historyman = None
         self.queueman = None
         time.sleep(0.25)
         return gtk.main_quit()
 
+    def _check_db_sanity(self):
+        dbutils.create_vpackager_db()
+
 if __name__ == '__main__':
     gtk.gdk.threads_init()
     w = App()

vpackager/buildutils.py

 class MissingSourcesHomeError(Exception):
     pass
 
+class PackageNotFoundError(Exception):
+    pass
 
 def get_vltag():
     ''' Return a string representing the distro tag for the installed system'''
         self.__dump = []
         self.builder = self.FindSourceType()
 
+    def install_pkg(self):
+        fullpath = glob.glob(os.path.join(
+            self.__myhome, self.ver,'%s-%s-*.t?z'% (
+                self.app, self.ger)))[0]
+        if not fullpath:
+            raise PackageNotFoundError
+
+        return bottools.Execute('installpkg %s'% fullpath)
+
+
     def makeSlackBuild(self, buildno='1', packager='vpackager'):
         """ Generate a slackbuild using sbbuilder to build this source"""
         ### Use sbbuilder to create a slackbuild for his package.
 
         return None
 
+    def install_pkg(self):
+        pkgpath = glob.glob(
+                os.path.join(
+                    self.__myhome, self.ver,'%s-%s-*.t?z'% (
+                        self.app, self.ver)))[0]
+        if not pkgpath:
+            raise PackageNotFoundError
+
+        return bottools.Execute('installpkg %s'% pkgpath)
+
+
     def buildSlackBuild(self):
         """ Execute the build script generated by the class"""
         # Make sure we are at the correct location

vpackager/dbutils.py

 
 dbpath = '/tmp/vpackager.db'
 
+def __verify_tables():
+    ''' Verify that the essential tables for the vpackager environment
+    exist'''
+    db = sqlite3.connect(dbpath)
+    c = db.cursor()
+    c.execute('select name from sqlite_master where type="table"')
+    res = c.fetchall()
+    c.close()
+    db.close()
+    if len(res) > 0:
+        return False
+    return True
+
+def create_vpackager_db():
+    ''' Create the essential tables for the vpackager environment'''
+    if __verify_tables() is True:
+        __create_queue_table()
+        __create_history_table()
+        return
+    return
+
 def __create_queue_table():
     """ Create the job queue table. NEVER to be called from the program
     itself!"""
     install text)""")
     db.commit()
     c.close()
+    db.close()
 
     return
 
 
     db.commit()
     c.close()
+    db.close()
 
     return
 
 
     db.commit()
     c.close()
+    db.close()
 
 def RemoveJob(_id):
     """ Delete a job from the job queue"""
     c.execute('delete from queue where id=?', t)
     db.commit()
     c.close()
+    db.close()
 
 def LogJobStart(jobid):
     """ Move job from queue to history and add the timestamp to the buidl
     c.execute('delete from queue where id=?',t)
     c.close()
     db.commit()
+    db.close()
 
 def LogJobEnd(jobid, stdoutpath, result):
     """ Update the job history to log the end time and end result of the
     c.execute('''update history set result=? where id=?''',t)
     c.close()
     db.commit()
+    db.close()
 
 def GetNextJob():
     """ Find the next job in line to be built"""
     except StopIteration:
         ret = None
     c.close()
+    db.close()
     return ret
 
 def GetQueue():
     c = db.cursor()
     ret = c.execute('select * from queue').fetchall()
     c.close()
+    db.close()
     return ret
 
 def GetHistory():
     c = db.cursor()
     ret = c.execute('select * from history').fetchall()
     c.close()
+    db.close()
     return ret
 
 

vpackager/vpackager.py

         l.pack_start(lb, False, False, 4)
         l.pack_start(lbl, False, False, 12)
 
-#        appline = gtk.HBox()
-#        applbl = gtk.Label(_('Application'))
-#        self.roAppNameBox = gtk.Entry()
-#        appline.pack_start(applbl, False, False, 2)
-#        appline.pack_start(self.roAppNameBox, False, False, 2)
-
-#        appverlbl = gtk.Label(_('Version'))
-#        self.roAppVerBox = gtk.Entry()
-#        appline.pack_start(appverlbl, False, False, 2)
-#        appline.pack_start(self.roAppVerBox, False, False, 2)
-
-#        l.pack_start(appline, False, False, 2)
-
-
         lbr = gtk.Label()
         lbr.set_use_markup(True)
         lbr.set_markup(
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.