mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-06 21:14:38 +08:00
Change build_type detection
This commit is contained in:
parent
ffe7563583
commit
35baba9e6d
6 changed files with 23 additions and 18 deletions
|
@ -8,12 +8,12 @@ import sys
|
|||
|
||||
sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
import npbackup.__env__
|
||||
npbackup.__env__.BUILD_TYPE = "cli"
|
||||
from npbackup.__main__ import main
|
||||
|
||||
del sys.path[0]
|
||||
|
||||
if __name__ == "__main__":
|
||||
while "--run-as-cli" in sys.argv:
|
||||
# Drop --run-as-cli argument since cli doesn't know about it
|
||||
sys.argv.pop(sys.argv.index("--run-as-cli"))
|
||||
sys.argv.pop(sys.argv.index("--run-as-cli"))
|
||||
main()
|
||||
|
|
|
@ -8,13 +8,15 @@ import sys
|
|||
|
||||
sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
import npbackup.__env__
|
||||
npbackup.__env__.BUILD_TYPE = "gui"
|
||||
from npbackup.gui.__main__ import main_gui
|
||||
from npbackup.__main__ import main
|
||||
|
||||
del sys.path[0]
|
||||
|
||||
if __name__ == "__main__":
|
||||
while "--run-as-cli" in sys.argv:
|
||||
if "--run-as-cli" in sys.argv:
|
||||
# Drop --run-as-cli argument since cli doesn't know about it
|
||||
sys.argv.pop(sys.argv.index("--run-as-cli"))
|
||||
main()
|
||||
|
|
|
@ -8,6 +8,8 @@ import sys
|
|||
|
||||
sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
import npbackup.__env__
|
||||
npbackup.__env__.BUILD_TYPE = "viewer"
|
||||
from npbackup.gui.__main__ import main_gui
|
||||
|
||||
del sys.path[0]
|
||||
|
|
|
@ -33,3 +33,8 @@ FAST_COMMANDS_TIMEOUT = 180
|
|||
|
||||
# # Wait x seconds before we actually do the upgrade so current program could quit before being erased
|
||||
UPGRADE_DEFER_TIME = 60
|
||||
|
||||
|
||||
def set_build_type(build_type: str) -> None:
|
||||
global BUILD_TYPE
|
||||
BUILD_TYPE = build_type
|
||||
|
|
|
@ -17,6 +17,7 @@ import os
|
|||
import sys
|
||||
import psutil
|
||||
from ofunctions.platform import python_arch, get_os
|
||||
import npbackup.__env__
|
||||
from npbackup.configuration import IS_PRIV_BUILD
|
||||
from npbackup.core.nuitka_helper import IS_COMPILED
|
||||
|
||||
|
@ -25,16 +26,6 @@ from npbackup.core.nuitka_helper import IS_COMPILED
|
|||
# Since developpment currently follows Python 3.12, let's consider anything below 3.12 as legacy
|
||||
IS_LEGACY = True if sys.version_info[1] < 12 else False
|
||||
|
||||
executable = sys.argv[0]
|
||||
if executable.startswith("npbackup-gui"):
|
||||
build_type = "gui"
|
||||
elif executable.startswith("npbackup-cli"):
|
||||
build_type = "cli"
|
||||
elif executable.startswith("npbackup-viewer"):
|
||||
build_type = "viewer"
|
||||
else:
|
||||
build_type = "UnknownBuildType"
|
||||
|
||||
try:
|
||||
CURRENT_USER = psutil.Process().username()
|
||||
except Exception:
|
||||
|
@ -42,7 +33,7 @@ except Exception:
|
|||
version_dict = {
|
||||
"name": __intname__,
|
||||
"version": __version__,
|
||||
"build_type": build_type,
|
||||
"build_type": npbackup.__env__.BUILD_TYPE,
|
||||
"audience": "private" if IS_PRIV_BUILD else "public",
|
||||
"os": get_os().lower(),
|
||||
"arch": python_arch() + ("-legacy" if IS_LEGACY else ""),
|
||||
|
|
|
@ -23,8 +23,12 @@ from functools import wraps
|
|||
from command_runner import command_runner
|
||||
from ofunctions.misc import BytesConverter, fn_name
|
||||
from npbackup.__debug__ import _DEBUG
|
||||
from npbackup.__version__ import build_type
|
||||
from npbackup.__env__ import FAST_COMMANDS_TIMEOUT, CHECK_INTERVAL, HEARTBEAT_INTERVAL
|
||||
from npbackup.__env__ import (
|
||||
FAST_COMMANDS_TIMEOUT,
|
||||
CHECK_INTERVAL,
|
||||
HEARTBEAT_INTERVAL,
|
||||
BUILD_TYPE,
|
||||
)
|
||||
from npbackup.path_helper import CURRENT_DIR
|
||||
from npbackup.restic_wrapper import schema
|
||||
|
||||
|
@ -857,7 +861,8 @@ class ResticRunner:
|
|||
cmd = "ls {}".format(snapshot)
|
||||
result, output = self.executor(cmd, method="monitor")
|
||||
if result:
|
||||
if build_type in ["gui", "viewer"]:
|
||||
# Don't show content when running in gui mode
|
||||
if BUILD_TYPE in ["gui", "viewer"]:
|
||||
msg = (
|
||||
f"Successfully listed snapshot {snapshot} content (not showed here)"
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue