Compare commits
No commits in common. "c17318aea4e3d33f36369867a90f976be1cb1c9b" and "f3c3fd231c17d01c801b8f2639ffa8f51a5d1c05" have entirely different histories.
c17318aea4
...
f3c3fd231c
46
ovh-bills.py
46
ovh-bills.py
@ -1,46 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import requests
|
||||
import ovh
|
||||
import pycurl
|
||||
import yaml
|
||||
|
||||
try:
|
||||
input = raw_input
|
||||
except NameError:
|
||||
pass
|
||||
|
||||
conf = yaml.load(open('creds.yml'), Loader=yaml.SafeLoader)
|
||||
username = conf['nextcloud']['username']
|
||||
password = conf['nextcloud']['password']
|
||||
client = ovh.Client()
|
||||
bills = client.get('/me/bill')
|
||||
for bill in bills:
|
||||
url = conf['nextcloud']['url_factures']
|
||||
details = client.get('/me/bill/%s' % bill)
|
||||
r = requests.get(details['pdfUrl'], stream=True)
|
||||
file_path = "/tmp/" + bill + ".pdf"
|
||||
with open(file_path, 'wb') as f:
|
||||
f.write(r.content)
|
||||
f.close()
|
||||
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)
|
||||
c = pycurl.Curl()
|
||||
c.setopt(c.URL, url)
|
||||
c.setopt(c.USERPWD, '%s:%s' %(username, password))
|
||||
c.setopt(c.UPLOAD, 1)
|
||||
c.setopt(c.READDATA, file)
|
||||
c.perform()
|
||||
c.close()
|
||||
file.close()
|
||||
35
ovh-factures.py
Executable file
35
ovh-factures.py
Executable file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import requests
|
||||
import ovh
|
||||
import pycurl
|
||||
import yaml
|
||||
|
||||
try:
|
||||
input = raw_input
|
||||
except NameError:
|
||||
pass
|
||||
|
||||
conf = yaml.load(open('creds.yml'))
|
||||
user = conf['nextcloud']['username']
|
||||
password = conf['nextcloud']['password']
|
||||
client = ovh.Client()
|
||||
bills = client.get('/me/bill')
|
||||
for bill in bills:
|
||||
url = conf['nextcloud']['url_factures']
|
||||
details = client.get('/me/bill/%s' % bill)
|
||||
r = requests.get(details['pdfUrl'], stream=True)
|
||||
file_path = "/tmp/" + bill + ".pdf"
|
||||
with open(file_path, 'wb') as f:
|
||||
f.write(r.content)
|
||||
f.close()
|
||||
url += bill + ".pdf"
|
||||
file = open(file_path)
|
||||
c = pycurl.Curl()
|
||||
c.setopt(c.URL, url)
|
||||
c.setopt(c.USERPWD, '%s:%s' %(username, password))
|
||||
c.setopt(c.UPLOAD, 1)
|
||||
c.setopt(c.READDATA, file)
|
||||
c.perform()
|
||||
c.close()
|
||||
file.close()
|
||||
Loading…
x
Reference in New Issue
Block a user