mirror of https://gitlab.com/bashrc2/epicyon
Replace directory creation with functions
parent
b57262bda8
commit
dfad31ef2d
3
auth.py
3
auth.py
|
|
@ -26,6 +26,7 @@ from data import load_list
|
||||||
from data import move_file
|
from data import move_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def _hash_password(password: str) -> str:
|
def _hash_password(password: str) -> str:
|
||||||
|
|
@ -191,7 +192,7 @@ def store_basic_credentials(base_dir: str,
|
||||||
|
|
||||||
dir_str = data_dir(base_dir)
|
dir_str = data_dir(base_dir)
|
||||||
if not is_a_dir(dir_str):
|
if not is_a_dir(dir_str):
|
||||||
os.mkdir(dir_str)
|
makedir(dir_str)
|
||||||
|
|
||||||
password_file = dir_str + '/passwords'
|
password_file = dir_str + '/passwords'
|
||||||
store_str = nickname + ':' + _hash_password(password)
|
store_str = nickname + ':' + _hash_password(password)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ from data import save_string
|
||||||
from data import erase_file
|
from data import erase_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
MAX_TAG_LENGTH = 42
|
MAX_TAG_LENGTH = 42
|
||||||
|
|
||||||
|
|
@ -244,7 +245,7 @@ def set_hashtag_category(base_dir: str, hashtag: str, category: str,
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not is_a_dir(base_dir + '/tags'):
|
if not is_a_dir(base_dir + '/tags'):
|
||||||
os.mkdir(base_dir + '/tags')
|
makedir(base_dir + '/tags')
|
||||||
category_filename = base_dir + '/tags/' + hashtag + '.category'
|
category_filename = base_dir + '/tags/' + hashtag + '.category'
|
||||||
if force:
|
if force:
|
||||||
# don't overwrite any existing categories
|
# don't overwrite any existing categories
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ from data import append_string
|
||||||
from data import erase_file
|
from data import erase_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
MUSIC_SITES = ('soundcloud.com', 'bandcamp.com', 'resonate.coop')
|
MUSIC_SITES = ('soundcloud.com', 'bandcamp.com', 'resonate.coop')
|
||||||
|
|
||||||
|
|
@ -377,7 +378,7 @@ def _save_custom_emoji(session, base_dir: str, emoji_name: str, url: str,
|
||||||
emoji_name = emoji_name.replace(':', '').strip().lower()
|
emoji_name = emoji_name.replace(':', '').strip().lower()
|
||||||
custom_emoji_dir = base_dir + '/emojicustom'
|
custom_emoji_dir = base_dir + '/emojicustom'
|
||||||
if not is_a_dir(custom_emoji_dir):
|
if not is_a_dir(custom_emoji_dir):
|
||||||
os.mkdir(custom_emoji_dir)
|
makedir(custom_emoji_dir)
|
||||||
emoji_image_filename = custom_emoji_dir + '/' + emoji_name + '.' + ext
|
emoji_image_filename = custom_emoji_dir + '/' + emoji_name + '.' + ext
|
||||||
if not download_image(session, url,
|
if not download_image(session, url,
|
||||||
emoji_image_filename, debug, False):
|
emoji_image_filename, debug, False):
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ __email__ = "bob@libreserver.org"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
__module_group__ = "Timeline"
|
__module_group__ = "Timeline"
|
||||||
|
|
||||||
import os
|
|
||||||
from utils import has_object_dict
|
from utils import has_object_dict
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from utils import remove_id_ending
|
from utils import remove_id_ending
|
||||||
|
|
@ -27,6 +26,7 @@ from data import append_string
|
||||||
from data import erase_file
|
from data import erase_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def _get_conversation_filename(base_dir: str, nickname: str, domain: str,
|
def _get_conversation_filename(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -45,7 +45,7 @@ def _get_conversation_filename(base_dir: str, nickname: str, domain: str,
|
||||||
return None
|
return None
|
||||||
conversation_dir = acct_dir(base_dir, nickname, domain) + '/conversation'
|
conversation_dir = acct_dir(base_dir, nickname, domain) + '/conversation'
|
||||||
if not is_a_dir(conversation_dir):
|
if not is_a_dir(conversation_dir):
|
||||||
os.mkdir(conversation_dir)
|
makedir(conversation_dir)
|
||||||
if post_json_object['object'].get('conversation'):
|
if post_json_object['object'].get('conversation'):
|
||||||
conversation_id = post_json_object['object']['conversation']
|
conversation_id = post_json_object['object']['conversation']
|
||||||
elif post_json_object['object'].get('context'):
|
elif post_json_object['object'].get('context'):
|
||||||
|
|
|
||||||
15
daemon.py
15
daemon.py
|
|
@ -108,6 +108,7 @@ from poison import load_2grams
|
||||||
from data import load_string
|
from data import load_string
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
class PubServer(BaseHTTPRequestHandler):
|
class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
@ -701,7 +702,7 @@ def run_daemon(accounts_data_dir: str,
|
||||||
dir_str = data_dir(base_dir)
|
dir_str = data_dir(base_dir)
|
||||||
if not is_a_dir(dir_str):
|
if not is_a_dir(dir_str):
|
||||||
print('Creating accounts directory')
|
print('Creating accounts directory')
|
||||||
os.mkdir(dir_str)
|
makedir(dir_str)
|
||||||
|
|
||||||
httpd = None
|
httpd = None
|
||||||
try:
|
try:
|
||||||
|
|
@ -1244,25 +1245,25 @@ def run_daemon(accounts_data_dir: str,
|
||||||
httpd.domain_full)
|
httpd.domain_full)
|
||||||
|
|
||||||
if not is_a_dir(base_dir + '/cache'):
|
if not is_a_dir(base_dir + '/cache'):
|
||||||
os.mkdir(base_dir + '/cache')
|
makedir(base_dir + '/cache')
|
||||||
if not is_a_dir(base_dir + '/cache/actors'):
|
if not is_a_dir(base_dir + '/cache/actors'):
|
||||||
print('Creating actors cache')
|
print('Creating actors cache')
|
||||||
os.mkdir(base_dir + '/cache/actors')
|
makedir(base_dir + '/cache/actors')
|
||||||
if not is_a_dir(base_dir + '/cache/announce'):
|
if not is_a_dir(base_dir + '/cache/announce'):
|
||||||
print('Creating announce cache')
|
print('Creating announce cache')
|
||||||
os.mkdir(base_dir + '/cache/announce')
|
makedir(base_dir + '/cache/announce')
|
||||||
if not is_a_dir(base_dir + '/cache/avatars'):
|
if not is_a_dir(base_dir + '/cache/avatars'):
|
||||||
print('Creating avatars cache')
|
print('Creating avatars cache')
|
||||||
os.mkdir(base_dir + '/cache/avatars')
|
makedir(base_dir + '/cache/avatars')
|
||||||
|
|
||||||
archive_dir = base_dir + '/archive'
|
archive_dir = base_dir + '/archive'
|
||||||
if not is_a_dir(archive_dir):
|
if not is_a_dir(archive_dir):
|
||||||
print('Creating archive')
|
print('Creating archive')
|
||||||
os.mkdir(archive_dir)
|
makedir(archive_dir)
|
||||||
|
|
||||||
if not is_a_dir(base_dir + '/sharefiles'):
|
if not is_a_dir(base_dir + '/sharefiles'):
|
||||||
print('Creating shared item files directory')
|
print('Creating shared item files directory')
|
||||||
os.mkdir(base_dir + '/sharefiles')
|
makedir(base_dir + '/sharefiles')
|
||||||
|
|
||||||
print('THREAD: Creating fitness thread')
|
print('THREAD: Creating fitness thread')
|
||||||
httpd.thrFitness = \
|
httpd.thrFitness = \
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ __email__ = "bob@libreserver.org"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
__module_group__ = "Daemon POST"
|
__module_group__ = "Daemon POST"
|
||||||
|
|
||||||
import os
|
|
||||||
import errno
|
import errno
|
||||||
from webfinger import webfinger_update
|
from webfinger import webfinger_update
|
||||||
from socket import error as SocketError
|
from socket import error as SocketError
|
||||||
|
|
@ -153,6 +152,7 @@ from data import save_flag_file
|
||||||
from data import erase_file
|
from data import erase_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_deactivate_account(base_dir: str, nickname: str, domain: str,
|
def _profile_post_deactivate_account(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -470,7 +470,7 @@ def _profile_post_import_theme(base_dir: str, nickname: str,
|
||||||
"""
|
"""
|
||||||
if fields.get('importTheme'):
|
if fields.get('importTheme'):
|
||||||
if not is_a_dir(base_dir + '/imports'):
|
if not is_a_dir(base_dir + '/imports'):
|
||||||
os.mkdir(base_dir + '/imports')
|
makedir(base_dir + '/imports')
|
||||||
filename_base = base_dir + '/imports/newtheme.zip'
|
filename_base = base_dir + '/imports/newtheme.zip'
|
||||||
if is_a_file(filename_base):
|
if is_a_file(filename_base):
|
||||||
erase_file(filename_base,
|
erase_file(filename_base,
|
||||||
|
|
@ -2725,7 +2725,7 @@ def profile_edit(self, calling_domain: str, cookie: str,
|
||||||
filename_base = data_dir(base_dir) + '/login.temp'
|
filename_base = data_dir(base_dir) + '/login.temp'
|
||||||
elif m_type == 'importTheme':
|
elif m_type == 'importTheme':
|
||||||
if not is_a_dir(base_dir + '/imports'):
|
if not is_a_dir(base_dir + '/imports'):
|
||||||
os.mkdir(base_dir + '/imports')
|
makedir(base_dir + '/imports')
|
||||||
filename_base = base_dir + '/imports/newtheme.zip'
|
filename_base = base_dir + '/imports/newtheme.zip'
|
||||||
if is_a_file(filename_base):
|
if is_a_file(filename_base):
|
||||||
erase_file(filename_base,
|
erase_file(filename_base,
|
||||||
|
|
|
||||||
6
data.py
6
data.py
|
|
@ -189,3 +189,9 @@ def is_a_dir(directory: str) -> bool:
|
||||||
"""Returns true if the given directory exists
|
"""Returns true if the given directory exists
|
||||||
"""
|
"""
|
||||||
return os.path.isdir(directory)
|
return os.path.isdir(directory)
|
||||||
|
|
||||||
|
|
||||||
|
def makedir(directory: str) -> None:
|
||||||
|
"""Creates a directory
|
||||||
|
"""
|
||||||
|
os.mkdir(directory)
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ from data import load_string
|
||||||
from data import prepend_string
|
from data import prepend_string
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def _desktop_help() -> None:
|
def _desktop_help() -> None:
|
||||||
|
|
@ -159,9 +160,9 @@ def _create_desktop_config(actor: str) -> None:
|
||||||
"""
|
"""
|
||||||
home_dir = str(Path.home())
|
home_dir = str(Path.home())
|
||||||
if not is_a_dir(home_dir + '/.config'):
|
if not is_a_dir(home_dir + '/.config'):
|
||||||
os.mkdir(home_dir + '/.config')
|
makedir(home_dir + '/.config')
|
||||||
if not is_a_dir(home_dir + '/.config/epicyon'):
|
if not is_a_dir(home_dir + '/.config/epicyon'):
|
||||||
os.mkdir(home_dir + '/.config/epicyon')
|
makedir(home_dir + '/.config/epicyon')
|
||||||
nickname = get_nickname_from_actor(actor)
|
nickname = get_nickname_from_actor(actor)
|
||||||
domain, port = get_domain_from_actor(actor)
|
domain, port = get_domain_from_actor(actor)
|
||||||
handle = nickname + '@' + domain
|
handle = nickname + '@' + domain
|
||||||
|
|
@ -169,7 +170,7 @@ def _create_desktop_config(actor: str) -> None:
|
||||||
handle += '_' + str(port)
|
handle += '_' + str(port)
|
||||||
read_posts_dir = home_dir + '/.config/epicyon/' + handle
|
read_posts_dir = home_dir + '/.config/epicyon/' + handle
|
||||||
if not is_a_dir(read_posts_dir):
|
if not is_a_dir(read_posts_dir):
|
||||||
os.mkdir(read_posts_dir)
|
makedir(read_posts_dir)
|
||||||
|
|
||||||
|
|
||||||
def _mark_post_as_read(actor: str, post_id: str, post_category: str) -> None:
|
def _mark_post_as_read(actor: str, post_id: str, post_category: str) -> None:
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,7 @@ from data import save_string
|
||||||
from data import load_list
|
from data import load_list
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def str2bool(value_str) -> bool:
|
def str2bool(value_str) -> bool:
|
||||||
|
|
@ -1591,13 +1592,13 @@ def _command_options() -> None:
|
||||||
|
|
||||||
# create cache for actors
|
# create cache for actors
|
||||||
if not is_a_dir(base_dir + '/cache'):
|
if not is_a_dir(base_dir + '/cache'):
|
||||||
os.mkdir(base_dir + '/cache')
|
makedir(base_dir + '/cache')
|
||||||
if not is_a_dir(base_dir + '/cache/actors'):
|
if not is_a_dir(base_dir + '/cache/actors'):
|
||||||
print('Creating actors cache')
|
print('Creating actors cache')
|
||||||
os.mkdir(base_dir + '/cache/actors')
|
makedir(base_dir + '/cache/actors')
|
||||||
if not is_a_dir(base_dir + '/cache/announce'):
|
if not is_a_dir(base_dir + '/cache/announce'):
|
||||||
print('Creating announce cache')
|
print('Creating announce cache')
|
||||||
os.mkdir(base_dir + '/cache/announce')
|
makedir(base_dir + '/cache/announce')
|
||||||
|
|
||||||
# set the theme in config.json
|
# set the theme in config.json
|
||||||
theme_name = get_config_param(base_dir, 'theme')
|
theme_name = get_config_param(base_dir, 'theme')
|
||||||
|
|
|
||||||
13
follow.py
13
follow.py
|
|
@ -53,6 +53,7 @@ from data import erase_file
|
||||||
from data import move_file
|
from data import move_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def create_initial_last_seen(base_dir: str, http_prefix: str) -> None:
|
def create_initial_last_seen(base_dir: str, http_prefix: str) -> None:
|
||||||
|
|
@ -71,7 +72,7 @@ def create_initial_last_seen(base_dir: str, http_prefix: str) -> None:
|
||||||
continue
|
continue
|
||||||
last_seen_dir = account_dir + '/lastseen'
|
last_seen_dir = account_dir + '/lastseen'
|
||||||
if not is_a_dir(last_seen_dir):
|
if not is_a_dir(last_seen_dir):
|
||||||
os.mkdir(last_seen_dir)
|
makedir(last_seen_dir)
|
||||||
following_handles: list[str] = \
|
following_handles: list[str] = \
|
||||||
load_list(following_filename,
|
load_list(following_filename,
|
||||||
'EX: create_initial_last_seen ' +
|
'EX: create_initial_last_seen ' +
|
||||||
|
|
@ -317,10 +318,10 @@ def unfollow_account(base_dir: str, nickname: str, domain: str,
|
||||||
handle_to_unfollow = '!' + handle_to_unfollow
|
handle_to_unfollow = '!' + handle_to_unfollow
|
||||||
dir_str = data_dir(base_dir)
|
dir_str = data_dir(base_dir)
|
||||||
if not is_a_dir(dir_str):
|
if not is_a_dir(dir_str):
|
||||||
os.mkdir(dir_str)
|
makedir(dir_str)
|
||||||
handle_dir = acct_handle_dir(base_dir, handle)
|
handle_dir = acct_handle_dir(base_dir, handle)
|
||||||
if not is_a_dir(handle_dir):
|
if not is_a_dir(handle_dir):
|
||||||
os.mkdir(handle_dir)
|
makedir(handle_dir)
|
||||||
|
|
||||||
accounts_dir = acct_dir(base_dir, nickname, domain)
|
accounts_dir = acct_dir(base_dir, nickname, domain)
|
||||||
filename = accounts_dir + '/' + follow_file
|
filename = accounts_dir + '/' + follow_file
|
||||||
|
|
@ -384,10 +385,10 @@ def clear_follows(base_dir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
dir_str = data_dir(base_dir)
|
dir_str = data_dir(base_dir)
|
||||||
if not is_a_dir(dir_str):
|
if not is_a_dir(dir_str):
|
||||||
os.mkdir(dir_str)
|
makedir(dir_str)
|
||||||
accounts_dir = acct_dir(base_dir, nickname, domain)
|
accounts_dir = acct_dir(base_dir, nickname, domain)
|
||||||
if not is_a_dir(accounts_dir):
|
if not is_a_dir(accounts_dir):
|
||||||
os.mkdir(accounts_dir)
|
makedir(accounts_dir)
|
||||||
filename = accounts_dir + '/' + follow_file
|
filename = accounts_dir + '/' + follow_file
|
||||||
if is_a_file(filename):
|
if is_a_file(filename):
|
||||||
erase_file(filename,
|
erase_file(filename,
|
||||||
|
|
@ -732,7 +733,7 @@ def store_follow_request(base_dir: str,
|
||||||
# We don't rely upon the inbox because items in there could expire
|
# We don't rely upon the inbox because items in there could expire
|
||||||
requests_dir = accounts_dir + '/requests'
|
requests_dir = accounts_dir + '/requests'
|
||||||
if not is_a_dir(requests_dir):
|
if not is_a_dir(requests_dir):
|
||||||
os.mkdir(requests_dir)
|
makedir(requests_dir)
|
||||||
follow_activity_filename = requests_dir + '/' + approve_handle + '.follow'
|
follow_activity_filename = requests_dir + '/' + approve_handle + '.follow'
|
||||||
return save_json(follow_json, follow_activity_filename)
|
return save_json(follow_json, follow_activity_filename)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ __email__ = "bob@libreserver.org"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
__module_group__ = "Timeline"
|
__module_group__ = "Timeline"
|
||||||
|
|
||||||
import os
|
|
||||||
import shutil
|
import shutil
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from utils import remove_html
|
from utils import remove_html
|
||||||
|
|
@ -19,6 +18,7 @@ from utils import get_gemini_blog_published
|
||||||
from utils import get_gemini_blog_filename
|
from utils import get_gemini_blog_filename
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def blog_to_gemini(base_dir: str, nickname: str, domain: str,
|
def blog_to_gemini(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -88,7 +88,7 @@ def blog_to_gemini(base_dir: str, nickname: str, domain: str,
|
||||||
else:
|
else:
|
||||||
gemini_blog_dir = account_dir + '/geminitest'
|
gemini_blog_dir = account_dir + '/geminitest'
|
||||||
if not is_a_dir(gemini_blog_dir):
|
if not is_a_dir(gemini_blog_dir):
|
||||||
os.mkdir(gemini_blog_dir)
|
makedir(gemini_blog_dir)
|
||||||
|
|
||||||
gemini_blog_filename = \
|
gemini_blog_filename = \
|
||||||
get_gemini_blog_filename(base_dir, nickname, domain,
|
get_gemini_blog_filename(base_dir, nickname, domain,
|
||||||
|
|
|
||||||
6
git.py
6
git.py
|
|
@ -7,7 +7,6 @@ __email__ = "bob@libreserver.org"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
__module_group__ = "Profile Metadata"
|
__module_group__ = "Profile Metadata"
|
||||||
|
|
||||||
import os
|
|
||||||
import html
|
import html
|
||||||
from utils import remove_link_tracking
|
from utils import remove_link_tracking
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
|
|
@ -20,6 +19,7 @@ from utils import string_contains
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def _git_format_content(content: str) -> str:
|
def _git_format_content(content: str) -> str:
|
||||||
|
|
@ -204,10 +204,10 @@ def receive_git_patch(base_dir: str, nickname: str, domain: str,
|
||||||
project_name = \
|
project_name = \
|
||||||
_get_git_project_name(base_dir, nickname, domain, subject)
|
_get_git_project_name(base_dir, nickname, domain, subject)
|
||||||
if not is_a_dir(patches_dir):
|
if not is_a_dir(patches_dir):
|
||||||
os.mkdir(patches_dir)
|
makedir(patches_dir)
|
||||||
project_dir = patches_dir + '/' + project_name
|
project_dir = patches_dir + '/' + project_name
|
||||||
if not is_a_dir(project_dir):
|
if not is_a_dir(project_dir):
|
||||||
os.mkdir(project_dir)
|
makedir(project_dir)
|
||||||
patch_filename = \
|
patch_filename = \
|
||||||
project_dir + '/' + patch_subject + '.patch'
|
project_dir + '/' + patch_subject + '.patch'
|
||||||
break
|
break
|
||||||
|
|
|
||||||
10
happening.py
10
happening.py
|
|
@ -7,7 +7,6 @@ __email__ = "bob@libreserver.org"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
__module_group__ = "Core"
|
__module_group__ = "Core"
|
||||||
|
|
||||||
import os
|
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
@ -44,6 +43,7 @@ from data import prepend_string
|
||||||
from data import erase_file
|
from data import erase_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def _strings_are_digits(strings_list: []) -> bool:
|
def _strings_are_digits(strings_list: []) -> bool:
|
||||||
|
|
@ -122,7 +122,7 @@ def save_event_post(base_dir: str, handle: str, post_id: str,
|
||||||
print('WARN: Account does not exist at ' + handle_dir)
|
print('WARN: Account does not exist at ' + handle_dir)
|
||||||
calendar_path = handle_dir + '/calendar'
|
calendar_path = handle_dir + '/calendar'
|
||||||
if not is_a_dir(calendar_path):
|
if not is_a_dir(calendar_path):
|
||||||
os.mkdir(calendar_path)
|
makedir(calendar_path)
|
||||||
|
|
||||||
# get the year, month and day from the event
|
# get the year, month and day from the event
|
||||||
event_time = date_from_string_format(event_json['startTime'],
|
event_time = date_from_string_format(event_json['startTime'],
|
||||||
|
|
@ -146,11 +146,11 @@ def save_event_post(base_dir: str, handle: str, post_id: str,
|
||||||
# as a separate json file
|
# as a separate json file
|
||||||
events_path = handle_dir + '/events'
|
events_path = handle_dir + '/events'
|
||||||
if not is_a_dir(events_path):
|
if not is_a_dir(events_path):
|
||||||
os.mkdir(events_path)
|
makedir(events_path)
|
||||||
events_year_path = \
|
events_year_path = \
|
||||||
handle_dir + '/events/' + str(event_year)
|
handle_dir + '/events/' + str(event_year)
|
||||||
if not is_a_dir(events_year_path):
|
if not is_a_dir(events_year_path):
|
||||||
os.mkdir(events_year_path)
|
makedir(events_year_path)
|
||||||
event_id = str(event_year) + '-' + event_time.strftime("%m") + '-' + \
|
event_id = str(event_year) + '-' + event_time.strftime("%m") + '-' + \
|
||||||
event_time.strftime("%d") + '_' + event_json['uuid']
|
event_time.strftime("%d") + '_' + event_json['uuid']
|
||||||
event_filename = events_year_path + '/' + event_id + '.json'
|
event_filename = events_year_path + '/' + event_id + '.json'
|
||||||
|
|
@ -173,7 +173,7 @@ def save_event_post(base_dir: str, handle: str, post_id: str,
|
||||||
|
|
||||||
# create a directory for the calendar year
|
# create a directory for the calendar year
|
||||||
if not is_a_dir(calendar_path + '/' + str(event_year)):
|
if not is_a_dir(calendar_path + '/' + str(event_year)):
|
||||||
os.mkdir(calendar_path + '/' + str(event_year))
|
makedir(calendar_path + '/' + str(event_year))
|
||||||
|
|
||||||
# calendar month file containing event post Ids
|
# calendar month file containing event post Ids
|
||||||
calendar_filename = calendar_path + '/' + str(event_year) + \
|
calendar_filename = calendar_path + '/' + str(event_year) + \
|
||||||
|
|
|
||||||
5
inbox.py
5
inbox.py
|
|
@ -146,6 +146,7 @@ from data import prepend_string
|
||||||
from data import erase_file
|
from data import erase_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def _store_last_post_id(base_dir: str, nickname: str, domain: str,
|
def _store_last_post_id(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -173,7 +174,7 @@ def _store_last_post_id(base_dir: str, nickname: str, domain: str,
|
||||||
lastpost_dir = account_dir + '/lastpost'
|
lastpost_dir = account_dir + '/lastpost'
|
||||||
if not is_a_dir(lastpost_dir):
|
if not is_a_dir(lastpost_dir):
|
||||||
if is_a_dir(account_dir):
|
if is_a_dir(account_dir):
|
||||||
os.mkdir(lastpost_dir)
|
makedir(lastpost_dir)
|
||||||
actor_filename = lastpost_dir + '/' + actor.replace('/', '#')
|
actor_filename = lastpost_dir + '/' + actor.replace('/', '#')
|
||||||
save_string(post_id, actor_filename,
|
save_string(post_id, actor_filename,
|
||||||
'EX: Unable to write last post id to ' + actor_filename)
|
'EX: Unable to write last post id to ' + actor_filename)
|
||||||
|
|
@ -1332,7 +1333,7 @@ def _update_last_seen(base_dir: str, handle: str, actor: str) -> None:
|
||||||
return
|
return
|
||||||
last_seen_path = account_path + '/lastseen'
|
last_seen_path = account_path + '/lastseen'
|
||||||
if not is_a_dir(last_seen_path):
|
if not is_a_dir(last_seen_path):
|
||||||
os.mkdir(last_seen_path)
|
makedir(last_seen_path)
|
||||||
last_seen_filename = \
|
last_seen_filename = \
|
||||||
last_seen_path + '/' + actor.replace('/', '#') + '.txt'
|
last_seen_path + '/' + actor.replace('/', '#') + '.txt'
|
||||||
curr_time = date_utcnow()
|
curr_time = date_utcnow()
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ __email__ = "bob@libreserver.org"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
__module_group__ = "Web Interface"
|
__module_group__ = "Web Interface"
|
||||||
|
|
||||||
import os
|
|
||||||
import shutil
|
import shutil
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from utils import remove_html
|
from utils import remove_html
|
||||||
|
|
@ -19,6 +18,7 @@ from utils import get_micron_blog_filename
|
||||||
from utils import get_gemini_blog_published
|
from utils import get_gemini_blog_published
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def _markdown_get_sections(markdown: str) -> []:
|
def _markdown_get_sections(markdown: str) -> []:
|
||||||
|
|
@ -547,7 +547,7 @@ def blog_to_markdown(base_dir: str, nickname: str, domain: str,
|
||||||
else:
|
else:
|
||||||
markdown_blog_dir = account_dir + '/markdowntest'
|
markdown_blog_dir = account_dir + '/markdowntest'
|
||||||
if not is_a_dir(markdown_blog_dir):
|
if not is_a_dir(markdown_blog_dir):
|
||||||
os.mkdir(markdown_blog_dir)
|
makedir(markdown_blog_dir)
|
||||||
|
|
||||||
markdown_blog_filename = \
|
markdown_blog_filename = \
|
||||||
get_markdown_blog_filename(base_dir, nickname, domain,
|
get_markdown_blog_filename(base_dir, nickname, domain,
|
||||||
|
|
@ -623,7 +623,7 @@ def blog_to_micron(base_dir: str, nickname: str, domain: str,
|
||||||
else:
|
else:
|
||||||
micron_blog_dir = account_dir + '/microntest'
|
micron_blog_dir = account_dir + '/microntest'
|
||||||
if not is_a_dir(micron_blog_dir):
|
if not is_a_dir(micron_blog_dir):
|
||||||
os.mkdir(micron_blog_dir)
|
makedir(micron_blog_dir)
|
||||||
|
|
||||||
micron_blog_filename = \
|
micron_blog_filename = \
|
||||||
get_micron_blog_filename(base_dir, nickname, domain,
|
get_micron_blog_filename(base_dir, nickname, domain,
|
||||||
|
|
|
||||||
9
media.py
9
media.py
|
|
@ -39,6 +39,7 @@ from data import erase_file
|
||||||
from data import move_file
|
from data import move_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
# music file ID3 v1 genres
|
# music file ID3 v1 genres
|
||||||
|
|
@ -547,9 +548,9 @@ def create_media_dirs(base_dir: str, media_path: str) -> None:
|
||||||
"""Creates stored media directories
|
"""Creates stored media directories
|
||||||
"""
|
"""
|
||||||
if not is_a_dir(base_dir + '/media'):
|
if not is_a_dir(base_dir + '/media'):
|
||||||
os.mkdir(base_dir + '/media')
|
makedir(base_dir + '/media')
|
||||||
if not is_a_dir(base_dir + '/' + media_path):
|
if not is_a_dir(base_dir + '/' + media_path):
|
||||||
os.mkdir(base_dir + '/' + media_path)
|
makedir(base_dir + '/' + media_path)
|
||||||
|
|
||||||
|
|
||||||
def get_media_path() -> str:
|
def get_media_path() -> str:
|
||||||
|
|
@ -774,9 +775,9 @@ def archive_media(base_dir: str, archive_directory: str,
|
||||||
|
|
||||||
if archive_directory:
|
if archive_directory:
|
||||||
if not is_a_dir(archive_directory):
|
if not is_a_dir(archive_directory):
|
||||||
os.mkdir(archive_directory)
|
makedir(archive_directory)
|
||||||
if not is_a_dir(archive_directory + '/media'):
|
if not is_a_dir(archive_directory + '/media'):
|
||||||
os.mkdir(archive_directory + '/media')
|
makedir(archive_directory + '/media')
|
||||||
|
|
||||||
for _, dirs, _ in os.walk(base_dir + '/media'):
|
for _, dirs, _ in os.walk(base_dir + '/media'):
|
||||||
for week_dir in dirs:
|
for week_dir in dirs:
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ from data import prepend_string
|
||||||
from data import erase_file
|
from data import erase_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def _update_feeds_outbox_index(base_dir: str, domain: str,
|
def _update_feeds_outbox_index(base_dir: str, domain: str,
|
||||||
|
|
@ -453,7 +454,7 @@ def _create_news_mirror(base_dir: str, domain: str,
|
||||||
|
|
||||||
mirror_dir = data_dir(base_dir) + '/newsmirror'
|
mirror_dir = data_dir(base_dir) + '/newsmirror'
|
||||||
if not is_a_dir(mirror_dir):
|
if not is_a_dir(mirror_dir):
|
||||||
os.mkdir(mirror_dir)
|
makedir(mirror_dir)
|
||||||
|
|
||||||
# count the directories
|
# count the directories
|
||||||
no_of_dirs: int = 0
|
no_of_dirs: int = 0
|
||||||
|
|
@ -562,7 +563,7 @@ def _convert_rss_to_activitypub(base_dir: str, http_prefix: str,
|
||||||
|
|
||||||
base_path = data_dir(base_dir) + '/news@' + domain + '/outbox'
|
base_path = data_dir(base_dir) + '/news@' + domain + '/outbox'
|
||||||
if not is_a_dir(base_path):
|
if not is_a_dir(base_path):
|
||||||
os.mkdir(base_path)
|
makedir(base_path)
|
||||||
|
|
||||||
# oldest items first
|
# oldest items first
|
||||||
newswire_reverse = OrderedDict(sorted(newswire.items(), reverse=False))
|
newswire_reverse = OrderedDict(sorted(newswire.items(), reverse=False))
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ from data import save_binary
|
||||||
from data import erase_file
|
from data import erase_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def _remove_cdata(text: str) -> str:
|
def _remove_cdata(text: str) -> str:
|
||||||
|
|
@ -190,7 +191,7 @@ def _download_newswire_feed_favicon(session, base_dir: str,
|
||||||
|
|
||||||
# create cached favicons directory if needed
|
# create cached favicons directory if needed
|
||||||
if not is_a_dir(base_dir + '/favicons'):
|
if not is_a_dir(base_dir + '/favicons'):
|
||||||
os.mkdir(base_dir + '/favicons')
|
makedir(base_dir + '/favicons')
|
||||||
|
|
||||||
# check svg for dubious scripts
|
# check svg for dubious scripts
|
||||||
if fav_url.endswith('.svg'):
|
if fav_url.endswith('.svg'):
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ __email__ = "bob@libreserver.org"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
__module_group__ = "Timeline"
|
__module_group__ = "Timeline"
|
||||||
|
|
||||||
import os
|
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from auth import create_password
|
from auth import create_password
|
||||||
from posts import is_image_media
|
from posts import is_image_media
|
||||||
|
|
@ -77,6 +76,7 @@ from data import erase_file
|
||||||
from data import move_file
|
from data import move_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def _localonly_not_local(message_json: {}, domain_full: str) -> bool:
|
def _localonly_not_local(message_json: {}, domain_full: str) -> bool:
|
||||||
|
|
@ -605,7 +605,7 @@ def post_message_to_outbox(session, translate: {},
|
||||||
blogs_dir = \
|
blogs_dir = \
|
||||||
data_dir(base_dir) + '/news@' + domain + '/tlblogs'
|
data_dir(base_dir) + '/news@' + domain + '/tlblogs'
|
||||||
if not is_a_dir(blogs_dir):
|
if not is_a_dir(blogs_dir):
|
||||||
os.mkdir(blogs_dir)
|
makedir(blogs_dir)
|
||||||
copyfile(saved_filename, blogs_dir + '/' + saved_post_id)
|
copyfile(saved_filename, blogs_dir + '/' + saved_post_id)
|
||||||
inbox_update_index('tlblogs', base_dir,
|
inbox_update_index('tlblogs', base_dir,
|
||||||
'news@' + domain,
|
'news@' + domain,
|
||||||
|
|
|
||||||
35
person.py
35
person.py
|
|
@ -100,6 +100,7 @@ from data import erase_file
|
||||||
from data import move_file
|
from data import move_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def generate_rsa_key() -> (str, str):
|
def generate_rsa_key() -> (str, str):
|
||||||
|
|
@ -605,26 +606,26 @@ def _create_person_base(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
if save_to_file:
|
if save_to_file:
|
||||||
# save person to file
|
# save person to file
|
||||||
if not is_a_dir(base_dir):
|
if not is_a_dir(base_dir):
|
||||||
os.mkdir(base_dir)
|
makedir(base_dir)
|
||||||
people_subdir = data_dir(base_dir)
|
people_subdir = data_dir(base_dir)
|
||||||
if not is_a_dir(people_subdir):
|
if not is_a_dir(people_subdir):
|
||||||
os.mkdir(people_subdir)
|
makedir(people_subdir)
|
||||||
if not is_a_dir(people_subdir + '/' + handle):
|
if not is_a_dir(people_subdir + '/' + handle):
|
||||||
os.mkdir(people_subdir + '/' + handle)
|
makedir(people_subdir + '/' + handle)
|
||||||
if not is_a_dir(people_subdir + '/' + handle + '/inbox'):
|
if not is_a_dir(people_subdir + '/' + handle + '/inbox'):
|
||||||
os.mkdir(people_subdir + '/' + handle + '/inbox')
|
makedir(people_subdir + '/' + handle + '/inbox')
|
||||||
if not is_a_dir(people_subdir + '/' + handle + '/outbox'):
|
if not is_a_dir(people_subdir + '/' + handle + '/outbox'):
|
||||||
os.mkdir(people_subdir + '/' + handle + '/outbox')
|
makedir(people_subdir + '/' + handle + '/outbox')
|
||||||
if not is_a_dir(people_subdir + '/' + handle + '/queue'):
|
if not is_a_dir(people_subdir + '/' + handle + '/queue'):
|
||||||
os.mkdir(people_subdir + '/' + handle + '/queue')
|
makedir(people_subdir + '/' + handle + '/queue')
|
||||||
filename = people_subdir + '/' + handle + '.json'
|
filename = people_subdir + '/' + handle + '.json'
|
||||||
save_json(new_person, filename)
|
save_json(new_person, filename)
|
||||||
|
|
||||||
# save to cache
|
# save to cache
|
||||||
if not is_a_dir(base_dir + '/cache'):
|
if not is_a_dir(base_dir + '/cache'):
|
||||||
os.mkdir(base_dir + '/cache')
|
makedir(base_dir + '/cache')
|
||||||
if not is_a_dir(base_dir + '/cache/actors'):
|
if not is_a_dir(base_dir + '/cache/actors'):
|
||||||
os.mkdir(base_dir + '/cache/actors')
|
makedir(base_dir + '/cache/actors')
|
||||||
cache_filename = base_dir + '/cache/actors/' + \
|
cache_filename = base_dir + '/cache/actors/' + \
|
||||||
new_person['id'].replace('/', '#') + '.json'
|
new_person['id'].replace('/', '#') + '.json'
|
||||||
save_json(new_person, cache_filename)
|
save_json(new_person, cache_filename)
|
||||||
|
|
@ -632,9 +633,9 @@ def _create_person_base(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
# save the private key
|
# save the private key
|
||||||
private_keys_subdir = '/keys/private'
|
private_keys_subdir = '/keys/private'
|
||||||
if not is_a_dir(base_dir + '/keys'):
|
if not is_a_dir(base_dir + '/keys'):
|
||||||
os.mkdir(base_dir + '/keys')
|
makedir(base_dir + '/keys')
|
||||||
if not is_a_dir(base_dir + private_keys_subdir):
|
if not is_a_dir(base_dir + private_keys_subdir):
|
||||||
os.mkdir(base_dir + private_keys_subdir)
|
makedir(base_dir + private_keys_subdir)
|
||||||
filename = base_dir + private_keys_subdir + '/' + handle + '.key'
|
filename = base_dir + private_keys_subdir + '/' + handle + '.key'
|
||||||
save_string(private_key_pem, filename,
|
save_string(private_key_pem, filename,
|
||||||
'EX: _create_person_base unable to save 1 ' + filename)
|
'EX: _create_person_base unable to save 1 ' + filename)
|
||||||
|
|
@ -642,7 +643,7 @@ def _create_person_base(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
# save the public key
|
# save the public key
|
||||||
public_keys_subdir = '/keys/public'
|
public_keys_subdir = '/keys/public'
|
||||||
if not is_a_dir(base_dir + public_keys_subdir):
|
if not is_a_dir(base_dir + public_keys_subdir):
|
||||||
os.mkdir(base_dir + public_keys_subdir)
|
makedir(base_dir + public_keys_subdir)
|
||||||
filename = base_dir + public_keys_subdir + '/' + handle + '.pem'
|
filename = base_dir + public_keys_subdir + '/' + handle + '.pem'
|
||||||
save_string(public_key_pem, filename,
|
save_string(public_key_pem, filename,
|
||||||
'EX: _create_person_base unable to save 2 ' + filename)
|
'EX: _create_person_base unable to save 2 ' + filename)
|
||||||
|
|
@ -777,10 +778,10 @@ def create_person(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
|
|
||||||
dir_str = data_dir(base_dir)
|
dir_str = data_dir(base_dir)
|
||||||
if not is_a_dir(dir_str):
|
if not is_a_dir(dir_str):
|
||||||
os.mkdir(dir_str)
|
makedir(dir_str)
|
||||||
account_dir = acct_dir(base_dir, nickname, domain)
|
account_dir = acct_dir(base_dir, nickname, domain)
|
||||||
if not is_a_dir(account_dir):
|
if not is_a_dir(account_dir):
|
||||||
os.mkdir(account_dir)
|
makedir(account_dir)
|
||||||
|
|
||||||
if manual_follower_approval:
|
if manual_follower_approval:
|
||||||
follow_dms_filename = \
|
follow_dms_filename = \
|
||||||
|
|
@ -1580,20 +1581,20 @@ def deactivate_account(base_dir: str, nickname: str, domain: str) -> bool:
|
||||||
return False
|
return False
|
||||||
deactivated_dir = base_dir + '/deactivated'
|
deactivated_dir = base_dir + '/deactivated'
|
||||||
if not is_a_dir(deactivated_dir):
|
if not is_a_dir(deactivated_dir):
|
||||||
os.mkdir(deactivated_dir)
|
makedir(deactivated_dir)
|
||||||
shutil.move(account_dir, deactivated_dir + '/' + handle)
|
shutil.move(account_dir, deactivated_dir + '/' + handle)
|
||||||
|
|
||||||
if is_a_file(base_dir + '/wfendpoints/' + handle + '.json'):
|
if is_a_file(base_dir + '/wfendpoints/' + handle + '.json'):
|
||||||
deactivated_webfinger_dir = base_dir + '/wfdeactivated'
|
deactivated_webfinger_dir = base_dir + '/wfdeactivated'
|
||||||
if not is_a_dir(deactivated_webfinger_dir):
|
if not is_a_dir(deactivated_webfinger_dir):
|
||||||
os.mkdir(deactivated_webfinger_dir)
|
makedir(deactivated_webfinger_dir)
|
||||||
shutil.move(base_dir + '/wfendpoints/' + handle + '.json',
|
shutil.move(base_dir + '/wfendpoints/' + handle + '.json',
|
||||||
deactivated_webfinger_dir + '/' + handle + '.json')
|
deactivated_webfinger_dir + '/' + handle + '.json')
|
||||||
|
|
||||||
if is_a_dir(base_dir + '/sharefiles/' + nickname):
|
if is_a_dir(base_dir + '/sharefiles/' + nickname):
|
||||||
deactivated_sharefiles_dir = base_dir + '/sharefilesdeactivated'
|
deactivated_sharefiles_dir = base_dir + '/sharefilesdeactivated'
|
||||||
if not is_a_dir(deactivated_sharefiles_dir):
|
if not is_a_dir(deactivated_sharefiles_dir):
|
||||||
os.mkdir(deactivated_sharefiles_dir)
|
makedir(deactivated_sharefiles_dir)
|
||||||
shutil.move(base_dir + '/sharefiles/' + nickname,
|
shutil.move(base_dir + '/sharefiles/' + nickname,
|
||||||
deactivated_sharefiles_dir + '/' + nickname)
|
deactivated_sharefiles_dir + '/' + nickname)
|
||||||
|
|
||||||
|
|
@ -1743,7 +1744,7 @@ def set_person_notes(base_dir: str, nickname: str, domain: str,
|
||||||
handle = handle[1:]
|
handle = handle[1:]
|
||||||
notes_dir = acct_dir(base_dir, nickname, domain) + '/notes'
|
notes_dir = acct_dir(base_dir, nickname, domain) + '/notes'
|
||||||
if not is_a_dir(notes_dir):
|
if not is_a_dir(notes_dir):
|
||||||
os.mkdir(notes_dir)
|
makedir(notes_dir)
|
||||||
notes_filename = notes_dir + '/' + handle + '.txt'
|
notes_filename = notes_dir + '/' + handle + '.txt'
|
||||||
if not save_string(notes, notes_filename,
|
if not save_string(notes, notes_filename,
|
||||||
'EX: set_person_notes unable to write ' +
|
'EX: set_person_notes unable to write ' +
|
||||||
|
|
|
||||||
17
posts.py
17
posts.py
|
|
@ -154,6 +154,7 @@ from data import erase_file
|
||||||
from data import move_file
|
from data import move_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def convert_post_content_to_html(message_json: {}) -> None:
|
def convert_post_content_to_html(message_json: {}) -> None:
|
||||||
|
|
@ -1081,7 +1082,7 @@ def _update_hashtags_index(base_dir: str, tag: {}, new_post_id: str,
|
||||||
# create hashtags directory
|
# create hashtags directory
|
||||||
tags_dir = base_dir + '/tags'
|
tags_dir = base_dir + '/tags'
|
||||||
if not is_a_dir(tags_dir):
|
if not is_a_dir(tags_dir):
|
||||||
os.mkdir(tags_dir)
|
makedir(tags_dir)
|
||||||
tag_name = tag['name']
|
tag_name = tag['name']
|
||||||
tags_filename = tags_dir + '/' + tag_name[1:] + '.txt'
|
tags_filename = tags_dir + '/' + tag_name[1:] + '.txt'
|
||||||
|
|
||||||
|
|
@ -5323,11 +5324,11 @@ def archive_posts(base_dir: str, http_prefix: str, archive_dir: str,
|
||||||
|
|
||||||
if archive_dir:
|
if archive_dir:
|
||||||
if not is_a_dir(archive_dir):
|
if not is_a_dir(archive_dir):
|
||||||
os.mkdir(archive_dir)
|
makedir(archive_dir)
|
||||||
|
|
||||||
if archive_dir:
|
if archive_dir:
|
||||||
if not is_a_dir(archive_dir + '/accounts'):
|
if not is_a_dir(archive_dir + '/accounts'):
|
||||||
os.mkdir(archive_dir + '/accounts')
|
makedir(archive_dir + '/accounts')
|
||||||
|
|
||||||
dir_str = data_dir(base_dir)
|
dir_str = data_dir(base_dir)
|
||||||
for _, dirs, _ in os.walk(dir_str):
|
for _, dirs, _ in os.walk(dir_str):
|
||||||
|
|
@ -5339,11 +5340,11 @@ def archive_posts(base_dir: str, http_prefix: str, archive_dir: str,
|
||||||
if archive_dir:
|
if archive_dir:
|
||||||
archive_handle_dir = acct_handle_dir(archive_dir, handle)
|
archive_handle_dir = acct_handle_dir(archive_dir, handle)
|
||||||
if not is_a_dir(archive_handle_dir):
|
if not is_a_dir(archive_handle_dir):
|
||||||
os.mkdir(archive_handle_dir)
|
makedir(archive_handle_dir)
|
||||||
if not is_a_dir(archive_handle_dir + '/inbox'):
|
if not is_a_dir(archive_handle_dir + '/inbox'):
|
||||||
os.mkdir(archive_handle_dir + '/inbox')
|
makedir(archive_handle_dir + '/inbox')
|
||||||
if not is_a_dir(archive_handle_dir + '/outbox'):
|
if not is_a_dir(archive_handle_dir + '/outbox'):
|
||||||
os.mkdir(archive_handle_dir + '/outbox')
|
makedir(archive_handle_dir + '/outbox')
|
||||||
archive_subdir = archive_handle_dir + '/inbox'
|
archive_subdir = archive_handle_dir + '/inbox'
|
||||||
archive_posts_for_person(http_prefix,
|
archive_posts_for_person(http_prefix,
|
||||||
nickname, domain, base_dir,
|
nickname, domain, base_dir,
|
||||||
|
|
@ -5564,7 +5565,7 @@ def archive_posts_for_person(http_prefix: str, nickname: str, domain: str,
|
||||||
return
|
return
|
||||||
if archive_dir:
|
if archive_dir:
|
||||||
if not is_a_dir(archive_dir):
|
if not is_a_dir(archive_dir):
|
||||||
os.mkdir(archive_dir)
|
makedir(archive_dir)
|
||||||
box_dir = create_person_dir(nickname, domain, base_dir, boxname)
|
box_dir = create_person_dir(nickname, domain, base_dir, boxname)
|
||||||
posts_in_box = os.scandir(box_dir)
|
posts_in_box = os.scandir(box_dir)
|
||||||
no_of_posts: int = 0
|
no_of_posts: int = 0
|
||||||
|
|
@ -6270,7 +6271,7 @@ def download_announce(session, base_dir: str, http_prefix: str,
|
||||||
# get the announced post
|
# get the announced post
|
||||||
announce_cache_dir = base_dir + '/cache/announce/' + nickname
|
announce_cache_dir = base_dir + '/cache/announce/' + nickname
|
||||||
if not is_a_dir(announce_cache_dir):
|
if not is_a_dir(announce_cache_dir):
|
||||||
os.mkdir(announce_cache_dir)
|
makedir(announce_cache_dir)
|
||||||
|
|
||||||
post_id = None
|
post_id = None
|
||||||
if post_json_object.get('id'):
|
if post_json_object.get('id'):
|
||||||
|
|
|
||||||
10
reading.py
10
reading.py
|
|
@ -8,7 +8,6 @@ __status__ = "Production"
|
||||||
__module_group__ = "Core"
|
__module_group__ = "Core"
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
from utils import get_post_attachments
|
from utils import get_post_attachments
|
||||||
|
|
@ -27,6 +26,7 @@ from data import load_string
|
||||||
from data import prepend_string
|
from data import prepend_string
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def get_book_link_from_content(content: str) -> str:
|
def get_book_link_from_content(content: str) -> str:
|
||||||
|
|
@ -475,15 +475,15 @@ def store_book_events(base_dir: str,
|
||||||
dir_str = data_dir(base_dir)
|
dir_str = data_dir(base_dir)
|
||||||
reading_path = dir_str + '/reading'
|
reading_path = dir_str + '/reading'
|
||||||
if not is_a_dir(dir_str):
|
if not is_a_dir(dir_str):
|
||||||
os.mkdir(dir_str)
|
makedir(dir_str)
|
||||||
if not is_a_dir(reading_path):
|
if not is_a_dir(reading_path):
|
||||||
os.mkdir(reading_path)
|
makedir(reading_path)
|
||||||
books_path = reading_path + '/books'
|
books_path = reading_path + '/books'
|
||||||
if not is_a_dir(books_path):
|
if not is_a_dir(books_path):
|
||||||
os.mkdir(books_path)
|
makedir(books_path)
|
||||||
readers_path = reading_path + '/readers'
|
readers_path = reading_path + '/readers'
|
||||||
if not is_a_dir(readers_path):
|
if not is_a_dir(readers_path):
|
||||||
os.mkdir(readers_path)
|
makedir(readers_path)
|
||||||
|
|
||||||
actor = book_dict['actor']
|
actor = book_dict['actor']
|
||||||
book_url = remove_id_ending(book_dict['href'])
|
book_url = remove_id_ending(book_dict['href'])
|
||||||
|
|
|
||||||
13
shares.py
13
shares.py
|
|
@ -65,6 +65,7 @@ from data import load_string
|
||||||
from data import erase_file
|
from data import erase_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def _load_dfc_ids(base_dir: str, system_language: str,
|
def _load_dfc_ids(base_dir: str, system_language: str,
|
||||||
|
|
@ -387,9 +388,9 @@ def add_share(base_dir: str,
|
||||||
if image_filename:
|
if image_filename:
|
||||||
if is_a_file(image_filename):
|
if is_a_file(image_filename):
|
||||||
if not is_a_dir(base_dir + '/sharefiles'):
|
if not is_a_dir(base_dir + '/sharefiles'):
|
||||||
os.mkdir(base_dir + '/sharefiles')
|
makedir(base_dir + '/sharefiles')
|
||||||
if not is_a_dir(base_dir + '/sharefiles/' + nickname):
|
if not is_a_dir(base_dir + '/sharefiles/' + nickname):
|
||||||
os.mkdir(base_dir + '/sharefiles/' + nickname)
|
makedir(base_dir + '/sharefiles/' + nickname)
|
||||||
item_idfile = base_dir + '/sharefiles/' + nickname + '/' + item_id
|
item_idfile = base_dir + '/sharefiles/' + nickname + '/' + item_id
|
||||||
formats = get_image_extensions()
|
formats = get_image_extensions()
|
||||||
for ext in formats:
|
for ext in formats:
|
||||||
|
|
@ -1735,13 +1736,13 @@ def _update_federated_shares_cache(session, shared_items_federated_domains: [],
|
||||||
# create directories where catalogs will be stored
|
# create directories where catalogs will be stored
|
||||||
cache_dir = base_dir + '/cache'
|
cache_dir = base_dir + '/cache'
|
||||||
if not is_a_dir(cache_dir):
|
if not is_a_dir(cache_dir):
|
||||||
os.mkdir(cache_dir)
|
makedir(cache_dir)
|
||||||
if shares_file_type == 'shares':
|
if shares_file_type == 'shares':
|
||||||
catalogs_dir = cache_dir + '/catalogs'
|
catalogs_dir = cache_dir + '/catalogs'
|
||||||
else:
|
else:
|
||||||
catalogs_dir = cache_dir + '/wantedItems'
|
catalogs_dir = cache_dir + '/wantedItems'
|
||||||
if not is_a_dir(catalogs_dir):
|
if not is_a_dir(catalogs_dir):
|
||||||
os.mkdir(catalogs_dir)
|
makedir(catalogs_dir)
|
||||||
|
|
||||||
as_header = {
|
as_header = {
|
||||||
"Accept": "application/ld+json",
|
"Accept": "application/ld+json",
|
||||||
|
|
@ -1822,9 +1823,9 @@ def _generate_next_shares_token_update(base_dir: str,
|
||||||
"""
|
"""
|
||||||
token_update_dir = data_dir(base_dir)
|
token_update_dir = data_dir(base_dir)
|
||||||
if not is_a_dir(base_dir):
|
if not is_a_dir(base_dir):
|
||||||
os.mkdir(base_dir)
|
makedir(base_dir)
|
||||||
if not is_a_dir(token_update_dir):
|
if not is_a_dir(token_update_dir):
|
||||||
os.mkdir(token_update_dir)
|
makedir(token_update_dir)
|
||||||
token_update_filename = token_update_dir + '/.tokenUpdate'
|
token_update_filename = token_update_dir + '/.tokenUpdate'
|
||||||
next_update_sec = None
|
next_update_sec = None
|
||||||
if is_a_file(token_update_filename):
|
if is_a_file(token_update_filename):
|
||||||
|
|
|
||||||
49
tests.py
49
tests.py
|
|
@ -249,6 +249,7 @@ from data import load_string
|
||||||
from data import save_string
|
from data import save_string
|
||||||
from data import erase_file
|
from data import erase_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
TEST_SERVER_GROUP_RUNNING = False
|
TEST_SERVER_GROUP_RUNNING = False
|
||||||
|
|
@ -332,7 +333,7 @@ def _test_http_signed_get(base_dir: str):
|
||||||
path = base_dir + '/.testHttpsigGET'
|
path = base_dir + '/.testHttpsigGET'
|
||||||
if is_a_dir(path):
|
if is_a_dir(path):
|
||||||
shutil.rmtree(path, ignore_errors=False)
|
shutil.rmtree(path, ignore_errors=False)
|
||||||
os.mkdir(path)
|
makedir(path)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
|
|
||||||
nickname = 'testactor'
|
nickname = 'testactor'
|
||||||
|
|
@ -612,7 +613,7 @@ def _test_httpsig_base(with_digest: bool, base_dir: str):
|
||||||
path = base_dir + '/.testHttpsigBase'
|
path = base_dir + '/.testHttpsigBase'
|
||||||
if is_a_dir(path):
|
if is_a_dir(path):
|
||||||
shutil.rmtree(path, ignore_errors=False)
|
shutil.rmtree(path, ignore_errors=False)
|
||||||
os.mkdir(path)
|
makedir(path)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
|
|
||||||
algorithm = 'rsa-sha256'
|
algorithm = 'rsa-sha256'
|
||||||
|
|
@ -773,7 +774,7 @@ def create_server_alice(path: str, domain: str, port: int,
|
||||||
print('Creating test server: Alice on port ' + str(port))
|
print('Creating test server: Alice on port ' + str(port))
|
||||||
if is_a_dir(path):
|
if is_a_dir(path):
|
||||||
shutil.rmtree(path, ignore_errors=False)
|
shutil.rmtree(path, ignore_errors=False)
|
||||||
os.mkdir(path)
|
makedir(path)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
shared_items_federated_domains: list[str] = []
|
shared_items_federated_domains: list[str] = []
|
||||||
system_language: str = 'en'
|
system_language: str = 'en'
|
||||||
|
|
@ -978,7 +979,7 @@ def create_server_bob(path: str, domain: str, port: int,
|
||||||
print('Creating test server: Bob on port ' + str(port))
|
print('Creating test server: Bob on port ' + str(port))
|
||||||
if is_a_dir(path):
|
if is_a_dir(path):
|
||||||
shutil.rmtree(path, ignore_errors=False)
|
shutil.rmtree(path, ignore_errors=False)
|
||||||
os.mkdir(path)
|
makedir(path)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
shared_items_federated_domains: list[str] = []
|
shared_items_federated_domains: list[str] = []
|
||||||
system_language: str = 'en'
|
system_language: str = 'en'
|
||||||
|
|
@ -1183,7 +1184,7 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [],
|
||||||
print('Creating test server: Eve on port ' + str(port))
|
print('Creating test server: Eve on port ' + str(port))
|
||||||
if is_a_dir(path):
|
if is_a_dir(path):
|
||||||
shutil.rmtree(path, ignore_errors=False)
|
shutil.rmtree(path, ignore_errors=False)
|
||||||
os.mkdir(path)
|
makedir(path)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
shared_items_federated_domains: list[str] = []
|
shared_items_federated_domains: list[str] = []
|
||||||
nickname: str = 'eve'
|
nickname: str = 'eve'
|
||||||
|
|
@ -1308,7 +1309,7 @@ def create_server_group(path: str, domain: str, port: int,
|
||||||
print('Creating test server: Group on port ' + str(port))
|
print('Creating test server: Group on port ' + str(port))
|
||||||
if is_a_dir(path):
|
if is_a_dir(path):
|
||||||
shutil.rmtree(path, ignore_errors=False)
|
shutil.rmtree(path, ignore_errors=False)
|
||||||
os.mkdir(path)
|
makedir(path)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
shared_items_federated_domains: list[str] = []
|
shared_items_federated_domains: list[str] = []
|
||||||
# system_language = 'en'
|
# system_language = 'en'
|
||||||
|
|
@ -1425,7 +1426,7 @@ def test_post_message_between_servers(base_dir: str) -> None:
|
||||||
|
|
||||||
if is_a_dir(base_dir + '/.tests'):
|
if is_a_dir(base_dir + '/.tests'):
|
||||||
shutil.rmtree(base_dir + '/.tests', ignore_errors=False)
|
shutil.rmtree(base_dir + '/.tests', ignore_errors=False)
|
||||||
os.mkdir(base_dir + '/.tests')
|
makedir(base_dir + '/.tests')
|
||||||
|
|
||||||
# create the servers
|
# create the servers
|
||||||
alice_dir = base_dir + '/.tests/alice'
|
alice_dir = base_dir + '/.tests/alice'
|
||||||
|
|
@ -1785,7 +1786,7 @@ def test_follow_between_servers(base_dir: str) -> None:
|
||||||
|
|
||||||
if is_a_dir(base_dir + '/.tests'):
|
if is_a_dir(base_dir + '/.tests'):
|
||||||
shutil.rmtree(base_dir + '/.tests', ignore_errors=False)
|
shutil.rmtree(base_dir + '/.tests', ignore_errors=False)
|
||||||
os.mkdir(base_dir + '/.tests')
|
makedir(base_dir + '/.tests')
|
||||||
|
|
||||||
# create the servers
|
# create the servers
|
||||||
alice_dir = base_dir + '/.tests/alice'
|
alice_dir = base_dir + '/.tests/alice'
|
||||||
|
|
@ -1995,7 +1996,7 @@ def test_shared_items_federation(base_dir: str) -> None:
|
||||||
|
|
||||||
if is_a_dir(base_dir + '/.tests'):
|
if is_a_dir(base_dir + '/.tests'):
|
||||||
shutil.rmtree(base_dir + '/.tests', ignore_errors=False)
|
shutil.rmtree(base_dir + '/.tests', ignore_errors=False)
|
||||||
os.mkdir(base_dir + '/.tests')
|
makedir(base_dir + '/.tests')
|
||||||
|
|
||||||
# create the servers
|
# create the servers
|
||||||
alice_dir = base_dir + '/.tests/alice'
|
alice_dir = base_dir + '/.tests/alice'
|
||||||
|
|
@ -2157,7 +2158,7 @@ def test_shared_items_federation(base_dir: str) -> None:
|
||||||
print('Bob publishes some shared items')
|
print('Bob publishes some shared items')
|
||||||
if is_a_dir(bob_dir + '/ontology'):
|
if is_a_dir(bob_dir + '/ontology'):
|
||||||
shutil.rmtree(bob_dir + '/ontology', ignore_errors=False)
|
shutil.rmtree(bob_dir + '/ontology', ignore_errors=False)
|
||||||
os.mkdir(bob_dir + '/ontology')
|
makedir(bob_dir + '/ontology')
|
||||||
copyfile(base_dir + '/img/logo.png', bob_dir + '/logo.png')
|
copyfile(base_dir + '/img/logo.png', bob_dir + '/logo.png')
|
||||||
copyfile(base_dir + '/ontology/foodTypes.json',
|
copyfile(base_dir + '/ontology/foodTypes.json',
|
||||||
bob_dir + '/ontology/foodTypes.json')
|
bob_dir + '/ontology/foodTypes.json')
|
||||||
|
|
@ -2472,7 +2473,7 @@ def test_group_follow(base_dir: str) -> None:
|
||||||
|
|
||||||
if is_a_dir(base_dir + '/.tests'):
|
if is_a_dir(base_dir + '/.tests'):
|
||||||
shutil.rmtree(base_dir + '/.tests', ignore_errors=False)
|
shutil.rmtree(base_dir + '/.tests', ignore_errors=False)
|
||||||
os.mkdir(base_dir + '/.tests')
|
makedir(base_dir + '/.tests')
|
||||||
|
|
||||||
# create the servers
|
# create the servers
|
||||||
alice_dir = base_dir + '/.tests/alice'
|
alice_dir = base_dir + '/.tests/alice'
|
||||||
|
|
@ -2905,7 +2906,7 @@ def _test_followers_of_person(base_dir: str) -> None:
|
||||||
base_dir = curr_dir + '/.tests_followersofperson'
|
base_dir = curr_dir + '/.tests_followersofperson'
|
||||||
if is_a_dir(base_dir):
|
if is_a_dir(base_dir):
|
||||||
shutil.rmtree(base_dir, ignore_errors=False)
|
shutil.rmtree(base_dir, ignore_errors=False)
|
||||||
os.mkdir(base_dir)
|
makedir(base_dir)
|
||||||
os.chdir(base_dir)
|
os.chdir(base_dir)
|
||||||
create_person(base_dir, nickname, domain, port,
|
create_person(base_dir, nickname, domain, port,
|
||||||
http_prefix, True, False, password)
|
http_prefix, True, False, password)
|
||||||
|
|
@ -2955,7 +2956,7 @@ def _test_followers_on_domain(base_dir: str) -> None:
|
||||||
base_dir = curr_dir + '/.tests_nooffollowersOndomain'
|
base_dir = curr_dir + '/.tests_nooffollowersOndomain'
|
||||||
if is_a_dir(base_dir):
|
if is_a_dir(base_dir):
|
||||||
shutil.rmtree(base_dir, ignore_errors=False)
|
shutil.rmtree(base_dir, ignore_errors=False)
|
||||||
os.mkdir(base_dir)
|
makedir(base_dir)
|
||||||
os.chdir(base_dir)
|
os.chdir(base_dir)
|
||||||
create_person(base_dir, nickname, domain, port, http_prefix, True,
|
create_person(base_dir, nickname, domain, port, http_prefix, True,
|
||||||
False, password)
|
False, password)
|
||||||
|
|
@ -3022,7 +3023,7 @@ def _test_group_followers(base_dir: str) -> None:
|
||||||
base_dir = curr_dir + '/.tests_testgroupfollowers'
|
base_dir = curr_dir + '/.tests_testgroupfollowers'
|
||||||
if is_a_dir(base_dir):
|
if is_a_dir(base_dir):
|
||||||
shutil.rmtree(base_dir, ignore_errors=False)
|
shutil.rmtree(base_dir, ignore_errors=False)
|
||||||
os.mkdir(base_dir)
|
makedir(base_dir)
|
||||||
os.chdir(base_dir)
|
os.chdir(base_dir)
|
||||||
create_person(base_dir, nickname, domain, port, http_prefix, True,
|
create_person(base_dir, nickname, domain, port, http_prefix, True,
|
||||||
False, password)
|
False, password)
|
||||||
|
|
@ -3068,7 +3069,7 @@ def _test_follows(base_dir: str) -> None:
|
||||||
base_dir = curr_dir + '/.tests_testfollows'
|
base_dir = curr_dir + '/.tests_testfollows'
|
||||||
if is_a_dir(base_dir):
|
if is_a_dir(base_dir):
|
||||||
shutil.rmtree(base_dir, ignore_errors=False)
|
shutil.rmtree(base_dir, ignore_errors=False)
|
||||||
os.mkdir(base_dir)
|
makedir(base_dir)
|
||||||
os.chdir(base_dir)
|
os.chdir(base_dir)
|
||||||
create_person(base_dir, nickname, domain, port, http_prefix, True,
|
create_person(base_dir, nickname, domain, port, http_prefix, True,
|
||||||
False, password)
|
False, password)
|
||||||
|
|
@ -3160,7 +3161,7 @@ def _test_create_person_account(base_dir: str):
|
||||||
base_dir: str = curr_dir + '/.tests_createperson'
|
base_dir: str = curr_dir + '/.tests_createperson'
|
||||||
if is_a_dir(base_dir):
|
if is_a_dir(base_dir):
|
||||||
shutil.rmtree(base_dir, ignore_errors=False)
|
shutil.rmtree(base_dir, ignore_errors=False)
|
||||||
os.mkdir(base_dir)
|
makedir(base_dir)
|
||||||
os.chdir(base_dir)
|
os.chdir(base_dir)
|
||||||
|
|
||||||
private_key_pem, public_key_pem, person, wf_endpoint = \
|
private_key_pem, public_key_pem, person, wf_endpoint = \
|
||||||
|
|
@ -3300,7 +3301,7 @@ def _test_authentication(base_dir: str) -> None:
|
||||||
base_dir = curr_dir + '/.tests_authentication'
|
base_dir = curr_dir + '/.tests_authentication'
|
||||||
if is_a_dir(base_dir):
|
if is_a_dir(base_dir):
|
||||||
shutil.rmtree(base_dir, ignore_errors=False)
|
shutil.rmtree(base_dir, ignore_errors=False)
|
||||||
os.mkdir(base_dir)
|
makedir(base_dir)
|
||||||
os.chdir(base_dir)
|
os.chdir(base_dir)
|
||||||
|
|
||||||
assert store_basic_credentials(base_dir, 'othernick', 'otherpass')
|
assert store_basic_credentials(base_dir, 'othernick', 'otherpass')
|
||||||
|
|
@ -3352,7 +3353,7 @@ def test_client_to_server(base_dir: str):
|
||||||
|
|
||||||
if is_a_dir(base_dir + '/.tests'):
|
if is_a_dir(base_dir + '/.tests'):
|
||||||
shutil.rmtree(base_dir + '/.tests', ignore_errors=False)
|
shutil.rmtree(base_dir + '/.tests', ignore_errors=False)
|
||||||
os.mkdir(base_dir + '/.tests')
|
makedir(base_dir + '/.tests')
|
||||||
|
|
||||||
# create the servers
|
# create the servers
|
||||||
alice_dir = base_dir + '/.tests/alice'
|
alice_dir = base_dir + '/.tests/alice'
|
||||||
|
|
@ -4218,16 +4219,16 @@ def _test_addemoji(base_dir: str):
|
||||||
base_dir_original = base_dir
|
base_dir_original = base_dir
|
||||||
path = base_dir + '/.tests'
|
path = base_dir + '/.tests'
|
||||||
if not is_a_dir(path):
|
if not is_a_dir(path):
|
||||||
os.mkdir(path)
|
makedir(path)
|
||||||
path = base_dir + '/.tests/emoji'
|
path = base_dir + '/.tests/emoji'
|
||||||
if is_a_dir(path):
|
if is_a_dir(path):
|
||||||
shutil.rmtree(path, ignore_errors=False)
|
shutil.rmtree(path, ignore_errors=False)
|
||||||
os.mkdir(path)
|
makedir(path)
|
||||||
base_dir = path
|
base_dir = path
|
||||||
path = base_dir + '/emoji'
|
path = base_dir + '/emoji'
|
||||||
if is_a_dir(path):
|
if is_a_dir(path):
|
||||||
shutil.rmtree(path, ignore_errors=False)
|
shutil.rmtree(path, ignore_errors=False)
|
||||||
os.mkdir(path)
|
makedir(path)
|
||||||
copytree(base_dir_original + '/emoji', base_dir + '/emoji', False, None)
|
copytree(base_dir_original + '/emoji', base_dir + '/emoji', False, None)
|
||||||
os.chdir(base_dir)
|
os.chdir(base_dir)
|
||||||
private_key_pem, public_key_pem, person, wf_endpoint = \
|
private_key_pem, public_key_pem, person, wf_endpoint = \
|
||||||
|
|
@ -6867,7 +6868,7 @@ def test_update_actor(base_dir: str):
|
||||||
if is_a_dir(base_dir + '/.tests'):
|
if is_a_dir(base_dir + '/.tests'):
|
||||||
shutil.rmtree(base_dir + '/.tests',
|
shutil.rmtree(base_dir + '/.tests',
|
||||||
ignore_errors=False)
|
ignore_errors=False)
|
||||||
os.mkdir(base_dir + '/.tests')
|
makedir(base_dir + '/.tests')
|
||||||
|
|
||||||
# create the server
|
# create the server
|
||||||
alice_dir = base_dir + '/.tests/alice'
|
alice_dir = base_dir + '/.tests/alice'
|
||||||
|
|
@ -7783,7 +7784,7 @@ def _test_httpsig_base_new(with_digest: bool, base_dir: str,
|
||||||
path = base_dir + '/.testHttpsigBaseNew'
|
path = base_dir + '/.testHttpsigBaseNew'
|
||||||
if is_a_dir(path):
|
if is_a_dir(path):
|
||||||
shutil.rmtree(path, ignore_errors=False)
|
shutil.rmtree(path, ignore_errors=False)
|
||||||
os.mkdir(path)
|
makedir(path)
|
||||||
os.chdir(path)
|
os.chdir(path)
|
||||||
|
|
||||||
content_type = 'application/activity+json'
|
content_type = 'application/activity+json'
|
||||||
|
|
@ -8959,7 +8960,7 @@ def _test_book_link(base_dir: str):
|
||||||
base_dir2 = base_dir + '/.testbookevents'
|
base_dir2 = base_dir + '/.testbookevents'
|
||||||
if is_a_dir(base_dir2):
|
if is_a_dir(base_dir2):
|
||||||
shutil.rmtree(base_dir2, ignore_errors=False)
|
shutil.rmtree(base_dir2, ignore_errors=False)
|
||||||
os.mkdir(base_dir2)
|
makedir(base_dir2)
|
||||||
|
|
||||||
content = 'Not a link'
|
content = 'Not a link'
|
||||||
result = get_book_link_from_content(content)
|
result = get_book_link_from_content(content)
|
||||||
|
|
|
||||||
7
theme.py
7
theme.py
|
|
@ -34,6 +34,7 @@ from data import save_flag_file
|
||||||
from data import erase_file
|
from data import erase_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def import_theme(base_dir: str, filename: str) -> bool:
|
def import_theme(base_dir: str, filename: str) -> bool:
|
||||||
|
|
@ -44,7 +45,7 @@ def import_theme(base_dir: str, filename: str) -> bool:
|
||||||
temp_theme_dir = base_dir + '/imports/files'
|
temp_theme_dir = base_dir + '/imports/files'
|
||||||
if is_a_dir(temp_theme_dir):
|
if is_a_dir(temp_theme_dir):
|
||||||
rmtree(temp_theme_dir, ignore_errors=False, onexc=None)
|
rmtree(temp_theme_dir, ignore_errors=False, onexc=None)
|
||||||
os.mkdir(temp_theme_dir)
|
makedir(temp_theme_dir)
|
||||||
unpack_archive(filename, temp_theme_dir, 'zip')
|
unpack_archive(filename, temp_theme_dir, 'zip')
|
||||||
essential_theme_files = ('name.txt', 'theme.json')
|
essential_theme_files = ('name.txt', 'theme.json')
|
||||||
for theme_file in essential_theme_files:
|
for theme_file in essential_theme_files:
|
||||||
|
|
@ -88,7 +89,7 @@ def import_theme(base_dir: str, filename: str) -> bool:
|
||||||
|
|
||||||
theme_dir = base_dir + '/theme/' + new_theme_name
|
theme_dir = base_dir + '/theme/' + new_theme_name
|
||||||
if not is_a_dir(theme_dir):
|
if not is_a_dir(theme_dir):
|
||||||
os.mkdir(theme_dir)
|
makedir(theme_dir)
|
||||||
copytree(temp_theme_dir, theme_dir, False, None)
|
copytree(temp_theme_dir, theme_dir, False, None)
|
||||||
if is_a_dir(temp_theme_dir):
|
if is_a_dir(temp_theme_dir):
|
||||||
rmtree(temp_theme_dir, ignore_errors=False, onexc=None)
|
rmtree(temp_theme_dir, ignore_errors=False, onexc=None)
|
||||||
|
|
@ -105,7 +106,7 @@ def export_theme(base_dir: str, theme: str) -> bool:
|
||||||
if not is_a_file(theme_dir + '/theme.json'):
|
if not is_a_file(theme_dir + '/theme.json'):
|
||||||
return False
|
return False
|
||||||
if not is_a_dir(base_dir + '/exports'):
|
if not is_a_dir(base_dir + '/exports'):
|
||||||
os.mkdir(base_dir + '/exports')
|
makedir(base_dir + '/exports')
|
||||||
export_filename = base_dir + '/exports/' + theme + '.zip'
|
export_filename = base_dir + '/exports/' + theme + '.zip'
|
||||||
if is_a_file(export_filename):
|
if is_a_file(export_filename):
|
||||||
ex_text = \
|
ex_text = \
|
||||||
|
|
|
||||||
7
utils.py
7
utils.py
|
|
@ -30,6 +30,7 @@ from data import append_string
|
||||||
from data import erase_file
|
from data import erase_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
VALID_HASHTAG_CHARS = \
|
VALID_HASHTAG_CHARS = \
|
||||||
set('_0123456789' +
|
set('_0123456789' +
|
||||||
|
|
@ -1037,10 +1038,10 @@ def create_person_dir(nickname: str, domain: str, base_dir: str,
|
||||||
handle: str = nickname + '@' + domain
|
handle: str = nickname + '@' + domain
|
||||||
handle_dir: str = acct_handle_dir(base_dir, handle)
|
handle_dir: str = acct_handle_dir(base_dir, handle)
|
||||||
if not is_a_dir(handle_dir):
|
if not is_a_dir(handle_dir):
|
||||||
os.mkdir(handle_dir)
|
makedir(handle_dir)
|
||||||
box_dir: str = acct_handle_dir(base_dir, handle) + '/' + dir_name
|
box_dir: str = acct_handle_dir(base_dir, handle) + '/' + dir_name
|
||||||
if not is_a_dir(box_dir):
|
if not is_a_dir(box_dir):
|
||||||
os.mkdir(box_dir)
|
makedir(box_dir)
|
||||||
return box_dir
|
return box_dir
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1624,7 +1625,7 @@ def follow_person(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
dir_str: str = data_dir(base_dir)
|
dir_str: str = data_dir(base_dir)
|
||||||
if not is_a_dir(dir_str):
|
if not is_a_dir(dir_str):
|
||||||
os.mkdir(dir_str)
|
makedir(dir_str)
|
||||||
handle_to_follow = follow_nickname + '@' + follow_domain
|
handle_to_follow = follow_nickname + '@' + follow_domain
|
||||||
if group_account:
|
if group_account:
|
||||||
handle_to_follow = '!' + handle_to_follow
|
handle_to_follow = '!' + handle_to_follow
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ from data import save_string
|
||||||
from data import load_line
|
from data import load_line
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def get_hashtag_categories_feed(base_dir: str,
|
def get_hashtag_categories_feed(base_dir: str,
|
||||||
|
|
@ -431,7 +432,7 @@ def store_hash_tags(base_dir: str, nickname: str, domain: str,
|
||||||
# add tags directory if it doesn't exist
|
# add tags directory if it doesn't exist
|
||||||
if not is_a_dir(tags_dir):
|
if not is_a_dir(tags_dir):
|
||||||
print('Creating tags directory')
|
print('Creating tags directory')
|
||||||
os.mkdir(tags_dir)
|
makedir(tags_dir)
|
||||||
|
|
||||||
# obtain any map links and these can be associated with hashtags
|
# obtain any map links and these can be associated with hashtags
|
||||||
# get geolocations from content
|
# get geolocations from content
|
||||||
|
|
@ -459,7 +460,7 @@ def store_hash_tags(base_dir: str, nickname: str, domain: str,
|
||||||
# add tagmaps directory if it doesn't exist
|
# add tagmaps directory if it doesn't exist
|
||||||
if not is_a_dir(tag_maps_dir):
|
if not is_a_dir(tag_maps_dir):
|
||||||
print('Creating tagmaps directory')
|
print('Creating tagmaps directory')
|
||||||
os.mkdir(tag_maps_dir)
|
makedir(tag_maps_dir)
|
||||||
|
|
||||||
post_url = remove_id_ending(post_json_object['id'])
|
post_url = remove_id_ending(post_json_object['id'])
|
||||||
post_url = post_url.replace('/', '#')
|
post_url = post_url.replace('/', '#')
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ __email__ = "bob@libreserver.org"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
__module_group__ = "Web Interface"
|
__module_group__ = "Web Interface"
|
||||||
|
|
||||||
import os
|
|
||||||
import time
|
import time
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from dateutil.parser import parse
|
from dateutil.parser import parse
|
||||||
|
|
@ -150,6 +149,7 @@ from data import save_string
|
||||||
from data import save_flag_file
|
from data import save_flag_file
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
# maximum length for display name within html posts
|
# maximum length for display name within html posts
|
||||||
MAX_DISPLAY_NAME_LENGTH = 42
|
MAX_DISPLAY_NAME_LENGTH = 42
|
||||||
|
|
@ -573,7 +573,7 @@ def _save_individual_post_as_html_to_cache(base_dir: str,
|
||||||
|
|
||||||
# create the cache directory if needed
|
# create the cache directory if needed
|
||||||
if not is_a_dir(html_post_cache_dir):
|
if not is_a_dir(html_post_cache_dir):
|
||||||
os.mkdir(html_post_cache_dir)
|
makedir(html_post_cache_dir)
|
||||||
|
|
||||||
if save_string(post_html, cached_post_filename,
|
if save_string(post_html, cached_post_filename,
|
||||||
'ERROR: saving post to cache, [ex]'):
|
'ERROR: saving post to cache, [ex]'):
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ __email__ = "bob@libreserver.org"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
__module_group__ = "ActivityPub"
|
__module_group__ = "ActivityPub"
|
||||||
|
|
||||||
import os
|
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from session import get_json
|
from session import get_json
|
||||||
from session import get_json_valid
|
from session import get_json_valid
|
||||||
|
|
@ -31,6 +30,7 @@ from utils import get_domain_from_actor
|
||||||
from utils import is_yggdrasil_url
|
from utils import is_yggdrasil_url
|
||||||
from data import is_a_file
|
from data import is_a_file
|
||||||
from data import is_a_dir
|
from data import is_a_dir
|
||||||
|
from data import makedir
|
||||||
|
|
||||||
|
|
||||||
def _parse_handle(handle: str) -> (str, str, bool):
|
def _parse_handle(handle: str) -> (str, str, bool):
|
||||||
|
|
@ -162,7 +162,7 @@ def store_webfinger_endpoint(nickname: str, domain: str, port: int,
|
||||||
handle = nickname + '@' + domain
|
handle = nickname + '@' + domain
|
||||||
wf_subdir = '/wfendpoints'
|
wf_subdir = '/wfendpoints'
|
||||||
if not is_a_dir(base_dir + wf_subdir):
|
if not is_a_dir(base_dir + wf_subdir):
|
||||||
os.mkdir(base_dir + wf_subdir)
|
makedir(base_dir + wf_subdir)
|
||||||
filename = base_dir + wf_subdir + '/' + handle + '.json'
|
filename = base_dir + wf_subdir + '/' + handle + '.json'
|
||||||
save_json(wf_json, filename)
|
save_json(wf_json, filename)
|
||||||
if nickname == 'inbox':
|
if nickname == 'inbox':
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue