Skip to content

Commit 2d50e7d

Browse files
committed
Fix issue ietf-tools#355: module tarfile's .add() needs a string name (not unicode) on the production server (Python 2.5.1).
- Legacy-Id: 2465
1 parent 36bb34d commit 2d50e7d

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

ietf/iesg/views.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,19 +297,31 @@ def agenda_documents(request):
297297
telechats.append({'date':date, 'docs':res})
298298
return direct_to_template(request, 'iesg/agenda_documents.html', {'telechats':telechats, 'hide_telechat_date':True})
299299

300-
def agenda_downloaddocstgz(request,year,month,day):
300+
def telechat_docs_tarfile(request,year,month,day):
301+
from tempfile import mkstemp
301302
date=datetime.date(int(year),int(month),int(day))
302303
docs= IDInternal.objects.filter(telechat_date=date, primary_flag=1, agenda=1)
303304
response = HttpResponse(mimetype='application/octet-stream')
304305
response['Content-Disposition'] = 'attachment; filename=telechat-%s-%s-%s-docs.tgz'%(year, month, day)
305306
tarstream = tarfile.open('','w:gz',response)
307+
mfh, mfn = mkstemp()
308+
manifest = open(mfn, "w")
306309
for doc in docs:
307-
tarstream.add(os.path.join(settings.INTERNET_DRAFT_PATH, doc.draft.filename+"-"+doc.draft.revision_display()+".txt"),
308-
doc.draft.filename+"-"+doc.draft.revision_display()+".txt")
310+
doc_path = os.path.join(settings.INTERNET_DRAFT_PATH, doc.draft.filename+"-"+doc.draft.revision_display()+".txt")
311+
if os.path.exists(doc_path):
312+
try:
313+
tarstream.add(doc_path, str(doc.draft.filename+"-"+doc.draft.revision_display()+".txt"))
314+
manifest.write("Included: "+doc_path+"\n")
315+
except Exception, e:
316+
manifest.write(("Failed (%s): "%e)+doc_path+"\n")
317+
else:
318+
manifest.write("Not found: "+doc_path+"\n")
319+
manifest.close()
320+
tarstream.add(mfn, "manifest.txt")
309321
tarstream.close()
322+
os.unlink(mfn)
310323
return response
311324

312-
313325
def discusses(request):
314326
positions = Position.objects.filter(discuss=1)
315327
res = []

0 commit comments

Comments
 (0)