浏览代码

Handle making Requests in Python 3.

Bentley James Oakes 7 年之前
父节点
当前提交
f86caf3d13
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      scripts/prompt.py

+ 6 - 4
scripts/prompt.py

@@ -47,8 +47,8 @@ except IndexError:
 
 # If task doesn't exist yet, we create it
 
-url = urlencode({"op": "set_input", "value": '"%s"' % taskname, "taskname": "task_manager"})
-urlopen(Request(address, url.encode())).read()
+data = urlencode({"op": "set_input", "value": '"%s"' % taskname, "taskname": "task_manager"})
+urlopen(Request(address, data.encode())).read()
 
 
 
@@ -60,7 +60,8 @@ local_print("To quit: execute command 'quit'")
 
 def print_output():
     while 1:
-        output = urlopen(Request(address, urlencode({"op": "get_output", "taskname": taskname}))).read()
+        data = urlencode({"op": "get_output", "taskname": taskname})
+        output = urlopen(Request(address, data.encode())).read()
         remote_print("%s" % str(json.loads(output)))
 
 thrd = threading.Thread(target=print_output)
@@ -126,4 +127,5 @@ while 1:
         else:
             command = '"%s"' % command
 
-        urlopen(Request(address, urlencode({"op": "set_input", "value": command, "taskname": taskname}))).read()
+        data = urlencode({"op": "set_input", "value": command, "taskname": taskname})
+        urlopen(Request(address, data.encode(qgit))).read()