mirror of https://gitlab.com/bashrc2/epicyon
Replace file deletion with function
parent
831ea8a612
commit
ab2ced1e14
25
announce.py
25
announce.py
|
|
@ -41,6 +41,7 @@ from session import post_json
|
||||||
from webfinger import webfinger_handle
|
from webfinger import webfinger_handle
|
||||||
from auth import create_basic_auth_header
|
from auth import create_basic_auth_header
|
||||||
from data import save_string
|
from data import save_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def no_of_announces(post_json_object: {}) -> int:
|
def no_of_announces(post_json_object: {}) -> int:
|
||||||
|
|
@ -592,13 +593,11 @@ def undo_announce_collection_entry(recent_posts_cache: {},
|
||||||
post_json_object)
|
post_json_object)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(cached_post_filename)
|
'EX: undo_announce_collection_entry ' + \
|
||||||
except OSError:
|
'unable to delete cached post ' + \
|
||||||
if debug:
|
str(cached_post_filename)
|
||||||
print('EX: undo_announce_collection_entry ' +
|
remove_file(cached_post_filename, ex_text)
|
||||||
'unable to delete cached post ' +
|
|
||||||
str(cached_post_filename))
|
|
||||||
remove_post_from_cache(post_json_object, recent_posts_cache)
|
remove_post_from_cache(post_json_object, recent_posts_cache)
|
||||||
|
|
||||||
if not post_json_object.get('type'):
|
if not post_json_object.get('type'):
|
||||||
|
|
@ -666,13 +665,11 @@ def update_announce_collection(recent_posts_cache: {},
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
print('update_announce_collection: removing ' +
|
print('update_announce_collection: removing ' +
|
||||||
cached_post_filename)
|
cached_post_filename)
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(cached_post_filename)
|
'EX: update_announce_collection ' + \
|
||||||
except OSError:
|
'unable to delete cached post ' + \
|
||||||
if debug:
|
str(cached_post_filename)
|
||||||
print('EX: update_announce_collection ' +
|
remove_file(cached_post_filename, ex_text)
|
||||||
'unable to delete cached post ' +
|
|
||||||
str(cached_post_filename))
|
|
||||||
remove_post_from_cache(post_json_object, recent_posts_cache)
|
remove_post_from_cache(post_json_object, recent_posts_cache)
|
||||||
|
|
||||||
if not has_object_dict(post_json_object):
|
if not has_object_dict(post_json_object):
|
||||||
|
|
|
||||||
105
blocking.py
105
blocking.py
|
|
@ -58,6 +58,7 @@ from data import load_list
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import save_flag_file
|
from data import save_flag_file
|
||||||
from data import append_string
|
from data import append_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def get_global_block_reason(search_text: str,
|
def get_global_block_reason(search_text: str,
|
||||||
|
|
@ -216,17 +217,13 @@ def add_account_blocks(base_dir: str,
|
||||||
|
|
||||||
if not blocking_file_text:
|
if not blocking_file_text:
|
||||||
if os.path.isfile(blocking_filename):
|
if os.path.isfile(blocking_filename):
|
||||||
try:
|
remove_file(blocking_filename,
|
||||||
os.remove(blocking_filename)
|
'EX: _profile_edit unable to delete blocking ' +
|
||||||
except OSError:
|
blocking_filename)
|
||||||
print('EX: _profile_edit unable to delete blocking ' +
|
|
||||||
blocking_filename)
|
|
||||||
if os.path.isfile(blocking_reasons_filename):
|
if os.path.isfile(blocking_reasons_filename):
|
||||||
try:
|
remove_file(blocking_reasons_filename,
|
||||||
os.remove(blocking_reasons_filename)
|
'EX: _profile_edit unable to delete blocking reasons' +
|
||||||
except OSError:
|
blocking_reasons_filename)
|
||||||
print('EX: _profile_edit unable to delete blocking reasons' +
|
|
||||||
blocking_reasons_filename)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
save_string(blocking_file_text, blocking_filename,
|
save_string(blocking_file_text, blocking_filename,
|
||||||
|
|
@ -1244,12 +1241,10 @@ def mute_post(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
get_cached_post_filename(base_dir, nickname, domain, post_json_object)
|
get_cached_post_filename(base_dir, nickname, domain, post_json_object)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
if remove_file(cached_post_filename,
|
||||||
os.remove(cached_post_filename)
|
'EX: MUTE cached post not removed ' +
|
||||||
|
cached_post_filename):
|
||||||
print('MUTE: cached post removed ' + cached_post_filename)
|
print('MUTE: cached post removed ' + cached_post_filename)
|
||||||
except OSError:
|
|
||||||
print('EX: MUTE cached post not removed ' +
|
|
||||||
cached_post_filename)
|
|
||||||
else:
|
else:
|
||||||
print('MUTE: cached post not found ' + cached_post_filename)
|
print('MUTE: cached post not found ' + cached_post_filename)
|
||||||
|
|
||||||
|
|
@ -1285,14 +1280,13 @@ def mute_post(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
post_json_obj)
|
post_json_obj)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(cached_post_filename)
|
'EX: ' + \
|
||||||
|
'MUTE cached referenced post not removed ' + \
|
||||||
|
cached_post_filename
|
||||||
|
if remove_file(cached_post_filename, ex_text):
|
||||||
print('MUTE: cached referenced post removed ' +
|
print('MUTE: cached referenced post removed ' +
|
||||||
cached_post_filename)
|
cached_post_filename)
|
||||||
except OSError:
|
|
||||||
print('EX: ' +
|
|
||||||
'MUTE cached referenced post not removed ' +
|
|
||||||
cached_post_filename)
|
|
||||||
|
|
||||||
if recent_posts_cache.get('json'):
|
if recent_posts_cache.get('json'):
|
||||||
if recent_posts_cache['json'].get(also_update_post_id):
|
if recent_posts_cache['json'].get(also_update_post_id):
|
||||||
|
|
@ -1320,12 +1314,10 @@ def unmute_post(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
|
|
||||||
mute_filename = post_filename + '.muted'
|
mute_filename = post_filename + '.muted'
|
||||||
if os.path.isfile(mute_filename):
|
if os.path.isfile(mute_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(mute_filename)
|
'EX: unmute_post mute filename not deleted ' + \
|
||||||
except OSError:
|
str(mute_filename)
|
||||||
if debug:
|
remove_file(mute_filename, ex_text)
|
||||||
print('EX: unmute_post mute filename not deleted ' +
|
|
||||||
str(mute_filename))
|
|
||||||
print('UNMUTE: ' + mute_filename + ' file removed')
|
print('UNMUTE: ' + mute_filename + ' file removed')
|
||||||
|
|
||||||
post_json_obj = post_json_object
|
post_json_obj = post_json_object
|
||||||
|
|
@ -1381,12 +1373,10 @@ def unmute_post(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
get_cached_post_filename(base_dir, nickname, domain, post_json_object)
|
get_cached_post_filename(base_dir, nickname, domain, post_json_object)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(cached_post_filename)
|
'EX: unmute_post cached post not deleted ' + \
|
||||||
except OSError:
|
str(cached_post_filename)
|
||||||
if debug:
|
remove_file(cached_post_filename, ex_text)
|
||||||
print('EX: unmute_post cached post not deleted ' +
|
|
||||||
str(cached_post_filename))
|
|
||||||
|
|
||||||
# if the post is in the recent posts cache then mark it as unmuted
|
# if the post is in the recent posts cache then mark it as unmuted
|
||||||
if recent_posts_cache.get('index'):
|
if recent_posts_cache.get('index'):
|
||||||
|
|
@ -1412,15 +1402,13 @@ def unmute_post(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
post_json_obj)
|
post_json_obj)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(cached_post_filename)
|
'EX: ' + \
|
||||||
|
'unmute_post cached ref post not removed ' + \
|
||||||
|
str(cached_post_filename)
|
||||||
|
if remove_file(cached_post_filename, ex_text):
|
||||||
print('MUTE: cached referenced post removed ' +
|
print('MUTE: cached referenced post removed ' +
|
||||||
cached_post_filename)
|
cached_post_filename)
|
||||||
except OSError:
|
|
||||||
if debug:
|
|
||||||
print('EX: ' +
|
|
||||||
'unmute_post cached ref post not removed ' +
|
|
||||||
str(cached_post_filename))
|
|
||||||
|
|
||||||
if recent_posts_cache.get('json'):
|
if recent_posts_cache.get('json'):
|
||||||
if recent_posts_cache['json'].get(also_update_post_id):
|
if recent_posts_cache['json'].get(also_update_post_id):
|
||||||
|
|
@ -1581,11 +1569,10 @@ def set_broch_mode(base_dir: str, domain_full: str, enabled: bool) -> None:
|
||||||
if not enabled:
|
if not enabled:
|
||||||
# remove instance allow list
|
# remove instance allow list
|
||||||
if os.path.isfile(allow_filename):
|
if os.path.isfile(allow_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(allow_filename)
|
'EX: set_broch_mode allow file not deleted ' + \
|
||||||
except OSError:
|
str(allow_filename)
|
||||||
print('EX: set_broch_mode allow file not deleted ' +
|
remove_file(allow_filename, ex_text)
|
||||||
str(allow_filename))
|
|
||||||
print('Broch mode turned off')
|
print('Broch mode turned off')
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(allow_filename):
|
if os.path.isfile(allow_filename):
|
||||||
|
|
@ -1650,12 +1637,11 @@ def broch_modeLapses(base_dir: str, lapse_days: int) -> bool:
|
||||||
days_since_broch = (curr_time - modified_date).days
|
days_since_broch = (curr_time - modified_date).days
|
||||||
if days_since_broch >= lapse_days:
|
if days_since_broch >= lapse_days:
|
||||||
removed: bool = False
|
removed: bool = False
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(allow_filename)
|
'EX: broch_modeLapses allow file not deleted ' + \
|
||||||
|
str(allow_filename)
|
||||||
|
if remove_file(allow_filename, ex_text):
|
||||||
removed = True
|
removed = True
|
||||||
except OSError:
|
|
||||||
print('EX: broch_modeLapses allow file not deleted ' +
|
|
||||||
str(allow_filename))
|
|
||||||
if removed:
|
if removed:
|
||||||
set_config_param(base_dir, "brochMode", False)
|
set_config_param(base_dir, "brochMode", False)
|
||||||
print('Broch mode has elapsed')
|
print('Broch mode has elapsed')
|
||||||
|
|
@ -2178,10 +2164,9 @@ def _update_federated_blocks(session, base_dir: str,
|
||||||
if not new_block_api_str:
|
if not new_block_api_str:
|
||||||
print('DEBUG: federated blocklist not loaded: ' + block_api_filename)
|
print('DEBUG: federated blocklist not loaded: ' + block_api_filename)
|
||||||
if os.path.isfile(block_api_filename):
|
if os.path.isfile(block_api_filename):
|
||||||
try:
|
remove_file(block_api_filename,
|
||||||
os.remove(block_api_filename)
|
'EX: unable to remove block api: ' +
|
||||||
except OSError:
|
block_api_filename)
|
||||||
print('EX: unable to remove block api: ' + block_api_filename)
|
|
||||||
else:
|
else:
|
||||||
print('DEBUG: federated blocklist loaded: ' + str(block_federated))
|
print('DEBUG: federated blocklist loaded: ' + str(block_federated))
|
||||||
save_string(new_block_api_str, block_api_filename,
|
save_string(new_block_api_str, block_api_filename,
|
||||||
|
|
@ -2212,17 +2197,13 @@ def save_block_federated_endpoints(base_dir: str,
|
||||||
result.append(endpoint)
|
result.append(endpoint)
|
||||||
if not block_federated_endpoints_str:
|
if not block_federated_endpoints_str:
|
||||||
if os.path.isfile(block_api_endpoints_filename):
|
if os.path.isfile(block_api_endpoints_filename):
|
||||||
try:
|
remove_file(block_api_endpoints_filename,
|
||||||
os.remove(block_api_endpoints_filename)
|
'EX: unable to delete block_api_endpoints.txt')
|
||||||
except OSError:
|
|
||||||
print('EX: unable to delete block_api_endpoints.txt')
|
|
||||||
block_api_filename = \
|
block_api_filename = \
|
||||||
data_dir(base_dir) + '/block_api.txt'
|
data_dir(base_dir) + '/block_api.txt'
|
||||||
if os.path.isfile(block_api_filename):
|
if os.path.isfile(block_api_filename):
|
||||||
try:
|
remove_file(block_api_filename,
|
||||||
os.remove(block_api_filename)
|
'EX: unable to delete block_api.txt')
|
||||||
except OSError:
|
|
||||||
print('EX: unable to delete block_api.txt')
|
|
||||||
else:
|
else:
|
||||||
save_string(block_federated_endpoints_str,
|
save_string(block_federated_endpoints_str,
|
||||||
block_api_endpoints_filename,
|
block_api_endpoints_filename,
|
||||||
|
|
|
||||||
25
bookmarks.py
25
bookmarks.py
|
|
@ -38,6 +38,7 @@ from session import post_json
|
||||||
from data import load_string
|
from data import load_string
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import prepend_string
|
from data import prepend_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def undo_bookmarks_collection_entry(recent_posts_cache: {},
|
def undo_bookmarks_collection_entry(recent_posts_cache: {},
|
||||||
|
|
@ -60,13 +61,11 @@ def undo_bookmarks_collection_entry(recent_posts_cache: {},
|
||||||
domain, post_json_object)
|
domain, post_json_object)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(cached_post_filename)
|
'EX: undo_bookmarks_collection_entry ' + \
|
||||||
except OSError:
|
'unable to delete cached post file ' + \
|
||||||
if debug:
|
str(cached_post_filename)
|
||||||
print('EX: undo_bookmarks_collection_entry ' +
|
remove_file(cached_post_filename, ex_text)
|
||||||
'unable to delete cached post file ' +
|
|
||||||
str(cached_post_filename))
|
|
||||||
remove_post_from_cache(post_json_object, recent_posts_cache)
|
remove_post_from_cache(post_json_object, recent_posts_cache)
|
||||||
|
|
||||||
# remove from the index
|
# remove from the index
|
||||||
|
|
@ -182,13 +181,11 @@ def update_bookmarks_collection(recent_posts_cache: {},
|
||||||
domain, post_json_object)
|
domain, post_json_object)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(cached_post_filename)
|
'EX: update_bookmarks_collection ' + \
|
||||||
except OSError:
|
'unable to delete cached post ' + \
|
||||||
if debug:
|
str(cached_post_filename)
|
||||||
print('EX: update_bookmarks_collection ' +
|
remove_file(cached_post_filename, ex_text)
|
||||||
'unable to delete cached post ' +
|
|
||||||
str(cached_post_filename))
|
|
||||||
remove_post_from_cache(post_json_object, recent_posts_cache)
|
remove_post_from_cache(post_json_object, recent_posts_cache)
|
||||||
|
|
||||||
if not post_json_object.get('object'):
|
if not post_json_object.get('object'):
|
||||||
|
|
|
||||||
28
cache.py
28
cache.py
|
|
@ -33,6 +33,7 @@ from timeFunctions import date_utcnow
|
||||||
from content import remove_script
|
from content import remove_script
|
||||||
from data import save_binary
|
from data import save_binary
|
||||||
from data import load_binary
|
from data import load_binary
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def remove_person_from_cache(base_dir: str, person_url: str,
|
def remove_person_from_cache(base_dir: str, person_url: str,
|
||||||
|
|
@ -42,10 +43,9 @@ def remove_person_from_cache(base_dir: str, person_url: str,
|
||||||
cache_filename = base_dir + '/cache/actors/' + \
|
cache_filename = base_dir + '/cache/actors/' + \
|
||||||
person_url.replace('/', '#') + '.json'
|
person_url.replace('/', '#') + '.json'
|
||||||
if os.path.isfile(cache_filename):
|
if os.path.isfile(cache_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(cache_filename)
|
'EX: unable to delete cached actor ' + str(cache_filename)
|
||||||
except OSError:
|
remove_file(cache_filename, ex_text)
|
||||||
print('EX: unable to delete cached actor ' + str(cache_filename))
|
|
||||||
if person_cache.get(person_url):
|
if person_cache.get(person_url):
|
||||||
del person_cache[person_url]
|
del person_cache[person_url]
|
||||||
|
|
||||||
|
|
@ -404,12 +404,11 @@ def remove_avatar_from_cache(base_dir: str, actor_str: str) -> None:
|
||||||
base_dir + '/cache/avatars/' + actor_str + '.' + extension
|
base_dir + '/cache/avatars/' + actor_str + '.' + extension
|
||||||
if not os.path.isfile(avatar_filename):
|
if not os.path.isfile(avatar_filename):
|
||||||
continue
|
continue
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(avatar_filename)
|
'EX: remove_avatar_from_cache ' + \
|
||||||
except OSError:
|
'unable to delete cached avatar ' + \
|
||||||
print('EX: remove_avatar_from_cache ' +
|
str(avatar_filename)
|
||||||
'unable to delete cached avatar ' +
|
remove_file(avatar_filename, ex_text)
|
||||||
str(avatar_filename))
|
|
||||||
|
|
||||||
|
|
||||||
def clear_from_post_caches(base_dir: str, recent_posts_cache: {},
|
def clear_from_post_caches(base_dir: str, recent_posts_cache: {},
|
||||||
|
|
@ -428,11 +427,10 @@ def clear_from_post_caches(base_dir: str, recent_posts_cache: {},
|
||||||
cache_dir = os.path.join(dir_str, acct)
|
cache_dir = os.path.join(dir_str, acct)
|
||||||
post_filename = cache_dir + filename
|
post_filename = cache_dir + filename
|
||||||
if os.path.isfile(post_filename):
|
if os.path.isfile(post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(post_filename)
|
'EX: clear_from_post_caches file not removed ' + \
|
||||||
except OSError:
|
str(post_filename)
|
||||||
print('EX: clear_from_post_caches file not removed ' +
|
remove_file(post_filename, ex_text)
|
||||||
str(post_filename))
|
|
||||||
# if the post is in the recent posts cache then remove it
|
# if the post is in the recent posts cache then remove it
|
||||||
if recent_posts_cache.get('index'):
|
if recent_posts_cache.get('index'):
|
||||||
if post_id in recent_posts_cache['index']:
|
if post_id in recent_posts_cache['index']:
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ from utils import replace_strings
|
||||||
from utils import get_invalid_characters
|
from utils import get_invalid_characters
|
||||||
from data import load_string
|
from data import load_string
|
||||||
from data import save_string
|
from data import save_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
MAX_TAG_LENGTH = 42
|
MAX_TAG_LENGTH = 42
|
||||||
|
|
||||||
|
|
@ -174,12 +175,10 @@ def update_hashtag_categories(base_dir: str) -> None:
|
||||||
hashtag_categories = get_hashtag_categories(base_dir, False, None)
|
hashtag_categories = get_hashtag_categories(base_dir, False, None)
|
||||||
if not hashtag_categories:
|
if not hashtag_categories:
|
||||||
if os.path.isfile(category_list_filename):
|
if os.path.isfile(category_list_filename):
|
||||||
try:
|
remove_file(category_list_filename,
|
||||||
os.remove(category_list_filename)
|
'EX: update_hashtag_categories ' +
|
||||||
except OSError:
|
'unable to delete cached category list ' +
|
||||||
print('EX: update_hashtag_categories ' +
|
category_list_filename)
|
||||||
'unable to delete cached category list ' +
|
|
||||||
category_list_filename)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
category_list: list[str] = []
|
category_list: list[str] = []
|
||||||
|
|
|
||||||
36
content.py
36
content.py
|
|
@ -55,6 +55,7 @@ from data import load_string
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import save_binary
|
from data import save_binary
|
||||||
from data import append_string
|
from data import append_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
MUSIC_SITES = ('soundcloud.com', 'bandcamp.com', 'resonate.coop')
|
MUSIC_SITES = ('soundcloud.com', 'bandcamp.com', 'resonate.coop')
|
||||||
|
|
||||||
|
|
@ -1685,21 +1686,16 @@ def save_media_in_form_post(media_bytes, debug: bool,
|
||||||
for ex in extension_types:
|
for ex in extension_types:
|
||||||
possible_other_format = filename_base + '.' + ex
|
possible_other_format = filename_base + '.' + ex
|
||||||
if os.path.isfile(possible_other_format):
|
if os.path.isfile(possible_other_format):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(possible_other_format)
|
'EX: save_media_in_form_post ' + \
|
||||||
except OSError:
|
'unable to delete other ' + \
|
||||||
if debug:
|
str(possible_other_format)
|
||||||
print('EX: save_media_in_form_post ' +
|
remove_file(possible_other_format, ex_text)
|
||||||
'unable to delete other ' +
|
|
||||||
str(possible_other_format))
|
|
||||||
if os.path.isfile(filename_base):
|
if os.path.isfile(filename_base):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(filename_base)
|
'EX: save_media_in_form_post ' + \
|
||||||
except OSError:
|
'unable to delete ' + str(filename_base)
|
||||||
if debug:
|
remove_file(filename_base, ex_text)
|
||||||
print('EX: save_media_in_form_post ' +
|
|
||||||
'unable to delete ' +
|
|
||||||
str(filename_base))
|
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: No media found within POST')
|
print('DEBUG: No media found within POST')
|
||||||
|
|
@ -1788,13 +1784,11 @@ def save_media_in_form_post(media_bytes, debug: bool,
|
||||||
detected_extension, '.' +
|
detected_extension, '.' +
|
||||||
ex)
|
ex)
|
||||||
if os.path.isfile(possible_other_format):
|
if os.path.isfile(possible_other_format):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(possible_other_format)
|
'EX: save_media_in_form_post ' + \
|
||||||
except OSError:
|
'unable to delete other 2 ' + \
|
||||||
if debug:
|
str(possible_other_format)
|
||||||
print('EX: save_media_in_form_post ' +
|
remove_file(possible_other_format, ex_text)
|
||||||
'unable to delete other 2 ' +
|
|
||||||
str(possible_other_format))
|
|
||||||
|
|
||||||
# don't allow scripts within svg files
|
# don't allow scripts within svg files
|
||||||
if detected_extension == 'svg':
|
if detected_extension == 'svg':
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ from session import get_json_valid
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import save_flag_file
|
from data import save_flag_file
|
||||||
from data import append_string
|
from data import append_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _get_conversation_filename(base_dir: str, nickname: str, domain: str,
|
def _get_conversation_filename(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -112,11 +113,9 @@ def unmute_conversation(base_dir: str, nickname: str, domain: str,
|
||||||
return
|
return
|
||||||
if not os.path.isfile(conversation_filename + '.muted'):
|
if not os.path.isfile(conversation_filename + '.muted'):
|
||||||
return
|
return
|
||||||
try:
|
remove_file(conversation_filename + '.muted',
|
||||||
os.remove(conversation_filename + '.muted')
|
'EX: unmute_conversation unable to delete ' +
|
||||||
except OSError:
|
conversation_filename + '.muted')
|
||||||
print('EX: unmute_conversation unable to delete ' +
|
|
||||||
conversation_filename + '.muted')
|
|
||||||
|
|
||||||
|
|
||||||
def _get_replies_to_post(post_json_object: {},
|
def _get_replies_to_post(post_json_object: {},
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ from content import extract_text_fields_in_post
|
||||||
from blocking import is_blocked_hashtag
|
from blocking import is_blocked_hashtag
|
||||||
from filters import is_filtered
|
from filters import is_filtered
|
||||||
from categories import set_hashtag_category
|
from categories import set_hashtag_category
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def set_hashtag_category2(self, calling_domain: str, cookie: str,
|
def set_hashtag_category2(self, calling_domain: str, cookie: str,
|
||||||
|
|
@ -131,11 +132,9 @@ def set_hashtag_category2(self, calling_domain: str, cookie: str,
|
||||||
else:
|
else:
|
||||||
category_filename = base_dir + '/tags/' + hashtag + '.category'
|
category_filename = base_dir + '/tags/' + hashtag + '.category'
|
||||||
if os.path.isfile(category_filename):
|
if os.path.isfile(category_filename):
|
||||||
try:
|
remove_file(category_filename,
|
||||||
os.remove(category_filename)
|
'EX: _set_hashtag_category unable to delete ' +
|
||||||
except OSError:
|
category_filename)
|
||||||
print('EX: _set_hashtag_category unable to delete ' +
|
|
||||||
category_filename)
|
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
redirect_headers(self, tag_screen_str,
|
redirect_headers(self, tag_screen_str,
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ from utils import get_config_param
|
||||||
from httpheaders import redirect_headers
|
from httpheaders import redirect_headers
|
||||||
from content import extract_text_fields_in_post
|
from content import extract_text_fields_in_post
|
||||||
from data import save_string
|
from data import save_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _links_update_edited(fields: {}, links_filename: str) -> None:
|
def _links_update_edited(fields: {}, links_filename: str) -> None:
|
||||||
|
|
@ -43,11 +44,9 @@ def _links_update_edited(fields: {}, links_filename: str) -> None:
|
||||||
links_filename)
|
links_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(links_filename):
|
if os.path.isfile(links_filename):
|
||||||
try:
|
remove_file(links_filename,
|
||||||
os.remove(links_filename)
|
'EX: _links_update unable to delete ' +
|
||||||
except OSError:
|
links_filename)
|
||||||
print('EX: _links_update unable to delete ' +
|
|
||||||
links_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _links_update_about(fields: {}, allow_local_network_access: bool,
|
def _links_update_about(fields: {}, allow_local_network_access: bool,
|
||||||
|
|
@ -63,11 +62,9 @@ def _links_update_about(fields: {}, allow_local_network_access: bool,
|
||||||
about_filename)
|
about_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(about_filename):
|
if os.path.isfile(about_filename):
|
||||||
try:
|
remove_file(about_filename,
|
||||||
os.remove(about_filename)
|
'EX: _links_update unable to delete ' +
|
||||||
except OSError:
|
about_filename)
|
||||||
print('EX: _links_update unable to delete ' +
|
|
||||||
about_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _links_update_tos(fields: {}, allow_local_network_access: bool,
|
def _links_update_tos(fields: {}, allow_local_network_access: bool,
|
||||||
|
|
@ -82,11 +79,9 @@ def _links_update_tos(fields: {}, allow_local_network_access: bool,
|
||||||
'EX: unable to write TOS ' + tos_filename)
|
'EX: unable to write TOS ' + tos_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(tos_filename):
|
if os.path.isfile(tos_filename):
|
||||||
try:
|
remove_file(tos_filename,
|
||||||
os.remove(tos_filename)
|
'EX: _links_update unable to delete ' +
|
||||||
except OSError:
|
tos_filename)
|
||||||
print('EX: _links_update unable to delete ' +
|
|
||||||
tos_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _links_update_sepcification(fields: {},
|
def _links_update_sepcification(fields: {},
|
||||||
|
|
@ -100,11 +95,9 @@ def _links_update_sepcification(fields: {},
|
||||||
specification_filename)
|
specification_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(specification_filename):
|
if os.path.isfile(specification_filename):
|
||||||
try:
|
remove_file(specification_filename,
|
||||||
os.remove(specification_filename)
|
'EX: _links_update_specification unable to delete ' +
|
||||||
except OSError:
|
specification_filename)
|
||||||
print('EX: _links_update_specification unable to delete ' +
|
|
||||||
specification_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def links_update(self, calling_domain: str, cookie: str,
|
def links_update(self, calling_domain: str, cookie: str,
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ from httpheaders import redirect_headers
|
||||||
from content import extract_text_fields_in_post
|
from content import extract_text_fields_in_post
|
||||||
from content import load_dogwhistles
|
from content import load_dogwhistles
|
||||||
from data import save_string
|
from data import save_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def newswire_update(self, calling_domain: str, cookie: str,
|
def newswire_update(self, calling_domain: str, cookie: str,
|
||||||
|
|
@ -128,11 +129,9 @@ def newswire_update(self, calling_domain: str, cookie: str,
|
||||||
else:
|
else:
|
||||||
# text area has been cleared and there is no new feed
|
# text area has been cleared and there is no new feed
|
||||||
if os.path.isfile(newswire_filename):
|
if os.path.isfile(newswire_filename):
|
||||||
try:
|
remove_file(newswire_filename,
|
||||||
os.remove(newswire_filename)
|
'EX: _newswire_update unable to delete ' +
|
||||||
except OSError:
|
newswire_filename)
|
||||||
print('EX: _newswire_update unable to delete ' +
|
|
||||||
newswire_filename)
|
|
||||||
|
|
||||||
# save filtered words list for the newswire
|
# save filtered words list for the newswire
|
||||||
filter_newswire_filename = \
|
filter_newswire_filename = \
|
||||||
|
|
@ -144,11 +143,9 @@ def newswire_update(self, calling_domain: str, cookie: str,
|
||||||
filter_newswire_filename)
|
filter_newswire_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filter_newswire_filename):
|
if os.path.isfile(filter_newswire_filename):
|
||||||
try:
|
remove_file(filter_newswire_filename,
|
||||||
os.remove(filter_newswire_filename)
|
'EX: _newswire_update unable to delete ' +
|
||||||
except OSError:
|
filter_newswire_filename)
|
||||||
print('EX: _newswire_update unable to delete ' +
|
|
||||||
filter_newswire_filename)
|
|
||||||
|
|
||||||
# save dogwhistle words list
|
# save dogwhistle words list
|
||||||
dogwhistles_filename = data_dir(base_dir) + '/dogwhistles.txt'
|
dogwhistles_filename = data_dir(base_dir) + '/dogwhistles.txt'
|
||||||
|
|
@ -175,11 +172,9 @@ def newswire_update(self, calling_domain: str, cookie: str,
|
||||||
hashtag_rules_filename)
|
hashtag_rules_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(hashtag_rules_filename):
|
if os.path.isfile(hashtag_rules_filename):
|
||||||
try:
|
remove_file(hashtag_rules_filename,
|
||||||
os.remove(hashtag_rules_filename)
|
'EX: _newswire_update unable to delete ' +
|
||||||
except OSError:
|
hashtag_rules_filename)
|
||||||
print('EX: _newswire_update unable to delete ' +
|
|
||||||
hashtag_rules_filename)
|
|
||||||
|
|
||||||
newswire_tusted_filename = data_dir(base_dir) + '/newswiretrusted.txt'
|
newswire_tusted_filename = data_dir(base_dir) + '/newswiretrusted.txt'
|
||||||
if fields.get('trustedNewswire'):
|
if fields.get('trustedNewswire'):
|
||||||
|
|
@ -191,11 +186,9 @@ def newswire_update(self, calling_domain: str, cookie: str,
|
||||||
newswire_tusted_filename)
|
newswire_tusted_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(newswire_tusted_filename):
|
if os.path.isfile(newswire_tusted_filename):
|
||||||
try:
|
remove_file(newswire_tusted_filename,
|
||||||
os.remove(newswire_tusted_filename)
|
'EX: _newswire_update unable to delete ' +
|
||||||
except OSError:
|
newswire_tusted_filename)
|
||||||
print('EX: _newswire_update unable to delete ' +
|
|
||||||
newswire_tusted_filename)
|
|
||||||
|
|
||||||
# redirect back to the default timeline
|
# redirect back to the default timeline
|
||||||
redirect_headers(self, actor_str + '/' + default_timeline,
|
redirect_headers(self, actor_str + '/' + default_timeline,
|
||||||
|
|
@ -230,11 +223,9 @@ def citations_update(self, calling_domain: str, cookie: str,
|
||||||
acct_dir(base_dir, nickname, domain) + '/.citations.txt'
|
acct_dir(base_dir, nickname, domain) + '/.citations.txt'
|
||||||
# remove any existing citations file
|
# remove any existing citations file
|
||||||
if os.path.isfile(citations_filename):
|
if os.path.isfile(citations_filename):
|
||||||
try:
|
remove_file(citations_filename,
|
||||||
os.remove(citations_filename)
|
'EX: _citations_update unable to delete ' +
|
||||||
except OSError:
|
citations_filename)
|
||||||
print('EX: _citations_update unable to delete ' +
|
|
||||||
citations_filename)
|
|
||||||
|
|
||||||
if newswire and \
|
if newswire and \
|
||||||
' boundary=' in self.headers['Content-type']:
|
' boundary=' in self.headers['Content-type']:
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ from notifyOnPost import add_notify_on_post
|
||||||
from notifyOnPost import remove_notify_on_post
|
from notifyOnPost import remove_notify_on_post
|
||||||
from flags import is_moderator
|
from flags import is_moderator
|
||||||
from data import save_flag_file
|
from data import save_flag_file
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _person_options_page_number(options_confirm_params: str) -> int:
|
def _person_options_page_number(options_confirm_params: str) -> int:
|
||||||
|
|
@ -603,11 +604,9 @@ def _person_options_post_to_news(self, options_confirm_params: str,
|
||||||
newswire_blocked_filename = account_dir + '/.nonewswire'
|
newswire_blocked_filename = account_dir + '/.nonewswire'
|
||||||
if posts_to_news == 'on':
|
if posts_to_news == 'on':
|
||||||
if os.path.isfile(newswire_blocked_filename):
|
if os.path.isfile(newswire_blocked_filename):
|
||||||
try:
|
remove_file(newswire_blocked_filename,
|
||||||
os.remove(newswire_blocked_filename)
|
'EX: _person_options unable to delete ' +
|
||||||
except OSError:
|
newswire_blocked_filename)
|
||||||
print('EX: _person_options unable to delete ' +
|
|
||||||
newswire_blocked_filename)
|
|
||||||
refresh_newswire(base_dir)
|
refresh_newswire(base_dir)
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(account_dir):
|
if os.path.isdir(account_dir):
|
||||||
|
|
@ -657,11 +656,9 @@ def _person_options_post_to_features(self, options_confirm_params: str,
|
||||||
features_blocked_filename = account_dir + '/.nofeatures'
|
features_blocked_filename = account_dir + '/.nofeatures'
|
||||||
if posts_to_features == 'on':
|
if posts_to_features == 'on':
|
||||||
if os.path.isfile(features_blocked_filename):
|
if os.path.isfile(features_blocked_filename):
|
||||||
try:
|
remove_file(features_blocked_filename,
|
||||||
os.remove(features_blocked_filename)
|
'EX: _person_options unable to delete ' +
|
||||||
except OSError:
|
features_blocked_filename)
|
||||||
print('EX: _person_options unable to delete ' +
|
|
||||||
features_blocked_filename)
|
|
||||||
refresh_newswire(base_dir)
|
refresh_newswire(base_dir)
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(account_dir):
|
if os.path.isdir(account_dir):
|
||||||
|
|
@ -711,11 +708,9 @@ def _person_options_mod_news(self, options_confirm_params: str,
|
||||||
newswire_mod_filename = account_dir + '/.newswiremoderated'
|
newswire_mod_filename = account_dir + '/.newswiremoderated'
|
||||||
if mod_posts_to_news != 'on':
|
if mod_posts_to_news != 'on':
|
||||||
if os.path.isfile(newswire_mod_filename):
|
if os.path.isfile(newswire_mod_filename):
|
||||||
try:
|
remove_file(newswire_mod_filename,
|
||||||
os.remove(newswire_mod_filename)
|
'EX: _person_options unable to delete ' +
|
||||||
except OSError:
|
newswire_mod_filename)
|
||||||
print('EX: _person_options unable to delete ' +
|
|
||||||
newswire_mod_filename)
|
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(account_dir):
|
if os.path.isdir(account_dir):
|
||||||
nw_filename = newswire_mod_filename
|
nw_filename = newswire_mod_filename
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,7 @@ from cache import store_person_in_cache
|
||||||
from daemon_utils import post_to_outbox
|
from daemon_utils import post_to_outbox
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import save_flag_file
|
from data import save_flag_file
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_deactivate_account(base_dir: str, nickname: str, domain: str,
|
def _profile_post_deactivate_account(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -257,11 +258,9 @@ def _profile_post_git_projects(base_dir: str, nickname: str, domain: str,
|
||||||
'EX: unable to write git ' + git_projects_filename)
|
'EX: unable to write git ' + git_projects_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(git_projects_filename):
|
if os.path.isfile(git_projects_filename):
|
||||||
try:
|
remove_file(git_projects_filename,
|
||||||
os.remove(git_projects_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
git_projects_filename)
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
git_projects_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_peertube_instances(base_dir: str, fields: {}, self,
|
def _profile_post_peertube_instances(base_dir: str, fields: {}, self,
|
||||||
|
|
@ -285,11 +284,9 @@ def _profile_post_peertube_instances(base_dir: str, fields: {}, self,
|
||||||
peertube_instances.append(url)
|
peertube_instances.append(url)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(peertube_instances_file):
|
if os.path.isfile(peertube_instances_file):
|
||||||
try:
|
remove_file(peertube_instances_file,
|
||||||
os.remove(peertube_instances_file)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
peertube_instances_file)
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
peertube_instances_file)
|
|
||||||
peertube_instances.clear()
|
peertube_instances.clear()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -319,12 +316,10 @@ def _profile_post_robots_txt(base_dir: str, fields: {}, self) -> None:
|
||||||
if not new_robots_txt:
|
if not new_robots_txt:
|
||||||
self.server.robots_txt = ''
|
self.server.robots_txt = ''
|
||||||
if os.path.isfile(robots_txt_filename):
|
if os.path.isfile(robots_txt_filename):
|
||||||
try:
|
remove_file(robots_txt_filename,
|
||||||
os.remove(robots_txt_filename)
|
'EX: _profile_post_robots_txt' +
|
||||||
except OSError:
|
' unable to delete ' +
|
||||||
print('EX: _profile_post_robots_txt' +
|
robots_txt_filename)
|
||||||
' unable to delete ' +
|
|
||||||
robots_txt_filename)
|
|
||||||
else:
|
else:
|
||||||
save_string(new_robots_txt, robots_txt_filename,
|
save_string(new_robots_txt, robots_txt_filename,
|
||||||
'EX: _profile_post_robots_txt unable to save ' +
|
'EX: _profile_post_robots_txt unable to save ' +
|
||||||
|
|
@ -362,11 +357,8 @@ def _profile_post_buy_domains(base_dir: str, fields: {}, self) -> None:
|
||||||
save_json(buy_sites, buy_sites_filename)
|
save_json(buy_sites, buy_sites_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(buy_sites_filename):
|
if os.path.isfile(buy_sites_filename):
|
||||||
try:
|
remove_file(buy_sites_filename,
|
||||||
os.remove(buy_sites_filename)
|
'EX: unable to delete ' + buy_sites_filename)
|
||||||
except OSError:
|
|
||||||
print('EX: unable to delete ' +
|
|
||||||
buy_sites_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_crawlers_allowed(base_dir: str, fields: {}, self) -> None:
|
def _profile_post_crawlers_allowed(base_dir: str, fields: {}, self) -> None:
|
||||||
|
|
@ -445,12 +437,9 @@ def _profile_post_allowed_instances(base_dir: str, nickname: str, domain: str,
|
||||||
allowed_instances_filename)
|
allowed_instances_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(allowed_instances_filename):
|
if os.path.isfile(allowed_instances_filename):
|
||||||
try:
|
remove_file(allowed_instances_filename,
|
||||||
os.remove(allowed_instances_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
allowed_instances_filename)
|
||||||
print('EX: _profile_edit ' +
|
|
||||||
'unable to delete ' +
|
|
||||||
allowed_instances_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_dm_instances(base_dir: str, nickname: str, domain: str,
|
def _profile_post_dm_instances(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -468,12 +457,9 @@ def _profile_post_dm_instances(base_dir: str, nickname: str, domain: str,
|
||||||
dm_allowed_instances_filename)
|
dm_allowed_instances_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(dm_allowed_instances_filename):
|
if os.path.isfile(dm_allowed_instances_filename):
|
||||||
try:
|
remove_file(dm_allowed_instances_filename,
|
||||||
os.remove(dm_allowed_instances_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
dm_allowed_instances_filename)
|
||||||
print('EX: _profile_edit ' +
|
|
||||||
'unable to delete ' +
|
|
||||||
dm_allowed_instances_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_import_theme(base_dir: str, nickname: str,
|
def _profile_post_import_theme(base_dir: str, nickname: str,
|
||||||
|
|
@ -485,11 +471,9 @@ def _profile_post_import_theme(base_dir: str, nickname: str,
|
||||||
os.mkdir(base_dir + '/imports')
|
os.mkdir(base_dir + '/imports')
|
||||||
filename_base = base_dir + '/imports/newtheme.zip'
|
filename_base = base_dir + '/imports/newtheme.zip'
|
||||||
if os.path.isfile(filename_base):
|
if os.path.isfile(filename_base):
|
||||||
try:
|
remove_file(filename_base,
|
||||||
os.remove(filename_base)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
filename_base)
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
filename_base)
|
|
||||||
if nickname == admin_nickname or is_artist(base_dir, nickname):
|
if nickname == admin_nickname or is_artist(base_dir, nickname):
|
||||||
if import_theme(base_dir, filename_base):
|
if import_theme(base_dir, filename_base):
|
||||||
print(nickname + ' uploaded a theme')
|
print(nickname + ' uploaded a theme')
|
||||||
|
|
@ -541,12 +525,9 @@ def _profile_post_auto_cw(base_dir: str, nickname: str, domain: str,
|
||||||
self.server.auto_cw_cache[nickname] = fields['autoCW'].split('\n')
|
self.server.auto_cw_cache[nickname] = fields['autoCW'].split('\n')
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(auto_cw_filename):
|
if os.path.isfile(auto_cw_filename):
|
||||||
try:
|
remove_file(auto_cw_filename,
|
||||||
os.remove(auto_cw_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
auto_cw_filename)
|
||||||
print('EX: _profile_edit ' +
|
|
||||||
'unable to delete ' +
|
|
||||||
auto_cw_filename)
|
|
||||||
self.server.auto_cw_cache[nickname]: list[str] = []
|
self.server.auto_cw_cache[nickname]: list[str] = []
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -563,11 +544,9 @@ def _profile_post_autogenerated_tags(base_dir: str,
|
||||||
auto_tags_filename)
|
auto_tags_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(auto_tags_filename):
|
if os.path.isfile(auto_tags_filename):
|
||||||
try:
|
remove_file(auto_tags_filename,
|
||||||
os.remove(auto_tags_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
auto_tags_filename)
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
auto_tags_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_word_replacements(base_dir: str,
|
def _profile_post_word_replacements(base_dir: str,
|
||||||
|
|
@ -583,12 +562,9 @@ def _profile_post_word_replacements(base_dir: str,
|
||||||
switch_filename)
|
switch_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(switch_filename):
|
if os.path.isfile(switch_filename):
|
||||||
try:
|
remove_file(switch_filename,
|
||||||
os.remove(switch_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
switch_filename)
|
||||||
print('EX: _profile_edit ' +
|
|
||||||
'unable to delete ' +
|
|
||||||
switch_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_filtered_words_within_bio(base_dir: str,
|
def _profile_post_filtered_words_within_bio(base_dir: str,
|
||||||
|
|
@ -604,12 +580,10 @@ def _profile_post_filtered_words_within_bio(base_dir: str,
|
||||||
filter_bio_filename)
|
filter_bio_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filter_bio_filename):
|
if os.path.isfile(filter_bio_filename):
|
||||||
try:
|
remove_file(filter_bio_filename,
|
||||||
os.remove(filter_bio_filename)
|
'EX: _profile_edit ' +
|
||||||
except OSError:
|
'unable to delete bio filter ' +
|
||||||
print('EX: _profile_edit ' +
|
filter_bio_filename)
|
||||||
'unable to delete bio filter ' +
|
|
||||||
filter_bio_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_filtered_words(base_dir: str, nickname: str, domain: str,
|
def _profile_post_filtered_words(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -623,12 +597,9 @@ def _profile_post_filtered_words(base_dir: str, nickname: str, domain: str,
|
||||||
filter_filename)
|
filter_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filter_filename):
|
if os.path.isfile(filter_filename):
|
||||||
try:
|
remove_file(filter_filename,
|
||||||
os.remove(filter_filename)
|
'EX: _profile_edit unable to delete filter ' +
|
||||||
except OSError:
|
filter_filename)
|
||||||
print('EX: _profile_edit ' +
|
|
||||||
'unable to delete filter ' +
|
|
||||||
filter_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_low_bandwidth(base_dir: str, path: str,
|
def _profile_post_low_bandwidth(base_dir: str, path: str,
|
||||||
|
|
@ -749,12 +720,9 @@ def _profile_post_notify_reactions(base_dir: str,
|
||||||
notify_reactions_filename)
|
notify_reactions_filename)
|
||||||
if not notify_reactions_active:
|
if not notify_reactions_active:
|
||||||
if os.path.isfile(notify_reactions_filename):
|
if os.path.isfile(notify_reactions_filename):
|
||||||
try:
|
remove_file(notify_reactions_filename,
|
||||||
os.remove(notify_reactions_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
notify_reactions_filename)
|
||||||
print('EX: _profile_edit ' +
|
|
||||||
'unable to delete ' +
|
|
||||||
notify_reactions_filename)
|
|
||||||
return actor_changed
|
return actor_changed
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -782,12 +750,9 @@ def _profile_post_notify_likes(on_final_welcome_screen: bool,
|
||||||
notify_likes_filename)
|
notify_likes_filename)
|
||||||
if not notify_likes_active:
|
if not notify_likes_active:
|
||||||
if os.path.isfile(notify_likes_filename):
|
if os.path.isfile(notify_likes_filename):
|
||||||
try:
|
remove_file(notify_likes_filename,
|
||||||
os.remove(notify_likes_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
notify_likes_filename)
|
||||||
print('EX: _profile_edit ' +
|
|
||||||
'unable to delete ' +
|
|
||||||
notify_likes_filename)
|
|
||||||
return actor_changed
|
return actor_changed
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -884,12 +849,9 @@ def _profile_post_no_reply_boosts(base_dir: str, nickname: str, domain: str,
|
||||||
no_reply_boosts_filename)
|
no_reply_boosts_filename)
|
||||||
if not no_reply_boosts:
|
if not no_reply_boosts:
|
||||||
if os.path.isfile(no_reply_boosts_filename):
|
if os.path.isfile(no_reply_boosts_filename):
|
||||||
try:
|
remove_file(no_reply_boosts_filename,
|
||||||
os.remove(no_reply_boosts_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
no_reply_boosts_filename)
|
||||||
print('EX: _profile_edit ' +
|
|
||||||
'unable to delete ' +
|
|
||||||
no_reply_boosts_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_no_seen_posts(base_dir: str, nickname: str, domain: str,
|
def _profile_post_no_seen_posts(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -909,12 +871,9 @@ def _profile_post_no_seen_posts(base_dir: str, nickname: str, domain: str,
|
||||||
no_seen_posts_filename)
|
no_seen_posts_filename)
|
||||||
if not no_seen_posts:
|
if not no_seen_posts:
|
||||||
if os.path.isfile(no_seen_posts_filename):
|
if os.path.isfile(no_seen_posts_filename):
|
||||||
try:
|
remove_file(no_seen_posts_filename,
|
||||||
os.remove(no_seen_posts_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
no_seen_posts_filename)
|
||||||
print('EX: _profile_edit ' +
|
|
||||||
'unable to delete ' +
|
|
||||||
no_seen_posts_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_watermark_enabled(base_dir: str,
|
def _profile_post_watermark_enabled(base_dir: str,
|
||||||
|
|
@ -935,12 +894,10 @@ def _profile_post_watermark_enabled(base_dir: str,
|
||||||
watermark_enabled_filename)
|
watermark_enabled_filename)
|
||||||
if not watermark_enabled:
|
if not watermark_enabled:
|
||||||
if os.path.isfile(watermark_enabled_filename):
|
if os.path.isfile(watermark_enabled_filename):
|
||||||
try:
|
remove_file(watermark_enabled_filename,
|
||||||
os.remove(watermark_enabled_filename)
|
'EX: _profile_edit ' +
|
||||||
except OSError:
|
'unable to delete ' +
|
||||||
print('EX: _profile_edit ' +
|
watermark_enabled_filename)
|
||||||
'unable to delete ' +
|
|
||||||
watermark_enabled_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_hide_follows(base_dir: str, nickname: str, domain: str,
|
def _profile_post_hide_follows(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -970,12 +927,10 @@ def _profile_post_hide_follows(base_dir: str, nickname: str, domain: str,
|
||||||
del self.server.hide_follows[nickname]
|
del self.server.hide_follows[nickname]
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
if os.path.isfile(hide_follows_filename):
|
if os.path.isfile(hide_follows_filename):
|
||||||
try:
|
remove_file(hide_follows_filename,
|
||||||
os.remove(hide_follows_filename)
|
'EX: _profile_post_hide_follows ' +
|
||||||
except OSError:
|
'unable to delete ' +
|
||||||
print('EX: _profile_post_hide_follows ' +
|
hide_follows_filename)
|
||||||
'unable to delete ' +
|
|
||||||
hide_follows_filename)
|
|
||||||
return actor_changed
|
return actor_changed
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1006,12 +961,10 @@ def _profile_post_hide_recent_posts(base_dir: str, nickname: str, domain: str,
|
||||||
del self.server.hide_recent_posts[nickname]
|
del self.server.hide_recent_posts[nickname]
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
if os.path.isfile(hide_recent_posts_filename):
|
if os.path.isfile(hide_recent_posts_filename):
|
||||||
try:
|
remove_file(hide_recent_posts_filename,
|
||||||
os.remove(hide_recent_posts_filename)
|
'EX: _profile_post_hide_recent_posts ' +
|
||||||
except OSError:
|
'unable to delete ' +
|
||||||
print('EX: _profile_post_hide_recent_posts ' +
|
hide_recent_posts_filename)
|
||||||
'unable to delete ' +
|
|
||||||
hide_recent_posts_filename)
|
|
||||||
return actor_changed
|
return actor_changed
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1025,11 +978,9 @@ def _profile_post_mutuals_replies(account_dir: str, fields: {}) -> None:
|
||||||
show_replies_mutuals_file = account_dir + '/.repliesFromMutualsOnly'
|
show_replies_mutuals_file = account_dir + '/.repliesFromMutualsOnly'
|
||||||
if os.path.isfile(show_replies_mutuals_file):
|
if os.path.isfile(show_replies_mutuals_file):
|
||||||
if not show_replies_mutuals:
|
if not show_replies_mutuals:
|
||||||
try:
|
remove_file(show_replies_mutuals_file,
|
||||||
os.remove(show_replies_mutuals_file)
|
'EX: unable to remove repliesFromMutualsOnly file ' +
|
||||||
except OSError:
|
show_replies_mutuals_file)
|
||||||
print('EX: unable to remove repliesFromMutualsOnly file ' +
|
|
||||||
show_replies_mutuals_file)
|
|
||||||
else:
|
else:
|
||||||
if show_replies_mutuals:
|
if show_replies_mutuals:
|
||||||
save_flag_file(show_replies_mutuals_file,
|
save_flag_file(show_replies_mutuals_file,
|
||||||
|
|
@ -1048,12 +999,10 @@ def _profile_post_only_follower_replies(fields: {},
|
||||||
show_replies_followers_file = account_dir + '/.repliesFromFollowersOnly'
|
show_replies_followers_file = account_dir + '/.repliesFromFollowersOnly'
|
||||||
if os.path.isfile(show_replies_followers_file):
|
if os.path.isfile(show_replies_followers_file):
|
||||||
if not show_replies_followers:
|
if not show_replies_followers:
|
||||||
try:
|
remove_file(show_replies_followers_file,
|
||||||
os.remove(show_replies_followers_file)
|
'EX: unable to remove ' +
|
||||||
except OSError:
|
'repliesFromFollowersOnly file ' +
|
||||||
print('EX: unable to remove ' +
|
show_replies_followers_file)
|
||||||
'repliesFromFollowersOnly file ' +
|
|
||||||
show_replies_followers_file)
|
|
||||||
else:
|
else:
|
||||||
if show_replies_followers:
|
if show_replies_followers:
|
||||||
save_flag_file(show_replies_followers_file,
|
save_flag_file(show_replies_followers_file,
|
||||||
|
|
@ -1072,11 +1021,9 @@ def _profile_post_show_quote_toots(fields: {}, account_dir: str) -> None:
|
||||||
show_quote_toots_file = account_dir + '/.allowQuotes'
|
show_quote_toots_file = account_dir + '/.allowQuotes'
|
||||||
if os.path.isfile(show_quote_toots_file):
|
if os.path.isfile(show_quote_toots_file):
|
||||||
if not show_quote_toots:
|
if not show_quote_toots:
|
||||||
try:
|
remove_file(show_quote_toots_file,
|
||||||
os.remove(show_quote_toots_file)
|
'EX: unable to remove allowQuotes file ' +
|
||||||
except OSError:
|
show_quote_toots_file)
|
||||||
print('EX: unable to remove allowQuotes file ' +
|
|
||||||
show_quote_toots_file)
|
|
||||||
else:
|
else:
|
||||||
if show_quote_toots:
|
if show_quote_toots:
|
||||||
save_flag_file(show_quote_toots_file,
|
save_flag_file(show_quote_toots_file,
|
||||||
|
|
@ -1094,11 +1041,9 @@ def _profile_post_show_questions(fields: {}, account_dir: str) -> None:
|
||||||
show_vote_file = account_dir + '/.noVotes'
|
show_vote_file = account_dir + '/.noVotes'
|
||||||
if os.path.isfile(show_vote_file):
|
if os.path.isfile(show_vote_file):
|
||||||
if show_vote_posts:
|
if show_vote_posts:
|
||||||
try:
|
remove_file(show_vote_file,
|
||||||
os.remove(show_vote_file)
|
'EX: unable to remove noVotes file ' +
|
||||||
except OSError:
|
show_vote_file)
|
||||||
print('EX: unable to remove noVotes file ' +
|
|
||||||
show_vote_file)
|
|
||||||
else:
|
else:
|
||||||
if not show_vote_posts:
|
if not show_vote_posts:
|
||||||
save_flag_file(show_vote_file,
|
save_flag_file(show_vote_file,
|
||||||
|
|
@ -1144,11 +1089,9 @@ def _profile_post_bold_reading(base_dir: str,
|
||||||
if self.server.bold_reading.get(nickname):
|
if self.server.bold_reading.get(nickname):
|
||||||
del self.server.bold_reading[nickname]
|
del self.server.bold_reading[nickname]
|
||||||
if os.path.isfile(bold_reading_filename):
|
if os.path.isfile(bold_reading_filename):
|
||||||
try:
|
remove_file(bold_reading_filename,
|
||||||
os.remove(bold_reading_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
bold_reading_filename)
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
bold_reading_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_hide_reaction_button2(base_dir: str,
|
def _profile_post_hide_reaction_button2(base_dir: str,
|
||||||
|
|
@ -1169,18 +1112,14 @@ def _profile_post_hide_reaction_button2(base_dir: str,
|
||||||
hide_reaction_button_file)
|
hide_reaction_button_file)
|
||||||
# remove notify Reaction selection
|
# remove notify Reaction selection
|
||||||
if os.path.isfile(notify_reactions_filename):
|
if os.path.isfile(notify_reactions_filename):
|
||||||
try:
|
remove_file(notify_reactions_filename,
|
||||||
os.remove(notify_reactions_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
notify_reactions_filename)
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
notify_reactions_filename)
|
|
||||||
if not hide_reaction_button_active:
|
if not hide_reaction_button_active:
|
||||||
if os.path.isfile(hide_reaction_button_file):
|
if os.path.isfile(hide_reaction_button_file):
|
||||||
try:
|
remove_file(hide_reaction_button_file,
|
||||||
os.remove(hide_reaction_button_file)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
hide_reaction_button_file)
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
hide_reaction_button_file)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_minimize_images(base_dir: str, nickname: str, domain: str,
|
def _profile_post_minimize_images(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -1224,18 +1163,14 @@ def _profile_post_hide_like_button2(base_dir: str, nickname: str, domain: str,
|
||||||
hide_like_button_file)
|
hide_like_button_file)
|
||||||
# remove notify likes selection
|
# remove notify likes selection
|
||||||
if os.path.isfile(notify_likes_filename):
|
if os.path.isfile(notify_likes_filename):
|
||||||
try:
|
remove_file(notify_likes_filename,
|
||||||
os.remove(notify_likes_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
notify_likes_filename)
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
notify_likes_filename)
|
|
||||||
if not hide_like_button_active:
|
if not hide_like_button_active:
|
||||||
if os.path.isfile(hide_like_button_file):
|
if os.path.isfile(hide_like_button_file):
|
||||||
try:
|
remove_file(hide_like_button_file,
|
||||||
os.remove(hide_like_button_file)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
hide_like_button_file)
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
hide_like_button_file)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_remove_retweets(base_dir: str, nickname: str, domain: str,
|
def _profile_post_remove_retweets(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -1253,11 +1188,9 @@ def _profile_post_remove_retweets(base_dir: str, nickname: str, domain: str,
|
||||||
remove_twitter_filename)
|
remove_twitter_filename)
|
||||||
if not remove_twitter_active:
|
if not remove_twitter_active:
|
||||||
if os.path.isfile(remove_twitter_filename):
|
if os.path.isfile(remove_twitter_filename):
|
||||||
try:
|
remove_file(remove_twitter_filename,
|
||||||
os.remove(remove_twitter_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
remove_twitter_filename)
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
remove_twitter_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_dms_from_followers(base_dir: str, nickname: str, domain: str,
|
def _profile_post_dms_from_followers(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -1284,11 +1217,9 @@ def _profile_post_dms_from_followers(base_dir: str, nickname: str, domain: str,
|
||||||
follow_dms_filename)
|
follow_dms_filename)
|
||||||
if not follow_dms_active:
|
if not follow_dms_active:
|
||||||
if os.path.isfile(follow_dms_filename):
|
if os.path.isfile(follow_dms_filename):
|
||||||
try:
|
remove_file(follow_dms_filename,
|
||||||
os.remove(follow_dms_filename)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
follow_dms_filename)
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
follow_dms_filename)
|
|
||||||
return actor_changed
|
return actor_changed
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1306,21 +1237,17 @@ def _profile_post_remove_custom_font(base_dir: str, nickname: str, domain: str,
|
||||||
font_ext = ('woff', 'woff2', 'otf', 'ttf')
|
font_ext = ('woff', 'woff2', 'otf', 'ttf')
|
||||||
for ext in font_ext:
|
for ext in font_ext:
|
||||||
if os.path.isfile(base_dir + '/fonts/custom.' + ext):
|
if os.path.isfile(base_dir + '/fonts/custom.' + ext):
|
||||||
try:
|
remove_file(base_dir + '/fonts/custom.' + ext,
|
||||||
os.remove(base_dir + '/fonts/custom.' + ext)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
base_dir + '/fonts/custom.' + ext)
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
base_dir + '/fonts/custom.' + ext)
|
|
||||||
if os.path.isfile(base_dir +
|
if os.path.isfile(base_dir +
|
||||||
'/fonts/custom.' + ext + '.etag'):
|
'/fonts/custom.' + ext + '.etag'):
|
||||||
try:
|
remove_file(base_dir +
|
||||||
os.remove(base_dir +
|
'/fonts/custom.' + ext + '.etag',
|
||||||
'/fonts/custom.' + ext + '.etag')
|
'EX: _profile_edit ' +
|
||||||
except OSError:
|
'unable to delete ' +
|
||||||
print('EX: _profile_edit ' +
|
base_dir + '/fonts/custom.' +
|
||||||
'unable to delete ' +
|
ext + '.etag')
|
||||||
base_dir + '/fonts/custom.' +
|
|
||||||
ext + '.etag')
|
|
||||||
curr_theme = get_theme(base_dir)
|
curr_theme = get_theme(base_dir)
|
||||||
if curr_theme:
|
if curr_theme:
|
||||||
self.server.theme_name = curr_theme
|
self.server.theme_name = curr_theme
|
||||||
|
|
@ -1379,10 +1306,8 @@ def _profile_post_reject_spam_actors(base_dir: str,
|
||||||
save_flag_file(actor_spam_filter_filename,
|
save_flag_file(actor_spam_filter_filename,
|
||||||
'EX: unable to write reject spam actors')
|
'EX: unable to write reject spam actors')
|
||||||
else:
|
else:
|
||||||
try:
|
remove_file(actor_spam_filter_filename,
|
||||||
os.remove(actor_spam_filter_filename)
|
'EX: unable to remove reject spam actors')
|
||||||
except OSError:
|
|
||||||
print('EX: unable to remove reject spam actors')
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_approve_followers(on_final_welcome_screen: bool,
|
def _profile_post_approve_followers(on_final_welcome_screen: bool,
|
||||||
|
|
@ -2805,11 +2730,9 @@ def profile_edit(self, calling_domain: str, cookie: str,
|
||||||
os.mkdir(base_dir + '/imports')
|
os.mkdir(base_dir + '/imports')
|
||||||
filename_base = base_dir + '/imports/newtheme.zip'
|
filename_base = base_dir + '/imports/newtheme.zip'
|
||||||
if os.path.isfile(filename_base):
|
if os.path.isfile(filename_base):
|
||||||
try:
|
remove_file(filename_base,
|
||||||
os.remove(filename_base)
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
filename_base)
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
filename_base)
|
|
||||||
elif m_type == 'importFollows':
|
elif m_type == 'importFollows':
|
||||||
filename_base = \
|
filename_base = \
|
||||||
acct_dir(base_dir, nickname, domain) + \
|
acct_dir(base_dir, nickname, domain) + \
|
||||||
|
|
@ -2853,11 +2776,9 @@ def profile_edit(self, calling_domain: str, cookie: str,
|
||||||
' media removing metadata')
|
' media removing metadata')
|
||||||
# remove existing etag
|
# remove existing etag
|
||||||
if os.path.isfile(post_image_filename + '.etag'):
|
if os.path.isfile(post_image_filename + '.etag'):
|
||||||
try:
|
remove_file(post_image_filename + '.etag',
|
||||||
os.remove(post_image_filename + '.etag')
|
'EX: _profile_edit unable to delete ' +
|
||||||
except OSError:
|
post_image_filename + '.etag')
|
||||||
print('EX: _profile_edit unable to delete ' +
|
|
||||||
post_image_filename + '.etag')
|
|
||||||
|
|
||||||
city = get_spoofed_city(self.server.city,
|
city = get_spoofed_city(self.server.city,
|
||||||
base_dir, nickname, domain)
|
base_dir, nickname, domain)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ from posts import create_direct_message_post
|
||||||
from daemon_utils import post_to_outbox
|
from daemon_utils import post_to_outbox
|
||||||
from inbox import populate_replies
|
from inbox import populate_replies
|
||||||
from data import append_string
|
from data import append_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def receive_vote(self, calling_domain: str, cookie: str,
|
def receive_vote(self, calling_domain: str, cookie: str,
|
||||||
|
|
@ -302,12 +303,10 @@ def _send_reply_to_question(self, base_dir: str,
|
||||||
post_json_object)
|
post_json_object)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
remove_file(cached_post_filename,
|
||||||
os.remove(cached_post_filename)
|
'EX: _send_reply_to_question ' +
|
||||||
except OSError:
|
'unable to delete ' +
|
||||||
print('EX: _send_reply_to_question ' +
|
cached_post_filename)
|
||||||
'unable to delete ' +
|
|
||||||
cached_post_filename)
|
|
||||||
# remove from memory cache
|
# remove from memory cache
|
||||||
remove_post_from_cache(post_json_object,
|
remove_post_from_cache(post_json_object,
|
||||||
recent_posts_cache)
|
recent_posts_cache)
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ from shares import add_shares_to_actor
|
||||||
from person import get_actor_update_json
|
from person import get_actor_update_json
|
||||||
from maps import geocoords_to_osm_link
|
from maps import geocoords_to_osm_link
|
||||||
from data import save_string
|
from data import save_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
NEW_POST_SUCCESS = 1
|
NEW_POST_SUCCESS = 1
|
||||||
NEW_POST_FAILED = -1
|
NEW_POST_FAILED = -1
|
||||||
|
|
@ -423,11 +424,9 @@ def _receive_new_post_process_editblog(self, fields: {},
|
||||||
fields['postUrl'].replace('/', '#') + '.html'
|
fields['postUrl'].replace('/', '#') + '.html'
|
||||||
if os.path.isfile(cached_filename):
|
if os.path.isfile(cached_filename):
|
||||||
print('Edited blog post, removing cached html')
|
print('Edited blog post, removing cached html')
|
||||||
try:
|
remove_file(cached_filename,
|
||||||
os.remove(cached_filename)
|
'EX: _receive_new_post_process ' +
|
||||||
except OSError:
|
'unable to delete ' + cached_filename)
|
||||||
print('EX: _receive_new_post_process ' +
|
|
||||||
'unable to delete ' + cached_filename)
|
|
||||||
# remove from memory cache
|
# remove from memory cache
|
||||||
remove_post_from_cache(post_json_object,
|
remove_post_from_cache(post_json_object,
|
||||||
recent_posts_cache)
|
recent_posts_cache)
|
||||||
|
|
@ -1746,11 +1745,9 @@ def _receive_new_post_process_newshare(self, fields: {},
|
||||||
|
|
||||||
if filename:
|
if filename:
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
try:
|
remove_file(filename,
|
||||||
os.remove(filename)
|
'EX: _receive_new_post_process ' +
|
||||||
except OSError:
|
'unable to delete ' + filename)
|
||||||
print('EX: _receive_new_post_process ' +
|
|
||||||
'unable to delete ' + filename)
|
|
||||||
self.post_to_nickname = nickname
|
self.post_to_nickname = nickname
|
||||||
return NEW_POST_SUCCESS
|
return NEW_POST_SUCCESS
|
||||||
|
|
||||||
|
|
|
||||||
15
data.py
15
data.py
|
|
@ -7,6 +7,8 @@ __email__ = "bob@libreserver.org"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
__module_group__ = "Core"
|
__module_group__ = "Core"
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
def _store_base(text: str, filename: str, exception_text: str,
|
def _store_base(text: str, filename: str, exception_text: str,
|
||||||
mode: str) -> bool:
|
mode: str) -> bool:
|
||||||
|
|
@ -148,3 +150,16 @@ def prepend_string(text: str, filename: str, exception_text: str) -> bool:
|
||||||
exception_text = exception_text.replace('[ex]', str(exc))
|
exception_text = exception_text.replace('[ex]', str(exc))
|
||||||
print(exception_text)
|
print(exception_text)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def remove_file(filename: str, exception_text: str) -> bool:
|
||||||
|
"""Deletes a file
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
os.remove(filename)
|
||||||
|
return True
|
||||||
|
except OSError as exc:
|
||||||
|
if '[ex]' in exception_text:
|
||||||
|
exception_text = exception_text.replace('[ex]', str(exc))
|
||||||
|
print(exception_text)
|
||||||
|
return False
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ from session import post_json
|
||||||
from webfinger import webfinger_handle
|
from webfinger import webfinger_handle
|
||||||
from auth import create_basic_auth_header
|
from auth import create_basic_auth_header
|
||||||
from posts import get_person_box
|
from posts import get_person_box
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def send_delete_via_server(base_dir: str, session,
|
def send_delete_via_server(base_dir: str, session,
|
||||||
|
|
@ -214,8 +215,6 @@ def remove_old_hashtags(base_dir: str, max_months: int) -> str:
|
||||||
break
|
break
|
||||||
|
|
||||||
for remove_filename in remove_hashtags:
|
for remove_filename in remove_hashtags:
|
||||||
try:
|
remove_file(remove_filename,
|
||||||
os.remove(remove_filename)
|
'EX: remove_old_hashtags unable to delete ' +
|
||||||
except OSError:
|
remove_filename)
|
||||||
print('EX: remove_old_hashtags unable to delete ' +
|
|
||||||
remove_filename)
|
|
||||||
|
|
|
||||||
25
follow.py
25
follow.py
|
|
@ -49,6 +49,7 @@ from data import load_string
|
||||||
from data import append_string
|
from data import append_string
|
||||||
from data import load_list
|
from data import load_list
|
||||||
from data import save_string
|
from data import save_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def create_initial_last_seen(base_dir: str, http_prefix: str) -> None:
|
def create_initial_last_seen(base_dir: str, http_prefix: str) -> None:
|
||||||
|
|
@ -388,10 +389,8 @@ def clear_follows(base_dir: str, nickname: str, domain: str,
|
||||||
os.mkdir(accounts_dir)
|
os.mkdir(accounts_dir)
|
||||||
filename = accounts_dir + '/' + follow_file
|
filename = accounts_dir + '/' + follow_file
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
try:
|
remove_file(filename,
|
||||||
os.remove(filename)
|
'EX: clear_follows unable to delete ' + filename)
|
||||||
except OSError:
|
|
||||||
print('EX: clear_follows unable to delete ' + filename)
|
|
||||||
|
|
||||||
|
|
||||||
def clear_followers(base_dir: str, nickname: str, domain: str) -> None:
|
def clear_followers(base_dir: str, nickname: str, domain: str) -> None:
|
||||||
|
|
@ -781,12 +780,10 @@ def followed_account_accepts(session, base_dir: str, http_prefix: str,
|
||||||
acct_dir(base_dir, nickname_to_follow, domain_to_follow) + \
|
acct_dir(base_dir, nickname_to_follow, domain_to_follow) + \
|
||||||
'/requests/' + nickname + '@' + domain + '.follow'
|
'/requests/' + nickname + '@' + domain + '.follow'
|
||||||
if os.path.isfile(follow_activity_filename):
|
if os.path.isfile(follow_activity_filename):
|
||||||
try:
|
remove_file(follow_activity_filename,
|
||||||
os.remove(follow_activity_filename)
|
'EX: follow Accept ' +
|
||||||
except OSError:
|
'followed_account_accepts unable to delete ' +
|
||||||
print('EX: follow Accept ' +
|
follow_activity_filename)
|
||||||
'followed_account_accepts unable to delete ' +
|
|
||||||
follow_activity_filename)
|
|
||||||
|
|
||||||
group_account: bool = False
|
group_account: bool = False
|
||||||
if follow_json:
|
if follow_json:
|
||||||
|
|
@ -873,11 +870,9 @@ def followed_account_rejects(session, session_onion, session_i2p,
|
||||||
remove_from_follow_requests(base_dir, nickname_to_follow, domain_to_follow,
|
remove_from_follow_requests(base_dir, nickname_to_follow, domain_to_follow,
|
||||||
deny_handle, debug)
|
deny_handle, debug)
|
||||||
# remove the follow request json
|
# remove the follow request json
|
||||||
try:
|
remove_file(follow_activity_filename,
|
||||||
os.remove(follow_activity_filename)
|
'EX: followed_account_rejects unable to delete ' +
|
||||||
except OSError:
|
follow_activity_filename)
|
||||||
print('EX: followed_account_rejects unable to delete ' +
|
|
||||||
follow_activity_filename)
|
|
||||||
curr_session = session
|
curr_session = session
|
||||||
if domain.endswith('.onion') and session_onion:
|
if domain.endswith('.onion') and session_onion:
|
||||||
curr_session = session_onion
|
curr_session = session_onion
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ from data import load_string
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import append_string
|
from data import append_string
|
||||||
from data import prepend_string
|
from data import prepend_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _strings_are_digits(strings_list: []) -> bool:
|
def _strings_are_digits(strings_list: []) -> bool:
|
||||||
|
|
@ -101,10 +102,8 @@ def _remove_event_from_timeline(event_id: str,
|
||||||
save_string(events_timeline, tl_events_filename,
|
save_string(events_timeline, tl_events_filename,
|
||||||
'EX: ERROR: unable to save events timeline')
|
'EX: ERROR: unable to save events timeline')
|
||||||
elif os.path.isfile(tl_events_filename):
|
elif os.path.isfile(tl_events_filename):
|
||||||
try:
|
remove_file(tl_events_filename,
|
||||||
os.remove(tl_events_filename)
|
'EX: ERROR: unable to remove events timeline')
|
||||||
except OSError:
|
|
||||||
print('EX: ERROR: unable to remove events timeline')
|
|
||||||
|
|
||||||
|
|
||||||
def save_event_post(base_dir: str, handle: str, post_id: str,
|
def save_event_post(base_dir: str, handle: str, post_id: str,
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ from threads import begin_thread
|
||||||
from person import set_person_notes
|
from person import set_person_notes
|
||||||
from data import load_string
|
from data import load_string
|
||||||
from data import save_string
|
from data import save_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _establish_import_session(httpd,
|
def _establish_import_session(httpd,
|
||||||
|
|
@ -220,11 +221,9 @@ def run_import_following(base_dir: str, httpd):
|
||||||
continue
|
continue
|
||||||
if not _update_import_following(base_dir, account, httpd,
|
if not _update_import_following(base_dir, account, httpd,
|
||||||
import_filename):
|
import_filename):
|
||||||
try:
|
remove_file(import_filename,
|
||||||
os.remove(import_filename)
|
'EX: unable to remove import file ' +
|
||||||
except OSError:
|
import_filename)
|
||||||
print('EX: unable to remove import file ' +
|
|
||||||
import_filename)
|
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
||||||
100
inbox.py
100
inbox.py
|
|
@ -143,6 +143,7 @@ from data import save_flag_file
|
||||||
from data import load_string
|
from data import load_string
|
||||||
from data import append_string
|
from data import append_string
|
||||||
from data import prepend_string
|
from data import prepend_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _store_last_post_id(base_dir: str, nickname: str, domain: str,
|
def _store_last_post_id(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -2810,12 +2811,11 @@ def clear_queue_items(base_dir: str, queue: []) -> None:
|
||||||
continue
|
continue
|
||||||
for _, _, queuefiles in os.walk(queue_dir):
|
for _, _, queuefiles in os.walk(queue_dir):
|
||||||
for qfile in queuefiles:
|
for qfile in queuefiles:
|
||||||
try:
|
filename = os.path.join(queue_dir, qfile)
|
||||||
os.remove(os.path.join(queue_dir, qfile))
|
if remove_file(filename,
|
||||||
|
'EX: clear_queue_items unable to delete ' +
|
||||||
|
qfile):
|
||||||
ctr += 1
|
ctr += 1
|
||||||
except OSError:
|
|
||||||
print('EX: clear_queue_items unable to delete ' +
|
|
||||||
qfile)
|
|
||||||
break
|
break
|
||||||
break
|
break
|
||||||
if ctr > 0:
|
if ctr > 0:
|
||||||
|
|
@ -2924,11 +2924,10 @@ def _inbox_quota_exceeded(queue: {}, queue_filename: str,
|
||||||
post_domain + ' reached (' +
|
post_domain + ' reached (' +
|
||||||
str(domain_max_posts_per_day) + ')')
|
str(domain_max_posts_per_day) + ')')
|
||||||
if queue:
|
if queue:
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(queue_filename)
|
'EX: _inbox_quota_exceeded unable to delete 1 ' + \
|
||||||
except OSError:
|
str(queue_filename)
|
||||||
print('EX: _inbox_quota_exceeded unable to delete 1 ' +
|
remove_file(queue_filename, ex_text)
|
||||||
str(queue_filename))
|
|
||||||
if queue:
|
if queue:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
return True
|
return True
|
||||||
|
|
@ -2947,11 +2946,10 @@ def _inbox_quota_exceeded(queue: {}, queue_filename: str,
|
||||||
post_domain + ' reached (' +
|
post_domain + ' reached (' +
|
||||||
str(domain_max_posts_per_min) + ')')
|
str(domain_max_posts_per_min) + ')')
|
||||||
if queue:
|
if queue:
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(queue_filename)
|
'EX: _inbox_quota_exceeded unable to delete 2 ' + \
|
||||||
except OSError:
|
str(queue_filename)
|
||||||
print('EX: _inbox_quota_exceeded unable to delete 2 ' +
|
remove_file(queue_filename, ex_text)
|
||||||
str(queue_filename))
|
|
||||||
if queue:
|
if queue:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
return True
|
return True
|
||||||
|
|
@ -2969,11 +2967,10 @@ def _inbox_quota_exceeded(queue: {}, queue_filename: str,
|
||||||
post_handle + ' reached (' +
|
post_handle + ' reached (' +
|
||||||
str(account_max_posts_per_day) + ')')
|
str(account_max_posts_per_day) + ')')
|
||||||
if queue:
|
if queue:
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(queue_filename)
|
'EX: _inbox_quota_exceeded unable to delete 3 ' + \
|
||||||
except OSError:
|
str(queue_filename)
|
||||||
print('EX: _inbox_quota_exceeded unable to delete 3 ' +
|
remove_file(queue_filename, ex_text)
|
||||||
str(queue_filename))
|
|
||||||
if queue:
|
if queue:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
return True
|
return True
|
||||||
|
|
@ -2992,11 +2989,10 @@ def _inbox_quota_exceeded(queue: {}, queue_filename: str,
|
||||||
post_handle + ' reached (' +
|
post_handle + ' reached (' +
|
||||||
str(account_max_posts_per_min) + ')')
|
str(account_max_posts_per_min) + ')')
|
||||||
if queue:
|
if queue:
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(queue_filename)
|
'EX: _inbox_quota_exceeded unable to delete 4 ' + \
|
||||||
except OSError:
|
str(queue_filename)
|
||||||
print('EX: _inbox_quota_exceeded unable to delete 4 ' +
|
remove_file(queue_filename, ex_text)
|
||||||
str(queue_filename))
|
|
||||||
if queue:
|
if queue:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
return True
|
return True
|
||||||
|
|
@ -3574,11 +3570,10 @@ def run_inbox_queue(server,
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
# delete the queue file
|
# delete the queue file
|
||||||
if os.path.isfile(queue_filename):
|
if os.path.isfile(queue_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(queue_filename)
|
'EX: run_inbox_queue 1 unable to delete ' + \
|
||||||
except OSError:
|
str(queue_filename)
|
||||||
print('EX: run_inbox_queue 1 unable to delete ' +
|
remove_file(queue_filename, ex_text)
|
||||||
str(queue_filename))
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
curr_time = get_current_time_int()
|
curr_time = get_current_time_int()
|
||||||
|
|
@ -3666,11 +3661,10 @@ def run_inbox_queue(server,
|
||||||
sender_nickname = get_nickname_from_actor(queue_json['actor'])
|
sender_nickname = get_nickname_from_actor(queue_json['actor'])
|
||||||
if evil_nickname(sender_nickname):
|
if evil_nickname(sender_nickname):
|
||||||
if os.path.isfile(queue_filename):
|
if os.path.isfile(queue_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(queue_filename)
|
'EX: run_inbox_queue 11 unable to delete ' + \
|
||||||
except OSError:
|
str(queue_filename)
|
||||||
print('EX: run_inbox_queue 11 unable to delete ' +
|
remove_file(queue_filename, ex_text)
|
||||||
str(queue_filename))
|
|
||||||
if queue:
|
if queue:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
|
@ -3743,11 +3737,10 @@ def run_inbox_queue(server,
|
||||||
if debug:
|
if debug:
|
||||||
print('Queue: public key could not be obtained from ' + key_id)
|
print('Queue: public key could not be obtained from ' + key_id)
|
||||||
if os.path.isfile(queue_filename):
|
if os.path.isfile(queue_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(queue_filename)
|
'EX: run_inbox_queue 2 unable to delete ' + \
|
||||||
except OSError:
|
str(queue_filename)
|
||||||
print('EX: run_inbox_queue 2 unable to delete ' +
|
remove_file(queue_filename, ex_text)
|
||||||
str(queue_filename))
|
|
||||||
if queue:
|
if queue:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
|
@ -3803,11 +3796,10 @@ def run_inbox_queue(server,
|
||||||
|
|
||||||
if http_signature_failed or verify_all_signatures:
|
if http_signature_failed or verify_all_signatures:
|
||||||
if os.path.isfile(queue_filename):
|
if os.path.isfile(queue_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(queue_filename)
|
'EX: run_inbox_queue 3 unable to delete ' + \
|
||||||
except OSError:
|
str(queue_filename)
|
||||||
print('EX: run_inbox_queue 3 unable to delete ' +
|
remove_file(queue_filename, ex_text)
|
||||||
str(queue_filename))
|
|
||||||
if queue:
|
if queue:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
continue
|
continue
|
||||||
|
|
@ -3825,11 +3817,10 @@ def run_inbox_queue(server,
|
||||||
print('WARN: jsonld inbox signature check failed ' +
|
print('WARN: jsonld inbox signature check failed ' +
|
||||||
key_id)
|
key_id)
|
||||||
if os.path.isfile(queue_filename):
|
if os.path.isfile(queue_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(queue_filename)
|
'EX: run_inbox_queue 4 unable to delete ' + \
|
||||||
except OSError:
|
str(queue_filename)
|
||||||
print('EX: run_inbox_queue 4 unable to delete ' +
|
remove_file(queue_filename, ex_text)
|
||||||
str(queue_filename))
|
|
||||||
if queue:
|
if queue:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
fitness_performance(inbox_start_time, server.fitness,
|
fitness_performance(inbox_start_time, server.fitness,
|
||||||
|
|
@ -4138,10 +4129,9 @@ def run_inbox_queue(server,
|
||||||
# should the current queue item be removed?
|
# should the current queue item be removed?
|
||||||
if remove_queue_item:
|
if remove_queue_item:
|
||||||
if os.path.isfile(queue_filename):
|
if os.path.isfile(queue_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(queue_filename)
|
'EX: run_inbox_queue 10 unable to delete ' + \
|
||||||
except OSError:
|
str(queue_filename)
|
||||||
print('EX: run_inbox_queue 10 unable to delete ' +
|
remove_file(queue_filename, ex_text)
|
||||||
str(queue_filename))
|
|
||||||
if queue:
|
if queue:
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ from data import save_flag_file
|
||||||
from data import append_string
|
from data import append_string
|
||||||
from data import prepend_string
|
from data import prepend_string
|
||||||
from data import load_string
|
from data import load_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def inbox_update_index(boxname: str, base_dir: str, handle: str,
|
def inbox_update_index(boxname: str, base_dir: str, handle: str,
|
||||||
|
|
@ -352,11 +353,9 @@ def _receive_update_to_question(recent_posts_cache: {}, message_json: {},
|
||||||
get_cached_post_filename(base_dir, nickname, domain, message_json)
|
get_cached_post_filename(base_dir, nickname, domain, message_json)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
remove_file(cached_post_filename,
|
||||||
os.remove(cached_post_filename)
|
'EX: _receive_update_to_question unable to delete ' +
|
||||||
except OSError:
|
cached_post_filename)
|
||||||
print('EX: _receive_update_to_question unable to delete ' +
|
|
||||||
cached_post_filename)
|
|
||||||
# remove from memory cache
|
# remove from memory cache
|
||||||
remove_post_from_cache(message_json, recent_posts_cache)
|
remove_post_from_cache(message_json, recent_posts_cache)
|
||||||
return True
|
return True
|
||||||
|
|
@ -484,11 +483,9 @@ def receive_edit_to_post(recent_posts_cache: {}, message_json: {},
|
||||||
get_cached_post_filename(base_dir, nickname, domain, message_json)
|
get_cached_post_filename(base_dir, nickname, domain, message_json)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
remove_file(cached_post_filename,
|
||||||
os.remove(cached_post_filename)
|
'EX: _receive_edit_to_post unable to delete ' +
|
||||||
except OSError:
|
cached_post_filename)
|
||||||
print('EX: _receive_edit_to_post unable to delete ' +
|
|
||||||
cached_post_filename)
|
|
||||||
# remove any cached html for the post which was edited
|
# remove any cached html for the post which was edited
|
||||||
delete_cached_html(base_dir, nickname, domain, post_json_object)
|
delete_cached_html(base_dir, nickname, domain, post_json_object)
|
||||||
# remove from memory cache
|
# remove from memory cache
|
||||||
|
|
@ -2088,11 +2085,10 @@ def receive_announce(recent_posts_cache: {},
|
||||||
if domain not in announce_url and not_in_onion:
|
if domain not in announce_url and not_in_onion:
|
||||||
if os.path.isfile(post_filename):
|
if os.path.isfile(post_filename):
|
||||||
# if the announce can't be downloaded then remove it
|
# if the announce can't be downloaded then remove it
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(post_filename)
|
'EX: _receive_announce unable to delete ' + \
|
||||||
except OSError:
|
str(post_filename)
|
||||||
print('EX: _receive_announce unable to delete ' +
|
remove_file(post_filename, ex_text)
|
||||||
str(post_filename))
|
|
||||||
else:
|
else:
|
||||||
if debug:
|
if debug:
|
||||||
actor_url = get_actor_from_post(message_json)
|
actor_url = get_actor_from_post(message_json)
|
||||||
|
|
@ -2213,11 +2209,9 @@ def receive_question_vote(server, base_dir: str, nickname: str, domain: str,
|
||||||
get_cached_post_filename(base_dir, nickname, domain, question_json)
|
get_cached_post_filename(base_dir, nickname, domain, question_json)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
remove_file(cached_post_filename,
|
||||||
os.remove(cached_post_filename)
|
'EX: replytoQuestion unable to delete ' +
|
||||||
except OSError:
|
cached_post_filename)
|
||||||
print('EX: replytoQuestion unable to delete ' +
|
|
||||||
cached_post_filename)
|
|
||||||
|
|
||||||
page_number: int = 1
|
page_number: int = 1
|
||||||
show_published_date_only: bool = False
|
show_published_date_only: bool = False
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ from follow import follower_approval_active
|
||||||
from bookmarks import undo_bookmarks_collection_entry
|
from bookmarks import undo_bookmarks_collection_entry
|
||||||
from webapp_post import individual_post_as_html
|
from webapp_post import individual_post_as_html
|
||||||
from reaction import undo_reaction_collection_entry
|
from reaction import undo_reaction_collection_entry
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _receive_undo_follow(base_dir: str, message_json: {},
|
def _receive_undo_follow(base_dir: str, message_json: {},
|
||||||
|
|
@ -652,9 +653,8 @@ def receive_undo_announce(recent_posts_cache: {},
|
||||||
undo_announce_collection_entry(recent_posts_cache, base_dir, post_filename,
|
undo_announce_collection_entry(recent_posts_cache, base_dir, post_filename,
|
||||||
actor_url, domain, debug)
|
actor_url, domain, debug)
|
||||||
if os.path.isfile(post_filename):
|
if os.path.isfile(post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(post_filename)
|
'EX: _receive_undo_announce unable to delete ' + \
|
||||||
except OSError:
|
str(post_filename)
|
||||||
print('EX: _receive_undo_announce unable to delete ' +
|
remove_file(post_filename, ex_text)
|
||||||
str(post_filename))
|
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
20
like.py
20
like.py
|
|
@ -33,6 +33,7 @@ from session import post_json
|
||||||
from webfinger import webfinger_handle
|
from webfinger import webfinger_handle
|
||||||
from auth import create_basic_auth_header
|
from auth import create_basic_auth_header
|
||||||
from posts import get_person_box
|
from posts import get_person_box
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def no_of_likes(post_json_object: {}) -> int:
|
def no_of_likes(post_json_object: {}) -> int:
|
||||||
|
|
@ -471,11 +472,9 @@ def update_likes_collection(recent_posts_cache: {},
|
||||||
domain, post_json_object)
|
domain, post_json_object)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
remove_file(cached_post_filename,
|
||||||
os.remove(cached_post_filename)
|
'EX: update_likes_collection unable to delete ' +
|
||||||
except OSError:
|
cached_post_filename)
|
||||||
print('EX: update_likes_collection unable to delete ' +
|
|
||||||
cached_post_filename)
|
|
||||||
|
|
||||||
obj = post_json_object
|
obj = post_json_object
|
||||||
if has_object_dict(post_json_object):
|
if has_object_dict(post_json_object):
|
||||||
|
|
@ -551,12 +550,11 @@ def undo_likes_collection_entry(recent_posts_cache: {},
|
||||||
domain, post_json_object)
|
domain, post_json_object)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(cached_post_filename)
|
'EX: undo_likes_collection_entry ' + \
|
||||||
except OSError:
|
'unable to delete cached post ' + \
|
||||||
print('EX: undo_likes_collection_entry ' +
|
str(cached_post_filename)
|
||||||
'unable to delete cached post ' +
|
remove_file(cached_post_filename, ex_text)
|
||||||
str(cached_post_filename))
|
|
||||||
remove_post_from_cache(post_json_object, recent_posts_cache)
|
remove_post_from_cache(post_json_object, recent_posts_cache)
|
||||||
|
|
||||||
if not post_json_object.get('type'):
|
if not post_json_object.get('type'):
|
||||||
|
|
|
||||||
7
lxmf.py
7
lxmf.py
|
|
@ -14,6 +14,7 @@ from utils import get_attachment_property_value
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from utils import load_json
|
from utils import load_json
|
||||||
from utils import string_contains
|
from utils import string_contains
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
VALID_LXMF_CHARS = set('0123456789abcdefghijklmnopqrstuvwxyz')
|
VALID_LXMF_CHARS = set('0123456789abcdefghijklmnopqrstuvwxyz')
|
||||||
|
|
||||||
|
|
@ -111,10 +112,8 @@ def set_lxmf_address(base_dir: str, nickname: str, domain: str,
|
||||||
qrcode_filename = \
|
qrcode_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '/qrcode_lxmf.png'
|
acct_dir(base_dir, nickname, domain) + '/qrcode_lxmf.png'
|
||||||
if os.path.isfile(qrcode_filename):
|
if os.path.isfile(qrcode_filename):
|
||||||
try:
|
remove_file(qrcode_filename,
|
||||||
os.remove(qrcode_filename)
|
'EX: cannot remove lxmf qrcode ' + qrcode_filename)
|
||||||
except OSError:
|
|
||||||
print('EX: cannot remove lxmf qrcode ' + qrcode_filename)
|
|
||||||
|
|
||||||
lxmf_address = lxmf_address.strip()
|
lxmf_address = lxmf_address.strip()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ from data import load_string
|
||||||
from data import append_string
|
from data import append_string
|
||||||
from data import prepend_string
|
from data import prepend_string
|
||||||
from data import load_list
|
from data import load_list
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def manual_deny_follow_request2(session, session_onion, session_i2p,
|
def manual_deny_follow_request2(session, session_onion, session_i2p,
|
||||||
|
|
@ -377,17 +378,13 @@ def manual_approve_follow_request(session, session_onion, session_i2p,
|
||||||
# remove the .follow file
|
# remove the .follow file
|
||||||
if follow_activity_filename:
|
if follow_activity_filename:
|
||||||
if os.path.isfile(follow_activity_filename):
|
if os.path.isfile(follow_activity_filename):
|
||||||
try:
|
remove_file(follow_activity_filename,
|
||||||
os.remove(follow_activity_filename)
|
'EX: manual_approve_follow_request ' +
|
||||||
except OSError:
|
'unable to delete ' + follow_activity_filename)
|
||||||
print('EX: manual_approve_follow_request ' +
|
|
||||||
'unable to delete ' + follow_activity_filename)
|
|
||||||
else:
|
else:
|
||||||
try:
|
remove_file(approve_follows_filename + '.new',
|
||||||
os.remove(approve_follows_filename + '.new')
|
'EX: manual_approve_follow_request unable to delete ' +
|
||||||
except OSError:
|
approve_follows_filename + '.new')
|
||||||
print('EX: manual_approve_follow_request unable to delete ' +
|
|
||||||
approve_follows_filename + '.new')
|
|
||||||
|
|
||||||
|
|
||||||
def manual_approve_follow_request_thread(session, session_onion, session_i2p,
|
def manual_approve_follow_request_thread(session, session_onion, session_i2p,
|
||||||
|
|
|
||||||
25
media.py
25
media.py
|
|
@ -35,6 +35,7 @@ from data import load_binary
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import load_string
|
from data import load_string
|
||||||
from data import append_string
|
from data import append_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
# music file ID3 v1 genres
|
# music file ID3 v1 genres
|
||||||
|
|
@ -475,11 +476,9 @@ def convert_image_to_low_bandwidth(image_filename: str) -> None:
|
||||||
"""
|
"""
|
||||||
low_bandwidth_filename = image_filename + '.low'
|
low_bandwidth_filename = image_filename + '.low'
|
||||||
if os.path.isfile(low_bandwidth_filename):
|
if os.path.isfile(low_bandwidth_filename):
|
||||||
try:
|
remove_file(low_bandwidth_filename,
|
||||||
os.remove(low_bandwidth_filename)
|
'EX: convert_image_to_low_bandwidth unable to delete ' +
|
||||||
except OSError:
|
low_bandwidth_filename)
|
||||||
print('EX: convert_image_to_low_bandwidth unable to delete ' +
|
|
||||||
low_bandwidth_filename)
|
|
||||||
|
|
||||||
cmd = \
|
cmd = \
|
||||||
'/usr/bin/convert +noise Multiplicative ' + \
|
'/usr/bin/convert +noise Multiplicative ' + \
|
||||||
|
|
@ -498,11 +497,9 @@ def convert_image_to_low_bandwidth(image_filename: str) -> None:
|
||||||
print('WARN: timed out waiting for low bandwidth image conversion')
|
print('WARN: timed out waiting for low bandwidth image conversion')
|
||||||
break
|
break
|
||||||
if os.path.isfile(low_bandwidth_filename):
|
if os.path.isfile(low_bandwidth_filename):
|
||||||
try:
|
remove_file(image_filename,
|
||||||
os.remove(image_filename)
|
'EX: convert_image_to_low_bandwidth unable to delete ' +
|
||||||
except OSError:
|
image_filename)
|
||||||
print('EX: convert_image_to_low_bandwidth unable to delete ' +
|
|
||||||
image_filename)
|
|
||||||
try:
|
try:
|
||||||
os.rename(low_bandwidth_filename, image_filename)
|
os.rename(low_bandwidth_filename, image_filename)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
|
@ -927,11 +924,9 @@ def apply_watermark_to_image(base_dir: str, nickname: str, domain: str,
|
||||||
if not os.path.isfile(post_image_filename + '.watermarked'):
|
if not os.path.isfile(post_image_filename + '.watermarked'):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
if not remove_file(post_image_filename,
|
||||||
os.remove(post_image_filename)
|
'EX: _apply_watermark_to_image unable to remove ' +
|
||||||
except OSError:
|
post_image_filename):
|
||||||
print('EX: _apply_watermark_to_image unable to remove ' +
|
|
||||||
post_image_filename)
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ from data import load_string
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import append_string
|
from data import append_string
|
||||||
from data import prepend_string
|
from data import prepend_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _update_feeds_outbox_index(base_dir: str, domain: str,
|
def _update_feeds_outbox_index(base_dir: str, domain: str,
|
||||||
|
|
@ -753,11 +754,10 @@ def _convert_rss_to_activitypub(base_dir: str, http_prefix: str,
|
||||||
blog['object']['arrived'])
|
blog['object']['arrived'])
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filename + '.arrived'):
|
if os.path.isfile(filename + '.arrived'):
|
||||||
try:
|
remove_file(filename + '.arrived',
|
||||||
os.remove(filename + '.arrived')
|
'EX: _convert_rss_to_activitypub ' +
|
||||||
except OSError:
|
'unable to delete ' +
|
||||||
print('EX: _convert_rss_to_activitypub ' +
|
filename + '.arrived')
|
||||||
'unable to delete ' + filename + '.arrived')
|
|
||||||
|
|
||||||
# setting the url here links to the activitypub object
|
# setting the url here links to the activitypub object
|
||||||
# stored locally
|
# stored locally
|
||||||
|
|
@ -866,11 +866,10 @@ def run_newswire_daemon(base_dir: str, httpd,
|
||||||
# waiting and recalculate the newswire
|
# waiting and recalculate the newswire
|
||||||
if not os.path.isfile(refresh_filename):
|
if not os.path.isfile(refresh_filename):
|
||||||
continue
|
continue
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(refresh_filename)
|
'EX: run_newswire_daemon unable to delete ' + \
|
||||||
except OSError:
|
str(refresh_filename)
|
||||||
print('EX: run_newswire_daemon unable to delete ' +
|
remove_file(refresh_filename, ex_text)
|
||||||
str(refresh_filename))
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
10
newswire.py
10
newswire.py
|
|
@ -57,6 +57,7 @@ from content import remove_script
|
||||||
from data import load_list
|
from data import load_list
|
||||||
from data import load_string
|
from data import load_string
|
||||||
from data import save_binary
|
from data import save_binary
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _remove_cdata(text: str) -> str:
|
def _remove_cdata(text: str) -> str:
|
||||||
|
|
@ -1799,11 +1800,10 @@ def _add_blogs_to_newswire(base_dir: str, domain: str, newswire: {},
|
||||||
else:
|
else:
|
||||||
# remove the file if there is nothing to moderate
|
# remove the file if there is nothing to moderate
|
||||||
if os.path.isfile(newswire_moderation_filename):
|
if os.path.isfile(newswire_moderation_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(newswire_moderation_filename)
|
'EX: _add_blogs_to_newswire unable to delete ' + \
|
||||||
except OSError:
|
str(newswire_moderation_filename)
|
||||||
print('EX: _add_blogs_to_newswire unable to delete ' +
|
remove_file(newswire_moderation_filename, ex_text)
|
||||||
str(newswire_moderation_filename))
|
|
||||||
|
|
||||||
|
|
||||||
def get_dict_from_newswire(session, base_dir: str, domain: str,
|
def get_dict_from_newswire(session, base_dir: str, domain: str,
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ from inbox_receive import inbox_update_index
|
||||||
from gemini import blog_to_gemini
|
from gemini import blog_to_gemini
|
||||||
from markdown import blog_to_markdown
|
from markdown import blog_to_markdown
|
||||||
from markdown import blog_to_micron
|
from markdown import blog_to_micron
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _localonly_not_local(message_json: {}, domain_full: str) -> bool:
|
def _localonly_not_local(message_json: {}, domain_full: str) -> bool:
|
||||||
|
|
@ -614,11 +615,9 @@ def post_message_to_outbox(session, translate: {},
|
||||||
data_dir(base_dir) + '/' + \
|
data_dir(base_dir) + '/' + \
|
||||||
post_to_nickname + '@' + domain + '/.citations.txt'
|
post_to_nickname + '@' + domain + '/.citations.txt'
|
||||||
if os.path.isfile(citations_filename):
|
if os.path.isfile(citations_filename):
|
||||||
try:
|
remove_file(citations_filename,
|
||||||
os.remove(citations_filename)
|
'EX: post_message_to_outbox unable to delete ' +
|
||||||
except OSError:
|
citations_filename)
|
||||||
print('EX: post_message_to_outbox unable to delete ' +
|
|
||||||
citations_filename)
|
|
||||||
|
|
||||||
# The following activity types get added to the index files
|
# The following activity types get added to the index files
|
||||||
indexed_activities = (
|
indexed_activities = (
|
||||||
|
|
|
||||||
73
person.py
73
person.py
|
|
@ -96,6 +96,7 @@ from data import save_string
|
||||||
from data import save_flag_file
|
from data import save_flag_file
|
||||||
from data import load_string
|
from data import load_string
|
||||||
from data import append_string
|
from data import append_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def generate_rsa_key() -> (str, str):
|
def generate_rsa_key() -> (str, str):
|
||||||
|
|
@ -704,15 +705,13 @@ def clear_person_qrcodes(base_dir: str) -> None:
|
||||||
qrcode_filename = \
|
qrcode_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '/qrcode.png'
|
acct_dir(base_dir, nickname, domain) + '/qrcode.png'
|
||||||
if os.path.isfile(qrcode_filename):
|
if os.path.isfile(qrcode_filename):
|
||||||
try:
|
remove_file(qrcode_filename,
|
||||||
os.remove(qrcode_filename)
|
'EX: clear_person_qrcodes 1 ' +
|
||||||
except OSError:
|
qrcode_filename)
|
||||||
pass
|
|
||||||
if os.path.isfile(qrcode_filename + '.etag'):
|
if os.path.isfile(qrcode_filename + '.etag'):
|
||||||
try:
|
remove_file(qrcode_filename + '.etag',
|
||||||
os.remove(qrcode_filename + '.etag')
|
'EX: clear_person_qrcodes 2 ' +
|
||||||
except OSError:
|
qrcode_filename + '.etag')
|
||||||
pass
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1388,16 +1387,12 @@ def suspend_account(base_dir: str, nickname: str, domain: str) -> None:
|
||||||
account_dir = acct_dir(base_dir, nickname, domain)
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
salt_filename = account_dir + '/.salt'
|
salt_filename = account_dir + '/.salt'
|
||||||
if os.path.isfile(salt_filename):
|
if os.path.isfile(salt_filename):
|
||||||
try:
|
remove_file(salt_filename,
|
||||||
os.remove(salt_filename)
|
'EX: suspend_account unable to delete ' + salt_filename)
|
||||||
except OSError:
|
|
||||||
print('EX: suspend_account unable to delete ' + salt_filename)
|
|
||||||
token_filename = acct_dir(base_dir, nickname, domain) + '/.token'
|
token_filename = acct_dir(base_dir, nickname, domain) + '/.token'
|
||||||
if os.path.isfile(token_filename):
|
if os.path.isfile(token_filename):
|
||||||
try:
|
remove_file(token_filename,
|
||||||
os.remove(token_filename)
|
'EX: suspend_account unable to delete 2 ' + token_filename)
|
||||||
except OSError:
|
|
||||||
print('EX: suspend_account unable to delete 2 ' + token_filename)
|
|
||||||
|
|
||||||
suspended_filename = data_dir(base_dir) + '/suspended.txt'
|
suspended_filename = data_dir(base_dir) + '/suspended.txt'
|
||||||
if os.path.isfile(suspended_filename):
|
if os.path.isfile(suspended_filename):
|
||||||
|
|
@ -1509,10 +1504,8 @@ def _remove_account_media(base_dir: str, nickname: str, domain: str) -> None:
|
||||||
media_filename = base_dir + filename
|
media_filename = base_dir + filename
|
||||||
if not os.path.isfile(media_filename):
|
if not os.path.isfile(media_filename):
|
||||||
continue
|
continue
|
||||||
try:
|
remove_file(media_filename,
|
||||||
os.remove(media_filename)
|
'EX: unable to remove media ' + media_filename)
|
||||||
except OSError:
|
|
||||||
print('EX: unable to remove media ' + media_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def remove_account(base_dir: str, nickname: str,
|
def remove_account(base_dir: str, nickname: str,
|
||||||
|
|
@ -1550,38 +1543,28 @@ def remove_account(base_dir: str, nickname: str,
|
||||||
if os.path.isdir(handle_dir):
|
if os.path.isdir(handle_dir):
|
||||||
shutil.rmtree(handle_dir, ignore_errors=False)
|
shutil.rmtree(handle_dir, ignore_errors=False)
|
||||||
if os.path.isfile(handle_dir + '.json'):
|
if os.path.isfile(handle_dir + '.json'):
|
||||||
try:
|
remove_file(handle_dir + '.json',
|
||||||
os.remove(handle_dir + '.json')
|
'EX: remove_account unable to delete ' +
|
||||||
except OSError:
|
handle_dir + '.json')
|
||||||
print('EX: remove_account unable to delete ' +
|
|
||||||
handle_dir + '.json')
|
|
||||||
if os.path.isfile(base_dir + '/wfendpoints/' + handle + '.json'):
|
if os.path.isfile(base_dir + '/wfendpoints/' + handle + '.json'):
|
||||||
try:
|
remove_file(base_dir + '/wfendpoints/' + handle + '.json',
|
||||||
os.remove(base_dir + '/wfendpoints/' + handle + '.json')
|
'EX: remove_account unable to delete ' +
|
||||||
except OSError:
|
base_dir + '/wfendpoints/' + handle + '.json')
|
||||||
print('EX: remove_account unable to delete ' +
|
|
||||||
base_dir + '/wfendpoints/' + handle + '.json')
|
|
||||||
if os.path.isfile(base_dir + '/keys/private/' + handle + '.key'):
|
if os.path.isfile(base_dir + '/keys/private/' + handle + '.key'):
|
||||||
try:
|
remove_file(base_dir + '/keys/private/' + handle + '.key',
|
||||||
os.remove(base_dir + '/keys/private/' + handle + '.key')
|
'EX: remove_account unable to delete ' +
|
||||||
except OSError:
|
base_dir + '/keys/private/' + handle + '.key')
|
||||||
print('EX: remove_account unable to delete ' +
|
|
||||||
base_dir + '/keys/private/' + handle + '.key')
|
|
||||||
if os.path.isfile(base_dir + '/keys/public/' + handle + '.pem'):
|
if os.path.isfile(base_dir + '/keys/public/' + handle + '.pem'):
|
||||||
try:
|
remove_file(base_dir + '/keys/public/' + handle + '.pem',
|
||||||
os.remove(base_dir + '/keys/public/' + handle + '.pem')
|
'EX: remove_account unable to delete ' +
|
||||||
except OSError:
|
base_dir + '/keys/public/' + handle + '.pem')
|
||||||
print('EX: remove_account unable to delete ' +
|
|
||||||
base_dir + '/keys/public/' + handle + '.pem')
|
|
||||||
if os.path.isdir(base_dir + '/sharefiles/' + nickname):
|
if os.path.isdir(base_dir + '/sharefiles/' + nickname):
|
||||||
shutil.rmtree(base_dir + '/sharefiles/' + nickname,
|
shutil.rmtree(base_dir + '/sharefiles/' + nickname,
|
||||||
ignore_errors=False)
|
ignore_errors=False)
|
||||||
if os.path.isfile(base_dir + '/wfdeactivated/' + handle + '.json'):
|
if os.path.isfile(base_dir + '/wfdeactivated/' + handle + '.json'):
|
||||||
try:
|
remove_file(base_dir + '/wfdeactivated/' + handle + '.json',
|
||||||
os.remove(base_dir + '/wfdeactivated/' + handle + '.json')
|
'EX: remove_account unable to delete ' +
|
||||||
except OSError:
|
base_dir + '/wfdeactivated/' + handle + '.json')
|
||||||
print('EX: remove_account unable to delete ' +
|
|
||||||
base_dir + '/wfdeactivated/' + handle + '.json')
|
|
||||||
if os.path.isdir(base_dir + '/sharefilesdeactivated/' + nickname):
|
if os.path.isdir(base_dir + '/sharefilesdeactivated/' + nickname):
|
||||||
shutil.rmtree(base_dir + '/sharefilesdeactivated/' + nickname,
|
shutil.rmtree(base_dir + '/sharefilesdeactivated/' + nickname,
|
||||||
ignore_errors=False)
|
ignore_errors=False)
|
||||||
|
|
|
||||||
84
posts.py
84
posts.py
|
|
@ -150,6 +150,7 @@ from data import save_string
|
||||||
from data import save_flag_file
|
from data import save_flag_file
|
||||||
from data import append_string
|
from data import append_string
|
||||||
from data import prepend_string
|
from data import prepend_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def convert_post_content_to_html(message_json: {}) -> None:
|
def convert_post_content_to_html(message_json: {}) -> None:
|
||||||
|
|
@ -1053,18 +1054,16 @@ def save_post_to_box(base_dir: str, http_prefix: str, post_id: str,
|
||||||
'/postcache/').replace('.json', '')
|
'/postcache/').replace('.json', '')
|
||||||
ssml_filename = base_filename + '.ssml'
|
ssml_filename = base_filename + '.ssml'
|
||||||
if os.path.isfile(ssml_filename):
|
if os.path.isfile(ssml_filename):
|
||||||
try:
|
remove_file(ssml_filename,
|
||||||
os.remove(ssml_filename)
|
'EX: ' +
|
||||||
except OSError:
|
'save_post_to_box unable to delete ssml file ' +
|
||||||
print('EX: save_post_to_box unable to delete ssml file ' +
|
ssml_filename)
|
||||||
ssml_filename)
|
|
||||||
html_filename = base_filename + '.html'
|
html_filename = base_filename + '.html'
|
||||||
if os.path.isfile(html_filename):
|
if os.path.isfile(html_filename):
|
||||||
try:
|
remove_file(html_filename,
|
||||||
os.remove(html_filename)
|
'EX: ' +
|
||||||
except OSError:
|
'save_post_to_box unable to delete html file ' +
|
||||||
print('EX: save_post_to_box unable to delete html file ' +
|
html_filename)
|
||||||
html_filename)
|
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2168,10 +2167,8 @@ def undo_pinned_post(base_dir: str, nickname: str, domain: str) -> None:
|
||||||
pinned_filename = account_dir + '/pinToProfile.txt'
|
pinned_filename = account_dir + '/pinToProfile.txt'
|
||||||
if not os.path.isfile(pinned_filename):
|
if not os.path.isfile(pinned_filename):
|
||||||
return
|
return
|
||||||
try:
|
remove_file(pinned_filename,
|
||||||
os.remove(pinned_filename)
|
'EX: undo_pinned_post unable to delete ' + pinned_filename)
|
||||||
except OSError:
|
|
||||||
print('EX: undo_pinned_post unable to delete ' + pinned_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def get_pinned_post_as_json(base_dir: str, http_prefix: str,
|
def get_pinned_post_as_json(base_dir: str, http_prefix: str,
|
||||||
|
|
@ -5114,11 +5111,9 @@ def _expire_announce_cache_for_person(base_dir: str,
|
||||||
last_modified = file_last_modified(full_filename)
|
last_modified = file_last_modified(full_filename)
|
||||||
# get time difference
|
# get time difference
|
||||||
if not valid_post_date(last_modified, max_age_days, False):
|
if not valid_post_date(last_modified, max_age_days, False):
|
||||||
try:
|
remove_file(full_filename,
|
||||||
os.remove(full_filename)
|
'EX: unable to delete from announce cache ' +
|
||||||
except OSError:
|
full_filename)
|
||||||
print('EX: unable to delete from announce cache ' +
|
|
||||||
full_filename)
|
|
||||||
expired_post_count += 1
|
expired_post_count += 1
|
||||||
return expired_post_count
|
return expired_post_count
|
||||||
|
|
||||||
|
|
@ -5146,11 +5141,9 @@ def _expire_conversations_for_person(base_dir: str,
|
||||||
last_modified = file_last_modified(full_filename)
|
last_modified = file_last_modified(full_filename)
|
||||||
# get time difference
|
# get time difference
|
||||||
if not valid_post_date(last_modified, max_age_days, False):
|
if not valid_post_date(last_modified, max_age_days, False):
|
||||||
try:
|
remove_file(full_filename,
|
||||||
os.remove(full_filename)
|
'EX: unable to delete from conversations ' +
|
||||||
except OSError:
|
full_filename)
|
||||||
print('EX: unable to delete from conversations ' +
|
|
||||||
full_filename)
|
|
||||||
expired_post_count += 1
|
expired_post_count += 1
|
||||||
return expired_post_count
|
return expired_post_count
|
||||||
|
|
||||||
|
|
@ -5175,11 +5168,9 @@ def _expire_posts_cache_for_person(base_dir: str,
|
||||||
last_modified = file_last_modified(full_filename)
|
last_modified = file_last_modified(full_filename)
|
||||||
# get time difference
|
# get time difference
|
||||||
if not valid_post_date(last_modified, max_age_days, False):
|
if not valid_post_date(last_modified, max_age_days, False):
|
||||||
try:
|
remove_file(full_filename,
|
||||||
os.remove(full_filename)
|
'EX: unable to delete from post cache ' +
|
||||||
except OSError:
|
full_filename)
|
||||||
print('EX: unable to delete from post cache ' +
|
|
||||||
full_filename)
|
|
||||||
expired_post_count += 1
|
expired_post_count += 1
|
||||||
return expired_post_count
|
return expired_post_count
|
||||||
|
|
||||||
|
|
@ -5478,11 +5469,9 @@ def set_post_expiry_keep_dms(base_dir: str, nickname: str, domain: str,
|
||||||
acct_handle_dir(base_dir, handle) + '/.expire_posts_dms'
|
acct_handle_dir(base_dir, handle) + '/.expire_posts_dms'
|
||||||
if keep_dms:
|
if keep_dms:
|
||||||
if os.path.isfile(expire_dms_filename):
|
if os.path.isfile(expire_dms_filename):
|
||||||
try:
|
remove_file(expire_dms_filename,
|
||||||
os.remove(expire_dms_filename)
|
'EX: unable to write set_post_expiry_keep_dms False ' +
|
||||||
except OSError:
|
expire_dms_filename)
|
||||||
print('EX: unable to write set_post_expiry_keep_dms False ' +
|
|
||||||
expire_dms_filename)
|
|
||||||
return
|
return
|
||||||
save_flag_file(expire_dms_filename,
|
save_flag_file(expire_dms_filename,
|
||||||
'EX: unable to write set_post_expiry_keep_dms True ' +
|
'EX: unable to write set_post_expiry_keep_dms True ' +
|
||||||
|
|
@ -5626,12 +5615,11 @@ def archive_posts_for_person(http_prefix: str, nickname: str, domain: str,
|
||||||
if not os.path.isfile(full_original_filename):
|
if not os.path.isfile(full_original_filename):
|
||||||
# if the original file doesn't exist (was remotely deleted by
|
# if the original file doesn't exist (was remotely deleted by
|
||||||
# its author) then remove the corresponding edits
|
# its author) then remove the corresponding edits
|
||||||
try:
|
if remove_file(full_filename,
|
||||||
os.remove(full_filename)
|
'EX: unable to remove ' + ext_name + ' file ' +
|
||||||
|
full_filename):
|
||||||
edits_removed_ctr += 1
|
edits_removed_ctr += 1
|
||||||
except OSError:
|
else:
|
||||||
print('EX: unable to remove ' + ext_name + ' file ' +
|
|
||||||
full_filename)
|
|
||||||
continue
|
continue
|
||||||
edit_files_ctr += 1
|
edit_files_ctr += 1
|
||||||
if os.path.isfile(full_filename):
|
if os.path.isfile(full_filename):
|
||||||
|
|
@ -5681,13 +5669,11 @@ def archive_posts_for_person(http_prefix: str, nickname: str, domain: str,
|
||||||
ext_name + ' ' + file_path + ' -> ' +
|
ext_name + ' ' + file_path + ' -> ' +
|
||||||
archive_path)
|
archive_path)
|
||||||
else:
|
else:
|
||||||
try:
|
if remove_file(edit_filename,
|
||||||
os.remove(edit_filename)
|
'EX: archive_posts_for_person ' +
|
||||||
|
'unable to delete ' +
|
||||||
|
ext_name + ' ' + edit_filename):
|
||||||
remove_edits_ctr += 1
|
remove_edits_ctr += 1
|
||||||
except OSError:
|
|
||||||
print('EX: ' +
|
|
||||||
'archive_posts_for_person unable to delete ' +
|
|
||||||
ext_name + ' ' + edit_filename)
|
|
||||||
if archive_dir:
|
if archive_dir:
|
||||||
print('Archived ' + str(remove_edits_ctr) + ' ' + boxname +
|
print('Archived ' + str(remove_edits_ctr) + ' ' + boxname +
|
||||||
' ' + ext_name + ' for ' + nickname + '@' + domain)
|
' ' + ext_name + ' for ' + nickname + '@' + domain)
|
||||||
|
|
@ -5780,11 +5766,9 @@ def archive_posts_for_person(http_prefix: str, nickname: str, domain: str,
|
||||||
os.path.join(post_cache_dir, post_filename)
|
os.path.join(post_cache_dir, post_filename)
|
||||||
post_cache_filename = post_cache_filename.replace('.json', '.html')
|
post_cache_filename = post_cache_filename.replace('.json', '.html')
|
||||||
if os.path.isfile(post_cache_filename):
|
if os.path.isfile(post_cache_filename):
|
||||||
try:
|
remove_file(post_cache_filename,
|
||||||
os.remove(post_cache_filename)
|
'EX: archive_posts_for_person unable to delete ' +
|
||||||
except OSError:
|
post_cache_filename)
|
||||||
print('EX: archive_posts_for_person unable to delete ' +
|
|
||||||
post_cache_filename)
|
|
||||||
|
|
||||||
no_of_posts -= 1
|
no_of_posts -= 1
|
||||||
remove_ctr += 1
|
remove_ctr += 1
|
||||||
|
|
|
||||||
20
reaction.py
20
reaction.py
|
|
@ -40,6 +40,7 @@ from auth import create_basic_auth_header
|
||||||
from posts import get_person_box
|
from posts import get_person_box
|
||||||
from data import load_list
|
from data import load_list
|
||||||
from data import save_string
|
from data import save_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
# the maximum number of reactions from individual actors which can be
|
# the maximum number of reactions from individual actors which can be
|
||||||
# added to a post. Hence an adversary can't bombard you with sockpuppet
|
# added to a post. Hence an adversary can't bombard you with sockpuppet
|
||||||
|
|
@ -546,11 +547,9 @@ def update_reaction_collection(recent_posts_cache: {},
|
||||||
domain, post_json_object)
|
domain, post_json_object)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
remove_file(cached_post_filename,
|
||||||
os.remove(cached_post_filename)
|
'EX: update_reaction_collection unable to delete ' +
|
||||||
except OSError:
|
cached_post_filename)
|
||||||
print('EX: update_reaction_collection unable to delete ' +
|
|
||||||
cached_post_filename)
|
|
||||||
|
|
||||||
obj = post_json_object
|
obj = post_json_object
|
||||||
if has_object_dict(post_json_object):
|
if has_object_dict(post_json_object):
|
||||||
|
|
@ -716,12 +715,11 @@ def undo_reaction_collection_entry(recent_posts_cache: {},
|
||||||
domain, post_json_object)
|
domain, post_json_object)
|
||||||
if cached_post_filename:
|
if cached_post_filename:
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(cached_post_filename)
|
'EX: undo_reaction_collection_entry ' + \
|
||||||
except OSError:
|
'unable to delete cached post ' + \
|
||||||
print('EX: undo_reaction_collection_entry ' +
|
str(cached_post_filename)
|
||||||
'unable to delete cached post ' +
|
remove_file(cached_post_filename, ex_text)
|
||||||
str(cached_post_filename))
|
|
||||||
remove_post_from_cache(post_json_object, recent_posts_cache)
|
remove_post_from_cache(post_json_object, recent_posts_cache)
|
||||||
|
|
||||||
if not post_json_object.get('type'):
|
if not post_json_object.get('type'):
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ from utils import get_domain_from_actor
|
||||||
from utils import load_json
|
from utils import load_json
|
||||||
from data import load_string
|
from data import load_string
|
||||||
from data import save_string
|
from data import save_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def get_moved_accounts(base_dir: str, nickname: str, domain: str,
|
def get_moved_accounts(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -306,11 +307,9 @@ def update_moved_actors(base_dir: str, debug: bool) -> None:
|
||||||
moved_accounts_filename = data_dir(base_dir) + '/actors_moved.txt'
|
moved_accounts_filename = data_dir(base_dir) + '/actors_moved.txt'
|
||||||
if not moved_str:
|
if not moved_str:
|
||||||
if os.path.isfile(moved_accounts_filename):
|
if os.path.isfile(moved_accounts_filename):
|
||||||
try:
|
remove_file(moved_accounts_filename,
|
||||||
os.remove(moved_accounts_filename)
|
'EX: update_moved_actors unable to remove ' +
|
||||||
except OSError:
|
moved_accounts_filename)
|
||||||
print('EX: update_moved_actors unable to remove ' +
|
|
||||||
moved_accounts_filename)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
save_string(moved_str, moved_accounts_filename,
|
save_string(moved_str, moved_accounts_filename,
|
||||||
|
|
|
||||||
7
roles.py
7
roles.py
|
|
@ -18,6 +18,7 @@ from utils import get_config_param
|
||||||
from status import get_status_number
|
from status import get_status_number
|
||||||
from data import load_list
|
from data import load_list
|
||||||
from data import save_string
|
from data import save_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _clear_role_status(base_dir: str, role: str) -> None:
|
def _clear_role_status(base_dir: str, role: str) -> None:
|
||||||
|
|
@ -315,10 +316,8 @@ def set_roles_from_list(base_dir: str, domain: str, admin_nickname: str,
|
||||||
if not fields.get(list_name):
|
if not fields.get(list_name):
|
||||||
if os.path.isfile(roles_filename):
|
if os.path.isfile(roles_filename):
|
||||||
_clear_role_status(base_dir, role_name)
|
_clear_role_status(base_dir, role_name)
|
||||||
try:
|
remove_file(roles_filename,
|
||||||
os.remove(roles_filename)
|
'EX: failed to remove roles file ' + roles_filename)
|
||||||
except OSError:
|
|
||||||
print('EX: failed to remove roles file ' + roles_filename)
|
|
||||||
return
|
return
|
||||||
_clear_role_status(base_dir, role_name)
|
_clear_role_status(base_dir, role_name)
|
||||||
if ',' in fields[list_name]:
|
if ',' in fields[list_name]:
|
||||||
|
|
|
||||||
37
schedule.py
37
schedule.py
|
|
@ -26,6 +26,7 @@ from threads import begin_thread
|
||||||
from siteactive import save_unavailable_sites
|
from siteactive import save_unavailable_sites
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import load_list
|
from data import load_list
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _update_post_schedule(base_dir: str, handle: str, httpd,
|
def _update_post_schedule(base_dir: str, handle: str, httpd,
|
||||||
|
|
@ -64,12 +65,11 @@ def _update_post_schedule(base_dir: str, handle: str, httpd,
|
||||||
if delete_schedule_post:
|
if delete_schedule_post:
|
||||||
# delete extraneous scheduled posts
|
# delete extraneous scheduled posts
|
||||||
if os.path.isfile(post_filename):
|
if os.path.isfile(post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(post_filename)
|
'EX: ' + \
|
||||||
except OSError:
|
'_update_post_schedule unable to delete ' + \
|
||||||
print('EX: ' +
|
str(post_filename)
|
||||||
'_update_post_schedule unable to delete ' +
|
remove_file(post_filename, ex_text)
|
||||||
str(post_filename))
|
|
||||||
continue
|
continue
|
||||||
# create the new index file
|
# create the new index file
|
||||||
index_lines.append(line)
|
index_lines.append(line)
|
||||||
|
|
@ -173,11 +173,10 @@ def _update_post_schedule(base_dir: str, handle: str, httpd,
|
||||||
httpd.mitm_servers,
|
httpd.mitm_servers,
|
||||||
httpd.instance_software):
|
httpd.instance_software):
|
||||||
index_lines.remove(line)
|
index_lines.remove(line)
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(post_filename)
|
'EX: _update_post_schedule unable to delete ' + \
|
||||||
except OSError:
|
str(post_filename)
|
||||||
print('EX: _update_post_schedule unable to delete ' +
|
remove_file(post_filename, ex_text)
|
||||||
str(post_filename))
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# move to the outbox
|
# move to the outbox
|
||||||
|
|
@ -262,11 +261,9 @@ def remove_scheduled_posts(base_dir: str, nickname: str, domain: str) -> None:
|
||||||
schedule_index_filename = \
|
schedule_index_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '/schedule.index'
|
acct_dir(base_dir, nickname, domain) + '/schedule.index'
|
||||||
if os.path.isfile(schedule_index_filename):
|
if os.path.isfile(schedule_index_filename):
|
||||||
try:
|
remove_file(schedule_index_filename,
|
||||||
os.remove(schedule_index_filename)
|
'EX: remove_scheduled_posts unable to delete ' +
|
||||||
except OSError:
|
schedule_index_filename)
|
||||||
print('EX: remove_scheduled_posts unable to delete ' +
|
|
||||||
schedule_index_filename)
|
|
||||||
# remove the scheduled posts
|
# remove the scheduled posts
|
||||||
scheduled_dir = acct_dir(base_dir, nickname, domain) + '/scheduled'
|
scheduled_dir = acct_dir(base_dir, nickname, domain) + '/scheduled'
|
||||||
if not os.path.isdir(scheduled_dir):
|
if not os.path.isdir(scheduled_dir):
|
||||||
|
|
@ -275,8 +272,6 @@ def remove_scheduled_posts(base_dir: str, nickname: str, domain: str) -> None:
|
||||||
file_path = os.path.join(scheduled_dir, scheduled_post_filename)
|
file_path = os.path.join(scheduled_dir, scheduled_post_filename)
|
||||||
if not os.path.isfile(file_path):
|
if not os.path.isfile(file_path):
|
||||||
continue
|
continue
|
||||||
try:
|
remove_file(file_path,
|
||||||
os.remove(file_path)
|
'EX: remove_scheduled_posts unable to delete ' +
|
||||||
except OSError:
|
file_path)
|
||||||
print('EX: remove_scheduled_posts unable to delete ' +
|
|
||||||
file_path)
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ from data import append_string
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import save_binary
|
from data import save_binary
|
||||||
from data import load_binary
|
from data import load_binary
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def create_session(proxy_type: str):
|
def create_session(proxy_type: str):
|
||||||
|
|
@ -846,11 +847,9 @@ def download_image(session, url: str, image_filename: str, debug: bool,
|
||||||
str(result.status_code))
|
str(result.status_code))
|
||||||
# remove partial download
|
# remove partial download
|
||||||
if os.path.isfile(image_filename):
|
if os.path.isfile(image_filename):
|
||||||
try:
|
remove_file(image_filename,
|
||||||
os.remove(image_filename)
|
'EX: download_image unable to delete ' +
|
||||||
except OSError:
|
image_filename)
|
||||||
print('EX: download_image unable to delete ' +
|
|
||||||
image_filename)
|
|
||||||
else:
|
else:
|
||||||
media_binary = result.content
|
media_binary = result.content
|
||||||
if binary_is_image(image_filename, media_binary):
|
if binary_is_image(image_filename, media_binary):
|
||||||
|
|
|
||||||
26
shares.py
26
shares.py
|
|
@ -62,6 +62,7 @@ from cache import remove_person_from_cache
|
||||||
from cache import store_person_in_cache
|
from cache import store_person_in_cache
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import load_string
|
from data import load_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _load_dfc_ids(base_dir: str, system_language: str,
|
def _load_dfc_ids(base_dir: str, system_language: str,
|
||||||
|
|
@ -171,11 +172,9 @@ def remove_shared_item2(base_dir: str, nickname: str, domain: str,
|
||||||
continue
|
continue
|
||||||
if not os.path.isfile(item_idfile + '.' + ext):
|
if not os.path.isfile(item_idfile + '.' + ext):
|
||||||
continue
|
continue
|
||||||
try:
|
remove_file(item_idfile + '.' + ext,
|
||||||
os.remove(item_idfile + '.' + ext)
|
'EX: remove_shared_item unable to delete ' +
|
||||||
except OSError:
|
item_idfile + '.' + ext)
|
||||||
print('EX: remove_shared_item unable to delete ' +
|
|
||||||
item_idfile + '.' + ext)
|
|
||||||
# remove the item itself
|
# remove the item itself
|
||||||
del shares_json[item_id]
|
del shares_json[item_id]
|
||||||
save_json(shares_json, shares_filename)
|
save_json(shares_json, shares_filename)
|
||||||
|
|
@ -401,11 +400,10 @@ def add_share(base_dir: str,
|
||||||
image_filename, item_idfile + '.' + ext,
|
image_filename, item_idfile + '.' + ext,
|
||||||
city, content_license_url, exif_json)
|
city, content_license_url, exif_json)
|
||||||
if move_image:
|
if move_image:
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(image_filename)
|
'EX: add_share unable to delete ' + \
|
||||||
except OSError:
|
str(image_filename)
|
||||||
print('EX: add_share unable to delete ' +
|
remove_file(image_filename, ex_text)
|
||||||
str(image_filename))
|
|
||||||
image_url = \
|
image_url = \
|
||||||
http_prefix + '://' + domain_full + \
|
http_prefix + '://' + domain_full + \
|
||||||
'/sharefiles/' + nickname + '/' + item_id + '.' + ext
|
'/sharefiles/' + nickname + '/' + item_id + '.' + ext
|
||||||
|
|
@ -507,11 +505,9 @@ def _expire_shares_for_account(base_dir: str, nickname: str, domain: str,
|
||||||
for ext in formats:
|
for ext in formats:
|
||||||
if not os.path.isfile(item_idfile + '.' + ext):
|
if not os.path.isfile(item_idfile + '.' + ext):
|
||||||
continue
|
continue
|
||||||
try:
|
remove_file(item_idfile + '.' + ext,
|
||||||
os.remove(item_idfile + '.' + ext)
|
'EX: _expire_shares_for_account unable to delete ' +
|
||||||
except OSError:
|
item_idfile + '.' + ext)
|
||||||
print('EX: _expire_shares_for_account unable to delete ' +
|
|
||||||
item_idfile + '.' + ext)
|
|
||||||
save_json(shares_json, shares_filename)
|
save_json(shares_json, shares_filename)
|
||||||
return removed_ctr
|
return removed_ctr
|
||||||
|
|
||||||
|
|
|
||||||
18
tests.py
18
tests.py
|
|
@ -247,6 +247,7 @@ from blog import html_blog_post_gemini_links
|
||||||
from data import load_list
|
from data import load_list
|
||||||
from data import load_string
|
from data import load_string
|
||||||
from data import save_string
|
from data import save_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
TEST_SERVER_GROUP_RUNNING = False
|
TEST_SERVER_GROUP_RUNNING = False
|
||||||
|
|
@ -4352,10 +4353,7 @@ def _test_json_string() -> None:
|
||||||
assert received_json['content'] == message_str
|
assert received_json['content'] == message_str
|
||||||
encoded_str = json.dumps(test_json, ensure_ascii=False)
|
encoded_str = json.dumps(test_json, ensure_ascii=False)
|
||||||
assert message_str in encoded_str
|
assert message_str in encoded_str
|
||||||
try:
|
remove_file(filename, 'EX: _test_json_string')
|
||||||
os.remove(filename)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def _test_save_load_json():
|
def _test_save_load_json():
|
||||||
|
|
@ -4366,10 +4364,7 @@ def _test_save_load_json():
|
||||||
}
|
}
|
||||||
test_filename = '.epicyon_tests_test_save_load_json.json'
|
test_filename = '.epicyon_tests_test_save_load_json.json'
|
||||||
if os.path.isfile(test_filename):
|
if os.path.isfile(test_filename):
|
||||||
try:
|
remove_file(test_filename, 'EX: _test_save_load_json 1')
|
||||||
os.remove(test_filename)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
assert save_json(test_json, test_filename)
|
assert save_json(test_json, test_filename)
|
||||||
assert os.path.isfile(test_filename)
|
assert os.path.isfile(test_filename)
|
||||||
test_load_json = load_json(test_filename)
|
test_load_json = load_json(test_filename)
|
||||||
|
|
@ -4378,10 +4373,7 @@ def _test_save_load_json():
|
||||||
assert test_load_json.get('param2')
|
assert test_load_json.get('param2')
|
||||||
assert test_load_json['param1'] == 3
|
assert test_load_json['param1'] == 3
|
||||||
assert test_load_json['param2'] == '"Crème brûlée यह एक परीक्षण ह"'
|
assert test_load_json['param2'] == '"Crème brûlée यह एक परीक्षण ह"'
|
||||||
try:
|
remove_file(test_filename, 'EX: _test_save_load_json 2')
|
||||||
os.remove(test_filename)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def _test_theme():
|
def _test_theme():
|
||||||
|
|
@ -4666,7 +4658,7 @@ def _test_danger_svg(base_dir: str) -> None:
|
||||||
|
|
||||||
with open(svg_image_filename, 'rb') as fp_svg:
|
with open(svg_image_filename, 'rb') as fp_svg:
|
||||||
cached_content = fp_svg.read().decode()
|
cached_content = fp_svg.read().decode()
|
||||||
os.remove(svg_image_filename)
|
remove_file(svg_image_filename, 'EX: _test_danger_svg')
|
||||||
assert cached_content == svg_clean
|
assert cached_content == svg_clean
|
||||||
|
|
||||||
assert not scan_themes_for_scripts(base_dir)
|
assert not scan_themes_for_scripts(base_dir)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import os
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
from data import load_string
|
from data import load_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def text_mode_browser(ua_str: str) -> bool:
|
def text_mode_browser(ua_str: str) -> bool:
|
||||||
|
|
@ -92,11 +93,9 @@ def set_text_mode_theme(base_dir: str, name: str) -> None:
|
||||||
text_mode_banner_filename = \
|
text_mode_banner_filename = \
|
||||||
base_dir + '/theme/' + name + '/banner.txt'
|
base_dir + '/theme/' + name + '/banner.txt'
|
||||||
if os.path.isfile(dir_str + '/banner.txt'):
|
if os.path.isfile(dir_str + '/banner.txt'):
|
||||||
try:
|
remove_file(dir_str + '/banner.txt',
|
||||||
os.remove(dir_str + '/banner.txt')
|
'EX: set_text_mode_theme unable to delete ' +
|
||||||
except OSError:
|
dir_str + '/banner.txt')
|
||||||
print('EX: set_text_mode_theme unable to delete ' +
|
|
||||||
dir_str + '/banner.txt')
|
|
||||||
if os.path.isfile(text_mode_banner_filename):
|
if os.path.isfile(text_mode_banner_filename):
|
||||||
try:
|
try:
|
||||||
copyfile(text_mode_banner_filename, dir_str + '/banner.txt')
|
copyfile(text_mode_banner_filename, dir_str + '/banner.txt')
|
||||||
|
|
|
||||||
67
theme.py
67
theme.py
|
|
@ -31,6 +31,7 @@ from textmode import set_text_mode_theme
|
||||||
from data import load_string
|
from data import load_string
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import save_flag_file
|
from data import save_flag_file
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def import_theme(base_dir: str, filename: str) -> bool:
|
def import_theme(base_dir: str, filename: str) -> bool:
|
||||||
|
|
@ -105,10 +106,9 @@ def export_theme(base_dir: str, theme: str) -> bool:
|
||||||
os.mkdir(base_dir + '/exports')
|
os.mkdir(base_dir + '/exports')
|
||||||
export_filename = base_dir + '/exports/' + theme + '.zip'
|
export_filename = base_dir + '/exports/' + theme + '.zip'
|
||||||
if os.path.isfile(export_filename):
|
if os.path.isfile(export_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(export_filename)
|
'EX: export_theme unable to delete ' + str(export_filename)
|
||||||
except OSError:
|
remove_file(export_filename, ex_text)
|
||||||
print('EX: export_theme unable to delete ' + str(export_filename))
|
|
||||||
try:
|
try:
|
||||||
make_archive(base_dir + '/exports/' + theme, 'zip', theme_dir)
|
make_archive(base_dir + '/exports/' + theme, 'zip', theme_dir)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
|
@ -265,11 +265,9 @@ def _remove_theme(base_dir: str):
|
||||||
for filename in theme_files:
|
for filename in theme_files:
|
||||||
if not os.path.isfile(base_dir + '/' + filename):
|
if not os.path.isfile(base_dir + '/' + filename):
|
||||||
continue
|
continue
|
||||||
try:
|
remove_file(base_dir + '/' + filename,
|
||||||
os.remove(base_dir + '/' + filename)
|
'EX: _remove_theme unable to delete ' +
|
||||||
except OSError:
|
base_dir + '/' + filename)
|
||||||
print('EX: _remove_theme unable to delete ' +
|
|
||||||
base_dir + '/' + filename)
|
|
||||||
|
|
||||||
|
|
||||||
def set_css_param(css: str, param: str, value: str) -> str:
|
def set_css_param(css: str, param: str, value: str) -> str:
|
||||||
|
|
@ -471,11 +469,9 @@ def disable_grayscale(base_dir: str) -> None:
|
||||||
filename + ' [ex]')
|
filename + ' [ex]')
|
||||||
grayscale_filename = data_dir(base_dir) + '/.grayscale'
|
grayscale_filename = data_dir(base_dir) + '/.grayscale'
|
||||||
if os.path.isfile(grayscale_filename):
|
if os.path.isfile(grayscale_filename):
|
||||||
try:
|
remove_file(grayscale_filename,
|
||||||
os.remove(grayscale_filename)
|
'EX: disable_grayscale unable to delete ' +
|
||||||
except OSError:
|
grayscale_filename)
|
||||||
print('EX: disable_grayscale unable to delete ' +
|
|
||||||
grayscale_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _set_dyslexic_font(base_dir: str) -> bool:
|
def _set_dyslexic_font(base_dir: str) -> bool:
|
||||||
|
|
@ -564,11 +560,10 @@ def reset_theme_designer_settings(base_dir: str) -> None:
|
||||||
"""
|
"""
|
||||||
custom_variables_file = data_dir(base_dir) + '/theme.json'
|
custom_variables_file = data_dir(base_dir) + '/theme.json'
|
||||||
if os.path.isfile(custom_variables_file):
|
if os.path.isfile(custom_variables_file):
|
||||||
try:
|
if remove_file(custom_variables_file,
|
||||||
os.remove(custom_variables_file)
|
'EX: ' +
|
||||||
|
'unable to remove theme designer settings on reset'):
|
||||||
print('Theme designer settings were reset')
|
print('Theme designer settings were reset')
|
||||||
except OSError:
|
|
||||||
print('EX: unable to remove theme designer settings on reset')
|
|
||||||
|
|
||||||
|
|
||||||
def _read_variables_file(base_dir: str, theme_name: str,
|
def _read_variables_file(base_dir: str, theme_name: str,
|
||||||
|
|
@ -708,13 +703,11 @@ def _set_theme_images(base_dir: str, name: str) -> None:
|
||||||
# so remove any existing file
|
# so remove any existing file
|
||||||
if os.path.isfile(dir_str + '/' +
|
if os.path.isfile(dir_str + '/' +
|
||||||
background_type + '-background.' + ext):
|
background_type + '-background.' + ext):
|
||||||
try:
|
remove_file(dir_str + '/' +
|
||||||
os.remove(dir_str + '/' +
|
background_type + '-background.' + ext,
|
||||||
background_type + '-background.' + ext)
|
'EX: _set_theme_images unable to delete ' +
|
||||||
except OSError:
|
dir_str + '/' +
|
||||||
print('EX: _set_theme_images unable to delete ' +
|
background_type + '-background.' + ext)
|
||||||
dir_str + '/' +
|
|
||||||
background_type + '-background.' + ext)
|
|
||||||
|
|
||||||
if os.path.isfile(profile_image_filename) and \
|
if os.path.isfile(profile_image_filename) and \
|
||||||
os.path.isfile(banner_filename):
|
os.path.isfile(banner_filename):
|
||||||
|
|
@ -746,11 +739,9 @@ def _set_theme_images(base_dir: str, name: str) -> None:
|
||||||
account_dir + '/left_col_image.png')
|
account_dir + '/left_col_image.png')
|
||||||
elif os.path.isfile(account_dir +
|
elif os.path.isfile(account_dir +
|
||||||
'/left_col_image.png'):
|
'/left_col_image.png'):
|
||||||
try:
|
remove_file(account_dir + '/left_col_image.png',
|
||||||
os.remove(account_dir + '/left_col_image.png')
|
'EX: _set_theme_images unable to delete ' +
|
||||||
except OSError:
|
account_dir + '/left_col_image.png')
|
||||||
print('EX: _set_theme_images unable to delete ' +
|
|
||||||
account_dir + '/left_col_image.png')
|
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: _set_theme_images unable to copy ' +
|
print('EX: _set_theme_images unable to copy ' +
|
||||||
left_col_image_filename)
|
left_col_image_filename)
|
||||||
|
|
@ -762,12 +753,10 @@ def _set_theme_images(base_dir: str, name: str) -> None:
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(account_dir +
|
if os.path.isfile(account_dir +
|
||||||
'/right_col_image.png'):
|
'/right_col_image.png'):
|
||||||
try:
|
remove_file(account_dir + '/right_col_image.png',
|
||||||
os.remove(account_dir + '/right_col_image.png')
|
'EX: _set_theme_images ' +
|
||||||
except OSError:
|
'unable to delete ' +
|
||||||
print('EX: _set_theme_images ' +
|
account_dir + '/right_col_image.png')
|
||||||
'unable to delete ' +
|
|
||||||
account_dir + '/right_col_image.png')
|
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: _set_theme_images unable to copy ' +
|
print('EX: _set_theme_images unable to copy ' +
|
||||||
right_col_image_filename)
|
right_col_image_filename)
|
||||||
|
|
@ -791,10 +780,8 @@ def set_news_avatar(base_dir: str, name: str,
|
||||||
filename = base_dir + '/cache/avatars/' + avatar_filename
|
filename = base_dir + '/cache/avatars/' + avatar_filename
|
||||||
|
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
try:
|
remove_file(filename,
|
||||||
os.remove(filename)
|
'EX: set_news_avatar unable to delete ' + filename)
|
||||||
except OSError:
|
|
||||||
print('EX: set_news_avatar unable to delete ' + filename)
|
|
||||||
if os.path.isdir(base_dir + '/cache/avatars'):
|
if os.path.isdir(base_dir + '/cache/avatars'):
|
||||||
copyfile(new_filename, filename)
|
copyfile(new_filename, filename)
|
||||||
account_dir = acct_dir(base_dir, nickname, domain)
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
|
|
|
||||||
179
utils.py
179
utils.py
|
|
@ -27,6 +27,7 @@ from data import save_string
|
||||||
from data import save_flag_file
|
from data import save_flag_file
|
||||||
from data import load_string
|
from data import load_string
|
||||||
from data import append_string
|
from data import append_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
VALID_HASHTAG_CHARS = \
|
VALID_HASHTAG_CHARS = \
|
||||||
set('_0123456789' +
|
set('_0123456789' +
|
||||||
|
|
@ -1795,11 +1796,10 @@ def _remove_attachment(base_dir: str, http_prefix: str,
|
||||||
media_filename: str = base_dir + '/' + \
|
media_filename: str = base_dir + '/' + \
|
||||||
attachment_url.replace(http_prefix + '://' + domain + '/', '')
|
attachment_url.replace(http_prefix + '://' + domain + '/', '')
|
||||||
if os.path.isfile(media_filename):
|
if os.path.isfile(media_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(media_filename)
|
'EX: _remove_attachment unable to delete media file ' + \
|
||||||
except OSError:
|
str(media_filename)
|
||||||
print('EX: _remove_attachment unable to delete media file ' +
|
remove_file(media_filename, ex_text)
|
||||||
str(media_filename))
|
|
||||||
|
|
||||||
# remove from the log file
|
# remove from the log file
|
||||||
account_dir: str = acct_dir(base_dir, nickname, domain)
|
account_dir: str = acct_dir(base_dir, nickname, domain)
|
||||||
|
|
@ -1819,20 +1819,18 @@ def _remove_attachment(base_dir: str, http_prefix: str,
|
||||||
|
|
||||||
# remove the transcript
|
# remove the transcript
|
||||||
if os.path.isfile(media_filename + '.vtt'):
|
if os.path.isfile(media_filename + '.vtt'):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(media_filename + '.vtt')
|
'EX: _remove_attachment unable to delete media transcript ' + \
|
||||||
except OSError:
|
str(media_filename) + '.vtt'
|
||||||
print('EX: _remove_attachment unable to delete media transcript ' +
|
remove_file(media_filename + '.vtt', ex_text)
|
||||||
str(media_filename) + '.vtt')
|
|
||||||
|
|
||||||
# remove the etag
|
# remove the etag
|
||||||
etag_filename: str = media_filename + '.etag'
|
etag_filename: str = media_filename + '.etag'
|
||||||
if os.path.isfile(etag_filename):
|
if os.path.isfile(etag_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(etag_filename)
|
'EX: _remove_attachment unable to delete etag file ' + \
|
||||||
except OSError:
|
str(etag_filename)
|
||||||
print('EX: _remove_attachment unable to delete etag file ' +
|
remove_file(etag_filename, ex_text)
|
||||||
str(etag_filename))
|
|
||||||
post_json['attachment']: list[dict] = []
|
post_json['attachment']: list[dict] = []
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1927,11 +1925,10 @@ def _delete_post_remove_replies(base_dir: str, nickname: str, domain: str,
|
||||||
nickname, domain, reply_file, debug,
|
nickname, domain, reply_file, debug,
|
||||||
recent_posts_cache, manual)
|
recent_posts_cache, manual)
|
||||||
# remove the replies file
|
# remove the replies file
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(replies_filename)
|
'EX: _delete_post_remove_replies ' + \
|
||||||
except OSError:
|
'unable to delete replies file ' + str(replies_filename)
|
||||||
print('EX: _delete_post_remove_replies ' +
|
remove_file(replies_filename, ex_text)
|
||||||
'unable to delete replies file ' + str(replies_filename))
|
|
||||||
|
|
||||||
|
|
||||||
def _is_bookmarked(base_dir: str, nickname: str, domain: str,
|
def _is_bookmarked(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -1989,31 +1986,27 @@ def delete_cached_html(base_dir: str, nickname: str, domain: str,
|
||||||
if not cached_post_filename:
|
if not cached_post_filename:
|
||||||
return
|
return
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(cached_post_filename)
|
'EX: delete_cached_html unable to delete cached post file ' + \
|
||||||
except OSError:
|
str(cached_post_filename)
|
||||||
print('EX: delete_cached_html ' +
|
remove_file(cached_post_filename, ex_text)
|
||||||
'unable to delete cached post file ' +
|
|
||||||
str(cached_post_filename))
|
|
||||||
|
|
||||||
cached_post_filename = cached_post_filename.replace('.html', '.ssml')
|
cached_post_filename = cached_post_filename.replace('.html', '.ssml')
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(cached_post_filename)
|
'EX: ' + \
|
||||||
except OSError:
|
'delete_cached_html unable to delete cached ssml post file ' + \
|
||||||
print('EX: delete_cached_html ' +
|
str(cached_post_filename)
|
||||||
'unable to delete cached ssml post file ' +
|
remove_file(cached_post_filename, ex_text)
|
||||||
str(cached_post_filename))
|
|
||||||
|
|
||||||
cached_post_filename = \
|
cached_post_filename = \
|
||||||
cached_post_filename.replace('/postcache/', '/outbox/')
|
cached_post_filename.replace('/postcache/', '/outbox/')
|
||||||
if os.path.isfile(cached_post_filename):
|
if os.path.isfile(cached_post_filename):
|
||||||
try:
|
ex_text = \
|
||||||
os.remove(cached_post_filename)
|
'EX: delete_cached_html ' + \
|
||||||
except OSError:
|
'unable to delete cached outbox ssml post file ' + \
|
||||||
print('EX: delete_cached_html ' +
|
str(cached_post_filename)
|
||||||
'unable to delete cached outbox ssml post file ' +
|
remove_file(cached_post_filename, ex_text)
|
||||||
str(cached_post_filename))
|
|
||||||
|
|
||||||
|
|
||||||
def _remove_post_id_from_tag_index(tag_index_filename: str,
|
def _remove_post_id_from_tag_index(tag_index_filename: str,
|
||||||
|
|
@ -2034,11 +2027,9 @@ def _remove_post_id_from_tag_index(tag_index_filename: str,
|
||||||
newlines += file_line
|
newlines += file_line
|
||||||
if not newlines.strip():
|
if not newlines.strip():
|
||||||
# if there are no lines then remove the hashtag file
|
# if there are no lines then remove the hashtag file
|
||||||
try:
|
ex_text = 'EX: _delete_hashtags_on_post ' + \
|
||||||
os.remove(tag_index_filename)
|
'unable to delete tag index ' + str(tag_index_filename)
|
||||||
except OSError:
|
remove_file(tag_index_filename, ex_text)
|
||||||
print('EX: _delete_hashtags_on_post ' +
|
|
||||||
'unable to delete tag index ' + str(tag_index_filename))
|
|
||||||
else:
|
else:
|
||||||
# write the new hashtag index without the given post in it
|
# write the new hashtag index without the given post in it
|
||||||
save_string(newlines, tag_index_filename,
|
save_string(newlines, tag_index_filename,
|
||||||
|
|
@ -2127,18 +2118,14 @@ def _delete_conversation_post(base_dir: str, nickname: str, domain: str,
|
||||||
conversation_filename)
|
conversation_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(conversation_filename + '.muted'):
|
if os.path.isfile(conversation_filename + '.muted'):
|
||||||
try:
|
ex_text = 'EX: _delete_conversation_post ' + \
|
||||||
os.remove(conversation_filename + '.muted')
|
'unable to remove conversation ' + \
|
||||||
except OSError:
|
str(conversation_filename) + '.muted'
|
||||||
print('EX: _delete_conversation_post ' +
|
remove_file(conversation_filename + '.muted', ex_text)
|
||||||
'unable to remove conversation ' +
|
ex_text = 'EX: _delete_conversation_post ' + \
|
||||||
str(conversation_filename) + '.muted')
|
'unable to remove conversation ' + \
|
||||||
try:
|
str(conversation_filename)
|
||||||
os.remove(conversation_filename)
|
remove_file(conversation_filename, ex_text)
|
||||||
except OSError:
|
|
||||||
print('EX: _delete_conversation_post ' +
|
|
||||||
'unable to remove conversation ' +
|
|
||||||
str(conversation_filename))
|
|
||||||
|
|
||||||
|
|
||||||
def is_dm(post_json_object: {}) -> bool:
|
def is_dm(post_json_object: {}) -> bool:
|
||||||
|
|
@ -2315,13 +2302,10 @@ def delete_post(base_dir: str, http_prefix: str,
|
||||||
http_prefix, post_filename,
|
http_prefix, post_filename,
|
||||||
recent_posts_cache, debug, manual)
|
recent_posts_cache, debug, manual)
|
||||||
# finally, remove the post itself
|
# finally, remove the post itself
|
||||||
try:
|
ex_text = 'EX: delete_post unable to delete post ' + \
|
||||||
os.remove(post_filename)
|
str(post_filename)
|
||||||
|
if remove_file(post_filename, ex_text):
|
||||||
return True
|
return True
|
||||||
except OSError:
|
|
||||||
if debug:
|
|
||||||
print('EX: delete_post unable to delete post ' +
|
|
||||||
str(post_filename))
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# don't allow DMs to be deleted if they came from a different instance
|
# don't allow DMs to be deleted if they came from a different instance
|
||||||
|
|
@ -2353,13 +2337,10 @@ def delete_post(base_dir: str, http_prefix: str,
|
||||||
debug, False)
|
debug, False)
|
||||||
if gemini_blog_filename:
|
if gemini_blog_filename:
|
||||||
if os.path.isfile(gemini_blog_filename):
|
if os.path.isfile(gemini_blog_filename):
|
||||||
try:
|
ex_text = 'EX: delete_post unable to delete gemini post ' + \
|
||||||
os.remove(gemini_blog_filename)
|
str(gemini_blog_filename)
|
||||||
|
if remove_file(gemini_blog_filename, ex_text):
|
||||||
return True
|
return True
|
||||||
except OSError:
|
|
||||||
if debug:
|
|
||||||
print('EX: delete_post unable to delete gemini post ' +
|
|
||||||
str(gemini_blog_filename))
|
|
||||||
|
|
||||||
# delete markdown blog post
|
# delete markdown blog post
|
||||||
markdown_blog_filename: str = \
|
markdown_blog_filename: str = \
|
||||||
|
|
@ -2368,13 +2349,10 @@ def delete_post(base_dir: str, http_prefix: str,
|
||||||
debug, False)
|
debug, False)
|
||||||
if markdown_blog_filename:
|
if markdown_blog_filename:
|
||||||
if os.path.isfile(markdown_blog_filename):
|
if os.path.isfile(markdown_blog_filename):
|
||||||
try:
|
ex_text = 'EX: delete_post unable to delete markdown post ' + \
|
||||||
os.remove(markdown_blog_filename)
|
str(markdown_blog_filename)
|
||||||
|
if remove_file(markdown_blog_filename, ex_text):
|
||||||
return True
|
return True
|
||||||
except OSError:
|
|
||||||
if debug:
|
|
||||||
print('EX: delete_post unable to delete markdown post ' +
|
|
||||||
str(markdown_blog_filename))
|
|
||||||
|
|
||||||
# delete micron blog post
|
# delete micron blog post
|
||||||
micron_blog_filename: str = \
|
micron_blog_filename: str = \
|
||||||
|
|
@ -2383,13 +2361,10 @@ def delete_post(base_dir: str, http_prefix: str,
|
||||||
debug, False)
|
debug, False)
|
||||||
if micron_blog_filename:
|
if micron_blog_filename:
|
||||||
if os.path.isfile(micron_blog_filename):
|
if os.path.isfile(micron_blog_filename):
|
||||||
try:
|
ex_text = 'EX: delete_post unable to delete micron post ' + \
|
||||||
os.remove(micron_blog_filename)
|
str(micron_blog_filename)
|
||||||
|
if remove_file(micron_blog_filename, ex_text):
|
||||||
return True
|
return True
|
||||||
except OSError:
|
|
||||||
if debug:
|
|
||||||
print('EX: delete_post unable to delete micron post ' +
|
|
||||||
str(micron_blog_filename))
|
|
||||||
|
|
||||||
# remove from recent posts cache in memory
|
# remove from recent posts cache in memory
|
||||||
remove_post_from_cache(post_json_object, recent_posts_cache)
|
remove_post_from_cache(post_json_object, recent_posts_cache)
|
||||||
|
|
@ -2407,19 +2382,15 @@ def delete_post(base_dir: str, http_prefix: str,
|
||||||
for ext in extensions:
|
for ext in extensions:
|
||||||
ext_filename: str = post_filename + '.' + ext
|
ext_filename: str = post_filename + '.' + ext
|
||||||
if os.path.isfile(ext_filename):
|
if os.path.isfile(ext_filename):
|
||||||
try:
|
ex_text = 'EX: delete_post unable to remove ext ' + \
|
||||||
os.remove(ext_filename)
|
str(ext_filename)
|
||||||
except OSError:
|
remove_file(ext_filename, ex_text)
|
||||||
print('EX: delete_post unable to remove ext ' +
|
|
||||||
str(ext_filename))
|
|
||||||
elif post_filename.endswith('.json'):
|
elif post_filename.endswith('.json'):
|
||||||
ext_filename = post_filename.replace('.json', '') + '.' + ext
|
ext_filename = post_filename.replace('.json', '') + '.' + ext
|
||||||
if os.path.isfile(ext_filename):
|
if os.path.isfile(ext_filename):
|
||||||
try:
|
ex_text = 'EX: delete_post unable to remove ext ' + \
|
||||||
os.remove(ext_filename)
|
str(ext_filename)
|
||||||
except OSError:
|
remove_file(ext_filename, ex_text)
|
||||||
print('EX: delete_post unable to remove ext ' +
|
|
||||||
str(ext_filename))
|
|
||||||
|
|
||||||
# remove cached html version of the post
|
# remove cached html version of the post
|
||||||
delete_cached_html(base_dir, nickname, domain, post_json_object)
|
delete_cached_html(base_dir, nickname, domain, post_json_object)
|
||||||
|
|
@ -2445,13 +2416,10 @@ def delete_post(base_dir: str, http_prefix: str,
|
||||||
http_prefix, post_filename,
|
http_prefix, post_filename,
|
||||||
recent_posts_cache, debug, manual)
|
recent_posts_cache, debug, manual)
|
||||||
# finally, remove the post itself
|
# finally, remove the post itself
|
||||||
try:
|
ex_text = 'EX: delete_post unable to delete post ' + \
|
||||||
os.remove(post_filename)
|
str(post_filename)
|
||||||
|
if remove_file(post_filename, ex_text):
|
||||||
return True
|
return True
|
||||||
except OSError:
|
|
||||||
if debug:
|
|
||||||
print('EX: delete_post unable to delete post ' +
|
|
||||||
str(post_filename))
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3513,10 +3481,8 @@ def set_minimize_all_images(base_dir: str,
|
||||||
if nickname in min_images_for_accounts:
|
if nickname in min_images_for_accounts:
|
||||||
min_images_for_accounts.remove(nickname)
|
min_images_for_accounts.remove(nickname)
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
try:
|
remove_file(filename,
|
||||||
os.remove(filename)
|
'EX: unable to delete ' + filename)
|
||||||
except OSError:
|
|
||||||
print('EX: unable to delete ' + filename)
|
|
||||||
|
|
||||||
|
|
||||||
def load_reverse_timeline(base_dir: str) -> []:
|
def load_reverse_timeline(base_dir: str) -> []:
|
||||||
|
|
@ -3560,11 +3526,9 @@ def save_reverse_timeline(base_dir: str, reverse_sequence: []) -> None:
|
||||||
reverse_filename)
|
reverse_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(reverse_filename):
|
if os.path.isfile(reverse_filename):
|
||||||
try:
|
remove_file(reverse_filename,
|
||||||
os.remove(reverse_filename)
|
'EX: failed to delete reverse ' +
|
||||||
except OSError:
|
reverse_filename)
|
||||||
print('EX: failed to delete reverse ' +
|
|
||||||
reverse_filename)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -4115,10 +4079,9 @@ def set_premium_account(base_dir: str, nickname: str, domain: str,
|
||||||
premium_filename: str = acct_dir(base_dir, nickname, domain) + '/.premium'
|
premium_filename: str = acct_dir(base_dir, nickname, domain) + '/.premium'
|
||||||
if os.path.isfile(premium_filename):
|
if os.path.isfile(premium_filename):
|
||||||
if not flag_state:
|
if not flag_state:
|
||||||
try:
|
if not remove_file(premium_filename,
|
||||||
os.remove(premium_filename)
|
'EX: unable to remove premium flag ' +
|
||||||
except OSError:
|
premium_filename):
|
||||||
print('EX: unable to remove premium flag ' + premium_filename)
|
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
if flag_state:
|
if flag_state:
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ from webapp_utils import html_footer
|
||||||
from webapp_utils import html_hide_from_screen_reader
|
from webapp_utils import html_hide_from_screen_reader
|
||||||
from webapp_utils import html_keyboard_navigation
|
from webapp_utils import html_keyboard_navigation
|
||||||
from maps import html_open_street_map
|
from maps import html_open_street_map
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def html_calendar_delete_confirm(translate: {}, base_dir: str,
|
def html_calendar_delete_confirm(translate: {}, base_dir: str,
|
||||||
|
|
@ -131,10 +132,8 @@ def _html_calendar_day(person_cache: {}, translate: {},
|
||||||
account_dir = acct_dir(base_dir, nickname, domain)
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
calendar_file = account_dir + '/.newCalendar'
|
calendar_file = account_dir + '/.newCalendar'
|
||||||
if os.path.isfile(calendar_file):
|
if os.path.isfile(calendar_file):
|
||||||
try:
|
remove_file(calendar_file,
|
||||||
os.remove(calendar_file)
|
'EX: _html_calendar_day unable to delete ' + calendar_file)
|
||||||
except OSError:
|
|
||||||
print('EX: _html_calendar_day unable to delete ' + calendar_file)
|
|
||||||
|
|
||||||
css_filename = base_dir + '/epicyon-calendar.css'
|
css_filename = base_dir + '/epicyon-calendar.css'
|
||||||
if os.path.isfile(base_dir + '/calendar.css'):
|
if os.path.isfile(base_dir + '/calendar.css'):
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ __module_group__ = "Timeline"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
|
from data import remove_file
|
||||||
from data import save_flag_file
|
from data import save_flag_file
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -35,10 +36,8 @@ def set_minimal(base_dir: str, domain: str, nickname: str,
|
||||||
minimal_filename = account_dir + '/.notminimal'
|
minimal_filename = account_dir + '/.notminimal'
|
||||||
minimal_file_exists = os.path.isfile(minimal_filename)
|
minimal_file_exists = os.path.isfile(minimal_filename)
|
||||||
if minimal and minimal_file_exists:
|
if minimal and minimal_file_exists:
|
||||||
try:
|
remove_file(minimal_filename,
|
||||||
os.remove(minimal_filename)
|
'EX: set_minimal unable to delete ' + minimal_filename)
|
||||||
except OSError:
|
|
||||||
print('EX: set_minimal unable to delete ' + minimal_filename)
|
|
||||||
elif not minimal and not minimal_file_exists:
|
elif not minimal and not minimal_file_exists:
|
||||||
save_flag_file(minimal_filename,
|
save_flag_file(minimal_filename,
|
||||||
'EX: unable to write minimal ' + minimal_filename)
|
'EX: unable to write minimal ' + minimal_filename)
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ from question import is_html_question
|
||||||
from question import is_question
|
from question import is_question
|
||||||
from data import load_string
|
from data import load_string
|
||||||
from data import load_list
|
from data import load_list
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def _log_timeline_timing(enable_timing_log: bool, timeline_start_time,
|
def _log_timeline_timing(enable_timing_log: bool, timeline_start_time,
|
||||||
|
|
@ -520,10 +521,8 @@ def html_timeline(default_timeline: str,
|
||||||
if os.path.isfile(dm_file):
|
if os.path.isfile(dm_file):
|
||||||
new_dm = True
|
new_dm = True
|
||||||
if box_name == 'dm':
|
if box_name == 'dm':
|
||||||
try:
|
remove_file(dm_file,
|
||||||
os.remove(dm_file)
|
'EX: html_timeline unable to delete ' + dm_file)
|
||||||
except OSError:
|
|
||||||
print('EX: html_timeline unable to delete ' + dm_file)
|
|
||||||
|
|
||||||
# should the Replies button be highlighted?
|
# should the Replies button be highlighted?
|
||||||
new_reply: bool = False
|
new_reply: bool = False
|
||||||
|
|
@ -531,10 +530,8 @@ def html_timeline(default_timeline: str,
|
||||||
if os.path.isfile(reply_file):
|
if os.path.isfile(reply_file):
|
||||||
new_reply = True
|
new_reply = True
|
||||||
if box_name == 'tlreplies':
|
if box_name == 'tlreplies':
|
||||||
try:
|
remove_file(reply_file,
|
||||||
os.remove(reply_file)
|
'EX: html_timeline unable to delete ' + reply_file)
|
||||||
except OSError:
|
|
||||||
print('EX: html_timeline unable to delete ' + reply_file)
|
|
||||||
|
|
||||||
# should the Shares button be highlighted?
|
# should the Shares button be highlighted?
|
||||||
new_share: bool = False
|
new_share: bool = False
|
||||||
|
|
@ -542,10 +539,9 @@ def html_timeline(default_timeline: str,
|
||||||
if os.path.isfile(new_share_file):
|
if os.path.isfile(new_share_file):
|
||||||
new_share = True
|
new_share = True
|
||||||
if box_name == 'tlshares':
|
if box_name == 'tlshares':
|
||||||
try:
|
remove_file(new_share_file,
|
||||||
os.remove(new_share_file)
|
'EX: html_timeline unable to delete ' +
|
||||||
except OSError:
|
new_share_file)
|
||||||
print('EX: html_timeline unable to delete ' + new_share_file)
|
|
||||||
|
|
||||||
# should the Wanted button be highlighted?
|
# should the Wanted button be highlighted?
|
||||||
new_wanted: bool = False
|
new_wanted: bool = False
|
||||||
|
|
@ -553,10 +549,9 @@ def html_timeline(default_timeline: str,
|
||||||
if os.path.isfile(new_wanted_file):
|
if os.path.isfile(new_wanted_file):
|
||||||
new_wanted = True
|
new_wanted = True
|
||||||
if box_name == 'tlwanted':
|
if box_name == 'tlwanted':
|
||||||
try:
|
remove_file(new_wanted_file,
|
||||||
os.remove(new_wanted_file)
|
'EX: html_timeline unable to delete ' +
|
||||||
except OSError:
|
new_wanted_file)
|
||||||
print('EX: html_timeline unable to delete ' + new_wanted_file)
|
|
||||||
|
|
||||||
# should the Moderation/reports button be highlighted?
|
# should the Moderation/reports button be highlighted?
|
||||||
new_report: bool = False
|
new_report: bool = False
|
||||||
|
|
@ -564,10 +559,9 @@ def html_timeline(default_timeline: str,
|
||||||
if os.path.isfile(new_report_file):
|
if os.path.isfile(new_report_file):
|
||||||
new_report = True
|
new_report = True
|
||||||
if box_name == 'moderation':
|
if box_name == 'moderation':
|
||||||
try:
|
remove_file(new_report_file,
|
||||||
os.remove(new_report_file)
|
'EX: html_timeline unable to delete ' +
|
||||||
except OSError:
|
new_report_file)
|
||||||
print('EX: html_timeline unable to delete ' + new_report_file)
|
|
||||||
|
|
||||||
# show polls/votes?
|
# show polls/votes?
|
||||||
show_vote_posts: bool = True
|
show_vote_posts: bool = True
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ from data import load_list
|
||||||
from data import save_flag_file
|
from data import save_flag_file
|
||||||
from data import save_binary
|
from data import save_binary
|
||||||
from data import load_string
|
from data import load_string
|
||||||
|
from data import remove_file
|
||||||
|
|
||||||
|
|
||||||
def minimizing_attached_images(base_dir: str, nickname: str, domain: str,
|
def minimizing_attached_images(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -424,12 +425,10 @@ def update_avatar_image_cache(signing_priv_key_pem: str,
|
||||||
str(result.status_code))
|
str(result.status_code))
|
||||||
# remove partial download
|
# remove partial download
|
||||||
if os.path.isfile(avatar_image_filename):
|
if os.path.isfile(avatar_image_filename):
|
||||||
try:
|
remove_file(avatar_image_filename,
|
||||||
os.remove(avatar_image_filename)
|
'EX: ' +
|
||||||
except OSError:
|
'update_avatar_image_cache unable to delete ' +
|
||||||
print('EX: ' +
|
avatar_image_filename)
|
||||||
'update_avatar_image_cache unable to delete ' +
|
|
||||||
avatar_image_filename)
|
|
||||||
else:
|
else:
|
||||||
media_binary = result.content
|
media_binary = result.content
|
||||||
if binary_is_image(avatar_image_filename, media_binary):
|
if binary_is_image(avatar_image_filename, media_binary):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue