Skip to content
Snippets Groups Projects

[internal #1848537] Upgrade scripts to use Python3

Merged József Gyürüsi requested to merge jgyrsi/titan.Libraries.CLL:master into master
1 file
+ 4
4
Compare changes
  • Side-by-side
  • Inline
@@ -32,7 +32,7 @@ class DsRestAPI:
@@ -32,7 +32,7 @@ class DsRestAPI:
'''
'''
if not isinstance(postdata, str):
if not isinstance(postdata, str):
postdata = json.dumps(postdata)
postdata = json.dumps(postdata)
req = urllib.request.Request(self.__url, postdata, {'Content-Type': 'application/json'})
req = urllib.request.Request(self.__url, postdata.encode(), {'Content-Type': 'application/json'})
req.add_header('Connection', 'close')
req.add_header('Connection', 'close')
req.get_method = lambda: method
req.get_method = lambda: method
try:
try:
@@ -166,11 +166,11 @@ def DsRestAPIPythonAPIMain(argv):
@@ -166,11 +166,11 @@ def DsRestAPIPythonAPIMain(argv):
f = open(fileName, 'r')
f = open(fileName, 'r')
request = json.load(f)
request = json.load(f)
f.close()
f.close()
print(api.getContentList(request))
print(api.getContentList(request).decode())
elif '-j' in argv:
elif '-j' in argv:
jsonString = argv[argv.index('-j') + 1]
jsonString = argv[argv.index('-j') + 1]
request = json.loads(jsonString)
request = json.loads(jsonString)
print(api.getContentList(request))
print(api.getContentList(request).decode())
else:
else:
requests = []
requests = []
request = {}
request = {}
@@ -222,4 +222,4 @@ if __name__ == "__main__":
@@ -222,4 +222,4 @@ if __name__ == "__main__":
errCode = DsRestAPIPythonAPIMain(sys.argv)
errCode = DsRestAPIPythonAPIMain(sys.argv)
except Exception as e:
except Exception as e:
print('Error while processing your request: ' + str(e))
print('Error while processing your request: ' + str(e))
sys.exit(errCode)
sys.exit(errCode)
\ No newline at end of file
Loading