From 6c4501b3431bf8b389480a28356d069f04842979 Mon Sep 17 00:00:00 2001 From: Christopher McAvaney Date: Wed, 21 Oct 2020 15:55:58 +1100 Subject: [PATCH] updated to be portable for python2 and python3 --- SolarmanPV-to-PVoutput.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/SolarmanPV-to-PVoutput.py b/SolarmanPV-to-PVoutput.py index 53cbc30..4d48723 100755 --- a/SolarmanPV-to-PVoutput.py +++ b/SolarmanPV-to-PVoutput.py @@ -51,7 +51,7 @@ args = parser.parse_args() if args.debug: - print "debug turned on" + print("debug turned on") debug = True client_id = args.smpv_client_id @@ -64,7 +64,7 @@ smpv = SolarmanPVAPI(client_id, client_secret, plant_id) smpv.setDebug(debug) if smpv.connected is not True: - print 'An issue with connection to the SolarmanPV API' + print('An issue with connection to the SolarmanPV API') sys.exit(1) power_details = smpv.getPower(datetime.date.today().strftime("%Y-%m-%d"), True) @@ -90,10 +90,10 @@ else: DEBUG('no need to update - power %dW' % power) except: - print 'An error with PVoutput ', sys.exc_info()[0] + print('An error with PVoutput ', sys.exc_info()[0]) raise else: - print 'Invalid data from SolarmanPV API - no further action' + print('Invalid data from SolarmanPV API - no further action') # temporary exit, looking to include voltage and current data - but need to find out why the current day data doesn't come back through the API sys.exit(5) @@ -117,21 +117,21 @@ Temperature = str(current['TKK']) Voltage = str(current['UL1']) - print "Date: " + str(powerdate) + " Time: " + str( - powerTime) + " W: " + PowerGeneration + " temp: " + Temperature + " volt: " + Voltage + print("Date: " + str(powerdate) + " Time: " + str( + powerTime) + " W: " + PowerGeneration + " temp: " + Temperature + " volt: " + Voltage) # update pvoutput if (PowerGeneration): # make sure that we have actual values... pvoutz.add_status(powerdate, powerTime, power_exp=PowerGeneration, temp=Temperature, vdc=Voltage) - print "Sucessful Log " + print("Sucessful Log ") #Ensure API limits adhered to time.sleep(apiDelay) else: - print "aint no data bitch.. make the sun come up" + print("aint no data bitch.. make the sun come up") count += 1 except: - print 'Communication Error, WR %i' % no + print('Communication Error, WR %i' % no) continue #(status, errors) = sm.status(count) @@ -143,8 +143,8 @@ # pass if count < len(allinverters): - print 'Not all inverters queried (%i < %i)' % (count, len(allinverters)) + print('Not all inverters queried (%i < %i)' % (count, len(allinverters))) -print "Data Succesfully query and posted." +print("Data Succesfully query and posted.") time.sleep(1)