def upload_to_apt_repository(apt_target, apt_dist, changes_file, logger):
try:
# Change distribution for new apt repository in changes file
- cmd = ['sed', '-i', r's/^\(Distribution: \).*$/\1' + apt_dist + '/',
- changes_file]
+ cmd = ['sed', r's/^\(Distribution: \).*$/\1' + apt_dist + '/', changes_file]
command = ' '.join(cmd)
logger.debug('Executing "{command}" ...'.format(command=command))
- if subprocess.call(cmd) == 0:
+ process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ changes = process.communicate()[0]
+ if process.returncode == 0:
logger.debug('%s succeeded.' % command)
else:
logger.warn('%s failed.' % command)
+ figlet('apt01 upload failed')
return
+ new_changes_file = os.path.join(ENV['WORKSPACE'], apt_target + '.changes')
+ filehandle = open(new_changes_file, 'w')
+ filehandle.write(changes)
+ filehandle.close()
- cmd = ['dput', apt_target, changes_file]
+ cmd = ['dput', apt_target, new_changes_file]
command = ' '.join(cmd)
logger.debug('Executing "{command}" ...'.format(command=command))
if subprocess.call(cmd) == 0:
logger.debug('%s succeeded.' % command)
+ figlet('apt01 upload OK')
else:
logger.warn('%s failed.' % command)
+ figlet('apt01 upload failed')
except Exception as error:
logger.warning("Experimental upload to http://apt01.pb.local failed. "
"See above for details.", exc_info=error)
+ figlet('apt01 upload failed')
if __name__ == '__main__':
))
fh.close()
+ # upload to new apt01 archive
+ upload_to_apt_repository(apt_target, apt_dist, changes_file, logger)
+
# upload changes file
dput_obj.configure()
dput_obj.upload(changes_file)
figlet('Upload OK')
- upload_to_apt_repository(apt_target, apt_dist, changes_file, logger)
-
except Exception as error:
logger.error('Upload failed. See above for details.', exc_info=error)
figlet('Upload failed')