Skip to content

Commit

Permalink
updated to handle both python2 and python3
Browse files Browse the repository at this point in the history
  • Loading branch information
clmcavaney committed Oct 21, 2020
1 parent c7d3889 commit 35bbcd2
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions PVoutput/pvoutput.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import urllib
import httplib
# I think this would be better using the requests library - 20201021

pvo_host= "pvoutput.org"
# put in place for python2 vs python3 compatibility
import six
if six.PY2:
import urllib
elif six.PY3:
import urllib.parse as urllib

if six.PY2:
import httplib
elif six.PY3:
import http.client as httplib

pvo_host = "pvoutput.org"
pvo_statusInterval = 5 # Your PVoutput status interval - normally 5, 10 (default) or 15


Expand Down Expand Up @@ -136,7 +147,7 @@ def make_request(self, method, path, params=None):
try:
response = conn.getresponse()
except httplib.BadStatusLine as e:
print '%s: request failed - %s' % (self.__class__.__name__, e)
print('%s: request failed - %s' % (self.__class__.__name__, e))
response = False

return response

0 comments on commit 35bbcd2

Please sign in to comment.