move settings into conf file

This commit is contained in:
Job Evers-Meltzer 2016-10-27 14:18:25 -05:00
parent 7076c0c870
commit 862055a6de
33 changed files with 39 additions and 38 deletions

View file

@ -1,13 +1,6 @@
import logging
from conf import Config
__version__ = "0.6.9"
version = tuple(__version__.split('.'))
# TODO: don't load the configuration automatically. The configuration
# should be loaded at runtime, not at module import time. Module
# import should have no side-effects. This is also bad because
# it means that settings are read from the environment even for
# tests, which is rarely what you want to happen.
settings = Config()
logging.getLogger(__name__).addHandler(logging.NullHandler())

View file

@ -5,7 +5,7 @@ import logging
from requests import auth
from requests_futures import sessions
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.analytics import utils

View file

@ -226,3 +226,11 @@ class Config(DefaultSettings):
@property
def UI_ADDRESS(self):
return "http://%s:%i" % (DEFAULT_SETTINGS.API_INTERFACE, self.api_port)
# TODO: don't load the configuration automatically. The configuration
# should be loaded at runtime, not at module import time. Module
# import should have no side-effects. This is also bad because
# it means that settings are read from the environment even for
# tests, which is rarely what you want to happen.
settings = Config()

View file

@ -8,7 +8,7 @@ from twisted.internet import interfaces, defer, threads
from twisted.protocols.basic import FileSender
from twisted.python.failure import Failure
from zope.interface import implements
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.core.Error import DownloadCanceledError, InvalidDataError
from lbrynet.core.cryptoutils import get_lbry_hash_obj

View file

@ -1,5 +1,5 @@
from lbrynet.core.Strategy import get_default_strategy
from lbrynet import settings
from lbrynet.conf import settings
from decimal import Decimal

View file

@ -2,7 +2,7 @@ from zope.interface import implementer
from decimal import Decimal
from lbrynet.interfaces import IBlobPriceModel
from lbrynet import settings
from lbrynet.conf import settings
def get_default_price_model(blob_tracker, base_price, **kwargs):

View file

@ -1,6 +1,6 @@
from zope.interface import implementer
from decimal import Decimal
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.interfaces import INegotiationStrategy
from lbrynet.core.Offer import Offer
from lbrynet.core.PriceModel import MeanAvailabilityWeightedPrice

View file

@ -4,7 +4,7 @@ from decimal import Decimal
from twisted.internet import error, defer
from twisted.internet.protocol import Protocol, ClientFactory
from twisted.python import failure
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.core.Error import ConnectionClosedBeforeResponseError, NoResponseError
from lbrynet.core.Error import DownloadCanceledError, MisbehavingPeerError
from lbrynet.core.Error import RequestCanceledError

View file

@ -1,4 +1,4 @@
from lbrynet import settings
from lbrynet.conf import settings
class ClientRequest(object):

View file

@ -2,7 +2,7 @@ import logging
from twisted.internet import defer
from zope.interface import implements
from lbrynet import interfaces
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.core.client.ClientProtocol import ClientProtocolFactory
from lbrynet.core.Error import InsufficientFundsError

View file

@ -7,7 +7,7 @@ import traceback
from requests_futures.sessions import FuturesSession
import lbrynet
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.core import utils
session = FuturesSession()

View file

@ -8,7 +8,7 @@ import os
import socket
import yaml
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.conf import AdjustableSettings
from lbrynet.core.cryptoutils import get_lbry_hash_obj

View file

@ -1,7 +1,7 @@
import binascii
import logging
from Crypto.Cipher import AES
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.core.BlobInfo import BlobInfo

View file

@ -7,7 +7,7 @@ import logging
import os
from lbrynet.core.StreamDescriptor import PlainStreamDescriptorWriter
from lbrynet.cryptstream.CryptStreamCreator import CryptStreamCreator
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.lbryfile.StreamDescriptor import get_sd_info
from lbrynet.core.cryptoutils import get_lbry_hash_obj
from twisted.protocols.basic import FileSender

View file

@ -6,7 +6,7 @@ from lbrynet.core.cryptoutils import get_lbry_hash_obj, get_pub_key, sign_with_p
from Crypto import Random
import binascii
import logging
from lbrynet import settings
from lbrynet.conf import settings
from twisted.internet import interfaces, defer
from twisted.protocols.basic import FileSender
from zope.interface import implements

View file

@ -3,7 +3,7 @@ import logging
from zope.interface import implements
from twisted.internet import defer
from twisted.python.failure import Failure
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.core.client.ClientRequest import ClientRequest, ClientPaidRequest
from lbrynet.lbrylive.LiveBlob import LiveBlobInfo
from lbrynet.core.cryptoutils import get_lbry_hash_obj, verify_signature

View file

@ -19,7 +19,7 @@ from lbrynet.core.Session import Session
from lbrynet.lbrynet_console.ConsoleControl import ConsoleControl
from lbrynet.lbrynet_console.Settings import Settings
from lbrynet.lbryfilemanager.EncryptedFileManager import EncryptedFileManager
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.core.utils import generate_id
from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier
from lbrynet.core.PaymentRateManager import PaymentRateManager

View file

@ -1,6 +1,6 @@
from lbrynet.lbrynet_console import Plugin
from twisted.internet import defer
from lbrynet import settings
from lbrynet.conf import settings
from BlindRepeater import BlindRepeater
from BlindInfoManager import BlindInfoManager
from BlindRepeaterSettings import BlindRepeaterSettings

View file

@ -26,7 +26,7 @@ from lbrynet import __version__ as lbrynet_version
from lbryum.version import LBRYUM_VERSION as lbryum_version
from lbrynet import __version__ as lbrynet_version
from lbrynet import settings as lbrynet_settings
from lbrynet.conf import settings as lbrynet_settings
from lbrynet import analytics
from lbrynet import reflector
from lbrynet.metadata.Metadata import Metadata, verify_name_characters

View file

@ -2,7 +2,7 @@ import sys
import json
import argparse
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.lbrynet_daemon.auth.client import LBRYAPIClient
help_msg = "Usage: lbrynet-cli method json-args\n" \

View file

@ -16,7 +16,7 @@ from lbrynet.core import log_support
from lbrynet.core import utils
from lbrynet.lbrynet_daemon.DaemonServer import DaemonServer
from lbrynet.lbrynet_daemon.DaemonRequest import DaemonRequest
from lbrynet import settings
from lbrynet.conf import settings
log_dir = settings.data_dir

View file

@ -6,7 +6,7 @@ from appdirs import user_data_dir
from twisted.internet import defer
from lbrynet.lbrynet_daemon.Daemon import Daemon
from lbrynet.lbrynet_daemon.Resources import LBRYindex, HostedEncryptedFile, EncryptedFileUpload
from lbrynet import settings
from lbrynet.conf import settings
# TODO: omg, this code is essentially duplicated in Daemon

View file

@ -12,7 +12,7 @@ from lbrynet.core.Error import InsufficientFundsError, KeyFeeAboveMaxAllowed
from lbrynet.core.StreamDescriptor import download_sd_blob
from lbrynet.metadata.Fee import FeeValidator
from lbrynet.lbryfilemanager.EncryptedFileDownloader import ManagedEncryptedFileDownloaderFactory
from lbrynet import settings
from lbrynet.conf import settings
INITIALIZING_CODE = 'initializing'
DOWNLOAD_METADATA_CODE = 'downloading_metadata'

View file

@ -1,7 +1,7 @@
import logging
import random
from txjsonrpc.web.jsonrpc import Proxy
from lbrynet import settings
from lbrynet.conf import settings
log = logging.getLogger(__name__)

View file

@ -12,7 +12,7 @@ from lbrynet.lbryfile.StreamDescriptor import publish_sd_blob
from lbrynet.metadata.Metadata import Metadata
from lbrynet.lbryfilemanager.EncryptedFileDownloader import ManagedEncryptedFileDownloader
from lbrynet import reflector
from lbrynet import settings
from lbrynet.conf import settings
from twisted.internet import threads, defer, reactor
if sys.platform != "darwin":

View file

@ -10,7 +10,7 @@ from appdirs import user_data_dir
from twisted.web import server, static, resource
from twisted.internet import defer, error
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.lbrynet_daemon.FileStreamer import EncryptedFileStreamer
# TODO: omg, this code is essentially duplicated in Daemon

View file

@ -8,7 +8,7 @@ from urllib2 import urlopen
from StringIO import StringIO
from twisted.internet import defer
from twisted.internet.task import LoopingCall
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.lbrynet_daemon.Resources import NoCacheStaticFile
from lbrynet import __version__ as lbrynet_version
from lbryum.version import LBRYUM_VERSION as lbryum_version

View file

@ -6,7 +6,7 @@ import base64
import json
from lbrynet.lbrynet_daemon.auth.util import load_api_keys, APIKey, API_KEY_NAME, get_auth_message
from lbrynet import settings
from lbrynet.conf import settings
from jsonrpc.proxy import JSONRPCProxy
log = logging.getLogger(__name__)

View file

@ -7,7 +7,7 @@ from twisted.internet import defer
from txjsonrpc import jsonrpclib
from lbrynet.core.Error import InvalidAuthenticationToken, InvalidHeaderError, SubhandlerError
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.lbrynet_daemon.auth.util import APIKey, get_auth_message
from lbrynet.lbrynet_daemon.auth.client import LBRY_SECRET

View file

@ -1,4 +1,4 @@
from lbrynet import settings
from lbrynet.conf import settings
from twisted.web.client import Agent, FileBodyProducer, Headers, ResponseDone
from twisted.internet import threads, defer, protocol

View file

@ -11,7 +11,7 @@ import unittest
from Crypto.PublicKey import RSA
from Crypto import Random
from Crypto.Hash import MD5
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.lbrylive.LiveStreamCreator import FileLiveStreamCreator
from lbrynet.lbrylive.LiveStreamMetadataManager import DBLiveStreamMetadataManager
from lbrynet.lbrylive.LiveStreamMetadataManager import TempLiveStreamMetadataManager

View file

@ -4,7 +4,7 @@ import shutil
from twisted.internet import defer, threads, error
from twisted.trial import unittest
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet import lbryfile
from lbrynet import reflector
from lbrynet.core import BlobManager

View file

@ -6,7 +6,7 @@ from Crypto.Hash import MD5
from twisted.trial.unittest import TestCase
from twisted.internet import defer, threads
from lbrynet import settings
from lbrynet.conf import settings
from lbrynet.lbryfile.EncryptedFileMetadataManager import TempEncryptedFileMetadataManager
from lbrynet.lbryfile.EncryptedFileMetadataManager import DBEncryptedFileMetadataManager
from lbrynet.lbryfilemanager.EncryptedFileManager import EncryptedFileManager