Mercurial > bitten > bitten-test
comparison bitten/slave.py @ 49:b4c51e32952b
Build slave now also handles snapshot archives in bzip2 and zip format.
author | cmlenz |
---|---|
date | Fri, 24 Jun 2005 17:26:47 +0000 |
parents | 757aa3bf9594 |
children | 5caccd7b247e |
comparison
equal
deleted
inserted
replaced
48:757aa3bf9594 | 49:b4c51e32952b |
---|---|
63 xmlio.Element('os', family=os.name, version=release)[sysname] | 63 xmlio.Element('os', family=os.name, version=release)[sysname] |
64 ] | 64 ] |
65 self.channel.send_msg(beep.MIMEMessage(xml), handle_reply) | 65 self.channel.send_msg(beep.MIMEMessage(xml), handle_reply) |
66 | 66 |
67 def handle_msg(self, msgno, msg): | 67 def handle_msg(self, msgno, msg): |
68 if msg.get_content_type() == 'application/tar': | 68 content_type = msg.get_content_type() |
69 if content_type in ('application/tar', 'application/zip'): | |
69 workdir = tempfile.mkdtemp(prefix='bitten') | 70 workdir = tempfile.mkdtemp(prefix='bitten') |
70 archive_name = msg.get('Content-Disposition', 'snapshot.tar.gz') | 71 |
72 archive_name = msg.get('Content-Disposition') | |
73 if not archive_name: | |
74 if content_type == 'application/tar': | |
75 encoding = msg.get('Content-Transfer-Encoding') | |
76 if encoding == 'gzip': | |
77 archive_name = 'snapshot.tar.gz' | |
78 elif encoding == 'bzip2': | |
79 archive_name = 'snapshot.tar.bz2' | |
80 else: | |
81 archive_name = 'snapshot.tar' | |
82 else: | |
83 archive_name = 'snapshot.zip' | |
71 archive_path = os.path.join(workdir, archive_name) | 84 archive_path = os.path.join(workdir, archive_name) |
72 file(archive_path, 'wb').write(msg.get_payload()) | 85 file(archive_path, 'wb').write(msg.get_payload()) |
73 logging.debug('Received snapshot archive: %s', archive_path) | 86 logging.debug('Received snapshot archive: %s', archive_path) |
74 | 87 |
75 # Unpack the archive | 88 # Unpack the archive |