extras-buildsys/server Makefile, NONE, 1.1 BuildJob.py, 1.9, 1.10 BuildMaster.py, 1.7, 1.8 Repo.py, 1.2, 1.3 User.py, 1.2, 1.3 UserInterface.py, 1.9, 1.10 buildserver.py, 1.9, 1.10 client_manager.py, 1.24, 1.25 build-server, 1.2, NONE

Daniel Williams (dcbw) fedora-extras-commits at redhat.com
Sun Jun 26 14:52:32 UTC 2005


Author: dcbw

Update of /cvs/fedora/extras-buildsys/server
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv6600/server

Modified Files:
	BuildJob.py BuildMaster.py Repo.py User.py UserInterface.py 
	buildserver.py client_manager.py 
Added Files:
	Makefile 
Removed Files:
	build-server 
Log Message:
2005-06-25  Dan Williams <dcbw at redhat.com>

    * We have a name: "(The) Plague".  We come to eat your packages.

    * Add Makefiles, install common stuff in python site-packages,
        and convert files to use config from /etc




--- NEW FILE Makefile ---
BINDIR=/usr/bin
ETCDIR=/etc
DESTDIR=''
INSTALL=/usr/bin/install
MKDIR=/bin/mkdir

clean:
	rm -f *.pyc *.pyo *~ *.bak

FILES = \
	BuildJob.py \
	BuildMaster.py \
	client_manager.py \
	Repo.py \
	UserInterface.py \
	User.py

INSTDIR=$(DESTDIR)/$(BINDIR)/$(PKGNAME)/server
CONFIGDIR=$(DESTDIR)/$(ETCDIR)/$(PKGNAME)/server

install:
	$(MKDIR) -p $(INSTDIR)
	$(INSTALL) -m 755 buildserver.py $(INSTDIR)/$(PKGNAME)-server
	for file in $(FILES); do $(INSTALL) -m 644 $$file $(INSTDIR)/$$file; done
	$(MKDIR) -p $(CONFIGDIR)
	$(INSTALL) -m 755 CONFIG.py $(CONFIGDIR)/CONFIG.py



Index: BuildJob.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/BuildJob.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- BuildJob.py	24 Jun 2005 17:24:20 -0000	1.9
+++ BuildJob.py	26 Jun 2005 14:52:30 -0000	1.10
@@ -32,14 +32,16 @@
 import string
 import SimpleXMLRPCServer
 import xmlrpclib
-import CONFIG
 import socket
 from client_manager import BuildClientManager
 from client_manager import BuildClientJob
 
-os.environ['CVSROOT'] = CONFIG.get('pkg_cvs_root')
-if len(CONFIG.get('pkg_cvs_rsh')) > 0:
-    os.environ['CVS_RSH'] = CONFIG.get('pkg_cvs_rsh')
+# Load in the config
+execfile("/etc/plague/server/CONFIG.py")
+
+os.environ['CVSROOT'] = config_opts['pkg_cvs_root']
+if len(config_opts['pkg_cvs_rsh']) > 0:
+    os.environ['CVS_RSH'] = config_opts['pkg_cvs_rsh']
 
 DEBUG = False
 def debugprint(stuff=''):
@@ -67,7 +69,7 @@
 
         
 
-http_dir = os.path.join(CONFIG.get('server_work_dir'), "srpm_http_dir")
+http_dir = os.path.join(config_opts['server_work_dir'], "srpm_http_dir")
 
 class BuildJob(threading.Thread):
     """ Controller object for building 1 SRPM on multiple arches """
@@ -87,7 +89,7 @@
         self.buildarches = []
         self.sub_jobs = {}
         self.failed = False
-        self.no_cvs = CONFIG.get('use_srpm_not_cvs')
+        self.no_cvs = config_opts['use_srpm_not_cvs']
         self.cvs_tag = cvs_tag
         self.stage_dir = None
         self.srpm_path = None
@@ -134,7 +136,7 @@
         # Grab additional build arches out of the Additional Package
         # Arches file
         apa_file_name = self.target + "addl-arches"
-        apa_file = os.path.join(CONFIG.get('addl_package_arches_dir'), apa_file_name)
+        apa_file = os.path.join(config_opts['addl_package_arches_dir'], apa_file_name)
         addl_arches = []
         try:
             f = open(apa_file, "r")
@@ -152,10 +154,10 @@
                         addl_arches = tmp_arches.split(' ')
                         break
 
-        targets = CONFIG.get('targets')
+        targets = config_opts['targets']
         buildable_arches = targets[self.target]
 
-        target_opt_arches = CONFIG.get('target_optional_arches')
+        target_opt_arches = config_opts['target_optional_arches']
         opt_arches = []
         if target_opt_arches.has_key(self.target):
             opt_arches = target_opt_arches[self.target]
@@ -226,11 +228,11 @@
     def _checkout(self):
         self._set_cur_stage('checkout')
         dir_prefix = self.cvs_tag + "-"
-        self.checkout_tmpdir = tempfile.mkdtemp(prefix=dir_prefix, dir=CONFIG.get('tmpdir'))
+        self.checkout_tmpdir = tempfile.mkdtemp(prefix=dir_prefix, dir=config_opts['tmpdir'])
         os.chdir(self.checkout_tmpdir)
 
         # Checkout the module
-        cmd = '%s co -r %s %s' % (CONFIG.get('cvs_cmd'), self.cvs_tag, self.package)
+        cmd = '%s co -r %s %s' % (config_opts['cvs_cmd'], self.cvs_tag, self.package)
         debugprint("%d: Running %s" % (self.uid, cmd))
         s, o = commands.getstatusoutput(cmd)
         if s != 0:
@@ -247,7 +249,7 @@
         pkg_path = os.path.join(self.checkout_tmpdir, self.package)
         if not os.path.exists(os.path.join(pkg_path, "common")):
             os.chdir(pkg_path)
-            cmd = '%s co common' % CONFIG.get('cvs_cmd')
+            cmd = '%s co common' % config_opts['cvs_cmd']
             debugprint("%d: Running %s" % (self.uid, cmd))
             s, o = commands.getstatusoutput(cmd)
             os.chdir(self.checkout_tmpdir)
@@ -275,7 +277,7 @@
 
         os.chdir(srpm_dir)
 
-        cmd = '%s srpm' % CONFIG.get('make_cmd')
+        cmd = '%s srpm' % config_opts['make_cmd']
         debugprint("%d: Running %s in %s" % (self.uid, cmd, srpm_dir))
         s, o = commands.getstatusoutput(cmd)
         if s != 0:
@@ -325,7 +327,7 @@
             self._set_cur_stage('finished')
             return
 
-        self.stage_dir = self._make_stage_dir(CONFIG.get('server_work_dir'))
+        self.stage_dir = self._make_stage_dir(config_opts['server_work_dir'])
         for arch in self.buildarches:
             thisdir = os.path.join(self.stage_dir, arch)
             if not os.path.exists(thisdir):
@@ -459,7 +461,7 @@
                     continue
                 src_file = os.path.join(self.stage_dir, job.arch, f)
                 verrel = "%s-%s" % (self.ver, self.release)
-                dst_path = os.path.join(CONFIG.get('repo_dir'), self.target, self.name, verrel, job.arch)
+                dst_path = os.path.join(config_opts['repo_dir'], self.target, self.name, verrel, job.arch)
                 self.repofiles[src_file] = dst_path
 
         # Request the repo copy our files.  It will get the file
@@ -487,10 +489,10 @@
                 name = self.package
             subject = 'Build Result: %d - %s on %s' % (self.uid, name, self.target)
         msg['Subject'] = subject
-        msg['From'] = CONFIG.get('email_from')
+        msg['From'] = config_opts['email_from']
         msg['To'] = self.username
         s = smtplib.SMTP()
         s.connect()
-        s.sendmail(CONFIG.get('email_from'), [self.username], msg.as_string())
+        s.sendmail(config_opts['email_from'], [self.username], msg.as_string())
         s.close()
 


Index: BuildMaster.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/BuildMaster.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BuildMaster.py	25 Jun 2005 22:22:10 -0000	1.7
+++ BuildMaster.py	26 Jun 2005 14:52:30 -0000	1.8
@@ -17,7 +17,6 @@
 
 
 import time
-import CONFIG
 import BuildJob
 import sqlite
 import threading
@@ -25,6 +24,11 @@
 import Repo
 
 
+# Load in the config
+CONFIG_LOCATION = "/etc/plague/server/"
+execfile(CONFIG_LOCATION + "CONFIG.py")
+
+
 class JobsQuery:
     """ Wrapper class around DB query results.  Since only one
         thread has access to the database (to work around sqlite
@@ -71,7 +75,7 @@
         self.building_jobs = []
         self.should_stop = False
         self.repos = {}
-        for target in CONFIG.get('targets').keys():
+        for target in config_opts['targets'].keys():
             repo = Repo.Repo(target, client_manager)
             self.repos[target] = repo
             repo.start()
@@ -86,7 +90,13 @@
         self._query_queue = []
         self._query_queue_lock = threading.Lock()
 
-        self.dbcx = sqlite.connect("jobdb", encoding="utf-8", timeout=3)
+        try:
+            self.dbcx = sqlite.connect(CONFIG_LOCATION + "jobdb", encoding="utf-8", timeout=3)
+        except sqlite.DatabaseError, e:
+            s = "%s" % e
+            if s == 'unable to open database file':
+                print "Unable to open the jobs database.  Exiting..."
+                os._exit(1)
         self.curs = self.dbcx.cursor()
         ensure_job_db_tables(self.dbcx)
 
@@ -143,10 +153,9 @@
 
         for job in self._done_queue:
             curstage = job.get_cur_stage()
-            if curstage == 'failed' or curstage == 'needsign':
-                self._write_status_to_db(job.get_uid(), curstage)
-                print "%s (%s): Job finished." % (job.get_uid(), job.package)
-                self.building_jobs.remove(job)
+            self._write_status_to_db(job.get_uid(), curstage)
+            print "%s (%s): Job finished." % (job.get_uid(), job.package)
+            self.building_jobs.remove(job)
 
         self._done_queue = []
         self._done_queue_lock.release()


Index: Repo.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/Repo.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Repo.py	24 Jun 2005 17:14:27 -0000	1.2
+++ Repo.py	26 Jun 2005 14:52:30 -0000	1.3
@@ -17,18 +17,21 @@
 import os
 import threading
 import shutil
-import CONFIG
 import time
 import commands
 
 
+# Load in the config
+execfile("/etc/plague/server/CONFIG.py")
+
+
 class Repo(threading.Thread):
     """ Represents an on-disk repository of RPMs and manages updates to the repo. """
 
     def __init__(self, target, client_manager):
         self._bcm = client_manager
         self._target = target
-        self._repodir = os.path.join(CONFIG.get('repo_dir'), target)
+        self._repodir = os.path.join(config_opts['repo_dir'], target)
         if not os.path.exists(self._repodir):
             os.makedirs(self._repodir)
         self._lock = threading.Lock()


Index: User.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/User.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- User.py	14 Jun 2005 13:37:42 -0000	1.2
+++ User.py	26 Jun 2005 14:52:30 -0000	1.3
@@ -15,9 +15,12 @@
 # Copyright 2005 Dan Williams <dcbw at redhat.com> and Red Hat, Inc.
 
 
-import CONFIG
 import sqlite
 
+# Load in the config
+CONFIG_LOCATION = "/etc/plague/server/"
+execfile(CONFIG_LOCATION + "CONFIG.py")
+
 
 class User:
     def __init__(self, email, guest):
@@ -38,7 +41,13 @@
     """
 
     def __init__(self):
-        self.dbcx = sqlite.connect("userdb", encoding="utf-8", timeout=2)
+        try:
+            self.dbcx = sqlite.connect(CONFIG_LOCATION + "userdb", encoding="utf-8", timeout=2)
+        except sqlite.DatabaseError, e:
+            s = "%s" % e
+            if s == 'unable to open database file':
+                print "Unable to open the user database.  Exiting..."
+                os._exit(1)
         self.curs = self.dbcx.cursor()
 
         # Ensure the table exists in the database
@@ -72,7 +81,7 @@
             user.modify_users = item['modify_users']
             user.server_admin = item['server_admin']
         else:
-            if CONFIG.get('guest_allowed'):
+            if config_opts['guest_allowed']:
                 user = User('guest at guest', True)
         return user
 


Index: UserInterface.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/UserInterface.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- UserInterface.py	25 Jun 2005 22:22:10 -0000	1.9
+++ UserInterface.py	26 Jun 2005 14:52:30 -0000	1.10
@@ -15,7 +15,6 @@
 # Copyright 2005 Dan Williams <dcbw at redhat.com> and Red Hat, Inc.
 
 
-import CONFIG
 import sqlite
 import smtplib
 from email.MIMEText import MIMEText
@@ -33,11 +32,11 @@
     if not subject:
         subject = 'Build Result: %s' % cvs_tag
     msg['Subject'] = subject
-    msg['From'] = CONFIG.get('email_from')
+    msg['From'] = config_opts['email_from']
     msg['To'] = email
     s = smtplib.SMTP()
     s.connect()
-    s.sendmail(CONFIG.get('email_from'), [email], msg.as_string())
+    s.sendmail(config_opts['email_from'], [email], msg.as_string())
     s.close()
 
 
@@ -55,14 +54,14 @@
     def enqueue(self, email, package, cvs_tag, target, buildreq=None):
         """ Accept a job to build and stuff it into the job database """
 
-        if CONFIG.get('use_srpm_not_cvs') == True:
+        if config_opts['use_srpm_not_cvs'] == True:
             email_result(email, cvs_tag, "Error setting up build for %s on "\
                     "%s: this server builds SRPMs, not CVS checkouts." % (cvs_tag, target))
             return (-1, "This build server is set up for building SRPMS only.  Use the 'enqueue_srpm' command instead.")
 
         print "Request to enqueue '%s' tag '%s' for target '%s' (user '%s')" \
                 % (package, cvs_tag, target, email)
-        targets = CONFIG.get('targets')
+        targets = config_opts['targets']
         jobid = -1
         if not targets.has_key(target):
             print "Error setting up build for %s on %s: target does not exist."\
@@ -78,7 +77,7 @@
     def enqueue_srpm(self, email, package, srpm_file, target, buildreq=None):
         """ Accept a job to build from SRPM file and stuff it into the job database """
 
-        if CONFIG.get('use_srpm_not_cvs') == False:
+        if config_opts['use_srpm_not_cvs'] == False:
             email_result(email, srpm_file, "Error setting up build for %s on "\
                     "%s: this server builds CVS checkouts, not SRPMS." % (srpm_file, target))
             return (-1, "This build server is set up for building from CVS.  Use the 'enqueue' command instead.")
@@ -91,7 +90,7 @@
 
         print "Request to enqueue '%s' file '%s' for target '%s' (user '%s')" \
                 % (package, srpm_file, target, email)
-        targets = CONFIG.get('targets')
+        targets = config_opts['targets']
         jobid = -1
         if not targets.has_key(target):
             print "Error setting up build for %s on %s: target does not exist."\


Index: buildserver.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/buildserver.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- buildserver.py	24 Jun 2005 17:24:20 -0000	1.9
+++ buildserver.py	26 Jun 2005 14:52:30 -0000	1.10
@@ -16,18 +16,21 @@
 # written by Seth Vidal
 
 
-import CONFIG
 import sys
 import os
 import BuildMaster
 from client_manager import BuildClientManager
-import SimpleHTTPSServer
-import SimpleSSLXMLRPCServer
+from plague import SimpleHTTPSServer
+from plague import SimpleSSLXMLRPCServer
 import User
 from UserInterface import UserInterfaceSSLAuth, UserInterfaceNoAuth
 import SimpleXMLRPCServer
 
 
+# Load in the config
+execfile("/etc/plague/server/CONFIG.py")
+
+
 class AuthenticatedSSLXMLRPCServer(SimpleSSLXMLRPCServer.SimpleSSLXMLRPCServer):
     """
     SSL XMLRPC server that authenticates clients based on their certificate.
@@ -87,20 +90,20 @@
 
     # SSL certificate and key filenames
     srpm_server_certs = {}
-    srpm_server_certs['cert'] = CONFIG.get('server_cert')
-    srpm_server_certs['key'] = CONFIG.get('server_key')
-    srpm_server_certs['ca_cert'] = CONFIG.get('ca_cert')
-    srpm_server_certs['peer_ca_cert'] = CONFIG.get('ca_cert')
+    srpm_server_certs['cert'] = config_opts['server_cert']
+    srpm_server_certs['key'] = config_opts['server_key']
+    srpm_server_certs['ca_cert'] = config_opts['ca_cert']
+    srpm_server_certs['peer_ca_cert'] = config_opts['ca_cert']
 
     ui_certs = {}
-    ui_certs['cert'] = CONFIG.get('server_cert')
-    ui_certs['key'] = CONFIG.get('server_key')
-    ui_certs['ca_cert'] = CONFIG.get('ca_cert')
-    ui_certs['peer_ca_cert'] = CONFIG.get('ui_ca_cert')
+    ui_certs['cert'] = config_opts['server_cert']
+    ui_certs['key'] = config_opts['server_key']
+    ui_certs['ca_cert'] = config_opts['ca_cert']
+    ui_certs['peer_ca_cert'] = config_opts['ui_ca_cert']
 
     # Create the BuildMaster XMLRPC server
     ui = None
-    if CONFIG.get('ssl_frontend') == True:
+    if config_opts['ssl_frontend'] == True:
         ui = UserInterfaceSSLAuth(bcm, bm)
         bm_server = AuthenticatedSSLXMLRPCServer(ui_certs, (hostname, 8887))
     else:
@@ -109,7 +112,7 @@
     bm_server.register_instance(ui)
 
     # SRPM fileserver
-    http_dir = os.path.join(CONFIG.get('server_work_dir'), "srpm_http_dir")
+    http_dir = os.path.join(config_opts['server_work_dir'], "srpm_http_dir")
     srpm_server = SimpleHTTPSServer.SimpleHTTPSServer(srpm_server_certs, (hostname, 8886), http_dir)
     srpm_server.start()
 


Index: client_manager.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/server/client_manager.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- client_manager.py	25 Jun 2005 22:19:10 -0000	1.24
+++ client_manager.py	26 Jun 2005 14:52:30 -0000	1.25
@@ -18,24 +18,26 @@
 import time
 import string
 import xmlrpclib
-import CONFIG
 import sys
 import socket
-import FileDownloader
 import os
 import threading
 import urllib
-import SSLXMLRPCServerProxy
+from plague import FileDownloader
+from plague import SSLXMLRPCServerProxy
+from plague import CommonErrors
 from M2Crypto import SSL
-import CommonErrors
+
+# Load in the config
+execfile("/etc/plague/server/CONFIG.py")
 
 
 # SSL certificate and key filenames
 certs = {}
-certs['cert'] = CONFIG.get('server_cert')
-certs['key'] = CONFIG.get('server_key')
-certs['ca_cert'] = CONFIG.get('ca_cert')
-certs['peer_ca_cert'] = CONFIG.get('ca_cert')
+certs['cert'] = config_opts['server_cert']
+certs['key'] = config_opts['server_key']
+certs['ca_cert'] = config_opts['ca_cert']
+certs['peer_ca_cert'] = config_opts['ca_cert']
 
 
 def result_is_finished(result):
@@ -339,7 +341,7 @@
         self._clients_lock = threading.Lock()
 
         # List of addresses of possible builders
-        self.possible_clients = CONFIG.get('builders')
+        self.possible_clients = config_opts['builders']
         self.running_clients = []
         client_list = self.update_clients()
 


--- build-server DELETED ---




More information about the fedora-extras-commits mailing list