diff --git a/cms50dplus/cms50dplus.py b/cms50dplus/cms50dplus.py index 82e2920..b77876f 100755 --- a/cms50dplus/cms50dplus.py +++ b/cms50dplus/cms50dplus.py @@ -111,7 +111,7 @@ def getDictData(self): class RecordedDataPoint(object): def __init__(self, time, data): if data[0] & 0xfe != 0xf0 or data[1] & 0x80 == 0 or data[2] & 0x80 != 0: - print data + print(data) raise ValueError("Invalid data packet.") self.time = time @@ -266,7 +266,7 @@ def getRecordedData(self, time): m = int(s / 60) s -= m * 60 - print "Number of measurements: {0} ({1}h{2}m{3}s)".format(length / 3, h, m, s) + print("Number of measurements: {0} ({1}h{2}m{3}s)".format(length / 3, h, m, s)) # Content... packet = [0]*3 @@ -285,11 +285,11 @@ def getRecordedData(self, time): self.disconnect() def dumpLiveData(port, filename): - print "Saving live data..." - print "Press CTRL-C or disconnect the device to terminate data collection." + print("Saving live data...") + print("Press CTRL-C or disconnect the device to terminate data collection.") oximeter = CMS50Dplus(port) measurements = 0 - with open(filename, 'wb') as csvfile: + with open(filename, 'w') as csvfile: writer = csv.writer(csvfile, quoting=csv.QUOTE_NONNUMERIC) writer.writerow(LiveDataPoint.getCsvColumns()) for liveData in oximeter.getLiveData(): @@ -307,11 +307,11 @@ def getLiveData(port, framerate=None): def dumpRecordedData(starttime, port, filename): - print "Saving recorded data..." - print "Please wait as the latest session is downloaded..." + print("Saving recorded data...") + print("Please wait as the latest session is downloaded...") oximeter = CMS50Dplus(port) measurements = 0 - with open(filename, 'wb') as csvfile: + with open(filename, 'w') as csvfile: writer = csv.writer(csvfile, quoting=csv.QUOTE_NONNUMERIC) writer.writerow(RecordedDataPoint.getCsvColumns()) for recordedData in oximeter.getRecordedData(starttime): @@ -341,7 +341,7 @@ def valid_datetime(s): elif args.mode == 'RECORDED' and args.starttime is not None: dumpRecordedData(args.starttime, args.serialport, args.output) else: - print "Missing start time for RECORDED mode." + print("Missing start time for RECORDED mode.") - print "" - print "Done." \ No newline at end of file + print("") + print("Done.")