content_type = data_file.file_type.mimetype
if os.path.exists(data_file.pathname):
- return HttpResponse(open(data_file.pathname,'r'),
+ return HttpResponse(open(data_file.pathname,'rb'),
content_type=content_type)
raise Http404
self._reads = 0
for pathname in self.pathnames:
- stream = autoopen(pathname, 'r')
+ stream = autoopen(pathname, 'rt')
if self.eland_type == ELAND_SINGLE:
result = self._update_eland_result(stream)
elif self.eland_type == ELAND_MULTI or \
"""
Determine if we have a scarf or fastq sequence file
"""
- f = open(pathname,'r')
+ f = open(pathname,'rt')
l = f.readline()
f.close()
LOGGER.info("summarizing results for %s" % (pathname))
lines = 0
- f = open(pathname)
- for l in f.xreadlines():
+ f = open(pathname, 'rt')
+ for l in f:
lines += 1
f.close()
self.daf = daf_file.read()
else:
# file
- stream = open(daf_file, 'r')
+ stream = open(daf_file, 'rt')
self.daf = stream.read()
stream.close()
md5_cache = os.path.join(filename+".md5")
if os.path.exists(md5_cache):
logger.debug("Found md5sum in {0}".format(md5_cache))
- stream = open(md5_cache,'r')
+ stream = open(md5_cache,'rt')
lines = stream.readlines()
md5sum = parse_md5sum_line(lines, filename)
else:
md5sum = parse_md5sum_line(lines, filename)
if md5sum is not None:
logger.debug("Caching sum in {0}".format(md5_cache))
- stream = open(md5_cache, "w")
- stream.write(stdin)
+ stream = open(md5_cache, "wt")
+ stream.write(smart_text(stdin))
stream.close()
return md5sum
def parse_md5sum_line(lines, filename):
- md5sum, md5sum_filename = lines[0].split()
+ md5sum, md5sum_filename = smart_text(lines[0]).split()
md5sum_filename = os.path.basename(md5sum_filename)
filename = os.path.basename(filename)
if md5sum_filename != filename:
for path in schema_path:
for pathname in glob(os.path.join(path, '*.turtle')):
url = 'file://' + os.path.splitext(pathname)[0]
- stream = open(pathname, 'r')
+ stream = open(pathname, 'rt')
add_schema(model, stream, url)
stream.close()