27
30
# and add it, so we can always safely import stuff
28
31
sys.path.append(os.path.join(os.path.dirname(__file__), '../ci-utils'))
29
32
from ci_utils import amqp_utils
33
TIME_BETWEEN_CHECKS = 60
32
35
def on_message(msg):
33
log.info('on_message: %s', msg.body)
36
log.info('on_message: {}'.format(msg.body))
34
37
params = json.loads(msg.body)
35
38
sources = params['source_packages']
36
39
ppa = params['ppa']
40
log.info('The PPA is: {}'.format(ppa))
37
41
trigger = params['progress_trigger']
38
42
amqp_utils.progress_update(trigger, params)
42
if amqp_utils.progress_completed(trigger):
43
log.error('Unable to notify progress-trigger completition of action')
45
# remove from queue so request becomes completed
46
msg.channel.basic_ack(msg.delivery_tag)
44
# TODO Replace these hardcoded parameters with params from the message
45
archive_ppa = 'ppa:ci-engineering-airline/ci-archive'
48
upload_list = upload_package.upload_source_packages(ppa, sources)
49
log.info('upload_list: {}'.format(upload_list))
50
start_time = time.time()
52
(ret, status) = watch_ppa.watch_ppa(start_time, series, ppa,
57
progress[key] = str(status[key])
58
log.info('progress: {}'.format(progress))
59
params['status'] = progress
60
amqp_utils.progress_update(trigger, params)
62
log.info('Going to sleep for {}'.format(TIME_BETWEEN_CHECKS))
63
time.sleep(TIME_BETWEEN_CHECKS)
68
if amqp_utils.progress_completed(trigger):
69
log.error('Unable to notify progress-trigger completition of action')
70
except EnvironmentError as e:
71
log.error('Exception: {}'.format(e))
73
# remove from queue so request becomes completed
74
log.info('Acking the request: {}'.format(msg.body))
75
msg.channel.basic_ack(msg.delivery_tag)
49
78
if __name__ == '__main__':