Bugfix with tempfile

This commit is contained in:
Phyks 2014-04-26 18:40:32 +02:00
parent 6e6418fbad
commit 0c8e52844a
2 changed files with 9 additions and 7 deletions

View File

@ -100,9 +100,10 @@ Here are some sources of inspirations for this project :
A list of ideas and TODO. Don't hesitate to give feedback on the ones you really want or to propose your owns.
* if doi not found ? if no doi ?
* store url of articles
* if doi does not exist ?
* download djvu
* test file field for bibtex
* No fail if proxy not accessible
* Open
* Confirmation for deletion
* Rebuild

View File

@ -267,6 +267,7 @@ def addFile(src, filetype):
else:
# Idem
bibtex = isbn2Bib(isbn).strip()+"\n"
bibtex = checkBibtex(src, bibtex)
authors = re.split(' and ', bibtex['author'])
@ -352,13 +353,13 @@ def deleteFile(filename):
def downloadFile(url, filetype):
pdf = fetcher.download_url(url)
dl = fetcher.download_url(url)
if pdf is not False:
tmp = tempfile.NamedTemporaryFile()
if dl is not False:
tmp = tempfile.NamedTemporaryFile(suffix='.pdf')
with open(tmp.name, 'w+') as fh:
fh.write(pdf)
fh.write(dl)
new_name = addFile(tmp.name, filetype)
tmp.close()
return new_name