Using simplejson and fixed some encodes and decodes

This commit is contained in:
hackrush 2018-07-21 22:42:23 +05:30 committed by Jack Robison
parent 0fbf131df3
commit c01716a6c0
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
26 changed files with 29 additions and 27 deletions

View file

@ -1,5 +1,5 @@
import glob
import json
import simplejson as json
import os
import subprocess
import sys

View file

@ -1,5 +1,5 @@
import base58
import json
import simplejson as json
import logging
import os
import re

View file

@ -1,6 +1,6 @@
import binascii
from collections import defaultdict
import json
import simplejson as json
import logging
from twisted.internet import threads, defer

View file

@ -1,4 +1,4 @@
import json
import simplejson as json
import logging
from decimal import Decimal
from twisted.internet import error, defer

View file

@ -1,4 +1,4 @@
import json
import simplejson as json
import logging
from twisted.internet import defer

View file

@ -1,7 +1,7 @@
from __future__ import print_function
import platform
import json
import simplejson as json
import subprocess
import os

View file

@ -4,7 +4,7 @@ import datetime
import random
import socket
import string
import json
import simplejson as json
import traceback
import functools
import logging

View file

@ -3,7 +3,7 @@ import mimetypes
import os
import requests
import urllib
import json
import simplejson as json
import textwrap
import signal
from binascii import hexlify, unhexlify, b2a_hex

View file

@ -1,4 +1,4 @@
import json
import simplejson as json
import os
import sys
import colorama

View file

@ -1,6 +1,6 @@
import time
import logging
import json
import simplejson as json
import treq
from twisted.internet import defer

View file

@ -1,5 +1,5 @@
import os
import json
import simplejson as json
import urlparse
import requests
from requests.cookies import RequestsCookieJar

View file

@ -1,6 +1,6 @@
import logging
from six.moves.urllib import parse as urlparse
import json
import simplejson as json
import inspect
import signal

View file

@ -3,7 +3,7 @@ import hmac
import hashlib
import yaml
import os
import json
import simplejson as json
import logging
log = logging.getLogger(__name__)

View file

@ -1,6 +1,6 @@
import sqlite3
import os
import json
import simplejson as json
import logging
from lbryschema.decode import smart_decode
from lbrynet import conf

View file

@ -268,7 +268,7 @@ class SQLiteStorage(WalletDatabase):
blob_hashes = yield self.run_and_return_list(
"select blob_hash from blob where status='finished'"
)
defer.returnValue([blob_hash.decode('hex') for blob_hash in blob_hashes])
defer.returnValue([bytes.fromhex(blob_hash).decode('latin-1') for blob_hash in blob_hashes])
def count_finished_blobs(self):
return self.run_and_return_one_or_none(
@ -492,7 +492,8 @@ class SQLiteStorage(WalletDatabase):
@defer.inlineCallbacks
def save_downloaded_file(self, stream_hash, file_name, download_directory, data_payment_rate):
# touch the closest available file to the file name
file_name = yield open_file_for_writing(download_directory.decode('hex'), file_name.decode('hex'))
file_name = yield open_file_for_writing(bytes.fromhex(download_directory).decode(),
bytes.fromhex(file_name).decode())
result = yield self.save_published_file(
stream_hash, file_name.encode('hex'), download_directory, data_payment_rate
)

View file

@ -181,7 +181,7 @@ class EncryptedFileSaver(EncryptedFileDownloader):
class EncryptedFileSaverFactory(EncryptedFileDownloaderFactory):
def __init__(self, peer_finder, rate_limiter, blob_manager, storage, wallet, download_directory):
EncryptedFileDownloaderFactory.__init__(self, peer_finder, rate_limiter, blob_manager, storage, wallet)
self.download_directory = binascii.hexlify(download_directory)
self.download_directory = binascii.hexlify(download_directory.encode())
def _make_downloader(self, stream_hash, payment_rate_manager, stream_info):
stream_name = stream_info.raw_info['stream_name']

View file

@ -1,4 +1,4 @@
import json
import simplejson as json
import logging
from twisted.protocols.basic import FileSender

View file

@ -1,4 +1,4 @@
import json
import simplejson as json
import logging
from twisted.internet.error import ConnectionRefusedError

View file

@ -1,5 +1,5 @@
import logging
import json
import simplejson as json
from twisted.python import failure
from twisted.internet import error, defer
from twisted.internet.protocol import Protocol, ServerFactory

View file

@ -1,7 +1,7 @@
"""A test script that downloads blobs from a reflector server"""
import argparse
import itertools
import json
import simplejson as json
import random
import subprocess
import sys

View file

@ -1,6 +1,6 @@
import argparse
import hashlib
import json
import simplejson as json
import subprocess
import sys

View file

@ -7,7 +7,7 @@ the new blobs to the manager.
import argparse
import binascii
import logging
import json
import simplejson as json
import os
import sys

View file

@ -1,5 +1,5 @@
import struct
import json
import simplejson as json
import logging
import argparse
import hashlib

View file

@ -35,7 +35,8 @@ requires = [
'colorama==0.3.7',
'six',
'pyopenssl',
'service-identity'
'service-identity',
'simplejson'
]
console_scripts = [

View file

@ -1,5 +1,5 @@
import mock
import json
import simplejson as json
import random
from os import path

View file

@ -1,5 +1,5 @@
import os
import json
import simplejson as json
import sys
import tempfile
from unittest import skipIf