mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
438dcce9e3
commit
3128c724a1
|
@ -21,7 +21,7 @@ from utils import get_cached_post_filename
|
|||
from utils import load_json
|
||||
from utils import save_json
|
||||
from utils import fileLastModified
|
||||
from utils import setConfigParam
|
||||
from utils import set_config_param
|
||||
from utils import has_users_path
|
||||
from utils import get_full_domain
|
||||
from utils import remove_id_ending
|
||||
|
@ -945,7 +945,7 @@ def setBrochMode(base_dir: str, domain_full: str, enabled: bool) -> None:
|
|||
print('EX: Broch mode not enabled due to file write ' + str(ex))
|
||||
return
|
||||
|
||||
setConfigParam(base_dir, "broch_mode", enabled)
|
||||
set_config_param(base_dir, "broch_mode", enabled)
|
||||
|
||||
|
||||
def broch_modeLapses(base_dir: str, lapseDays: int) -> bool:
|
||||
|
@ -976,7 +976,7 @@ def broch_modeLapses(base_dir: str, lapseDays: int) -> bool:
|
|||
print('EX: broch_modeLapses allow file not deleted ' +
|
||||
str(allowFilename))
|
||||
if removed:
|
||||
setConfigParam(base_dir, "broch_mode", False)
|
||||
set_config_param(base_dir, "broch_mode", False)
|
||||
print('Broch mode has elapsed')
|
||||
return True
|
||||
return False
|
||||
|
|
87
daemon.py
87
daemon.py
|
@ -283,7 +283,7 @@ from utils import first_paragraph_from_string
|
|||
from utils import clearFromPostCaches
|
||||
from utils import contains_invalid_chars
|
||||
from utils import is_system_account
|
||||
from utils import setConfigParam
|
||||
from utils import set_config_param
|
||||
from utils import get_config_param
|
||||
from utils import remove_id_ending
|
||||
from utils import undoLikesCollectionEntry
|
||||
|
@ -5055,20 +5055,20 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.blogs_instance = False
|
||||
self.server.news_instance = False
|
||||
self.server.defaultTimeline = 'tlmedia'
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
"media_instance",
|
||||
self.server.media_instance)
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
"blogs_instance",
|
||||
self.server.blogs_instance)
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
"news_instance",
|
||||
self.server.news_instance)
|
||||
else:
|
||||
if self.server.media_instance:
|
||||
self.server.media_instance = False
|
||||
self.server.defaultTimeline = 'inbox'
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
"media_instance",
|
||||
self.server.media_instance)
|
||||
|
||||
|
@ -5086,20 +5086,20 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.blogs_instance = False
|
||||
self.server.media_instance = False
|
||||
self.server.defaultTimeline = 'tlfeatures'
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
"media_instance",
|
||||
self.server.media_instance)
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
"blogs_instance",
|
||||
self.server.blogs_instance)
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
"news_instance",
|
||||
self.server.news_instance)
|
||||
else:
|
||||
if self.server.news_instance:
|
||||
self.server.news_instance = False
|
||||
self.server.defaultTimeline = 'inbox'
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
"news_instance",
|
||||
self.server.media_instance)
|
||||
|
||||
|
@ -5112,20 +5112,20 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.media_instance = False
|
||||
self.server.news_instance = False
|
||||
self.server.defaultTimeline = 'tlblogs'
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
"blogs_instance",
|
||||
self.server.blogs_instance)
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
"media_instance",
|
||||
self.server.media_instance)
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
"news_instance",
|
||||
self.server.news_instance)
|
||||
else:
|
||||
if self.server.blogs_instance:
|
||||
self.server.blogs_instance = False
|
||||
self.server.defaultTimeline = 'inbox'
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
"blogs_instance",
|
||||
self.server.blogs_instance)
|
||||
|
||||
|
@ -5134,7 +5134,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
currInstanceTitle = \
|
||||
get_config_param(base_dir, 'instanceTitle')
|
||||
if fields['instanceTitle'] != currInstanceTitle:
|
||||
setConfigParam(base_dir, 'instanceTitle',
|
||||
set_config_param(base_dir, 'instanceTitle',
|
||||
fields['instanceTitle'])
|
||||
|
||||
# change YouTube alternate domain
|
||||
|
@ -5147,13 +5147,13 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if '/' in newYTDomain:
|
||||
newYTDomain = newYTDomain.split('/')[0]
|
||||
if '.' in newYTDomain:
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'youtubedomain',
|
||||
newYTDomain)
|
||||
self.server.yt_replace_domain = \
|
||||
newYTDomain
|
||||
else:
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'youtubedomain', '')
|
||||
self.server.yt_replace_domain = None
|
||||
|
||||
|
@ -5170,13 +5170,13 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
newTwitterDomain = \
|
||||
newTwitterDomain.split('/')[0]
|
||||
if '.' in newTwitterDomain:
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'twitterdomain',
|
||||
newTwitterDomain)
|
||||
self.server.twitter_replacement_domain = \
|
||||
newTwitterDomain
|
||||
else:
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'twitterdomain', '')
|
||||
self.server.twitter_replacement_domain = None
|
||||
|
||||
|
@ -5187,12 +5187,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if fields['customSubmitText'] != \
|
||||
currCustomSubmitText:
|
||||
customText = fields['customSubmitText']
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'customSubmitText',
|
||||
customText)
|
||||
else:
|
||||
if currCustomSubmitText:
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'customSubmitText', '')
|
||||
|
||||
# libretranslate URL
|
||||
|
@ -5205,12 +5205,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
ltUrl = fields['libretranslateUrl']
|
||||
if '://' in ltUrl and \
|
||||
'.' in ltUrl:
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'libretranslateUrl',
|
||||
ltUrl)
|
||||
else:
|
||||
if currLibretranslateUrl:
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'libretranslateUrl', '')
|
||||
|
||||
# libretranslate API Key
|
||||
|
@ -5221,12 +5221,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if fields['libretranslateApiKey'] != \
|
||||
currLibretranslateApiKey:
|
||||
ltApiKey = fields['libretranslateApiKey']
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'libretranslateApiKey',
|
||||
ltApiKey)
|
||||
else:
|
||||
if currLibretranslateApiKey:
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'libretranslateApiKey', '')
|
||||
|
||||
# change instance short description
|
||||
|
@ -5234,7 +5234,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if fields['content_license_url'] != \
|
||||
self.server.content_license_url:
|
||||
licenseStr = fields['content_license_url']
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'content_license_url',
|
||||
licenseStr)
|
||||
self.server.content_license_url = \
|
||||
|
@ -5242,7 +5242,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
licenseStr = \
|
||||
'https://creativecommons.org/licenses/by/4.0'
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'content_license_url',
|
||||
licenseStr)
|
||||
self.server.content_license_url = licenseStr
|
||||
|
@ -5255,13 +5255,14 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if fields['instanceDescriptionShort'] != \
|
||||
currInstanceDescriptionShort:
|
||||
iDesc = fields['instanceDescriptionShort']
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'instanceDescriptionShort',
|
||||
iDesc)
|
||||
else:
|
||||
if currInstanceDescriptionShort:
|
||||
setConfigParam(base_dir,
|
||||
'instanceDescriptionShort', '')
|
||||
set_config_param(base_dir,
|
||||
'instanceDescriptionShort',
|
||||
'')
|
||||
|
||||
# change instance description
|
||||
currInstanceDescription = \
|
||||
|
@ -5269,12 +5270,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if fields.get('instanceDescription'):
|
||||
if fields['instanceDescription'] != \
|
||||
currInstanceDescription:
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'instanceDescription',
|
||||
fields['instanceDescription'])
|
||||
else:
|
||||
if currInstanceDescription:
|
||||
setConfigParam(base_dir,
|
||||
set_config_param(base_dir,
|
||||
'instanceDescription', '')
|
||||
|
||||
# change email address
|
||||
|
@ -5560,7 +5561,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
show_node_info_accounts = True
|
||||
self.server.show_node_info_accounts = \
|
||||
show_node_info_accounts
|
||||
setConfigParam(base_dir, "show_node_info_accounts",
|
||||
set_config_param(base_dir,
|
||||
"show_node_info_accounts",
|
||||
show_node_info_accounts)
|
||||
|
||||
show_node_info_version = False
|
||||
|
@ -5569,7 +5571,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
show_node_info_version = True
|
||||
self.server.show_node_info_version = \
|
||||
show_node_info_version
|
||||
setConfigParam(base_dir, "show_node_info_version",
|
||||
set_config_param(base_dir,
|
||||
"show_node_info_version",
|
||||
show_node_info_version)
|
||||
|
||||
verify_all_signatures = False
|
||||
|
@ -5578,7 +5581,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
verify_all_signatures = True
|
||||
self.server.verify_all_signatures = \
|
||||
verify_all_signatures
|
||||
setConfigParam(base_dir, "verify_all_signatures",
|
||||
set_config_param(base_dir, "verify_all_signatures",
|
||||
verify_all_signatures)
|
||||
|
||||
broch_mode = False
|
||||
|
@ -5591,7 +5594,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
setBrochMode(self.server.base_dir,
|
||||
self.server.domain_full,
|
||||
broch_mode)
|
||||
setConfigParam(base_dir, "broch_mode",
|
||||
set_config_param(base_dir, "broch_mode",
|
||||
broch_mode)
|
||||
|
||||
# shared item federation domains
|
||||
|
@ -5618,14 +5621,16 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
shareDomainList.replace('\n', ',')
|
||||
sharedItemsField = \
|
||||
"shared_items_federated_domains"
|
||||
setConfigParam(base_dir, sharedItemsField,
|
||||
set_config_param(base_dir,
|
||||
sharedItemsField,
|
||||
sharedItemsFormStr2)
|
||||
siDomainUpdated = True
|
||||
else:
|
||||
if fed_domains_str:
|
||||
sharedItemsField = \
|
||||
"shared_items_federated_domains"
|
||||
setConfigParam(base_dir, sharedItemsField,
|
||||
set_config_param(base_dir,
|
||||
sharedItemsField,
|
||||
'')
|
||||
siDomainUpdated = True
|
||||
if siDomainUpdated:
|
||||
|
@ -6219,7 +6224,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if fields['low_bandwidth'] == 'on':
|
||||
low_bandwidth = True
|
||||
if currLowBandwidth != low_bandwidth:
|
||||
setConfigParam(base_dir, 'low_bandwidth',
|
||||
set_config_param(base_dir, 'low_bandwidth',
|
||||
low_bandwidth)
|
||||
self.server.low_bandwidth = low_bandwidth
|
||||
|
||||
|
@ -6400,7 +6405,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
newListsEnabled += name
|
||||
if newListsEnabled != self.server.lists_enabled:
|
||||
self.server.lists_enabled = newListsEnabled
|
||||
setConfigParam(self.server.base_dir,
|
||||
set_config_param(self.server.base_dir,
|
||||
"lists_enabled",
|
||||
newListsEnabled)
|
||||
|
||||
|
@ -6424,7 +6429,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if user_agents_blockedStr:
|
||||
user_agents_blockedStr += ','
|
||||
user_agents_blockedStr += ua
|
||||
setConfigParam(base_dir, 'user_agents_blocked',
|
||||
set_config_param(base_dir, 'user_agents_blocked',
|
||||
user_agents_blockedStr)
|
||||
|
||||
# save peertube instances list
|
||||
|
@ -18809,7 +18814,7 @@ def runDaemon(content_license_url: str,
|
|||
if not os.path.isdir(base_dir + '/accounts/news@' + domain):
|
||||
print('Creating news inbox: news@' + domain)
|
||||
createNewsInbox(base_dir, domain, port, http_prefix)
|
||||
setConfigParam(base_dir, "lists_enabled", "Murdoch press")
|
||||
set_config_param(base_dir, "lists_enabled", "Murdoch press")
|
||||
|
||||
# dict of known web crawlers accessing nodeinfo or the masto API
|
||||
# and how many times they have been seen
|
||||
|
|
67
epicyon.py
67
epicyon.py
|
@ -69,7 +69,7 @@ from utils import remove_domain_port
|
|||
from utils import get_port_from_domain
|
||||
from utils import has_users_path
|
||||
from utils import get_full_domain
|
||||
from utils import setConfigParam
|
||||
from utils import set_config_param
|
||||
from utils import get_config_param
|
||||
from utils import get_domain_from_actor
|
||||
from utils import getNicknameFromActor
|
||||
|
@ -688,9 +688,10 @@ if base_dir.endswith('/'):
|
|||
if args.libretranslateUrl:
|
||||
if '://' in args.libretranslateUrl and \
|
||||
'.' in args.libretranslateUrl:
|
||||
setConfigParam(base_dir, 'libretranslateUrl', args.libretranslateUrl)
|
||||
set_config_param(base_dir, 'libretranslateUrl', args.libretranslateUrl)
|
||||
if args.libretranslateApiKey:
|
||||
setConfigParam(base_dir, 'libretranslateApiKey', args.libretranslateApiKey)
|
||||
set_config_param(base_dir, 'libretranslateApiKey',
|
||||
args.libretranslateApiKey)
|
||||
|
||||
if args.posts:
|
||||
if not args.domain:
|
||||
|
@ -994,7 +995,7 @@ if not os.path.isdir(base_dir + '/cache/announce'):
|
|||
# set the theme in config.json
|
||||
theme_name = get_config_param(base_dir, 'theme')
|
||||
if not theme_name:
|
||||
setConfigParam(base_dir, 'theme', 'default')
|
||||
set_config_param(base_dir, 'theme', 'default')
|
||||
theme_name = 'default'
|
||||
|
||||
if not args.mediainstance:
|
||||
|
@ -1024,23 +1025,23 @@ if not args.blogsinstance:
|
|||
# set the instance title in config.json
|
||||
title = get_config_param(base_dir, 'instanceTitle')
|
||||
if not title:
|
||||
setConfigParam(base_dir, 'instanceTitle', 'Epicyon')
|
||||
set_config_param(base_dir, 'instanceTitle', 'Epicyon')
|
||||
|
||||
# set the instance description in config.json
|
||||
descFull = get_config_param(base_dir, 'instanceDescription')
|
||||
if not descFull:
|
||||
setConfigParam(base_dir, 'instanceDescription',
|
||||
set_config_param(base_dir, 'instanceDescription',
|
||||
'Just another ActivityPub server')
|
||||
|
||||
# set the short instance description in config.json
|
||||
descShort = get_config_param(base_dir, 'instanceDescriptionShort')
|
||||
if not descShort:
|
||||
setConfigParam(base_dir, 'instanceDescriptionShort',
|
||||
set_config_param(base_dir, 'instanceDescriptionShort',
|
||||
'Just another ActivityPub server')
|
||||
|
||||
if args.domain:
|
||||
domain = args.domain
|
||||
setConfigParam(base_dir, 'domain', domain)
|
||||
set_config_param(base_dir, 'domain', domain)
|
||||
|
||||
if args.rss:
|
||||
session = createSession(None)
|
||||
|
@ -1056,7 +1057,7 @@ if args.onion:
|
|||
if '://' in args.onion:
|
||||
args.onion = args.onion.split('://')[1]
|
||||
onion_domain = args.onion
|
||||
setConfigParam(base_dir, 'onion', onion_domain)
|
||||
set_config_param(base_dir, 'onion', onion_domain)
|
||||
|
||||
i2p_domain = None
|
||||
if args.i2p_domain:
|
||||
|
@ -1066,7 +1067,7 @@ if args.i2p_domain:
|
|||
if '://' in args.i2p_domain:
|
||||
args.onion = args.onion.split('://')[1]
|
||||
i2p_domain = args.i2p_domain
|
||||
setConfigParam(base_dir, 'i2p_domain', i2p_domain)
|
||||
set_config_param(base_dir, 'i2p_domain', i2p_domain)
|
||||
|
||||
if not args.language:
|
||||
languageCode = get_config_param(base_dir, 'language')
|
||||
|
@ -1080,30 +1081,30 @@ if not args.maxRegistrations:
|
|||
maxRegistrations = get_config_param(base_dir, 'maxRegistrations')
|
||||
if not maxRegistrations:
|
||||
maxRegistrations = 10
|
||||
setConfigParam(base_dir, 'maxRegistrations', str(maxRegistrations))
|
||||
set_config_param(base_dir, 'maxRegistrations', str(maxRegistrations))
|
||||
else:
|
||||
maxRegistrations = int(maxRegistrations)
|
||||
else:
|
||||
maxRegistrations = args.maxRegistrations
|
||||
setConfigParam(base_dir, 'maxRegistrations', str(maxRegistrations))
|
||||
set_config_param(base_dir, 'maxRegistrations', str(maxRegistrations))
|
||||
|
||||
# if this is the initial run then allow new registrations
|
||||
if not get_config_param(base_dir, 'registration'):
|
||||
if args.registration.lower() == 'open':
|
||||
setConfigParam(base_dir, 'registration', 'open')
|
||||
setConfigParam(base_dir, 'maxRegistrations', str(maxRegistrations))
|
||||
setConfigParam(base_dir, 'registrationsRemaining',
|
||||
set_config_param(base_dir, 'registration', 'open')
|
||||
set_config_param(base_dir, 'maxRegistrations', str(maxRegistrations))
|
||||
set_config_param(base_dir, 'registrationsRemaining',
|
||||
str(maxRegistrations))
|
||||
|
||||
if args.resetregistrations:
|
||||
setConfigParam(base_dir, 'registrationsRemaining', str(maxRegistrations))
|
||||
set_config_param(base_dir, 'registrationsRemaining', str(maxRegistrations))
|
||||
print('Number of new registrations reset to ' + str(maxRegistrations))
|
||||
|
||||
# unique ID for the instance
|
||||
instance_id = get_config_param(base_dir, 'instance_id')
|
||||
if not instance_id:
|
||||
instance_id = createPassword(32)
|
||||
setConfigParam(base_dir, 'instance_id', instance_id)
|
||||
set_config_param(base_dir, 'instance_id', instance_id)
|
||||
print('Instance ID: ' + instance_id)
|
||||
|
||||
# get domain name from configuration
|
||||
|
@ -1160,7 +1161,7 @@ if args.federation_list:
|
|||
': Federate with domains, not individual accounts')
|
||||
sys.exit()
|
||||
federation_list = args.federation_list.copy()
|
||||
setConfigParam(base_dir, 'federation_list', federation_list)
|
||||
set_config_param(base_dir, 'federation_list', federation_list)
|
||||
else:
|
||||
configFederationList = get_config_param(base_dir, 'federation_list')
|
||||
if configFederationList:
|
||||
|
@ -2058,13 +2059,13 @@ if args.followRequestsList:
|
|||
nickname = 'admin'
|
||||
if args.domain:
|
||||
domain = args.domain
|
||||
setConfigParam(base_dir, 'domain', domain)
|
||||
set_config_param(base_dir, 'domain', domain)
|
||||
if args.port:
|
||||
port = args.port
|
||||
setConfigParam(base_dir, 'port', port)
|
||||
set_config_param(base_dir, 'port', port)
|
||||
if args.proxy_port:
|
||||
proxy_port = args.proxy_port
|
||||
setConfigParam(base_dir, 'proxy_port', proxy_port)
|
||||
set_config_param(base_dir, 'proxy_port', proxy_port)
|
||||
if args.gnunet:
|
||||
http_prefix = 'gnunet'
|
||||
if args.dat or args.hyper:
|
||||
|
@ -2610,7 +2611,7 @@ if args.shared_items_federated_domains:
|
|||
shared_items_federated_domains = []
|
||||
if args.shared_items_federated_domains:
|
||||
fed_domains_str = args.shared_items_federated_domains
|
||||
setConfigParam(base_dir, 'shared_items_federated_domains',
|
||||
set_config_param(base_dir, 'shared_items_federated_domains',
|
||||
fed_domains_str)
|
||||
else:
|
||||
fed_domains_str = \
|
||||
|
@ -2811,7 +2812,7 @@ if args.testdata:
|
|||
shutil.rmtree(base_dir + '/wfendpoints',
|
||||
ignore_errors=False, onerror=None)
|
||||
|
||||
setConfigParam(base_dir, 'registrationsRemaining',
|
||||
set_config_param(base_dir, 'registrationsRemaining',
|
||||
str(maxRegistrations))
|
||||
|
||||
createPerson(base_dir, 'maxboardroom', domain, port, http_prefix,
|
||||
|
@ -2994,7 +2995,7 @@ if args.testdata:
|
|||
federation_list, False, False)
|
||||
followerOfPerson(base_dir, nickname, domain, 'maxboardroom', domain_full,
|
||||
federation_list, False, False)
|
||||
setConfigParam(base_dir, 'admin', nickname)
|
||||
set_config_param(base_dir, 'admin', nickname)
|
||||
|
||||
# set a lower bound to the maximum mentions
|
||||
# so that it can't be accidentally set to zero and disable replies
|
||||
|
@ -3012,7 +3013,7 @@ if minimumvotes:
|
|||
content_license_url = ''
|
||||
if args.content_license_url:
|
||||
content_license_url = args.content_license_url
|
||||
setConfigParam(base_dir, 'content_license_url', content_license_url)
|
||||
set_config_param(base_dir, 'content_license_url', content_license_url)
|
||||
else:
|
||||
content_license_url = get_config_param(base_dir, 'content_license_url')
|
||||
|
||||
|
@ -3141,7 +3142,7 @@ if low_bandwidth is not None:
|
|||
user_agents_blocked = []
|
||||
if args.userAgentBlocks:
|
||||
user_agents_blockedStr = args.userAgentBlocks
|
||||
setConfigParam(base_dir, 'user_agents_blocked', user_agents_blockedStr)
|
||||
set_config_param(base_dir, 'user_agents_blocked', user_agents_blockedStr)
|
||||
else:
|
||||
user_agents_blockedStr = \
|
||||
get_config_param(base_dir, 'user_agents_blocked')
|
||||
|
@ -3153,7 +3154,7 @@ if user_agents_blockedStr:
|
|||
lists_enabled = ''
|
||||
if args.lists_enabled:
|
||||
lists_enabled = args.lists_enabled
|
||||
setConfigParam(base_dir, 'lists_enabled', lists_enabled)
|
||||
set_config_param(base_dir, 'lists_enabled', lists_enabled)
|
||||
else:
|
||||
lists_enabled = get_config_param(base_dir, 'lists_enabled')
|
||||
|
||||
|
@ -3189,24 +3190,24 @@ if args.registration:
|
|||
if args.registration.lower() == 'open':
|
||||
registration = get_config_param(base_dir, 'registration')
|
||||
if not registration:
|
||||
setConfigParam(base_dir, 'registrationsRemaining',
|
||||
set_config_param(base_dir, 'registrationsRemaining',
|
||||
str(maxRegistrations))
|
||||
else:
|
||||
if registration != 'open':
|
||||
setConfigParam(base_dir, 'registrationsRemaining',
|
||||
set_config_param(base_dir, 'registrationsRemaining',
|
||||
str(maxRegistrations))
|
||||
setConfigParam(base_dir, 'registration', 'open')
|
||||
set_config_param(base_dir, 'registration', 'open')
|
||||
print('New registrations open')
|
||||
else:
|
||||
setConfigParam(base_dir, 'registration', 'closed')
|
||||
set_config_param(base_dir, 'registration', 'closed')
|
||||
print('New registrations closed')
|
||||
|
||||
defaultCurrency = get_config_param(base_dir, 'defaultCurrency')
|
||||
if not defaultCurrency:
|
||||
setConfigParam(base_dir, 'defaultCurrency', 'EUR')
|
||||
set_config_param(base_dir, 'defaultCurrency', 'EUR')
|
||||
if args.defaultCurrency:
|
||||
if args.defaultCurrency == args.defaultCurrency.upper():
|
||||
setConfigParam(base_dir, 'defaultCurrency', args.defaultCurrency)
|
||||
set_config_param(base_dir, 'defaultCurrency', args.defaultCurrency)
|
||||
print('Default currency set to ' + args.defaultCurrency)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -48,7 +48,7 @@ from utils import get_full_domain
|
|||
from utils import validNickname
|
||||
from utils import load_json
|
||||
from utils import save_json
|
||||
from utils import setConfigParam
|
||||
from utils import set_config_param
|
||||
from utils import get_config_param
|
||||
from utils import refresh_newswire
|
||||
from utils import get_protocol_prefixes
|
||||
|
@ -628,7 +628,7 @@ def createPerson(base_dir: str, nickname: str, domain: str, port: int,
|
|||
if not get_config_param(base_dir, 'admin'):
|
||||
if nickname != 'news':
|
||||
# print(nickname+' becomes the instance admin and a moderator')
|
||||
setConfigParam(base_dir, 'admin', nickname)
|
||||
set_config_param(base_dir, 'admin', nickname)
|
||||
setRole(base_dir, nickname, domain, 'admin')
|
||||
setRole(base_dir, nickname, domain, 'moderator')
|
||||
setRole(base_dir, nickname, domain, 'editor')
|
||||
|
@ -701,7 +701,7 @@ def createPerson(base_dir: str, nickname: str, domain: str, port: int,
|
|||
copyfile(defaultBannerFilename, accountDir + '/banner.png')
|
||||
if nickname != 'news' and remainingConfigExists:
|
||||
registrationsRemaining -= 1
|
||||
setConfigParam(base_dir, 'registrationsRemaining',
|
||||
set_config_param(base_dir, 'registrationsRemaining',
|
||||
str(registrationsRemaining))
|
||||
savePersonQrcode(base_dir, nickname, domain, port)
|
||||
return privateKeyPem, publicKeyPem, newPerson, webfingerEndpoint
|
||||
|
|
6
tests.py
6
tests.py
|
@ -61,7 +61,7 @@ from utils import is_group_account
|
|||
from utils import get_actor_languages_list
|
||||
from utils import get_category_types
|
||||
from utils import get_supported_languages
|
||||
from utils import setConfigParam
|
||||
from utils import set_config_param
|
||||
from utils import is_group_actor
|
||||
from utils import date_string_to_seconds
|
||||
from utils import date_seconds_to_string
|
||||
|
@ -1723,8 +1723,8 @@ def testSharedItemsFederation(base_dir: str) -> None:
|
|||
print("Alice and Bob agree to share items catalogs")
|
||||
assert os.path.isdir(aliceDir)
|
||||
assert os.path.isdir(bobDir)
|
||||
setConfigParam(aliceDir, 'shared_items_federated_domains', bobAddress)
|
||||
setConfigParam(bobDir, 'shared_items_federated_domains', aliceAddress)
|
||||
set_config_param(aliceDir, 'shared_items_federated_domains', bobAddress)
|
||||
set_config_param(bobDir, 'shared_items_federated_domains', aliceAddress)
|
||||
|
||||
print('*********************************************************')
|
||||
print('Alice sends a follow request to Bob')
|
||||
|
|
11
utils.py
11
utils.py
|
@ -501,16 +501,17 @@ def _create_config(base_dir: str) -> None:
|
|||
save_json(config_json, config_filename)
|
||||
|
||||
|
||||
def setConfigParam(base_dir: str, variable_name: str, variable_value) -> None:
|
||||
def set_config_param(base_dir: str, variable_name: str,
|
||||
variable_value) -> None:
|
||||
"""Sets a configuration value
|
||||
"""
|
||||
_create_config(base_dir)
|
||||
config_filename = base_dir + '/config.json'
|
||||
configJson = {}
|
||||
config_json = {}
|
||||
if os.path.isfile(config_filename):
|
||||
configJson = load_json(config_filename)
|
||||
configJson[variable_name] = variable_value
|
||||
save_json(configJson, config_filename)
|
||||
config_json = load_json(config_filename)
|
||||
config_json[variable_name] = variable_value
|
||||
save_json(config_json, config_filename)
|
||||
|
||||
|
||||
def get_config_param(base_dir: str, variable_name: str):
|
||||
|
|
Loading…
Reference in New Issue