Commit 530c0e6e authored by Robin Fischer's avatar Robin Fischer

Improve logging

parent a4518974
......@@ -12,12 +12,13 @@ def log(text):
print(text, file=sys.stderr)
def shell(command, targetDir):
log("Shell: " + command)
p = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True, cwd=targetDir)
(output, err) = p.communicate()
p_status = p.wait()
print("Command exit status/return code : ", p_status)
log("Command exit status/return code : ", p_status)
decodedOutput = output.decode('utf-8')
print("Output: " + decodedOutput)
log("Output: " + decodedOutput)
return decodedOutput
parser = argparse.ArgumentParser(description="Generate and await http certbot validation")
......@@ -52,7 +53,7 @@ def writeValidationFile():
outPath = os.path.join(targetDir, fileName)
with open(outPath, 'w') as file:
file.write(filedata)
log("Template file written")
# Push changes to origin
def gitPush():
......@@ -82,18 +83,18 @@ def waitForPageChange():
doesSiteExist = False
url = "http://" + domain + "/.well-known/acme-challenge/" + token
print("url: " + url)
log("url: " + url)
while not doesSiteExist:
r = requests.get(url)
responseText = r.text.strip()
print("R: " + responseText + ", V: " + validation)
log("R: " + responseText + ", V: " + validation)
if responseText == validation:
doesSiteExist = True
else:
print("Page not found yet. Waiting...")
log("Page not found yet. Waiting...")
time.sleep(30)
print("Passed validation")
log("Passed validation")
writeValidationFile()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment