source: trunk/packages/invirt-dev/invirt-submit-build @ 2939

Last change on this file since 2939 was 2639, checked in by broder, 15 years ago

Fix a typo in invirt-submit-build.

  • Property svn:executable set to *
File size: 1.4 KB
RevLine 
[2563]1#!/usr/bin/python
2
3"""Validate and add a new item to the Invirt build queue.
4
5This script, intended to be invoked by remctl, first validates the
6build submitted parameters, and then adds a new item to the
7Invirtibuilder build queue, triggering the Invirtibuilder to start the
8build.
9
10The expected arguments are
11
12  pocket package commit
13
14This script will also automatically extract the Kerberos principal
15used to submit the job, and include that in the queue file for records
16keeping.
17"""
18
19
20import datetime
21import os
22import sys
23import tempfile
24import uuid
25
26import invirt.builder as b
27
28
29def main():
30    pocket, package, commit = sys.argv[1:4]
31    principal = os.environ['REMOTE_USER']
32    request_time = datetime.datetime.utcnow()
33    q_path = os.path.join(b._QUEUE_DIR,
34                          '%s_%s' % (request_time.strftime('%Y%m%d%H%M%S'),
35                                     uuid.uuid4()))
36
37    try:
[2639]38        b.validateBuild(pocket, package, commit)
[2563]39    except b.InvalidBuild, e:
40        print >>sys.stderr, "E: %s" % e
41        sys.exit(1)
42
43    # To keep from triggering the Invirtibuilder before we've actually
44    # written the file out, first write the queue entry to a temporary
45    # file, and then move it into the queue directory.
[2567]46    q_fd, q_name = tempfile.mkstemp()
[2569]47    q = os.fdopen(q_fd, 'r+')
[2563]48    print >>q, "%s %s %s %s" % (pocket, package, commit, principal)
[2567]49    os.rename(q_name, q_path)
[2563]50
51
52if __name__ == '__main__':
53    main()
Note: See TracBrowser for help on using the repository browser.