#!/usr/bin/python import getopt, os, sys sys.path.append("/usr/share/pydar/pydar") sys.path.append("pydar") from xmlrpclib import Server from log import Log from config import Config class RemoteClient: def __init__(self,mylog,myconfig): METHOD_NAME = "RemoteClient::__init__(..) - " self.log = mylog self.config = myconfig # self.log.debug(METHOD_NAME + "start") # def checkAllSpecs(self): # METHOD_NAME = "RemoteClient::checkAllSpecs(self) - " # # ask the master to check if some spec file is changed # myserverclient = Server(self.config.buildmasterurl) # myserverclient.checkAllSpecs() # self.log.debug(METHOD_NAME + "done") # def doSvnUpdate(self): # METHOD_NAME = "RemoteClient::doSvnUpdate(self) - " # myserverclient = Server(self.config.buildmasterurl) # myserverclient.doSvnUpdate() # self.log.debug(METHOD_NAME + "done") def doBuildSpec(self, specFileName, releaseTag="", machRoot=""): METHOD_NAME = "RemoteClient::doBuildSpec(..) - " if releaseTag == "": releaseTag = self.config.releaseTag if machRoot == "": machRoot = self.config.machRoot self.log.debug(METHOD_NAME + "self.config.buildmasterurl=" + self.config.buildmasterurl) myserverclient = Server(self.config.buildmasterurl) self.log.debug(METHOD_NAME + "userid=" + self.config.userid + ",specFileName=" + specFileName + ",mailto=" + self.config.mailTo + ",releaseTag=" + releaseTag + ",machRoot=" + machRoot) myserverclient.buildSpec(self.config.userid, specFileName, self.config.mailTo, releaseTag, machRoot) def doTestBuildSpec(self, specFileName, releaseTag="", machRoot=""): METHOD_NAME = "RemoteClient::doTestBuildSpec(..) - " if releaseTag == "": releaseTag = self.config.releaseTag if machRoot == "": machRoot = self.config.machRoot self.log.debug(METHOD_NAME + "self.config.buildmasterurl=" + self.config.buildmasterurl) myserverclient = Server(self.config.buildmasterurl) self.log.debug(METHOD_NAME + "userid=" + self.config.userid + ",specFileName=" + specFileName + ",mailto=" + self.config.mailTo + ",releaseTag=" + releaseTag + ",machRoot=" + machRoot) f = open(specFileName, 'r') specFileContents = f.read() myserverclient.testBuildSpec(self.config.userid, specFileContents, self.config.mailTo, releaseTag, machRoot) def doLongWait(self): METHOD_NAME = "RemoteClient::doLongWait() - " self.log.debug(METHOD_NAME + "self.config.buildmasterurl=" + self.config.buildmasterurl) myserverclient = Server(self.config.buildmasterurl) myserverclient.longWait() myLog = Log(None) myConfig = Config() myClient = RemoteClient(myLog,myConfig) #myClient.doSvnUpdate() #myClient.checkAllSpecs() #myClient.doBuildSpec('aget.spec') # 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 " update execute a subversion update " # print " on the server" # print " checkall check all the directories and " # print " make a new list of all the spec files" print " build rebuild a specfile on the server" print " build rebuild a specfile on the server " print " and use the specified releasetag and machroot" sys.exit(1) #if sys.argv[1] == "update": # myClient.doSvnUpdate() #if sys.argv[1] == "checkall": # myClient.checkAllSpecs() if sys.argv[1] == "wait": myClient.doLongWait() if sys.argv[1] == "build" and len(sys.argv) == 3: # todo add check argv myClient.doBuildSpec(sys.argv[2]) if sys.argv[1] == "build" and len(sys.argv) == 5: myClient.doBuildSpec(sys.argv[2], sys.argv[3], sys.argv[4]) if sys.argv[1] == "testbuild" and len(sys.argv) == 3: # todo add check argv myClient.doTestBuildSpec(sys.argv[2]) if sys.argv[1] == "testbuild" and len(sys.argv) == 5: myClient.doTestBuildSpec(sys.argv[2], sys.argv[3], sys.argv[4])