Rework adl-submit.py so it can be used as a library

This commit is contained in:
Florent Fayolle 2018-11-08 21:23:28 +01:00
parent 68c8287d2f
commit 7c6fa54271

View File

@ -369,12 +369,7 @@ def SubmitEvent(event, testOutputFile):
finally: finally:
curl.close() curl.close()
def ensure_latest_version_is_used():
if (len(sys.argv) <= 1) or sys.argv[1] == "--help":
Usage()
(event, testOutputFile) = ParseOptions(sys.argv[1:])
# Check that we are running the latest version of the adl-submit # Check that we are running the latest version of the adl-submit
# script # script
contents = io.BytesIO() contents = io.BytesIO()
@ -392,5 +387,15 @@ try:
finally: finally:
curl.close() curl.close()
if __name__ == "__main__":
if (len(sys.argv) <= 1) or sys.argv[1] == "--help":
Usage()
(event, testOutputFile) = ParseOptions(sys.argv[1:])
ensure_latest_version_is_used()
SubmitEvent(event, testOutputFile) SubmitEvent(event, testOutputFile)