extras-buildsys/builder builder.py,1.42,1.43
Daniel Williams (dcbw)
fedora-extras-commits at redhat.com
Fri Sep 16 18:11:16 UTC 2005
Author: dcbw
Update of /cvs/fedora/extras-buildsys/builder
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8896/builder
Modified Files:
builder.py
Log Message:
2005-09-16 Dan Williams <dcbw at redhat.com>
* builder/builder.py
common/FileDownloader.py
server/ArchJob.py
- Rename FileNameError -> FileNameException
* builder/builder.py
- Clean up exception handling on job creation so that we
don't end up calling start() before Thread.__init__() got
called.
Index: builder.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/builder/builder.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- builder.py 13 Sep 2005 18:43:01 -0000 1.42
+++ builder.py 16 Sep 2005 18:11:14 -0000 1.43
@@ -111,24 +111,6 @@
logfile = os.path.join(self._result_dir, "job.log")
self._log_fd = open(logfile, "w+")
- target_dict = self._target_cfg.target_dict()
- target_str = "%s-%s-%s-%s" % (target_dict['distro'], target_dict['target'], target_dict['arch'], target_dict['repo'])
- self._log("""Starting job:
- Time: %s
- Target: %s
- UID: %s
- Architecture: %s
- SRPM: %s\n\n""" % (time.asctime(time.localtime(self._starttime)), target_str, self._uniqid, self.buildarch, srpm_url))
-
- try:
- srpm_filename = FileDownloader.get_base_filename_from_url(srpm_url, ['.src.rpm'])
- except FileDownloader.FileNameError, e:
- self._status = 'failed'
- self._srpm_path = None
- self._log("Failed to extract SRPM filename. Error: '%s' URL: %s\n" % (e, srpm_url))
- return
-
- self._srpm_path = os.path.join(work_dir, self._uniqid, "source", srpm_filename)
threading.Thread.__init__(self)
def starttime(self):
@@ -153,7 +135,7 @@
try:
os.kill(self._childpid, 9)
except OSError, e:
- self._log("Couldn't kill process %d: %s\n" % (self._childpid, e))
+ self._log("ERROR: Couldn't kill process %d: %s\n" % (self._childpid, e))
else:
# Ensure child process is reaped
self._log("Waiting for mock process %d to exit...\n" % self._childpid)
@@ -186,7 +168,7 @@
# and a download error ocurred
if not self.is_done_status():
self._status = 'failed'
- self._log("Failed to retrieve %s.\n" % url)
+ self._log("ERROR: Failed to retrieve %s.\n" % url)
def _copy_mock_output_to_log(self):
if self._mock_log and os.path.exists(self._mock_log):
@@ -323,38 +305,18 @@
f.close()
return contents
- def _mock_done(self):
- # Ensure child process is reaped
- if self._childpid:
- try:
- (pid, status) = os.waitpid(self._childpid, 0)
- except OSError, e:
- self._childpid = 0
- pass
-
- self._copy_mock_output_to_log()
-
- self._files = self._find_files()
- self._log("\n\n-----------------------\n\n")
- if self._status == 'done':
- self._log("Job completed successfully.\n")
- elif self._status == 'failed':
- self._log("Job failed due to mock errors! Please see output in root.log and build.log\n")
- elif self._status == 'killed':
- self._log("Job failed because it was killed.\n")
-
- if self._log_fd:
- self._log_fd.close()
- self._log_fd = None
-
def _status_init(self):
self._log("Starting download of %s.\n" % self._srpm_url)
self._status = 'downloading'
target_dir = os.path.dirname(self._srpm_path)
- dl_thread = FileDownloader.FileDownloader(self.dl_callback, self._srpm_url, self._srpm_url,
+ try:
+ dl_thread = FileDownloader.FileDownloader(self.dl_callback, self._srpm_url, self._srpm_url,
target_dir, ['.src.rpm'], certs)
- dl_thread.start()
-
+ dl_thread.start()
+ except FileDownloader.FileNameException, e:
+ self._status = 'failed'
+ self._log("ERROR: Failed to begin SRPM download. Error: '%s' URL: %s\n" % (e, self._srpm_url))
+
def _status_downloading(self):
pass
@@ -392,7 +354,7 @@
# something is wrong if mock takes more than 15s to write the status file
if time.time() > self._mockstarttime + 15:
self._mockstarttime = 0
- self._log("Timed out waiting for the mock status file! %s\n" % mockstatusfile)
+ self._log("ERROR: Timed out waiting for the mock status file! %s\n" % mockstatusfile)
self.die()
else:
if not self._mock_config and self._mock_is_prepping():
@@ -424,8 +386,51 @@
if source_dir.endswith(os.path.join(self._uniqid, "source")):
shutil.rmtree(source_dir, ignore_errors=True)
+ def _job_done(self):
+ # Ensure child process is reaped, if any
+ if self._childpid:
+ try:
+ self._log("Waiting for child process %d to exit." % self._childpid)
+ (pid, status) = os.waitpid(self._childpid, 0)
+ except OSError, e:
+ self._childpid = 0
+ pass
+
+ self._copy_mock_output_to_log()
+
+ self._files = self._find_files()
+ self._log("\n\n-----------------------\n\n")
+ if self._status == 'done':
+ self._log("Job completed successfully.\n")
+ elif self._status == 'failed':
+ self._log("Job failed due to build errors! Please see build logs.\n")
+ elif self._status == 'killed':
+ self._log("Job failed because it was killed.\n")
+
+ if self._log_fd:
+ self._log_fd.close()
+ self._log_fd = None
+
def run(self):
- while True:
+ # Print out a nice message at the start of the job
+ target_dict = self._target_cfg.target_dict()
+ target_str = "%s-%s-%s-%s" % (target_dict['distro'], target_dict['target'], target_dict['arch'], target_dict['repo'])
+ self._log("""Starting job:
+ Time: %s
+ Target: %s
+ UID: %s
+ Architecture: %s
+ SRPM: %s\n\n""" % (time.asctime(time.localtime(self._starttime)), target_str, self._uniqid, self.buildarch, self._srpm_url))
+
+ try:
+ srpm_filename = FileDownloader.get_base_filename_from_url(self._srpm_url, ['.src.rpm'])
+ self._srpm_path = os.path.join(work_dir, self._uniqid, "source", srpm_filename)
+ except FileDownloader.FileNameException, e:
+ self._log("ERROR: SRPM file name was invalid. Message: '%s'" % e)
+ self._status = 'failed'
+
+ # Main build job work loop
+ while not self.is_done_status():
if self._die:
self._handle_death()
@@ -433,16 +438,12 @@
try:
func = getattr(self, "_status_%s" % self._status)
func()
+ time.sleep(3)
except AttributeError:
self._log("ERROR: internal builder inconsistency, didn't recognize status '%s'." % self._status)
self._status = 'failed'
- if self.is_done_status():
- self._mock_done()
- break
-
- time.sleep(3)
-
+ self._job_done()
self._endtime = time.time()
if self._childpid:
self._log("ERROR: childpid was !NULL (%d)" % self._childpid)
@@ -460,6 +461,7 @@
self._log(" Output File: %s\n" % urllib.unquote(file_url))
else:
self._log(" Error: Couldn't get file URL for file %s" % f)
+ self._log("-----------------\n")
return file_list
def status(self):
@@ -607,10 +609,10 @@
self._building_jobs_lock.acquire()
self._building_jobs.append(job)
self._building_jobs_lock.release()
- job.start()
filename = os.path.basename(srpm_url)
self._log("%s: started %s on %s arch %s at time %d" % (uniqid, filename,
target_str, target_dict['arch'], job.starttime()))
+ job.start()
else:
self._log("%s: Failed request for %s on %s UNSUPPORTED arch %s" %
(uniqid, srpm_url, target_str, target_dict['arch'], cur_time))
More information about the fedora-extras-commits
mailing list