Revisit helper_startup: rewrite weird imports, fix W504 and line length

This commit is contained in:
Dmitri Bogomolov 2021-07-07 21:54:16 +03:00
parent b75585f26c
commit db21f3ea6b
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

View File

@ -10,19 +10,15 @@ import sys
import time
from distutils.version import StrictVersion
import sys
if sys.version_info[0] == 3:
from . import defaults
from . import helper_random
from . import paths
from . import state
from .bmconfigparser import BMConfigParser
else:
try:
import defaults
import helper_random
import paths
import state
from bmconfigparser import BMConfigParser
except ImportError:
from . import defaults, helper_random, paths, state
from .bmconfigparser import BMConfigParser
try:
from plugins.plugin import get_plugin
@ -180,9 +176,9 @@ def updateConfig():
# acts as a salt
config.set(
'bitmessagesettings', 'identiconsuffix', ''.join(
helper_random.randomchoice("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
for x in range(12)
)
helper_random.randomchoice(
"123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
"abcdefghijkmnopqrstuvwxyz") for x in range(12))
) # a twelve character pseudo-password to salt the identicons
# Add settings to support no longer resending messages after
@ -249,14 +245,15 @@ def updateConfig():
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte') == 0:
config.set(
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte',
str(defaults.ridiculousDifficulty *
defaults.networkDefaultProofOfWorkNonceTrialsPerByte)
str(defaults.ridiculousDifficulty
* defaults.networkDefaultProofOfWorkNonceTrialsPerByte)
)
if config.safeGetInt('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes') == 0:
if config.safeGetInt(
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes') == 0:
config.set(
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes',
str(defaults.ridiculousDifficulty *
defaults.networkDefaultPayloadLengthExtraBytes)
str(defaults.ridiculousDifficulty
* defaults.networkDefaultPayloadLengthExtraBytes)
)
if not config.has_option('bitmessagesettings', 'onionhostname'):
@ -298,8 +295,8 @@ def adjustHalfOpenConnectionsLimit():
# connections at a time.
VER_THIS = StrictVersion(platform.version())
is_limited = (
StrictVersion("5.1.2600") <= VER_THIS and
StrictVersion("6.0.6000") >= VER_THIS
StrictVersion("5.1.2600") <= VER_THIS
and StrictVersion("6.0.6000") >= VER_THIS
)
except ValueError:
pass