Skip to content

Commit

Permalink
Merge 5481339 into 4e4f011
Browse files Browse the repository at this point in the history
  • Loading branch information
david-caro committed Nov 21, 2017
2 parents 4e4f011 + 5481339 commit ae7affe
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions invenio_oaiharvester/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import os
import re
import tempfile
from contextlib import closing
from datetime import datetime

from flask import current_app
Expand Down Expand Up @@ -170,16 +171,16 @@ def create_file_name(output_dir):
"""
prefix = 'oaiharvest_' + datetime.now().strftime('%Y-%m-%d') + '_'

try:
temp = tempfile.NamedTemporaryFile(
with closing(
tempfile.NamedTemporaryFile(
prefix=prefix,
suffix='.xml',
dir=output_dir,
mode='w+'
)
) as temp:
file_name = temp.name[:]
finally:
temp.close()

return file_name


Expand Down

0 comments on commit ae7affe

Please sign in to comment.