[svn] r3158 - in trunk/tools/pydar2: . pydar sql

packagers at lists.rpmforge.net packagers at lists.rpmforge.net
Sun Apr 24 15:34:18 CEST 2005


Author: dries
Date: 2005-04-24 15:34:16 +0200 (Sun, 24 Apr 2005)
New Revision: 3158

Modified:
   trunk/tools/pydar2/pydar-buildserver-master.py
   trunk/tools/pydar2/pydar-buildserver-slave.py
   trunk/tools/pydar2/pydar-remote.py
   trunk/tools/pydar2/pydar/command.py
   trunk/tools/pydar2/pydar/commandlist.py
   trunk/tools/pydar2/pydar/config.py
   trunk/tools/pydar2/pydar/postgresqlstorage.py
   trunk/tools/pydar2/pydar/storage.py
   trunk/tools/pydar2/pydar/target.py
   trunk/tools/pydar2/pydar/targetlist.py
   trunk/tools/pydar2/sql/master.sql
Log:
update

Modified: trunk/tools/pydar2/pydar/command.py
===================================================================
--- trunk/tools/pydar2/pydar/command.py	2005-04-23 14:19:18 UTC (rev 3157)
+++ trunk/tools/pydar2/pydar/command.py	2005-04-24 13:34:16 UTC (rev 3158)
@@ -17,19 +17,44 @@
 # Copyright 2004 Dries Verachtert
 
 class Command:
-    def __init__(self, commandName,userId,specName,toEmail,releaseTag,machRoot,priority):
-        self.commandName=commandName
-        self.userId=userId
-        self.specName = specName
-        self.toEmail = toEmail
-        self.releaseTag = releaseTag
-        self.machRoot = machRoot
-        self.priority = priority
-
+    def __init__(self, commandName,userId,specRepoId,specFileId,toEmail,distroArchTag,priority,targetId):
+        self.__commandName=commandName
+        self.__userId=userId
+        self.__specRepoId = specRepoId
+        self.__specFileId = specFileId
+        self.__toEmail = toEmail
+        self.__distroArchTag = distroArchTag
+        self.__priority = priority
+        self.__targetId = targetId
+        
     def setCommandId(self,id):
-        self.commandId = id
-
+        self.__commandId = id
+    
+    def getCommandName(self):
+        return self.__commandName
+        
+    def getUserId(self):
+        return self.__userId
+        
+    def getSpecRepoId(self):
+        return self.__specRepoId
+        
+    def getSpecFileId(self):
+        return self.__specFileId
+        
+    def getToEmail(self):
+        return self.__toEmail
+        
+    def getDistroArchTag(self):
+        return self.__distroArchTag
+    
+    def getPriority(self):
+        return self.__priority
+        
+    def getTargetId(self):
+        return self.__targetId
+    
     def toString(self):
-        return "commandName=" + self.commandName + ",userId=" + self.userId + ",specName=" + self.specName + ",toEmail=" + self.toEmail + ",releaseTag=" + self.releaseTag + ",machRoot=" + self.machRoot + ",commandId=" + self.commandId + ",priority=" + self.priority
+        return "commandName=" + self.__commandName + ",userId=" + self.__userId + ",specRepoId=" + self.__specRepoId + ",toEmail=" + self.__toEmail + ",specFileId=" + self.__specFileId + ",distroArchTag=" + self.__distroArchTag + ",commandId=" + self.__commandId + ",priority=" + self.__priority
 
 

Modified: trunk/tools/pydar2/pydar/commandlist.py
===================================================================
--- trunk/tools/pydar2/pydar/commandlist.py	2005-04-23 14:19:18 UTC (rev 3157)
+++ trunk/tools/pydar2/pydar/commandlist.py	2005-04-24 13:34:16 UTC (rev 3158)
@@ -18,6 +18,7 @@
 
 import config
 import storagefactory
+from command import Command
 from log4py import Logger
 
 class CommandList:
@@ -40,4 +41,5 @@
         if target == None:
             raise Exception("unknown target")
         self.__cat.debug("command looks ok")
-        
+        aCommand = Command(commandName,userId,specRepo.getId(),specRepoSpecFile.getId(),toEmail,distroArchTag,priority,target.getId())
+        self.__storage.createCommand(aCommand)

Modified: trunk/tools/pydar2/pydar/config.py
===================================================================
--- trunk/tools/pydar2/pydar/config.py	2005-04-23 14:19:18 UTC (rev 3157)
+++ trunk/tools/pydar2/pydar/config.py	2005-04-24 13:34:16 UTC (rev 3158)
@@ -27,6 +27,7 @@
 from filter import Filter
 from log4py import Logger
 from targetlist import TargetList
+from target import Target
 
 class Config:
     __myInstance = None
@@ -90,22 +91,19 @@
         self.userid = myParser.get('client','userid')
         self.__dbconnectstring = myParser.get('master','dbconnectstring')
         self.__cat.debug('dbconnectstring set to:' + self.__dbconnectstring)
-        self.buildmachineid = myParser.get('slave','buildmachineid')
+        self.__buildmachineid = myParser.get('slave','buildmachineid')
         self.dirtestbuilds = myParser.get('slave','dirtestbuilds')
 
         self.__savespecrepositoryspecfiletags = True
         #self.__
         
-        self.sleeptime = 5
+        self.__sleeptime = 5
 
-        # get the supported machroots
-        self.machroots = []
+        # get the supported distro + arch strings like fc3-i386
+        self.__distroArchTags = []
         for key in myParser.options('machroots'):
-            self.machroots.append(myParser.get('machroots',key))
+            self.__distroArchTags.append(myParser.get('machroots',key))
         
-        
-        
-        
         # todo: rewrite this stuff so everything is read from some nice configuration files
         self.__specreposrootdir="/var/lib/pydar2/specrepos"
         self.__specRepositoryList = SpecRepositoryList()
@@ -127,7 +125,9 @@
         #sr = SpecRepository("local",SpecRepositoryFactory.TYPE_FILES,self.specreposrootdir + "/local")
         #sr = srf.createSpecRepository("local",SpecRepository.TYPE_FILES,self.__specreposrootdir + "/local")
         #self.getSpecRepositoryList().add(sr)
+        self.getTargetList().addTarget(Target("dries"))
  
+ 
         __withinFullInit = False
         __fullInitDone = True
         self.__cat.debug('end')
@@ -146,6 +146,10 @@
         self.__fullInit()
         return self.__commandList
         
+    def getTargetList(self):
+        self.__fullInit()
+        return self.__targetList
+        
     def getSaveSpecRepositorySpecFileTags(self):
         self.__fullInit()
         return self.__savespecrepositoryspecfiletags
@@ -157,3 +161,16 @@
     def getUpdateUserId(self):
         self.__fullInit()
         return self.__updateUserId
+
+    def getDistroArchTags(self):
+        self.__fullInit()
+        return self.__distroArchTags
+        
+    def getBuildMachineId(self):
+        self.__fullInit()
+        return self.__buildmachineid
+        
+    def getSleepTime(self):
+        self.__fullInit()
+        return self.__sleeptime
+        

Modified: trunk/tools/pydar2/pydar/postgresqlstorage.py
===================================================================
--- trunk/tools/pydar2/pydar/postgresqlstorage.py	2005-04-23 14:19:18 UTC (rev 3157)
+++ trunk/tools/pydar2/pydar/postgresqlstorage.py	2005-04-24 13:34:16 UTC (rev 3158)
@@ -222,23 +222,23 @@
         self.__releaseConnection(conn)
         return retval
         
-    def createCommand(self,commandName,userId,specName,toEmail,releaseTag,machRoot,priority):
-        # spec name can also be the contents of a specfile...
+    def createCommand(self,aCommand):
         self.__cat.debug("start")
-        aCommand = Command(commandName,userId,specName,toEmail,releaseTag,machRoot,priority)
-        conn = pgdb.connect(self.config.dbconnectstring)
+        conn = self.__getConnection()
         cursor = conn.cursor()
-        cursor.execute("insert into pydar_commands (commandname,userid,specname,toemail,releasetag,machroot,priority) values ('"
-        + aCommand.commandName + "','"
-        + aCommand.userId + "','"
-        + aCommand.specName + "','"
-        + aCommand.toEmail + "','"
-        + aCommand.releaseTag + "','"
-        + aCommand.machRoot + "',"
-        + aCommand.priority + ")")
+        #commandName,userId,specrepoid,specfileid,toEmail,distroArchTag,priority,targetid
+        cursor.execute("insert into pydar2_commands (commandname,userid,specrepoid,specfileid,toemail,distroarchtag,priority,targetid) values ('"
+        + aCommand.getCommandName() + "','"
+        + str(aCommand.getUserId()) + "',"
+        + str(aCommand.getSpecRepoId()) + ","
+        + str(aCommand.getSpecFileId()) + ",'"
+        + str(aCommand.getToEmail()) + "','"
+        + str(aCommand.getDistroArchTag()) + "',"
+        + str(aCommand.getPriority()) + ","
+        + str(aCommand.getTargetId()) + ")")
         conn.commit()
         cursor.close()
-        conn.close()
+        self.__releaseConnection(conn)
 
     def checkIfValidUserId(self, userId):
         self.__cat.debug("start, userId=" + str(userId))
@@ -255,35 +255,35 @@
 
     def checkIfValidBuildMachineId(self, buildmachineid):
         self.__cat.debug("start, id=" + buildmachineid)
-        conn = pgdb.connect(self.config.dbconnectstring)
+        conn = self.__getConnection()
         retval = 0
         cursor = conn.cursor()
-        cursor.execute("select * from pydar_buildmachines where id='" + buildmachineid + "'")
+        cursor.execute("select * from pydar2_buildmachines where id='" + buildmachineid + "'")
         if cursor.rowcount > 0:
             retval = 1
         cursor.close()
-        conn.close()
+        self.__releaseConnection(conn)
         self.__cat.debug("retval=" + str(retval))
         return retval
 
     def registerSlave(self, buildmachineid):
         self.__cat.debug("start, buildmachineid=" + buildmachineid)
-        conn = pgdb.connect(self.config.dbconnectstring)
+        conn = self.__getConnection()
         cursor = conn.cursor()
-        cursor.execute("insert into pydar_buildmachine_registrations (id) values ('" + buildmachineid + "')")
-        cursor.execute("delete from pydar_buildmachine_machroots where buildmachineid='" + buildmachineid + "'")
+        cursor.execute("insert into pydar2_buildmachine_registrations (id) values ('" + buildmachineid + "')")
+        cursor.execute("delete from pydar2_buildmachine_distroarchtags where buildmachineid='" + buildmachineid + "'")
         conn.commit()
         cursor.close()
-        conn.close()
+        self.__releaseConnection(conn)
 
-    def addMachRoot(self, buildmachineid, machroot):
-        self.__cat.debug("start, id=" + buildmachineid + ",machroot=" + machroot)
-        conn = pgdb.connect(self.config.dbconnectstring)
+    def addDistroArchTag(self, buildmachineid, distroArchTag):
+        self.__cat.debug("start, id=" + buildmachineid + ",distroArchTag=" + distroArchTag)
+        conn = self.__getConnection()
         cursor = conn.cursor()
-        cursor.execute("insert into pydar_buildmachine_machroots (buildmachineid,machroot) values ('" + buildmachineid + "','" + machroot + "')")
+        cursor.execute("insert into pydar2_buildmachine_distroarchtags (buildmachineid,distroarchtag) values ('" + buildmachineid + "','" + distroArchTag + "')")
         conn.commit()
         cursor.close()
-        conn.close()
+        self.__releaseConnection(conn)
 
     def addResultFileName(self,buildmachineid,commandId,fileName):
         # no check on buildmachineid yet...
@@ -316,22 +316,31 @@
 
     def reserveCommand(self, buildmachineid):
         self.__cat.debug("start, buildmachineid=" + buildmachineid)
-        conn = pgdb.connect(self.config.dbconnectstring)
+        conn = self.__getConnection()
         cursor = conn.cursor()
-        cursor.execute("select pc.id, pc.specname, pc.toemail, pc.releasetag, pc.machroot, pc.commandname from pydar_commands pc where (pc.commandname='BUILD' or pc.commandname='TESTBUILD') and not pc.handled and not pc.inprogress and pc.machroot in (select machroot from pydar_buildmachine_machroots where buildmachineid='" + buildmachineid + "')  order by pc.priority desc, pc.machroot desc, pc.id asc")
+        cursor.execute("select pc.id, pc.specfileid, pc.specrepoid, pc.toemail, pc.distroarchtag, pc.targetid, pc.commandname, pc.userid, pc.priority from pydar2_commands pc where pc.commandname='BUILD' and not pc.handled and not pc.inprogress and pc.distroarchtag in (select distroarchtag from pydar2_buildmachine_distroarchtags where buildmachineid='" + buildmachineid + "')  order by pc.priority desc, pc.distroarchtag desc, pc.id asc")
         retval = ""
         if cursor.rowcount > 0:
             rs = cursor.fetchone()
             self.__cat.debug("command found for buildmachineid=" + buildmachineid + ",rs=" + str(rs))
-            aCommand = Command(rs[5],'-1',rs[1],rs[2],rs[3],rs[4])
+            commandId = rs[0]
+            specFileId = rs[1]
+            specRepoId = rs[2]
+            toEmail = rs[3]
+            distroArchTag = rs[4]
+            targetId = rs[5]
+            commandName = rs[6]
+            userId = rs[7]
+            priority = rs[8]
+            aCommand = Command(commandName,userId,specRepoId,specFileId,toEmail,distroArchTag,priority,targetId)
             aCommand.setCommandId(rs[0])
-            cursor.execute("update pydar_commands set inprogress=true where id=" + str(aCommand.commandId))
-            cursor.execute("insert into pydar_actions (commandid, statusid, buildmachineid) values (" + str(aCommand.commandId) + ",0,'" + buildmachineid + "')")
+            cursor.execute("update pydar2_commands set inprogress=true where id=" + str(aCommand.commandId))
+            cursor.execute("insert into pydar2_actions (commandid, statusid, buildmachineid) values (" + str(aCommand.commandId) + ",0,'" + buildmachineid + "')")
             retval = aCommand
         else:
             self.__cat.debug("nothing to do for buildmachineid=" + buildmachineid)
             retval = ""
         conn.commit()
         cursor.close()
-        conn.close()
+        self.__releaseConnection(conn)
         return retval

Modified: trunk/tools/pydar2/pydar/storage.py
===================================================================
--- trunk/tools/pydar2/pydar/storage.py	2005-04-23 14:19:18 UTC (rev 3157)
+++ trunk/tools/pydar2/pydar/storage.py	2005-04-24 13:34:16 UTC (rev 3158)
@@ -72,7 +72,7 @@
     def registerSlave(self, buildmachineid):
         raise Exception("Dont use Storage but a subclass of Storage, use getInstance()")
 
-    def addMachRoot(self, buildmachineid, machroot):
+    def addDistroArchTag(self, buildmachineid, machroot):
         raise Exception("Dont use Storage but a subclass of Storage, use getInstance()")
 
     def addResultFileName(self,buildmachineid,commandId,fileName):

Modified: trunk/tools/pydar2/pydar/target.py
===================================================================
--- trunk/tools/pydar2/pydar/target.py	2005-04-23 14:19:18 UTC (rev 3157)
+++ trunk/tools/pydar2/pydar/target.py	2005-04-24 13:34:16 UTC (rev 3158)
@@ -21,5 +21,14 @@
 from log4py import Logger
 
 class Target:
-    def __init__(self):
+    def __init__(self, name):
         self.__cat = Logger().get_instance(self)
+        self.__name = name
+        self.__id = -1
+        
+    def getName(self):
+        return self.__name
+
+    def getId(self):
+        return self.__id
+        

Modified: trunk/tools/pydar2/pydar/targetlist.py
===================================================================
--- trunk/tools/pydar2/pydar/targetlist.py	2005-04-23 14:19:18 UTC (rev 3157)
+++ trunk/tools/pydar2/pydar/targetlist.py	2005-04-24 13:34:16 UTC (rev 3158)
@@ -28,7 +28,7 @@
         self.__targets = []
         
     def getTargetByName(self,name):
-        for i in self__targets:
+        for i in self.__targets:
             if i.getName() == name:
                 return i
         return None

Modified: trunk/tools/pydar2/pydar-buildserver-master.py
===================================================================
--- trunk/tools/pydar2/pydar-buildserver-master.py	2005-04-23 14:19:18 UTC (rev 3157)
+++ trunk/tools/pydar2/pydar-buildserver-master.py	2005-04-24 13:34:16 UTC (rev 3158)
@@ -83,11 +83,10 @@
             return "UNKNOWN BUILDMACHINEID"
 
 
-    def addMachRoot(self,buildmachineId,machRoot):
-        METHOD_NAME = "MasterRpc::addMachRoot(..) - "
-        self.__cat.debug("start, buildmachineId=" + buildmachineId + ", machRoot=" + machRoot)
+    def addDistroArch(self,buildmachineId,distroArchTag):
+        self.__cat.debug("start, buildmachineId=" + buildmachineId + ", distroArchTag=" + distroArchTag)
         if self.__storage.checkIfValidBuildMachineId(buildmachineId):
-            self.__storage.addMachRoot(buildmachineId,machRoot)
+            self.__storage.addDistroArchTag(buildmachineId,distroArchTag)
             return "OK"
         else:
             return "UNKNOWN BUILDMACHINEID"

Modified: trunk/tools/pydar2/pydar-buildserver-slave.py
===================================================================
--- trunk/tools/pydar2/pydar-buildserver-slave.py	2005-04-23 14:19:18 UTC (rev 3157)
+++ trunk/tools/pydar2/pydar-buildserver-slave.py	2005-04-24 13:34:16 UTC (rev 3158)
@@ -19,7 +19,7 @@
 
 
 import getopt, os, sys, Queue, posix, posixpath, string, re, os.path, shutil
-sys.path.append("/usr/share/pydar/pydar")
+#sys.path.append("/usr/share/pydar/pydar")
 sys.path.append("pydar")
 from log4py import Logger
 from config import Config
@@ -28,92 +28,73 @@
 from SimpleXMLRPCServer import SimpleXMLRPCServer
 from xmlrpclib import Server
 import time
-from svnwrapper import SvnWrapper
-from stringfile import StringFile
-import mach
+#from svnwrapper import SvnWrapper
+#from stringfile import StringFile
+#import mach
 import smtplib
 from svn import fs, repos
 from email.MIMEText import MIMEText
 
 class Slave:
-    def __init__(self,myconfig):
-        self.cat = Logger().get_instance(self)
-        self.config = myconfig
-        self.dirMapping = {}
-        self.cat.debug("initialized")
+    def __init__(self):
+        self.__cat = Logger().get_instance(self)
+        self.__config = Config.getInstance()
+        self.__cat.debug("initialized")
 
     def run(self):
-        self.cat.debug("url of master: " + self.config.buildmasterurl)
-        self.cat.debug("local buildmachineid: " + self.config.buildmachineid)
-        self.myserverclient = Server(self.config.buildmasterurl)
+        self.__cat.debug("url of master: " + self.__config.getBuildMasterUrl())
+        self.__cat.debug("local getBuildMachineId(): " + self.__config.getBuildMachineId())
+        self.__myserverclient = Server(self.__config.getBuildMasterUrl())
         # let the master now that we exist
-        self.notifyMaster()
-        # wait for commands from the master
-        #self.startListener()
-        self.doBuilds()
+        self.__notifyMaster()
+        self.__doBuilds()
 
-    def notifyMaster(self):
+    def __notifyMaster(self):
         # do a call to the master server so he knows
         # we're ready to build rpms
-        retval = self.myserverclient.registerSlave(self.config.buildmachineid)
-        self.cat.debug("retval:" + retval)
-        for m in self.config.machroots:
-            self.cat.debug("machroot:" + m)
-            retval = self.myserverclient.addMachRoot(self.config.buildmachineid, m)
-            self.cat.debug("retval=" + retval)
-        self.cat.debug("notify done")
+        retval = self.__myserverclient.registerSlave(self.__config.getBuildMachineId())
+        self.__cat.debug("retval:" + retval)
+        for m in self.__config.getDistroArchTags():
+            self.__cat.debug("distoArchTag:" + m)
+            retval = self.__myserverclient.addDistroArch(self.__config.getBuildMachineId(), m)
+            self.__cat.debug("retval=" + str(retval))
+        self.__cat.debug("notify done")
 
-    def doSvnUpdate(self):
-        self.cat.debug("start")
-        svnwrap = SvnWrapper(self.config)
-        svnwrap.startTransaction()
-        svnwrap.updateLocalCopy()
-        svnwrap.stopTransaction()
-        self.cat.debug("end")
-
-    def doCheckAllSpecs(self):
-        self.cat.debug("start")
-        self.dirMapping = {}
-        rpmsDirList = posix.listdir(self.config.mastersvnrpmsdir)
-        for rpmDir in rpmsDirList:
-            #self.cat.debug("rpmDir=" + rpmDir)
-            fullRpmDir = posixpath.join(self.config.mastersvnrpmsdir,rpmDir)
-            if posixpath.isdir(fullRpmDir):
-                #self.cat.debug("it's a dir!")
-                fileList = posix.listdir(fullRpmDir)
-                for file in fileList:
-                    #self.cat.debug("part1:" + str(string.rfind(file,'.spec')))
-                    #self.cat.debug("part2:" + str(len(file) - len('.spec')))
-                    rindex = string.rfind(file,'.spec')
-                    if rindex > 0 and rindex == len(file) - len('.spec'):
-                        #self.cat.debug("spec match, file=" + file)
-                        self.doCheckSpec(rpmDir, fullRpmDir, file)
-
-    def doCheckSpec(self,rpmDirName,fullRpmDir,specFileName):
-        self.dirMapping[specFileName] = fullRpmDir;
-
-    def getLastChangedSvnRevId(self, dirName, specName):
-        svnwrap = SvnWrapper(self.cat,self.config)
-        svnwrap.startTransaction()
-        retval = svnwrap.getLastCommitRev(dirName,dirName + "/" + specName)
-        svnwrap.stopTransaction()
-        return string.rstrip(str(retval))
-
-    def doBuildSpec(self,command):
+    def __doBuilds(self):
+        self.__cat.debug("start")
+        while 1:
+            retval = self.__myserverclient.getCommand(self.__config.getBuildMachineId())
+            if retval == "":
+                time.sleep(self.__config.getSleepTime())
+            else:
+                commandName = retval['commandName']
+                userId = retval['userId']
+                specName = retval['specName']
+                toEmail = retval['toEmail']
+                releaseTag = retval['releaseTag']
+                machRoot = retval['machRoot']
+                commandId = retval['commandId']
+                aCommand = Command(commandName,userId,specName,toEmail,releaseTag,machRoot)
+                aCommand.setCommandId(commandId)
+                self.__cat.debug("aCommand=" + str(aCommand))
+                self.__cat.debug("commandid=" + str(aCommand.commandId))
+                if commandName == "BUILD":
+                    self.__doBuildSpec(aCommand)
+                else:
+                    self.__cat.error("command is not BUILD or TESTBUILD ?? commandName=" + commandName)
+        
+    def __doBuildSpec(self,command):
         # choose one implementation
         self.doBuildSpecRsyncYumBased(command)
         
-    
     def doBuildSpecRsyncYumBased(self,command):
         specFileName = command.specName
-        lastChangedSvnRevId = self.getLastChangedSvnRevId(self.dirMapping[specFileName], command.specName)
+        #lastChangedSvnRevId = self.getLastChangedSvnRevId(self.dirMapping[specFileName], command.specName)
         self.cat.debug("start, specFileName=" + specFileName)
-        
-        
-        
+
     def doBuildSpecMachBased(self,command):
         specFileName=command.specName
-        lastChangedSvnRevId = self.getLastChangedSvnRevId(self.dirMapping[specFileName], command.specName)
+        #lastChangedSvnRevId = self.getLastChangedSvnRevId(self.dirMapping[specFileName], command.specName)
         finalOutputDir = ""
         self.cat.debug("start, specFileName=" + specFileName)
         buffer = StringFile()
@@ -130,7 +111,7 @@
             self.cat.debug("mach config set to quiet")
             os.chdir(self.dirMapping[specFileName])
             shutil.copyfile(specFileName,'rpmforge-' + specFileName)
-	    commandLine = 'perl -i -npe ' + "'" + 'if ($ch==1) {chomp; $_ = $_ . " #' + lastChangedSvnRevId + '\n"; $ch=0;} if (/\%changelog/) {$ch=1;}' + "' rpmforge-" + specFileName;
+            commandLine = 'perl -i -npe ' + "'" + 'if ($ch==1) {chomp; $_ = $_ . " #' + lastChangedSvnRevId + '\n"; $ch=0;} if (/\%changelog/) {$ch=1;}' + "' rpmforge-" + specFileName;
             self.cat.debug("command: " + commandLine)
             os.system(commandLine)
             sys.stdout = buffer2
@@ -185,72 +166,17 @@
         self.informMasterAfterRebuild(buildResult, tempbuf, srpm, rpms, command, self.dirMapping[specFileName])
         self.mailOutput(tempbuf,command.toEmail, specFileName, "build: " + str(buildResult), command)
 
-    def doTestBuildSpec(self,command):
-        METHOD_NAME = "Slave::doTestBuildSpec(..) - "
-        specContents=command.specName
-        specFileName=str(command.commandId) + ".spec"
-        finalOutputDir = ""
-        
-        self.cat.debug("start, specFileName=" + specFileName)
-        buffer = StringFile()
-        buildResult = 0
-        srpm = ""
-        rpms = ()
-        try:
-            specDir = self.config.dirtestbuilds + "/" + str(command.commandId)
-            self.cat.debug("dir will be: " + specDir)
-            mach.config['quiet'] = 1
-            mach.config['release'] = command.releaseTag
-            mach.config['defaultroot'] = command.machRoot
-            self.cat.debug("mach config set to quiet")
-            os.mkdir(specDir)
-            os.chdir(specDir)
-            f = open(specFileName, 'w')
-            f.write(specContents)
-            f.close()
-            sys.stdout = buffer
-            sys.stderr = buffer
-            mach.config['collect'] = 1
-            mach.DEBUG = 1
-            mach.main(mach.config,["unlock"])
-            (srpm, rpms) = mach.main(mach.config,["build",specFileName])
-            self.cat.debug("srpm:" + srpm)
-            self.cat.debug("rpms:" + str(rpms))
-            buildResult = 1
-            os.mkdir(str(command.commandId))
-            myFileName = self.getRpmFileName(srpm)
-            os.rename(myFileName , str(command.commandId) + "/" + myFileName)
-            for rpmname in rpms:
-                myFileName = self.getRpmFileName(rpmname)
-                os.rename(myFileName, str(command.commandId) + "/" + myFileName)
-            #os.system("mv *.log *.md5sum *.*.spec " + str(command.commandId))                
-        except:
-            sys.stdout = sys.__stdout__
-            sys.stderr = sys.__stderr__
-            self.cat.debug("in except part")
-            self.cat.print_exc()
-            buildResult = 0
-        sys.stdout = sys.__stdout__
-        sys.stderr = sys.__stderr__
-        self.cat.debug("buffer contains: ")
-        tempbuf = ""
-        for line in buffer.readlines():
-            self.cat.debug("line: " + line)
-            tempbuf = tempbuf + line
-        #  blabla to server
-        self.informMasterAfterRebuild(buildResult, tempbuf, srpm, rpms, command, specDir)
-        self.mailOutput(tempbuf,command.toEmail, specFileName, "build: " + str(buildResult), command)
 
     def informMasterAfterRebuild(self,buildResult, logbuffer, srpmname, rpmsnames, command, dirName):
         METHOD_NAME="informMasterAfterRebuild(..) - "
         self.cat.debug("start")
         if buildResult:
             fileName = self.getRpmFileName(srpmname)
-            self.myserverclient.sendResultFileName(self.config.buildmachineid, command.commandId,fileName)
+            self.myserverclient.sendResultFileName(self.__config.getBuildMachineId(), command.commandId,fileName)
             for rpm in rpmsnames:
                 fileName = self.getRpmFileName(rpm)
-                self.myserverclient.sendResultFileName(self.config.buildmachineid, command.commandId, fileName)
-        self.myserverclient.sendBuildResult(self.config.buildmachineid, command.commandId, buildResult)
+                self.myserverclient.sendResultFileName(self.__config.getBuildMachineId(), command.commandId, fileName)
+        self.myserverclient.sendBuildResult(self.__config.getBuildMachineId(), command.commandId, buildResult)
 
 
     def getRpmFileName(self, rpmname):
@@ -265,47 +191,107 @@
         output = "Results can be found at:\nhttp://buildmachine1.edesign.be/" + string.replace(specName,".spec","") + "/" + str(command.commandId) + "\n\n" + output
         msg = MIMEText(output)
         msg['Subject'] = "pydar: " + command.machRoot + " " + str(command.commandId) + " " + specName + ": " + subjectPart
-        msg['From'] = self.config.mailFrom
+        msg['From'] = self.__config.mailFrom
         msg['To'] = victim
-        me = self.config.mailFrom
+        me = self.__config.mailFrom
         you = victim
         # copypaste from example on www.python.org
-        s = smtplib.SMTP(self.config.smtpserver)
+        s = smtplib.SMTP(self.__config.smtpserver)
         #s.connect()
         s.sendmail(me, [you], msg.as_string())
         s.close()
 
-    def doBuilds(self):
-        METHOD_NAME = "Slave::doBuilds(self) - "
-        self.cat.debug("start")
-	self.doCheckAllSpecs()
-        while 1:
-            retval = self.myserverclient.getCommand(self.config.buildmachineid)
-            if retval == "":
-                time.sleep(self.config.sleeptime)
-            else:
-                commandName = retval['commandName']
-                userId = retval['userId']
-                specName = retval['specName']
-                toEmail = retval['toEmail']
-                releaseTag = retval['releaseTag']
-                machRoot = retval['machRoot']
-                commandId = retval['commandId']
-                aCommand = Command(commandName,userId,specName,toEmail,releaseTag,machRoot)
-                aCommand.setCommandId(commandId)
-                self.cat.debug("aCommand=" + str(aCommand))
-                self.cat.debug("commandid=" + str(aCommand.commandId))
-                if commandName == "BUILD":
-                    #self.doSvnUpdate()
-                    self.doCheckAllSpecs()
-                    self.doBuildSpec(aCommand)
-                else:
-                    if commandName == "TESTBUILD":
-                        self.doTestBuildSpec(aCommand)
-                    else:
-                        self.cat.debug("command is not BUILD or TESTBUILD ?? commandName=" + commandName)
+                      
+    #def doSvnUpdate(self):
+    #    self.cat.debug("start")
+    #    svnwrap = SvnWrapper(self.config)
+    #    svnwrap.startTransaction()
+    #    svnwrap.updateLocalCopy()
+    #    svnwrap.stopTransaction()
+    #    self.cat.debug("end")
 
+    #def doCheckAllSpecs(self):
+    #    self.cat.debug("start")
+    #    self.dirMapping = {}
+    #    rpmsDirList = posix.listdir(self.config.mastersvnrpmsdir)
+    #    for rpmDir in rpmsDirList:
+    #        #self.cat.debug("rpmDir=" + rpmDir)
+    #        fullRpmDir = posixpath.join(self.config.mastersvnrpmsdir,rpmDir)
+    #        if posixpath.isdir(fullRpmDir):
+    #            #self.cat.debug("it's a dir!")
+    #            fileList = posix.listdir(fullRpmDir)
+    #            for file in fileList:
+    #                #self.cat.debug("part1:" + str(string.rfind(file,'.spec')))
+    #                #self.cat.debug("part2:" + str(len(file) - len('.spec')))
+    #                rindex = string.rfind(file,'.spec')
+    #                if rindex > 0 and rindex == len(file) - len('.spec'):
+    #                    #self.cat.debug("spec match, file=" + file)
+    #                    self.doCheckSpec(rpmDir, fullRpmDir, file)
 
-myConfig = Config()
-myInstance = Slave(myConfig)
+    #def doCheckSpec(self,rpmDirName,fullRpmDir,specFileName):
+    #    self.dirMapping[specFileName] = fullRpmDir;
+
+    #def getLastChangedSvnRevId(self, dirName, specName):
+    #    svnwrap = SvnWrapper(self.cat,self.config)
+    #    svnwrap.startTransaction()
+    #    retval = svnwrap.getLastCommitRev(dirName,dirName + "/" + specName)
+    #    svnwrap.stopTransaction()
+    #    return string.rstrip(str(retval))
+    
+    #def doTestBuildSpec(self,command):
+    #    METHOD_NAME = "Slave::doTestBuildSpec(..) - "
+    #    specContents=command.specName
+    #    specFileName=str(command.commandId) + ".spec"
+    #    finalOutputDir = ""
+    #    
+    #    self.cat.debug("start, specFileName=" + specFileName)
+    #    buffer = StringFile()
+    #    buildResult = 0
+    #    srpm = ""
+    #    rpms = ()
+    #    try:
+    #        specDir = self.config.dirtestbuilds + "/" + str(command.commandId)
+    #        self.cat.debug("dir will be: " + specDir)
+    #        mach.config['quiet'] = 1
+    #        mach.config['release'] = command.releaseTag
+    #        mach.config['defaultroot'] = command.machRoot
+    #        self.cat.debug("mach config set to quiet")
+    #        os.mkdir(specDir)
+    #        os.chdir(specDir)
+    #        f = open(specFileName, 'w')
+    #        f.write(specContents)
+    #        f.close()
+    #        sys.stdout = buffer
+    #        mach.config['collect'] = 1
+    #        mach.DEBUG = 1
+    #        mach.main(mach.config,["unlock"])
+    #        (srpm, rpms) = mach.main(mach.config,["build",specFileName])
+    #        self.cat.debug("srpm:" + srpm)
+    #        self.cat.debug("rpms:" + str(rpms))
+    #        buildResult = 1
+    #        os.mkdir(str(command.commandId))
+    #        myFileName = self.getRpmFileName(srpm)
+    #        os.rename(myFileName , str(command.commandId) + "/" + myFileName)
+    #        for rpmname in rpms:
+    #            myFileName = self.getRpmFileName(rpmname)
+    #            os.rename(myFileName, str(command.commandId) + "/" + myFileName)
+    #        #os.system("mv *.log *.md5sum *.*.spec " + str(command.commandId))                
+    #    except:
+    #        sys.stdout = sys.__stdout__
+    #        sys.stderr = sys.__stderr__
+    #        self.cat.debug("in except part")
+    #        self.cat.print_exc()
+    #        buildResult = 0
+    #    sys.stdout = sys.__stdout__
+    #    sys.stderr = sys.__stderr__
+    #    self.cat.debug("buffer contains: ")
+    #    tempbuf = ""
+    #    for line in buffer.readlines():
+    #        self.cat.debug("line: " + line)
+    #        tempbuf = tempbuf + line
+    #    #  blabla to server
+    #    self.informMasterAfterRebuild(buildResult, tempbuf, srpm, rpms, command, specDir)
+    #    self.mailOutput(tempbuf,command.toEmail, specFileName, "build: " + str(buildResult), command)
+
+myInstance = Slave()
 myInstance.run()

Modified: trunk/tools/pydar2/pydar-remote.py
===================================================================
--- trunk/tools/pydar2/pydar-remote.py	2005-04-23 14:19:18 UTC (rev 3157)
+++ trunk/tools/pydar2/pydar-remote.py	2005-04-24 13:34:16 UTC (rev 3158)
@@ -23,9 +23,8 @@
 # todo: parse with getopt
 
 if len(sys.argv) < 2 or sys.argv[1] == "":
-    myLog.error("you need to specify a command")
     print "known commands:"
-    print "    build <userid> <specreponame> <specfilepath> <toemail> <distroarchtag> priority> <taraget>  rebuild a specfile on the server "
+    print "    build <userid> <specreponame> <specfilepath> <toemail> <distroarchtag> <priority> <taraget>  rebuild a specfile on the server "
     print "                and use the specified releasetag and machroot"
     sys.exit(1)
 

Modified: trunk/tools/pydar2/sql/master.sql
===================================================================
--- trunk/tools/pydar2/sql/master.sql	2005-04-23 14:19:18 UTC (rev 3157)
+++ trunk/tools/pydar2/sql/master.sql	2005-04-24 13:34:16 UTC (rev 3158)
@@ -15,10 +15,12 @@
 	addtimestamp	TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 	commandname	VARCHAR(255) NOT NULL,
         userid		VARCHAR(255) NOT NULL,
-        specname	VARCHAR(64000) NOT NULL,
+        specrepoid	INTEGER NOT NULL,
+	specfileid	INTEGER NOT NULL,
         toemail		VARCHAR(255) NOT NULL,
-        releasetag	VARCHAR(255) NOT NULL,
-        machroot	VARCHAR(255) NOT NULL,
+        distroarchtag	VARCHAR(255) NOT NULL,
+        priority	INTEGER NOT NULL default 0,
+	targetid	INTEGER NOT NULL,
         handled		BOOLEAN NOT NULL DEFAULT FALSE,
         inprogress	BOOLEAN NOT NULL DEFAULT FALSE
 );
@@ -50,9 +52,9 @@
 	id		VARCHAR(255) NOT NULL,
         ts		TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
 );
-create table pydar2_buildmachine_machroots (
+create table pydar2_buildmachine_distroarchtags (
 	buildmachineid	VARCHAR(255) NOT NULL,
-	machroot	VARCHAR(255) NOT NULL
+	distroarchtag	VARCHAR(255) NOT NULL
 );
 
 insert into pydar2_users (id,name) values ('0','test user');




More information about the commits mailing list