Skip to content

Commit

Permalink
[patch] Changed OS path to be same directory as the executable and se…
Browse files Browse the repository at this point in the history
…t auto generate file structure and config file
  • Loading branch information
Feramance committed Aug 27, 2023
1 parent a165ff6 commit 12cbbf2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions qBitrr/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import argparse
import contextlib
import os
import pathlib
import shutil
import signal
import sys

from qBitrr.bundled_data import license_text, patched_version
from qBitrr.env_config import ENVIRO_CONFIG
from qBitrr.gen_config import MyConfig, generate_doc
from qBitrr.gen_config import MyConfig, _write_config_file, generate_doc
from qBitrr.home_path import APPDATA_FOLDER, HOME_PATH, ON_DOCKER


Expand Down Expand Up @@ -82,24 +84,21 @@ def process_flags() -> argparse.Namespace | bool:
elif (not CONFIG_FILE.exists()) and (not CONFIG_PATH.exists()):
if ON_DOCKER:
print(f"{file} has not been found")
from qBitrr.gen_config import _write_config_file

CONFIG_FILE = _write_config_file(docker=True)
print(f"'{CONFIG_FILE.name}' has been generated")
print('Rename it to "config.toml" then edit it and restart the container')
import os
import signal

os.kill(os.getppid(), signal.SIGTERM)

else:
print(f"{file} has not been found")
print(f"{file} must be added to {CONFIG_FILE}")
print(
"You can run me with the `--gen-config` flag to generate a "
"template config file which you can then edit."
)
sys.exit(1)

CONFIG_FILE = _write_config_file(docker=True)
print(f"'{CONFIG_FILE.name}' has been generated")
print('Rename it to "config.toml" then edit it and restart the container')

os.kill(os.getppid(), signal.SIGTERM)

elif CONFIG_FILE.exists():
CONFIG = MyConfig(CONFIG_FILE)
Expand Down
2 changes: 1 addition & 1 deletion qBitrr/home_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
HOME_PATH.mkdir(parents=True, exist_ok=True)
else:
ON_DOCKER = False
HOME_PATH = pathlib.Path().home().joinpath(".qBitrr")
HOME_PATH = pathlib.Path().absolute().joinpath(".config")
HOME_PATH.mkdir(parents=True, exist_ok=True)
else:
HOME_PATH = p
Expand Down

0 comments on commit 12cbbf2

Please sign in to comment.