Merge branch 'master' into 'master'

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

See merge request agenda-libre/agenda-libre-ruby!20
This commit is contained in:
echarp 2018-11-08 21:29:27 +01:00
commit 567edd008e

View File

@ -369,17 +369,12 @@ def SubmitEvent(event, testOutputFile):
finally:
curl.close()
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
# script
contents = io.BytesIO()
curl = pycurl.Curl()
try:
def ensure_latest_version_is_used():
# Check that we are running the latest version of the adl-submit
# script
contents = io.BytesIO()
curl = pycurl.Curl()
try:
curl.setopt(curl.WRITEDATA, contents)
curl.setopt (curl.URL, baseUrl + './adl-submit-latest-version')
curl.perform()
@ -389,8 +384,18 @@ try:
print("Votre script n'est plus à jour, merci de télécharger la nouvelle version à l'adresse")
print(("%sadl-submit.py") % baseUrl)
sys.exit(1)
finally:
finally:
curl.close()
SubmitEvent(event, testOutputFile)
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)