1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-23 04:54:18 +00:00

- Force UTF-8 printing to terminal

This commit is contained in:
Christophe Dumez 2009-03-27 14:34:30 +00:00
parent 1cc039c147
commit e8454596ea
2 changed files with 17 additions and 10 deletions

View File

@ -100,16 +100,15 @@ if __name__ == '__main__':
what = '+'.join(sys.argv[2:]) what = '+'.join(sys.argv[2:])
threads = [] threads = []
for engine in engines_list: for engine in engines_list:
if 1: try:
#try:
if THREADED: if THREADED:
exec "l = EngineLauncher(%s(), what)" % engine exec "l = EngineLauncher(%s(), what)" % engine
threads.append(l) threads.append(l)
l.start() l.start()
else: else:
engine().search(what) engine().search(what)
#except: except:
# pass pass
if THREADED: if THREADED:
for t in threads: for t in threads:
t.join() t.join()

View File

@ -1,4 +1,4 @@
#VERSION: 1.2 #VERSION: 1.3
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:
@ -24,13 +24,21 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
import sys
# Force UTF-8 printing
from ctypes import pythonapi, py_object, c_char_p
PyFile_SetEncoding = pythonapi.PyFile_SetEncoding
PyFile_SetEncoding.argtypes = (py_object, c_char_p)
PyFile_SetEncoding(sys.stdout, "UTF-8")
def prettyPrinter(dictionnary): def prettyPrinter(dictionnary):
if isinstance(dictionnary['size'], str): # Convert everything to unicode for safe printing
dictionnary['size'] = dictionnary['size'].decode('utf-8') for key,value in dictionnary.items():
if isinstance(dictionnary[key], str):
dictionnary[key] = unicode(dictionnary[key], 'utf-8')
dictionnary['size'] = anySizeToBytes(dictionnary['size']) dictionnary['size'] = anySizeToBytes(dictionnary['size'])
if isinstance(dictionnary['name'], unicode): print u"%s|%s|%s|%s|%s|%s"%(dictionnary['link'],dictionnary['name'],dictionnary['size'],dictionnary['seeds'],dictionnary['leech'],dictionnary['engine_url'])
dictionnary['name'] = dictionnary['name'].encode('utf-8')
print dictionnary['link'],'|',dictionnary['name'],'|',dictionnary['size'],'|',dictionnary['seeds'],'|',dictionnary['leech'],'|',dictionnary['engine_url']
def anySizeToBytes(size_string): def anySizeToBytes(size_string):
""" """