I am hoping to get some insights on how to work with a function on Python. I had a working version of the script that is not great so I tried defining this function that I will use on a different file:
def controlfiles():
domain = f'domain'
if os.path.exists(domain):
with open(domain, 'r') as df:
domainoutput = df.readline()
else:
print("Could not load domain control file")
exit()
etc, etc. I open a couple more files and at the end I use:
values = [domainoutput, serveroutput, fflavoroutput, toflavoroutput, whooutput, date]
worksheet.append_row(values)
But I get:
values = [domainoutput, serveroutput, fflavoroutput, toflavoroutput, whooutput, date]
NameError: name 'domainoutput' is not defined
I am a total beginner at Python but I read that with open(file) was better than file=open()
Besides that I am trying to get the server time + 7 days in RF3339 to set up a Google Calendar Event, so far I have:
rtime = datetime.datetime.utcnow()
rtformatted = rtime.isoformat("T") + "Z"
Which works for the current time but not for 7 days in the future. I tried deltatime but could not get the right format. Any help is appreciated.