Commit 68cb95ba authored by juga  's avatar juga
Browse files

fix: Reorder imports with isort

parent 7248afc0
"""Util functions to cleanup disk space."""
import gzip
import logging
import os
import shutil
import time
import types
from argparse import ArgumentDefaultsHelpFormatter
from datetime import datetime, timedelta
from sbws.util.filelock import DirectoryLock
from sbws.globals import fail_hard
from sbws.util.filelock import DirectoryLock
from sbws.util.timestamp import unixts_to_dt_obj
from argparse import ArgumentDefaultsHelpFormatter
from datetime import datetime
from datetime import timedelta
import os
import gzip
import shutil
import logging
import time
log = logging.getLogger(__name__)
......
import logging
import os
from argparse import ArgumentDefaultsHelpFormatter
from math import ceil
from sbws.globals import (
fail_hard,
DAY_SECS,
GENERATE_PERIOD,
NUM_MIN_RESULTS,
PROP276_ROUND_DIG,
SBWS_SCALE_CONSTANT,
TORFLOW_SCALING,
SBWS_SCALING,
TORFLOW_BW_MARGIN,
PROP276_ROUND_DIG,
DAY_SECS,
NUM_MIN_RESULTS,
GENERATE_PERIOD,
TORFLOW_SCALING,
fail_hard,
)
from sbws.lib.v3bwfile import V3BWFile
from sbws.lib import destination
from sbws.lib.resultdump import load_recent_results_in_datadir
from argparse import ArgumentDefaultsHelpFormatter
import os
import logging
from sbws.lib.v3bwfile import V3BWFile
from sbws.util.timestamp import now_fname
from sbws.lib import destination
log = logging.getLogger(__name__)
......
""" Measure the relays. """
import logging
import os
import queue
import random
import signal
import sys
import threading
import time
import traceback
import uuid
from argparse import ArgumentDefaultsHelpFormatter
from multiprocessing.context import TimeoutError
from multiprocessing.dummy import Pool
import sbws.util.requests as requests_utils
import sbws.util.stem as stem_utils
from sbws.globals import HTTP_GET_HEADERS, TIMEOUT_MEASUREMENTS, fail_hard
from .. import settings
from ..lib.circuitbuilder import GapsCircuitBuilder as CB
from ..lib.resultdump import ResultDump
from ..lib.resultdump import (
ResultSuccess,
ResultErrorCircuit,
ResultErrorStream,
ResultErrorSecondRelay,
ResultError,
ResultErrorDestination,
)
from ..lib.relaylist import RelayList
from ..lib.relayprioritizer import RelayPrioritizer
from ..lib.destination import (
DestinationList,
connect_to_destination_over_circuit,
)
from ..util.timestamp import now_isodt_str
from ..util.state import State
from sbws.globals import fail_hard, HTTP_GET_HEADERS, TIMEOUT_MEASUREMENTS
import sbws.util.stem as stem_utils
import sbws.util.requests as requests_utils
from argparse import ArgumentDefaultsHelpFormatter
from multiprocessing.dummy import Pool
import time
import os
import logging
import random
from .. import settings
from ..lib.heartbeat import Heartbeat
from ..lib.relaylist import RelayList
from ..lib.relayprioritizer import RelayPrioritizer
from ..lib.resultdump import (
ResultDump,
ResultError,
ResultErrorCircuit,
ResultErrorDestination,
ResultErrorSecondRelay,
ResultErrorStream,
ResultSuccess,
)
from ..util.state import State
from ..util.timestamp import now_isodt_str
rng = random.SystemRandom()
log = logging.getLogger(__name__)
......
from sbws.globals import fail_hard
from sbws.lib.resultdump import Result
from sbws.lib.resultdump import ResultError
from sbws.lib.resultdump import ResultErrorCircuit
from sbws.lib.resultdump import ResultErrorStream
from sbws.lib.resultdump import ResultSuccess
from sbws.lib.resultdump import load_recent_results_in_datadir
from argparse import ArgumentDefaultsHelpFormatter
import logging
import os
from datetime import datetime
from datetime import timedelta
from argparse import ArgumentDefaultsHelpFormatter
from datetime import datetime, timedelta
from statistics import mean
import logging
from sbws.globals import fail_hard
from sbws.lib.resultdump import (
Result,
ResultError,
ResultErrorCircuit,
ResultErrorStream,
ResultSuccess,
load_recent_results_in_datadir,
)
log = logging.getLogger(__name__)
......
import os
import logging
import os
import platform
from collections import OrderedDict
from requests import __version__ as requests_version
from stem import __version__ as stem_version
from sbws import __version__
from collections import OrderedDict
log = logging.getLogger(__name__)
RESULT_VERSION = 4
......
......@@ -5,14 +5,11 @@ import logging
from stem import descriptor
from sbws.globals import (
PERIOD_DAYS,
FRACTION_RELAYS,
MAX_RECENT_PRIORITY_RELAY_COUNT, # 48000
MAX_RECENT_PRIORITY_LIST_COUNT, # 120
MAX_RECENT_CONSENSUS_COUNT, # 120
)
from sbws.lib.v3bwfile import HEADER_INT_KEYS, BWLINE_KEYS_V1_4
from sbws.globals import MAX_RECENT_CONSENSUS_COUNT # 120
from sbws.globals import MAX_RECENT_PRIORITY_LIST_COUNT # 120
from sbws.globals import MAX_RECENT_PRIORITY_RELAY_COUNT # 48000
from sbws.globals import FRACTION_RELAYS, PERIOD_DAYS
from sbws.lib.v3bwfile import BWLINE_KEYS_V1_4, HEADER_INT_KEYS
logging.basicConfig(
level=logging.INFO,
......
from stem import CircuitExtensionFailed, InvalidRequest, ProtocolError, Timeout
from stem import InvalidArguments, ControllerError, SocketClosed
import logging
from stem import (
CircuitExtensionFailed,
ControllerError,
InvalidArguments,
InvalidRequest,
ProtocolError,
SocketClosed,
Timeout,
)
log = logging.getLogger(__name__)
......
......@@ -2,21 +2,22 @@ import collections
import datetime
import logging
import random
import requests
from urllib.parse import urlparse
import requests
from stem.control import EventType
from sbws.globals import DESTINATION_VERIFY_CERTIFICATE
import sbws.util.stem as stem_utils
from sbws import settings
from sbws.globals import DESTINATION_VERIFY_CERTIFICATE
from ..globals import (
MAX_NUM_DESTINATION_FAILURES,
DELTA_SECONDS_RETRY_DESTINATION,
FACTOR_INCREMENT_DESTINATION_RETRY,
MAX_NUM_DESTINATION_FAILURES,
MAX_SECONDS_RETRY_DESTINATION,
NUM_DESTINATION_ATTEMPTS_STORED,
FACTOR_INCREMENT_DESTINATION_RETRY,
)
from sbws import settings
log = logging.getLogger(__name__)
......
......@@ -6,7 +6,6 @@ import time
from ..util.state import State
log = logging.getLogger(__name__)
......
import copy
import logging
import random
from datetime import datetime, timedelta
from threading import Lock
from stem import ControllerError, DescriptorUnavailable, Flag
from stem.descriptor.router_status_entry import RouterStatusEntryV3
from stem.descriptor.server_descriptor import ServerDescriptor
from stem import Flag, DescriptorUnavailable, ControllerError
import random
import logging
from threading import Lock
from ..globals import (
MAX_RECENT_CONSENSUS_COUNT,
MAX_RECENT_PRIORITY_RELAY_COUNT,
MAX_RECENT_PRIORITY_LIST_COUNT,
MAX_RECENT_PRIORITY_RELAY_COUNT,
MEASUREMENTS_PERIOD,
)
from ..util import timestamps
......
from decimal import Decimal
from ..lib.resultdump import ResultDump
from ..lib.resultdump import ResultError
from ..lib.relaylist import RelayList
import copy
import time
import logging
import time
from decimal import Decimal
from ..globals import MAX_RECENT_PRIORITY_RELAY_COUNT
from ..lib.relaylist import RelayList
from ..lib.resultdump import ResultDump, ResultError
from ..util import state, timestamps
log = logging.getLogger(__name__)
......
import os
import json
import time
import logging
from glob import glob
from threading import Thread
from threading import RLock
from queue import Queue
from queue import Empty
from datetime import datetime
from datetime import timedelta
import os
import time
from datetime import datetime, timedelta
from enum import Enum
from glob import glob
from queue import Empty, Queue
from threading import RLock, Thread
from sbws.globals import RESULT_VERSION, fail_hard
from sbws.util.filelock import DirectoryLock
from sbws.util.json import CustomEncoder, CustomDecoder
from sbws.lib.relaylist import Relay
from sbws.util.filelock import DirectoryLock
from sbws.util.json import CustomDecoder, CustomEncoder
from .. import settings
log = logging.getLogger(__name__)
......
......@@ -9,34 +9,35 @@ import logging
import math
import os
from itertools import combinations
from statistics import median, mean
from statistics import mean, median
from stem.descriptor import parse_file
from sbws import __version__
from sbws.globals import (
SPEC_VERSION,
BW_LINE_SIZE,
MAX_BW_DIFF_PERC,
MIN_REPORT,
PROP276_ROUND_DIG,
SBWS_SCALE_CONSTANT,
TORFLOW_SCALING,
SBWS_SCALING,
SPEC_VERSION,
TORFLOW_BW_MARGIN,
TORFLOW_OBS_LAST,
TORFLOW_OBS_MEAN,
PROP276_ROUND_DIG,
MIN_REPORT,
MAX_BW_DIFF_PERC,
TORFLOW_SCALING,
)
from sbws.lib import scaling
from sbws.lib.resultdump import ResultSuccess, _ResultType
from sbws.util.filelock import DirectoryLock
from sbws.util.state import State
from sbws.util.timestamp import (
dt_obj_to_isodt_str,
isostr_to_dt_obj,
now_isodt_str,
unixts_to_isodt_str,
now_unixts,
isostr_to_dt_obj,
dt_obj_to_isodt_str,
unixts_to_isodt_str,
)
from sbws.util.state import State
log = logging.getLogger(__name__)
......
import logging
import os
import platform
from requests.__version__ import __version__ as requests_version
from stem import __version__ as stem_version
import sbws.core.cleanup
import sbws.core.scanner
import sbws.core.generate
import sbws.core.scanner
import sbws.core.stats
from sbws.util.config import get_config
from sbws.util.config import validate_config
from sbws.util.config import configure_logging
from sbws.util.parser import create_parser
from sbws import __version__ as version
from stem import __version__ as stem_version
from requests.__version__ import __version__ as requests_version
import platform
import logging
from sbws.util.config import configure_logging, get_config, validate_config
from sbws.util.fs import sbws_required_disk_space
from sbws.util.parser import create_parser
log = logging.getLogger(__name__)
......
"""Util functions to manage sbws configuration files."""
from configparser import ConfigParser, ExtendedInterpolation
from configparser import InterpolationMissingOptionError
import os
import logging
import logging.config
from urllib.parse import urlparse
import os
from configparser import (
ConfigParser,
ExtendedInterpolation,
InterpolationMissingOptionError,
)
from string import Template
from tempfile import NamedTemporaryFile
from urllib.parse import urlparse
from sbws.globals import (
DEFAULT_CONFIG_PATH,
DEFAULT_LOG_CONFIG_PATH,
USER_CONFIG_PATH,
SUPERVISED_RUN_DPATH,
SUPERVISED_USER_CONFIG_PATH,
USER_CONFIG_PATH,
)
from sbws.util.iso3166 import ISO_3166_ALPHA_2
_ALPHANUM = "abcdefghijklmnopqrstuvwxyz"
......
import os
import fcntl
import logging
import os
from sbws.globals import fail_hard
log = logging.getLogger(__name__)
......
......@@ -2,7 +2,7 @@
import datetime
import json
from .timestamps import DateTimeSeq, DateTimeIntSeq
from .timestamps import DateTimeIntSeq, DateTimeSeq
class CustomEncoder(json.JSONEncoder):
......
import os
from argparse import ArgumentParser, RawTextHelpFormatter
import sbws.core.cleanup
import sbws.core.scanner
import sbws.core.generate
import sbws.core.scanner
import sbws.core.stats
from sbws import __version__
from argparse import ArgumentParser, RawTextHelpFormatter
import os
def _default_dot_sbws_dname():
home = os.path.expanduser("~")
......
from sbws.util.filelock import FileLock
import os
import json
import os
from sbws.util.filelock import FileLock
from .json import CustomDecoder, CustomEncoder
......
import socks
import copy
import logging
import os
from threading import RLock
from stem.control import Controller, Listener
import socks
import stem.process
from stem import (
SocketError,
InvalidRequest,
UnsatisfiableRequest,
OperationFailed,
ControllerError,
Flag,
InvalidArguments,
InvalidRequest,
OperationFailed,
ProtocolError,
SocketClosed,
SocketError,
UnsatisfiableRequest,
)
from stem.connection import IncorrectSocketType
import stem.process
from threading import RLock
import copy
import logging
import os
from sbws.globals import fail_hard
from stem.control import Controller, Listener
from sbws import settings
from sbws.globals import (
TORRC_STARTING_POINT,
TORRC_RUNTIME_OPTIONS,
GE,
TORRC_OPTIONS_CAN_FAIL,
TORRC_RUNTIME_OPTIONS,
TORRC_STARTING_POINT,
E,
G,
M,
E,
GE,
fail_hard,
)
from sbws import settings
from stem import Flag
log = logging.getLogger(__name__)
stream_building_lock = RLock()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment