Merged in [8209] from rjsparks@nostrum.com:\n Fixed several places where files were not being closed.

- Legacy-Id: 8315
Note: SVN reference [8209] has been migrated to Git commit 4aae3ff6785ca2649e54a212bd669369950f4b86
This commit is contained in:
Henrik Levkowetz 2014-09-16 19:48:30 +00:00
parent e661231b99
commit cbb5b84652
3 changed files with 8 additions and 2 deletions

View file

@ -3,6 +3,7 @@
import codecs
import datetime
from collections import OrderedDict
from contextlib import closing
from django.conf import settings
from django.http import Http404
@ -140,7 +141,7 @@ def fill_in_agenda_administrivia(date, sections):
for s, key, filename in extra_info_files:
try:
with codecs.open(filename, 'r', 'utf-8', 'replace') as f:
with closing(codecs.open(filename, 'r', 'utf-8', 'replace')) as f:
t = f.read().strip()
except IOError:
t = u"(Error reading %s)" % filename

View file

@ -35,7 +35,7 @@ def patent_file_search(url, q):
#print "*** Found file", fpath
file = codecs.open(fpath, mode='r', encoding='utf-8', errors='replace')
text = file.read()
file.close
file.close()
return q in text
return False

View file

@ -401,6 +401,7 @@ def convert_to_pdf(doc_name):
return
t,tempname = mkstemp()
os.close(t)
tempfile = open(tempname, "w")
pageend = 0;
@ -431,6 +432,7 @@ def convert_to_pdf(doc_name):
infile.close()
tempfile.close()
t,psname = mkstemp()
os.close(t)
pipe("enscript --margins 76::76: -B -q -p "+psname + " " +tempname)
os.unlink(tempname)
pipe("ps2pdf "+psname+" "+outpath)
@ -473,6 +475,7 @@ def session_draft_tarfile(request, num, session):
response['Content-Disposition'] = 'attachment; filename=%s-drafts.tgz'%(session)
tarstream = tarfile.open('','w:gz',response)
mfh, mfn = mkstemp()
os.close(mfh)
manifest = open(mfn, "w")
for doc_name in drafts:
@ -512,6 +515,7 @@ def session_draft_pdf(request, num, session):
drafts = session_draft_list(num, session);
curr_page = 1
pmh, pmn = mkstemp()
os.close(pmh)
pdfmarks = open(pmn, "w")
pdf_list = ""
@ -528,6 +532,7 @@ def session_draft_pdf(request, num, session):
pdfmarks.close()
pdfh, pdfn = mkstemp()
os.close(pdfh)
pipe("gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=" + pdfn + " " + pdf_list + " " + pmn)
pdf = open(pdfn,"r")