diff bitten/slave.py @ 48:757aa3bf9594

* Simplify code for making snapshot archives. * The build slave now unpacks a snapshot after transmission.
author cmlenz
date Fri, 24 Jun 2005 17:13:07 +0000
parents 083e848088ee
children b4c51e32952b
line wrap: on
line diff
--- a/bitten/slave.py
+++ b/bitten/slave.py
@@ -25,7 +25,7 @@
 import time
 
 from bitten import __version__ as VERSION
-from bitten.util import beep, xmlio
+from bitten.util import archive, beep, xmlio
 
 
 class Slave(beep.Initiator):
@@ -70,13 +70,25 @@
             archive_name = msg.get('Content-Disposition', 'snapshot.tar.gz')
             archive_path = os.path.join(workdir, archive_name)
             file(archive_path, 'wb').write(msg.get_payload())
-            logging.info('Received snapshot archive: %s', archive_path)
+            logging.debug('Received snapshot archive: %s', archive_path)
 
-            # TODO: Spawn the build process
+            # Unpack the archive
+            prefix = archive.unpack(archive_path, workdir)
+            path = os.path.join(workdir, prefix)
+            logging.info('Unpacked snapshot to %s' % path)
+
+            # Fix permissions
+            for root, dirs, files in os.walk(workdir, topdown=False):
+                for dirname in dirs:
+                    os.chmod(os.path.join(root, dirname), 0700)
+                for filename in files:
+                    os.chmod(os.path.join(root, filename), 0400)
 
             xml = xmlio.Element('ok')
             self.channel.send_rpy(msgno, beep.MIMEMessage(xml))
 
+            # TODO: Start the build process
+
         else:
             xml = xmlio.Element('error', code=500)['Sorry, what?']
             self.channel.send_err(msgno, beep.MIMEMessage(xml))
Copyright (C) 2012-2017 Edgewall Software