Commit d657f452 by heffnercj

Logging now working in python3, except for --csv.

parent e4a5254d
import io
import sys import sys
import hashlib import hashlib
import csv as pycsv import csv as pycsv
...@@ -62,7 +63,7 @@ class PrettyPrint: ...@@ -62,7 +63,7 @@ class PrettyPrint:
self.enable_formatting(True) self.enable_formatting(True)
if self.log is not None: if self.log is not None:
self.fp = open(log, "w") self.fp = io.FileIO(log, "w")
if self.log_csv: if self.log_csv:
self.enable_csv() self.enable_csv()
...@@ -107,7 +108,7 @@ class PrettyPrint: ...@@ -107,7 +108,7 @@ class PrettyPrint:
self.csv.writerow(data_parts) self.csv.writerow(data_parts)
else: else:
self.fp.write(data) self.fp.write(str2bytes(data))
def _pprint(self, data, nolog=False, noprint=False): def _pprint(self, data, nolog=False, noprint=False):
''' '''
...@@ -222,7 +223,7 @@ class PrettyPrint: ...@@ -222,7 +223,7 @@ class PrettyPrint:
if self.csv: if self.csv:
nolog = True nolog = True
self.csv.writerow(["FILE", "MD5SUM", "TIMESTAMP"]) self.csv.writerow([b"FILE", b"MD5SUM", b"TIMESTAMP"])
self.csv.writerow([file_name, md5sum, timestamp]) self.csv.writerow([file_name, md5sum, timestamp])
self._pprint("\n") self._pprint("\n")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment