Fixing yaml loading warnings, checking if bill is already in nextcloud
This commit is contained in:
parent
f3c3fd231c
commit
4450c6e07d
@ -10,8 +10,8 @@ try:
|
|||||||
except NameError:
|
except NameError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
conf = yaml.load(open('creds.yml'))
|
conf = yaml.load(open('creds.yml'), Loader=yaml.SafeLoader)
|
||||||
user = conf['nextcloud']['username']
|
username = conf['nextcloud']['username']
|
||||||
password = conf['nextcloud']['password']
|
password = conf['nextcloud']['password']
|
||||||
client = ovh.Client()
|
client = ovh.Client()
|
||||||
bills = client.get('/me/bill')
|
bills = client.get('/me/bill')
|
||||||
@ -24,6 +24,17 @@ for bill in bills:
|
|||||||
f.write(r.content)
|
f.write(r.content)
|
||||||
f.close()
|
f.close()
|
||||||
url += bill + ".pdf"
|
url += bill + ".pdf"
|
||||||
|
with open('/dev/null','wb') as output:
|
||||||
|
c = pycurl.Curl()
|
||||||
|
c.setopt(c.URL, url)
|
||||||
|
c.setopt(c.USERPWD, '%s:%s' %(username, password))
|
||||||
|
c.setopt(c.CUSTOMREQUEST, 'PROPFIND')
|
||||||
|
c.setopt(c.WRITEDATA, output)
|
||||||
|
c.perform()
|
||||||
|
status = c.getinfo(c.RESPONSE_CODE)
|
||||||
|
c.close()
|
||||||
|
output.close()
|
||||||
|
if (status == 404):
|
||||||
file = open(file_path)
|
file = open(file_path)
|
||||||
c = pycurl.Curl()
|
c = pycurl.Curl()
|
||||||
c.setopt(c.URL, url)
|
c.setopt(c.URL, url)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user