X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-dev.git/blobdiff_plain/66f2a7f0bd561c11302e9998caed0b34a4cbf4bb..1c9ac2563d5afefb47da45c352f4bdd25acf8635:/invirt-submit-build diff --git a/invirt-submit-build b/invirt-submit-build index caa949f..8175865 100755 --- a/invirt-submit-build +++ b/invirt-submit-build @@ -18,6 +18,7 @@ keeping. import datetime +import optparse import os import sys import tempfile @@ -27,7 +28,12 @@ import invirt.builder as b def main(): - pocket, package, commit = sys.argv[1:4] + parser = optparse.OptionParser('Usage: %prog pocket package commit') + opts, args = parser.parse_args() + if len(args) != 3: + parser.print_help() + return 1 + pocket, package, commit = args principal = os.environ['REMOTE_USER'] request_time = datetime.datetime.utcnow() q_path = os.path.join(b._QUEUE_DIR, @@ -35,7 +41,7 @@ def main(): uuid.uuid4())) try: - validateBuild(pocket, package, commit) + b.validateBuild(pocket, package, commit) except b.InvalidBuild, e: print >>sys.stderr, "E: %s" % e sys.exit(1) @@ -43,9 +49,11 @@ def main(): # To keep from triggering the Invirtibuilder before we've actually # written the file out, first write the queue entry to a temporary # file, and then move it into the queue directory. - q = tempfile.NamedTemporaryFile(delete=False) + q_fd, q_name = tempfile.mkstemp() + q = os.fdopen(q_fd, 'r+') print >>q, "%s %s %s %s" % (pocket, package, commit, principal) - os.rename(q.name, q_path) + q.close() + os.rename(q_name, q_path) if __name__ == '__main__':