diff --git a/blocking.py b/blocking.py index 3a5820af7..94599fee2 100644 --- a/blocking.py +++ b/blocking.py @@ -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 diff --git a/daemon.py b/daemon.py index eed95243a..4edfd9d21 100644 --- a/daemon.py +++ b/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,22 +5055,22 @@ class PubServer(BaseHTTPRequestHandler): self.server.blogs_instance = False self.server.news_instance = False self.server.defaultTimeline = 'tlmedia' - setConfigParam(base_dir, - "media_instance", - self.server.media_instance) - setConfigParam(base_dir, - "blogs_instance", - self.server.blogs_instance) - setConfigParam(base_dir, - "news_instance", - self.server.news_instance) + set_config_param(base_dir, + "media_instance", + self.server.media_instance) + set_config_param(base_dir, + "blogs_instance", + self.server.blogs_instance) + 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, - "media_instance", - self.server.media_instance) + set_config_param(base_dir, + "media_instance", + self.server.media_instance) # is this a news theme? if isNewsThemeName(self.server.base_dir, @@ -5086,22 +5086,22 @@ class PubServer(BaseHTTPRequestHandler): self.server.blogs_instance = False self.server.media_instance = False self.server.defaultTimeline = 'tlfeatures' - setConfigParam(base_dir, - "media_instance", - self.server.media_instance) - setConfigParam(base_dir, - "blogs_instance", - self.server.blogs_instance) - setConfigParam(base_dir, - "news_instance", - self.server.news_instance) + set_config_param(base_dir, + "media_instance", + self.server.media_instance) + set_config_param(base_dir, + "blogs_instance", + self.server.blogs_instance) + 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, - "news_instance", - self.server.media_instance) + set_config_param(base_dir, + "news_instance", + self.server.media_instance) # change blog instance status if fields.get('blogs_instance'): @@ -5112,30 +5112,30 @@ class PubServer(BaseHTTPRequestHandler): self.server.media_instance = False self.server.news_instance = False self.server.defaultTimeline = 'tlblogs' - setConfigParam(base_dir, - "blogs_instance", - self.server.blogs_instance) - setConfigParam(base_dir, - "media_instance", - self.server.media_instance) - setConfigParam(base_dir, - "news_instance", - self.server.news_instance) + set_config_param(base_dir, + "blogs_instance", + self.server.blogs_instance) + set_config_param(base_dir, + "media_instance", + self.server.media_instance) + 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, - "blogs_instance", - self.server.blogs_instance) + set_config_param(base_dir, + "blogs_instance", + self.server.blogs_instance) # change instance title if fields.get('instanceTitle'): currInstanceTitle = \ get_config_param(base_dir, 'instanceTitle') if fields['instanceTitle'] != currInstanceTitle: - setConfigParam(base_dir, 'instanceTitle', - fields['instanceTitle']) + set_config_param(base_dir, 'instanceTitle', + fields['instanceTitle']) # change YouTube alternate domain if fields.get('ytdomain'): @@ -5147,14 +5147,14 @@ class PubServer(BaseHTTPRequestHandler): if '/' in newYTDomain: newYTDomain = newYTDomain.split('/')[0] if '.' in newYTDomain: - setConfigParam(base_dir, - 'youtubedomain', - newYTDomain) + set_config_param(base_dir, + 'youtubedomain', + newYTDomain) self.server.yt_replace_domain = \ newYTDomain else: - setConfigParam(base_dir, - 'youtubedomain', '') + set_config_param(base_dir, + 'youtubedomain', '') self.server.yt_replace_domain = None # change twitter alternate domain @@ -5170,14 +5170,14 @@ class PubServer(BaseHTTPRequestHandler): newTwitterDomain = \ newTwitterDomain.split('/')[0] if '.' in newTwitterDomain: - setConfigParam(base_dir, - 'twitterdomain', - newTwitterDomain) + set_config_param(base_dir, + 'twitterdomain', + newTwitterDomain) self.server.twitter_replacement_domain = \ newTwitterDomain else: - setConfigParam(base_dir, - 'twitterdomain', '') + set_config_param(base_dir, + 'twitterdomain', '') self.server.twitter_replacement_domain = None # change custom post submit button text @@ -5187,13 +5187,13 @@ class PubServer(BaseHTTPRequestHandler): if fields['customSubmitText'] != \ currCustomSubmitText: customText = fields['customSubmitText'] - setConfigParam(base_dir, - 'customSubmitText', - customText) + set_config_param(base_dir, + 'customSubmitText', + customText) else: if currCustomSubmitText: - setConfigParam(base_dir, - 'customSubmitText', '') + set_config_param(base_dir, + 'customSubmitText', '') # libretranslate URL currLibretranslateUrl = \ @@ -5205,13 +5205,13 @@ class PubServer(BaseHTTPRequestHandler): ltUrl = fields['libretranslateUrl'] if '://' in ltUrl and \ '.' in ltUrl: - setConfigParam(base_dir, - 'libretranslateUrl', - ltUrl) + set_config_param(base_dir, + 'libretranslateUrl', + ltUrl) else: if currLibretranslateUrl: - setConfigParam(base_dir, - 'libretranslateUrl', '') + set_config_param(base_dir, + 'libretranslateUrl', '') # libretranslate API Key currLibretranslateApiKey = \ @@ -5221,30 +5221,30 @@ class PubServer(BaseHTTPRequestHandler): if fields['libretranslateApiKey'] != \ currLibretranslateApiKey: ltApiKey = fields['libretranslateApiKey'] - setConfigParam(base_dir, - 'libretranslateApiKey', - ltApiKey) + set_config_param(base_dir, + 'libretranslateApiKey', + ltApiKey) else: if currLibretranslateApiKey: - setConfigParam(base_dir, - 'libretranslateApiKey', '') + set_config_param(base_dir, + 'libretranslateApiKey', '') # change instance short description if fields.get('content_license_url'): if fields['content_license_url'] != \ self.server.content_license_url: licenseStr = fields['content_license_url'] - setConfigParam(base_dir, - 'content_license_url', - licenseStr) + set_config_param(base_dir, + 'content_license_url', + licenseStr) self.server.content_license_url = \ licenseStr else: licenseStr = \ 'https://creativecommons.org/licenses/by/4.0' - setConfigParam(base_dir, - 'content_license_url', - licenseStr) + set_config_param(base_dir, + 'content_license_url', + licenseStr) self.server.content_license_url = licenseStr # change instance short description @@ -5255,13 +5255,14 @@ class PubServer(BaseHTTPRequestHandler): if fields['instanceDescriptionShort'] != \ currInstanceDescriptionShort: iDesc = fields['instanceDescriptionShort'] - setConfigParam(base_dir, - 'instanceDescriptionShort', - iDesc) + 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,13 +5270,13 @@ class PubServer(BaseHTTPRequestHandler): if fields.get('instanceDescription'): if fields['instanceDescription'] != \ currInstanceDescription: - setConfigParam(base_dir, - 'instanceDescription', - fields['instanceDescription']) + set_config_param(base_dir, + 'instanceDescription', + fields['instanceDescription']) else: if currInstanceDescription: - setConfigParam(base_dir, - 'instanceDescription', '') + set_config_param(base_dir, + 'instanceDescription', '') # change email address currentEmailAddress = getEmailAddress(actor_json) @@ -5560,8 +5561,9 @@ 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", - show_node_info_accounts) + set_config_param(base_dir, + "show_node_info_accounts", + show_node_info_accounts) show_node_info_version = False if fields.get('show_node_info_version'): @@ -5569,8 +5571,9 @@ 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", - show_node_info_version) + set_config_param(base_dir, + "show_node_info_version", + show_node_info_version) verify_all_signatures = False if fields.get('verifyallsignatures'): @@ -5578,8 +5581,8 @@ class PubServer(BaseHTTPRequestHandler): verify_all_signatures = True self.server.verify_all_signatures = \ verify_all_signatures - setConfigParam(base_dir, "verify_all_signatures", - verify_all_signatures) + set_config_param(base_dir, "verify_all_signatures", + verify_all_signatures) broch_mode = False if fields.get('broch_mode'): @@ -5591,8 +5594,8 @@ class PubServer(BaseHTTPRequestHandler): setBrochMode(self.server.base_dir, self.server.domain_full, broch_mode) - setConfigParam(base_dir, "broch_mode", - broch_mode) + set_config_param(base_dir, "broch_mode", + broch_mode) # shared item federation domains siDomainUpdated = False @@ -5618,15 +5621,17 @@ class PubServer(BaseHTTPRequestHandler): shareDomainList.replace('\n', ',') sharedItemsField = \ "shared_items_federated_domains" - setConfigParam(base_dir, sharedItemsField, - sharedItemsFormStr2) + 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: siDomains = sharedItemsFormStr.split('\n') @@ -6219,8 +6224,8 @@ class PubServer(BaseHTTPRequestHandler): if fields['low_bandwidth'] == 'on': low_bandwidth = True if currLowBandwidth != low_bandwidth: - setConfigParam(base_dir, 'low_bandwidth', - low_bandwidth) + set_config_param(base_dir, 'low_bandwidth', + low_bandwidth) self.server.low_bandwidth = low_bandwidth # save filtered words list @@ -6400,9 +6405,9 @@ class PubServer(BaseHTTPRequestHandler): newListsEnabled += name if newListsEnabled != self.server.lists_enabled: self.server.lists_enabled = newListsEnabled - setConfigParam(self.server.base_dir, - "lists_enabled", - newListsEnabled) + set_config_param(self.server.base_dir, + "lists_enabled", + newListsEnabled) # save blocked user agents user_agents_blocked = [] @@ -6424,8 +6429,8 @@ class PubServer(BaseHTTPRequestHandler): if user_agents_blockedStr: user_agents_blockedStr += ',' user_agents_blockedStr += ua - setConfigParam(base_dir, 'user_agents_blocked', - user_agents_blockedStr) + set_config_param(base_dir, 'user_agents_blocked', + user_agents_blockedStr) # save peertube instances list peertube_instancesFile = \ @@ -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 diff --git a/epicyon.py b/epicyon.py index 27bfa5da1..2ca24edac 100644 --- a/epicyon.py +++ b/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', - 'Just another ActivityPub server') + 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', - 'Just another ActivityPub server') + 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', - str(maxRegistrations)) + 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,8 +2611,8 @@ 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', - fed_domains_str) + set_config_param(base_dir, 'shared_items_federated_domains', + fed_domains_str) else: fed_domains_str = \ get_config_param(base_dir, 'shared_items_federated_domains') @@ -2811,8 +2812,8 @@ if args.testdata: shutil.rmtree(base_dir + '/wfendpoints', ignore_errors=False, onerror=None) - setConfigParam(base_dir, 'registrationsRemaining', - str(maxRegistrations)) + set_config_param(base_dir, 'registrationsRemaining', + str(maxRegistrations)) createPerson(base_dir, 'maxboardroom', domain, port, http_prefix, True, False, password) @@ -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', - str(maxRegistrations)) + set_config_param(base_dir, 'registrationsRemaining', + str(maxRegistrations)) else: if registration != 'open': - setConfigParam(base_dir, 'registrationsRemaining', - str(maxRegistrations)) - setConfigParam(base_dir, 'registration', 'open') + set_config_param(base_dir, 'registrationsRemaining', + str(maxRegistrations)) + 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__": diff --git a/person.py b/person.py index 7b98b5792..2fa452e67 100644 --- a/person.py +++ b/person.py @@ -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,8 +701,8 @@ 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', - str(registrationsRemaining)) + set_config_param(base_dir, 'registrationsRemaining', + str(registrationsRemaining)) savePersonQrcode(base_dir, nickname, domain, port) return privateKeyPem, publicKeyPem, newPerson, webfingerEndpoint diff --git a/tests.py b/tests.py index f5ca7442a..02c4926cf 100644 --- a/tests.py +++ b/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') diff --git a/utils.py b/utils.py index 2fc628a90..72cf7e327 100644 --- a/utils.py +++ b/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):