mirror of https://gitlab.com/bashrc2/epicyon
Command option to ser accounts directory
parent
00152e800e
commit
1339ff57b5
|
@ -4,6 +4,12 @@ This system can be administrated from the command-line.
|
|||
|
||||
## Account Management
|
||||
|
||||
Ordinarily accounts data is stored within a subdirectory of the application directory. This can also be changed using the **accounts-dir** option, which may be used together with other options as needed:
|
||||
|
||||
``` bash
|
||||
python3 epicyon.py --accounts-dir [dir]
|
||||
```
|
||||
|
||||
The first thing you will need to do is to create an account. You can do this with the command:
|
||||
|
||||
``` bash
|
||||
|
|
|
@ -50,6 +50,7 @@ from shares import expire_shares
|
|||
from categories import load_city_hashtags
|
||||
from categories import update_hashtag_categories
|
||||
from languages import load_default_post_languages
|
||||
from utils import set_accounts_data_dir
|
||||
from utils import data_dir
|
||||
from utils import string_contains
|
||||
from utils import check_bad_path
|
||||
|
@ -679,7 +680,8 @@ def load_tokens(base_dir: str, tokens_dict: {}, tokens_lookup: {}) -> None:
|
|||
break
|
||||
|
||||
|
||||
def run_daemon(no_of_books: int,
|
||||
def run_daemon(accounts_data_dir: str,
|
||||
no_of_books: int,
|
||||
public_replies_unlisted: int,
|
||||
max_shares_on_profile: int,
|
||||
max_hashtags: int,
|
||||
|
@ -770,6 +772,9 @@ def run_daemon(no_of_books: int,
|
|||
server_address = ('', proxy_port)
|
||||
pub_handler = partial(PubServer)
|
||||
|
||||
if accounts_data_dir:
|
||||
set_accounts_data_dir(base_dir, accounts_data_dir)
|
||||
|
||||
dir_str = data_dir(base_dir)
|
||||
if not os.path.isdir(dir_str):
|
||||
print('Creating accounts directory')
|
||||
|
|
11
epicyon.py
11
epicyon.py
|
@ -72,6 +72,7 @@ from tests import test_update_actor
|
|||
from tests import run_all_tests
|
||||
from auth import store_basic_credentials
|
||||
from auth import create_password
|
||||
from utils import set_accounts_data_dir
|
||||
from utils import data_dir
|
||||
from utils import data_dir_testing
|
||||
from utils import string_ends_with
|
||||
|
@ -326,6 +327,9 @@ def _command_options() -> None:
|
|||
parser.add_argument('--path', dest='base_dir',
|
||||
type=str, default=os.getcwd(),
|
||||
help='Directory in which to store posts')
|
||||
parser.add_argument('--accounts-dir', dest='accounts_data_dir',
|
||||
type=str, default=None,
|
||||
help='Directory where accounts data is to be stored')
|
||||
parser.add_argument('--podcast-formats', dest='podcast_formats',
|
||||
type=str, default=None,
|
||||
help='Preferred podcast formats separated ' +
|
||||
|
@ -821,6 +825,10 @@ def _command_options() -> None:
|
|||
if os.path.isfile('debug'):
|
||||
debug = True
|
||||
|
||||
if argb.accounts_data_dir:
|
||||
base_dir = os.getcwd()
|
||||
set_accounts_data_dir(base_dir, argb.accounts_data_dir)
|
||||
|
||||
if argb.tests:
|
||||
run_all_tests()
|
||||
sys.exit()
|
||||
|
@ -4004,7 +4012,8 @@ def _command_options() -> None:
|
|||
if __name__ == "__main__":
|
||||
argb2, opt2 = _command_options()
|
||||
print('allowdeletion: ' + str(argb2.allowdeletion))
|
||||
run_daemon(argb2.no_of_books,
|
||||
run_daemon(argb2.accounts_data_dir,
|
||||
argb2.no_of_books,
|
||||
argb2.public_replies_unlisted,
|
||||
argb2.max_shares_on_profile,
|
||||
argb2.max_hashtags,
|
||||
|
|
15
tests.py
15
tests.py
|
@ -892,8 +892,10 @@ def create_server_alice(path: str, domain: str, port: int,
|
|||
max_shares_on_profile = 8
|
||||
public_replies_unlisted = False
|
||||
no_of_books = 10
|
||||
accounts_data_dir = None
|
||||
print('Server running: Alice')
|
||||
run_daemon(no_of_books, public_replies_unlisted,
|
||||
run_daemon(accounts_data_dir,
|
||||
no_of_books, public_replies_unlisted,
|
||||
max_shares_on_profile, max_hashtags, map_format,
|
||||
clacks, preferred_podcast_formats,
|
||||
check_actor_timeout,
|
||||
|
@ -1076,8 +1078,10 @@ def create_server_bob(path: str, domain: str, port: int,
|
|||
max_shares_on_profile = 8
|
||||
public_replies_unlisted = False
|
||||
no_of_books = 10
|
||||
accounts_data_dir = None
|
||||
print('Server running: Bob')
|
||||
run_daemon(no_of_books, public_replies_unlisted,
|
||||
run_daemon(accounts_data_dir,
|
||||
no_of_books, public_replies_unlisted,
|
||||
max_shares_on_profile, max_hashtags, map_format,
|
||||
clacks, preferred_podcast_formats,
|
||||
check_actor_timeout,
|
||||
|
@ -1168,8 +1172,9 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [],
|
|||
no_of_books = 10
|
||||
domain_max_posts_per_day = 1000
|
||||
account_max_posts_per_day = 1000
|
||||
accounts_data_dir = None
|
||||
print('Server running: Eve')
|
||||
run_daemon(no_of_books,
|
||||
run_daemon(accounts_data_dir, no_of_books,
|
||||
public_replies_unlisted,
|
||||
max_shares_on_profile,
|
||||
max_hashtags,
|
||||
|
@ -1283,8 +1288,10 @@ def create_server_group(path: str, domain: str, port: int,
|
|||
max_shares_on_profile = 8
|
||||
public_replies_unlisted = False
|
||||
no_of_books = 10
|
||||
accounts_data_dir = None
|
||||
print('Server running: Group')
|
||||
run_daemon(no_of_books, public_replies_unlisted,
|
||||
run_daemon(accounts_data_dir,
|
||||
no_of_books, public_replies_unlisted,
|
||||
max_shares_on_profile, max_hashtags, map_format,
|
||||
clacks, preferred_podcast_formats,
|
||||
check_actor_timeout,
|
||||
|
|
28
utils.py
28
utils.py
|
@ -582,6 +582,34 @@ def data_dir_testing(base_dir: str) -> None:
|
|||
print('Data directory is in testing mode')
|
||||
|
||||
|
||||
def set_accounts_data_dir(base_dir: str, accounts_data_path: str) -> None:
|
||||
"""Sets the directory used to store instance accounts data
|
||||
"""
|
||||
if not accounts_data_path:
|
||||
return
|
||||
|
||||
accounts_data_path_filename = base_dir + '/data_path.txt'
|
||||
if os.path.isfile(accounts_data_path_filename):
|
||||
# read the existing path
|
||||
path = None
|
||||
try:
|
||||
with open(accounts_data_path_filename, 'r',
|
||||
encoding='utf-8') as file:
|
||||
path = file.read()
|
||||
except OSError:
|
||||
print('EX: unable to read ' + accounts_data_path_filename)
|
||||
if path.strip() == accounts_data_path:
|
||||
# path is already set, so avoid writing it again
|
||||
return
|
||||
|
||||
try:
|
||||
with open(accounts_data_path_filename, 'w+',
|
||||
encoding='utf-8') as file:
|
||||
file.write(accounts_data_path)
|
||||
except OSError:
|
||||
print('EX: unable to write ' + accounts_data_path_filename)
|
||||
|
||||
|
||||
def data_dir(base_dir: str) -> str:
|
||||
"""Returns the directory where account data is stored
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue