Browse Source

Various fixes in util.py

seed_v14
Johann Bauer 8 years ago
committed by ThomasV
parent
commit
d4d93b3928
  1. 15
      lib/util.py

15
lib/util.py

@ -27,14 +27,13 @@ from __future__ import unicode_literals
import binascii import binascii
import os, sys, re, json import os, sys, re, json
import platform
import shutil
from collections import defaultdict from collections import defaultdict
from datetime import datetime from datetime import datetime
from decimal import Decimal from decimal import Decimal
import traceback import traceback
import urllib import urllib
import threading import threading
from .i18n import _ from .i18n import _
import six import six
@ -601,7 +600,7 @@ def create_URI(addr, amount, message):
if amount: if amount:
query.append('amount=%s'%format_satoshis_plain(amount)) query.append('amount=%s'%format_satoshis_plain(amount))
if message: if message:
if type(message) == unicode: if six.PY2 and type(message) == unicode:
message = message.encode('utf8') message = message.encode('utf8')
query.append('message=%s'%urllib.quote(message)) query.append('message=%s'%urllib.quote(message))
p = urllib_parse.ParseResult(scheme='bitcoin', netloc='', path=addr, params='', query='&'.join(query), fragment='') p = urllib_parse.ParseResult(scheme='bitcoin', netloc='', path=addr, params='', query='&'.join(query), fragment='')
@ -726,14 +725,14 @@ class SocketPipe:
class QueuePipe: class QueuePipe:
def __init__(self, send_queue=None, get_queue=None): def __init__(self, send_queue=None, get_queue=None):
self.send_queue = send_queue if send_queue else Queue.Queue() self.send_queue = send_queue if send_queue else queue.Queue()
self.get_queue = get_queue if get_queue else Queue.Queue() self.get_queue = get_queue if get_queue else queue.Queue()
self.set_timeout(0.1) self.set_timeout(0.1)
def get(self): def get(self):
try: try:
return self.get_queue.get(timeout=self.timeout) return self.get_queue.get(timeout=self.timeout)
except Queue.Empty: except queue.Empty:
raise timeout raise timeout
def get_all(self): def get_all(self):
@ -742,7 +741,7 @@ class QueuePipe:
try: try:
r = self.get_queue.get_nowait() r = self.get_queue.get_nowait()
responses.append(r) responses.append(r)
except Queue.Empty: except queue.Empty:
break break
return responses return responses
@ -778,4 +777,4 @@ def check_www_dir(rdir):
path = os.path.join(rdir, filename) path = os.path.join(rdir, filename)
if not os.path.exists(path): if not os.path.exists(path):
print_error("downloading ", URL) print_error("downloading ", URL)
urllib.urlretrieve(URL, path) urllib.request.urlretrieve(URL, path)

Loading…
Cancel
Save