Snake case

main
Bob Mottram 2021-12-25 18:38:19 +00:00
parent 091b576d3c
commit b028216dfd
7 changed files with 47 additions and 47 deletions

View File

@ -320,7 +320,7 @@ def isBlockedDomain(base_dir: str, domain: str,
shortDomain = _getShortDomain(domain) shortDomain = _getShortDomain(domain)
if not brochModeIsActive(base_dir): if not broch_modeIsActive(base_dir):
if blockedCache: if blockedCache:
for blockedStr in blockedCache: for blockedStr in blockedCache:
if '*@' + domain in blockedStr: if '*@' + domain in blockedStr:
@ -368,7 +368,7 @@ def isBlocked(base_dir: str, nickname: str, domain: str,
if blockNickname and blockDomain: if blockNickname and blockDomain:
blockHandle = blockNickname + '@' + blockDomain blockHandle = blockNickname + '@' + blockDomain
if not brochModeIsActive(base_dir): if not broch_modeIsActive(base_dir):
# instance level block list # instance level block list
if blockedCache: if blockedCache:
for blockedStr in blockedCache: for blockedStr in blockedCache:
@ -873,7 +873,7 @@ def outboxUndoMute(base_dir: str, http_prefix: str,
print('DEBUG: post undo mute via c2s - ' + postFilename) print('DEBUG: post undo mute via c2s - ' + postFilename)
def brochModeIsActive(base_dir: str) -> bool: def broch_modeIsActive(base_dir: str) -> bool:
"""Returns true if broch mode is active """Returns true if broch mode is active
""" """
allowFilename = base_dir + '/accounts/allowedinstances.txt' allowFilename = base_dir + '/accounts/allowedinstances.txt'
@ -943,10 +943,10 @@ def setBrochMode(base_dir: str, domainFull: str, enabled: bool) -> None:
print('EX: Broch mode not enabled due to file write ' + str(ex)) print('EX: Broch mode not enabled due to file write ' + str(ex))
return return
setConfigParam(base_dir, "brochMode", enabled) setConfigParam(base_dir, "broch_mode", enabled)
def brochModeLapses(base_dir: str, lapseDays: int) -> bool: def broch_modeLapses(base_dir: str, lapseDays: int) -> bool:
"""After broch mode is enabled it automatically """After broch mode is enabled it automatically
elapses after a period of time elapses after a period of time
""" """
@ -959,7 +959,7 @@ def brochModeLapses(base_dir: str, lapseDays: int) -> bool:
modifiedDate = \ modifiedDate = \
datetime.strptime(lastModified, "%Y-%m-%dT%H:%M:%SZ") datetime.strptime(lastModified, "%Y-%m-%dT%H:%M:%SZ")
except BaseException: except BaseException:
print('EX: brochModeLapses date not parsed ' + str(lastModified)) print('EX: broch_modeLapses date not parsed ' + str(lastModified))
return False return False
if not modifiedDate: if not modifiedDate:
return False return False
@ -971,10 +971,10 @@ def brochModeLapses(base_dir: str, lapseDays: int) -> bool:
os.remove(allowFilename) os.remove(allowFilename)
removed = True removed = True
except OSError: except OSError:
print('EX: brochModeLapses allow file not deleted ' + print('EX: broch_modeLapses allow file not deleted ' +
str(allowFilename)) str(allowFilename))
if removed: if removed:
setConfigParam(base_dir, "brochMode", False) setConfigParam(base_dir, "broch_mode", False)
print('Broch mode has elapsed') print('Broch mode has elapsed')
return True return True
return False return False

View File

@ -134,7 +134,7 @@ from blocking import updateBlockedCache
from blocking import mutePost from blocking import mutePost
from blocking import unmutePost from blocking import unmutePost
from blocking import setBrochMode from blocking import setBrochMode
from blocking import brochModeIsActive from blocking import broch_modeIsActive
from blocking import addBlock from blocking import addBlock
from blocking import removeBlock from blocking import removeBlock
from blocking import addGlobalBlock from blocking import addGlobalBlock
@ -1061,7 +1061,7 @@ class PubServer(BaseHTTPRequestHandler):
print('mastodon api v1: nickname ' + str(nickname)) print('mastodon api v1: nickname ' + str(nickname))
self._updateKnownCrawlers(uaStr) self._updateKnownCrawlers(uaStr)
brochMode = brochModeIsActive(base_dir) broch_mode = broch_modeIsActive(base_dir)
sendJson, sendJsonStr = mastoApiV1Response(path, sendJson, sendJsonStr = mastoApiV1Response(path,
callingDomain, callingDomain,
uaStr, uaStr,
@ -1078,7 +1078,7 @@ class PubServer(BaseHTTPRequestHandler):
projectVersion, projectVersion,
customEmoji, customEmoji,
show_node_info_accounts, show_node_info_accounts,
brochMode) broch_mode)
if sendJson is not None: if sendJson is not None:
msg = json.dumps(sendJson).encode('utf-8') msg = json.dumps(sendJson).encode('utf-8')
@ -1133,14 +1133,14 @@ class PubServer(BaseHTTPRequestHandler):
# For example, if this or allied instances are being attacked # For example, if this or allied instances are being attacked
# then numbers of accounts may be changing as people # then numbers of accounts may be changing as people
# migrate, and that information may be useful to an adversary # migrate, and that information may be useful to an adversary
brochMode = brochModeIsActive(self.server.base_dir) broch_mode = broch_modeIsActive(self.server.base_dir)
nodeInfoVersion = self.server.projectVersion nodeInfoVersion = self.server.projectVersion
if not self.server.show_node_info_version or brochMode: if not self.server.show_node_info_version or broch_mode:
nodeInfoVersion = '0.0.0' nodeInfoVersion = '0.0.0'
show_node_info_accounts = self.server.show_node_info_accounts show_node_info_accounts = self.server.show_node_info_accounts
if brochMode: if broch_mode:
show_node_info_accounts = False show_node_info_accounts = False
instanceUrl = self._getInstanceUrl(callingDomain) instanceUrl = self._getInstanceUrl(callingDomain)
@ -5571,18 +5571,18 @@ class PubServer(BaseHTTPRequestHandler):
setConfigParam(base_dir, "verifyAllSignatures", setConfigParam(base_dir, "verifyAllSignatures",
verifyAllSignatures) verifyAllSignatures)
brochMode = False broch_mode = False
if fields.get('brochMode'): if fields.get('broch_mode'):
if fields['brochMode'] == 'on': if fields['broch_mode'] == 'on':
brochMode = True broch_mode = True
currBrochMode = \ currBrochMode = \
getConfigParam(base_dir, "brochMode") getConfigParam(base_dir, "broch_mode")
if brochMode != currBrochMode: if broch_mode != currBrochMode:
setBrochMode(self.server.base_dir, setBrochMode(self.server.base_dir,
self.server.domainFull, self.server.domainFull,
brochMode) broch_mode)
setConfigParam(base_dir, "brochMode", setConfigParam(base_dir, "broch_mode",
brochMode) broch_mode)
# shared item federation domains # shared item federation domains
siDomainUpdated = False siDomainUpdated = False
@ -18411,7 +18411,7 @@ def runDaemon(content_license_url: str,
city: str, city: str,
show_node_info_accounts: bool, show_node_info_accounts: bool,
show_node_info_version: bool, show_node_info_version: bool,
brochMode: bool, broch_mode: bool,
verifyAllSignatures: bool, verifyAllSignatures: bool,
sendThreadsTimeoutMins: int, sendThreadsTimeoutMins: int,
dormantMonths: int, dormantMonths: int,
@ -18755,7 +18755,7 @@ def runDaemon(content_license_url: str,
metadataCustomEmoji(base_dir, http_prefix, httpd.domainFull) metadataCustomEmoji(base_dir, http_prefix, httpd.domainFull)
# whether to enable broch mode, which locks down the instance # whether to enable broch mode, which locks down the instance
setBrochMode(base_dir, httpd.domainFull, brochMode) setBrochMode(base_dir, httpd.domainFull, broch_mode)
if not os.path.isdir(base_dir + '/accounts/inbox@' + domain): if not os.path.isdir(base_dir + '/accounts/inbox@' + domain):
print('Creating shared inbox: inbox@' + domain) print('Creating shared inbox: inbox@' + domain)

View File

@ -377,8 +377,8 @@ parser.add_argument("--verifyAllSignatures",
const=True, default=False, const=True, default=False,
help="Whether to require that all incoming " + help="Whether to require that all incoming " +
"posts have valid jsonld signatures") "posts have valid jsonld signatures")
parser.add_argument("--brochMode", parser.add_argument("--broch_mode",
dest='brochMode', dest='broch_mode',
type=str2bool, nargs='?', type=str2bool, nargs='?',
const=True, default=False, const=True, default=False,
help="Enable broch mode") help="Enable broch mode")
@ -3113,10 +3113,10 @@ verifyAllSignatures = \
if verifyAllSignatures is not None: if verifyAllSignatures is not None:
args.verifyAllSignatures = bool(verifyAllSignatures) args.verifyAllSignatures = bool(verifyAllSignatures)
brochMode = \ broch_mode = \
getConfigParam(base_dir, 'brochMode') getConfigParam(base_dir, 'broch_mode')
if brochMode is not None: if broch_mode is not None:
args.brochMode = bool(brochMode) args.broch_mode = bool(broch_mode)
log_login_failures = \ log_login_failures = \
getConfigParam(base_dir, 'log_login_failures') getConfigParam(base_dir, 'log_login_failures')
@ -3220,7 +3220,7 @@ if __name__ == "__main__":
args.city, args.city,
args.show_node_info_accounts, args.show_node_info_accounts,
args.show_node_info_version, args.show_node_info_version,
args.brochMode, args.broch_mode,
args.verifyAllSignatures, args.verifyAllSignatures,
args.sendThreadsTimeoutMins, args.sendThreadsTimeoutMins,
args.dormantMonths, args.dormantMonths,

View File

@ -84,7 +84,7 @@ from bookmarks import updateBookmarksCollection
from bookmarks import undoBookmarksCollectionEntry from bookmarks import undoBookmarksCollectionEntry
from blocking import isBlocked from blocking import isBlocked
from blocking import isBlockedDomain from blocking import isBlockedDomain
from blocking import brochModeLapses from blocking import broch_modeLapses
from filters import isFiltered from filters import isFiltered
from utils import updateAnnounceCollection from utils import updateAnnounceCollection
from utils import undoAnnounceCollectionEntry from utils import undoAnnounceCollectionEntry
@ -4127,7 +4127,7 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
heartBeatCtr += 1 heartBeatCtr += 1
if heartBeatCtr >= 10: if heartBeatCtr >= 10:
# turn off broch mode after it has timed out # turn off broch mode after it has timed out
if brochModeLapses(base_dir, brochLapseDays): if broch_modeLapses(base_dir, brochLapseDays):
brochLapseDays = random.randrange(7, 14) brochLapseDays = random.randrange(7, 14)
print('>>> Heartbeat Q:' + str(len(queue)) + ' ' + print('>>> Heartbeat Q:' + str(len(queue)) + ' ' +
'{:%F %T}'.format(datetime.datetime.now())) '{:%F %T}'.format(datetime.datetime.now()))

View File

@ -94,7 +94,7 @@ def mastoApiV1Response(path: str, callingDomain: str,
projectVersion: str, projectVersion: str,
customEmoji: [], customEmoji: [],
show_node_info_accounts: bool, show_node_info_accounts: bool,
brochMode: bool) -> ({}, str): broch_mode: bool) -> ({}, str):
"""This is a vestigil mastodon API for the purpose """This is a vestigil mastodon API for the purpose
of returning an empty result to sites like of returning an empty result to sites like
https://mastopeek.app-dist.eu https://mastopeek.app-dist.eu
@ -215,7 +215,7 @@ def mastoApiV1Response(path: str, callingDomain: str,
domainFull = i2pDomain domainFull = i2pDomain
http_prefix = 'http' http_prefix = 'http'
if brochMode: if broch_mode:
show_node_info_accounts = False show_node_info_accounts = False
sendJson = \ sendJson = \

View File

@ -785,7 +785,7 @@ def createServerAlice(path: str, domain: str, port: int,
sendThreadsTimeoutMins = 30 sendThreadsTimeoutMins = 30
maxFollowers = 10 maxFollowers = 10
verifyAllSignatures = True verifyAllSignatures = True
brochMode = False broch_mode = False
show_node_info_accounts = True show_node_info_accounts = True
show_node_info_version = True show_node_info_version = True
city = 'London, England' city = 'London, England'
@ -804,7 +804,7 @@ def createServerAlice(path: str, domain: str, port: int,
log_login_failures, city, log_login_failures, city,
show_node_info_accounts, show_node_info_accounts,
show_node_info_version, show_node_info_version,
brochMode, broch_mode,
verifyAllSignatures, verifyAllSignatures,
sendThreadsTimeoutMins, sendThreadsTimeoutMins,
dormantMonths, maxNewswirePosts, dormantMonths, maxNewswirePosts,
@ -927,7 +927,7 @@ def createServerBob(path: str, domain: str, port: int,
sendThreadsTimeoutMins = 30 sendThreadsTimeoutMins = 30
maxFollowers = 10 maxFollowers = 10
verifyAllSignatures = True verifyAllSignatures = True
brochMode = False broch_mode = False
show_node_info_accounts = True show_node_info_accounts = True
show_node_info_version = True show_node_info_version = True
city = 'London, England' city = 'London, England'
@ -946,7 +946,7 @@ def createServerBob(path: str, domain: str, port: int,
log_login_failures, city, log_login_failures, city,
show_node_info_accounts, show_node_info_accounts,
show_node_info_version, show_node_info_version,
brochMode, broch_mode,
verifyAllSignatures, verifyAllSignatures,
sendThreadsTimeoutMins, sendThreadsTimeoutMins,
dormantMonths, maxNewswirePosts, dormantMonths, maxNewswirePosts,
@ -996,7 +996,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
sendThreadsTimeoutMins = 30 sendThreadsTimeoutMins = 30
maxFollowers = 10 maxFollowers = 10
verifyAllSignatures = True verifyAllSignatures = True
brochMode = False broch_mode = False
show_node_info_accounts = True show_node_info_accounts = True
show_node_info_version = True show_node_info_version = True
city = 'London, England' city = 'London, England'
@ -1016,7 +1016,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
log_login_failures, city, log_login_failures, city,
show_node_info_accounts, show_node_info_accounts,
show_node_info_version, show_node_info_version,
brochMode, broch_mode,
verifyAllSignatures, verifyAllSignatures,
sendThreadsTimeoutMins, sendThreadsTimeoutMins,
dormantMonths, maxNewswirePosts, dormantMonths, maxNewswirePosts,
@ -1068,7 +1068,7 @@ def createServerGroup(path: str, domain: str, port: int,
sendThreadsTimeoutMins = 30 sendThreadsTimeoutMins = 30
maxFollowers = 10 maxFollowers = 10
verifyAllSignatures = True verifyAllSignatures = True
brochMode = False broch_mode = False
show_node_info_accounts = True show_node_info_accounts = True
show_node_info_version = True show_node_info_version = True
city = 'London, England' city = 'London, England'
@ -1088,7 +1088,7 @@ def createServerGroup(path: str, domain: str, port: int,
log_login_failures, city, log_login_failures, city,
show_node_info_accounts, show_node_info_accounts,
show_node_info_version, show_node_info_version,
brochMode, broch_mode,
verifyAllSignatures, verifyAllSignatures,
sendThreadsTimeoutMins, sendThreadsTimeoutMins,
dormantMonths, maxNewswirePosts, dormantMonths, maxNewswirePosts,

View File

@ -1375,12 +1375,12 @@ def _htmlEditProfileInstance(base_dir: str, translate: {},
'verifyallsignatures', False) 'verifyallsignatures', False)
instanceStr += translate['Enabling broch mode'] + '<br>\n' instanceStr += translate['Enabling broch mode'] + '<br>\n'
if getConfigParam(base_dir, "brochMode"): if getConfigParam(base_dir, "broch_mode"):
instanceStr += \ instanceStr += \
editCheckBox(translate['Broch mode'], 'brochMode', True) editCheckBox(translate['Broch mode'], 'broch_mode', True)
else: else:
instanceStr += \ instanceStr += \
editCheckBox(translate['Broch mode'], 'brochMode', False) editCheckBox(translate['Broch mode'], 'broch_mode', False)
# Instance type # Instance type
instanceStr += \ instanceStr += \
' <br><label class="labels">' + \ ' <br><label class="labels">' + \