updated settext to py3

This commit is contained in:
Michael Murtaugh 2018-09-07 10:34:53 +02:00
parent 59de1fa7ca
commit 4a8219b48c

View File

@ -1,8 +1,16 @@
from __future__ import print_function
from argparse import ArgumentParser
import json, sys
from urllib import urlencode
from urllib2 import urlopen, HTTPError, URLError
try:
# python2
from urllib2 import urlopen, URLError, HTTPError
from urllib import urlencode
except ImportError:
# python3
from urllib.parse import urlencode, quote
from urllib.request import urlopen, URLError, HTTPError
import requests
@ -56,5 +64,5 @@ def main(args):
results = requests.post(requesturl, params=data) # json.load(urlopen(requesturl))
results = json.loads(results.text)
if results['code'] != 0:
print (u"setText: ERROR ({0}) on pad {1}: {2}".format(results['code'], args.padid, results['message']).encode("utf-8"))
print ("setText: ERROR ({0}) on pad {1}: {2}".format(results['code'], args.padid, results['message']))
# json.dumps(results, indent=2)