extras-buildsys/client build-client, NONE, 1.1 buildclient.py, 1.1, 1.2 FileDownloader.py, 1.1, NONE FileServer.py, 1.1, NONE

Daniel Williams (dcbw) fedora-extras-commits at redhat.com
Wed Jun 8 15:55:53 UTC 2005


Author: dcbw

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

Modified Files:
	buildclient.py 
Added Files:
	build-client 
Removed Files:
	FileDownloader.py FileServer.py 
Log Message:
2005-06-08  Dan Williams <dcbw at redhat.com>

    * Refactor FileDownload.py and FileServer.py, moving them into a shared
      directory common/.  Fix client & server to point to these modules and
      implement callbacks in each that are required by FileDownload.py.  Since
      at this time we don't install anything to site-packages, the build-client
      and build-server scripts are necessary to properly set up PYTHONPATH to
      find stuff in the common/ directory.




--- NEW FILE build-client ---
#!/bin/bash

export PYTHONPATH="$PYTHONPATH:../common"
python buildclient.py $@


Index: buildclient.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/client/buildclient.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- buildclient.py	7 Jun 2005 12:10:22 -0000	1.1
+++ buildclient.py	8 Jun 2005 15:55:51 -0000	1.2
@@ -43,6 +43,7 @@
 
 g_our_hostname = None
 
+
 def get_url_for_file(file_path):
     """ Return a URL pointing to a particular file in our work dir """
 
@@ -54,46 +55,6 @@
     return urllib.quote(full_url)
 
 
-def get_base_filename_from_url(url):
-    """ Safely unquotes a URL and gets the base file name from it.
-        We're not using urlparse here because it doesn't un-escape stuff """
-
-    unquoted = url
-    last_unquoted = None
-    count = 5
-    
-    # Keep unquoting the string until the last two unquote operations
-    # produce the same string
-    while (unquoted != last_unquoted) and (count > 0):
-        last_unquoted = unquoted
-        unquoted = urllib.unquote_plus(unquoted)
-        count = count - 1
-
-    # If after 5 iterations of unquoting, the strings still aren't the same,
-    # something is wrong.
-    if (count == 0) and (unquoted != last_unquoted):
-        return None
-
-    # Try to grab the filename off the end of the URL
-    index = url.rfind('/')
-    if index is -1:
-        return None
-    filename = url[index+1:]
-
-    if not filename.endswith('.src.rpm'):
-        return None
-
-    # FIXME: what other validation can we do here?
-    for c in filename:
-        # For now, legal characters are '_-.' plus alphanumeric
-        if (c == '_') or (c == '-') or (c == '.') or c.isalnum():
-            pass
-        else:
-            return None
-
-    return filename
-
-
 class BuildClientMach:
     """puts things together for an arch - baseclass for handling builds for 
        other arches"""
@@ -105,7 +66,7 @@
         self._target = target
         self._srpm_url = srpm_url
 
-        srpm_filename = get_base_filename_from_url(srpm_url)
+        srpm_filename = FileDownloader.get_base_filename_from_url(srpm_url, ['.src.rpm'])
         if not srpm_filename:
             self._status = 'failed'
             self._srpm_path = None
@@ -127,9 +88,22 @@
 
     def _download_srpm(self):
         self._status = 'downloading'
-        dl_thread = FileDownloader.FileDownloader(self)
+        target_dir = os.path.dirname(self._srpm_path)
+        dl_thread = FileDownloader.FileDownloader(self.dl_callback, self._srpm_url, self._srpm_url, target_dir, ['.src.rpm'])
         dl_thread.start()
 
+    def dl_callback(self, status, cb_data):
+        url = cb_data
+        if status == 'done':
+            self._status = 'downloaded'
+            log("%s: Finished downloading %s" % (self._uniqid, url))
+        elif status == 'failed':
+            # Don't overwrite our status with 'failed' if we were cancelled
+            # and a download error ocurred
+            if not self.is_done_status():
+                self._status = 'failed'
+                log("%s: Failed to download %s" % (self._uniqid, url))
+
     def _build(self):
         print "%s: starting step 'building'" % self._uniqid
         if not os.path.exists(self._result_dir):
@@ -183,29 +157,17 @@
     def status(self):
         return self._status
 
-    def set_status(self, status):
-        self._status = status
-
     def files(self):
         # ?? What to do with mock output...  another log file?
         #if self._pobj:
         #    self._output.extend(self._pobj.fromchild.readlines())
         return self._files
 
-    def srpm_url(self):
-        return self._srpm_url
-
-    def srpm_path(self):
-        return self._srpm_path
-
     def is_done_status(self):
         if (self._status is 'done') or (self._status is 'killed') or (self._status is 'failed'):
             return True
         return False
 
-    def uniqid(self):
-        return self._uniqid
-
 
 class i386Arch(BuildClientMach):
     def __init__(self, uniqid, target, buildarch, srpm_url):
@@ -375,7 +337,7 @@
 
     # Start up the HTTP server thread which the build server
     # pulls completed RPMs from
-    http_server = FileServer.FileServer((g_our_hostname, 8889), xmlserver)
+    http_server = FileServer.FileServer((g_our_hostname, 8889), CONFIG.get('client_work_dir'))
     http_server.start()
 
     last_time = time.time()


--- FileDownloader.py DELETED ---


--- FileServer.py DELETED ---




More information about the fedora-extras-commits mailing list