Refactored npbackup into package

This commit is contained in:
Orsiris de Jong 2023-01-27 11:30:06 +01:00
parent 8114c3c300
commit 8c0d4b4caf
13 changed files with 65 additions and 43 deletions

17
bin/npbackup Normal file
View file

@ -0,0 +1,17 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is part of npbackup, and is really just a binary shortcut to launch npbackup.main
import os
import sys
sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(__file__), "..")))
from npbackup.npbackup import main
del sys.path[0]
if __name__ == "__main__":
main()

View file

@ -17,8 +17,8 @@ import shutil
from distutils.dir_util import copy_tree
from command_runner import command_runner
import ofunctions.logger_utils
from customization import PROGRAM_NAME, PROGRAM_DIRECTORY
from path_helper import BASEDIR, CURRENT_DIR
from npbackup.customization import PROGRAM_NAME, PROGRAM_DIRECTORY
from npbackup.path_helper import BASEDIR, CURRENT_DIR
_DEBUG = os.environ.get("_DEBUG", False)

View file

@ -0,0 +1,8 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is part of npbackup
__name__ = "npbackup"
__build__ = "2023012701"
__version__ = "2.1.0-dev"

View file

@ -14,9 +14,9 @@ __version__ = "1.3.0"
import sys
import os
from command_runner import command_runner
from npbackup.npbackup import __version__ as npbackup_version
from NPBackupInstaller import __version__ as installer_version
from customization import (
from npbackup import VERSION as npbackup_version
from npbackup.NPBackupInstaller import __version__ as installer_version
from npbackup.customization import (
COMPANY_NAME,
TRADEMARKS,
PRODUCT_NAME,
@ -63,8 +63,9 @@ def get_private_conf_dist_file():
def compile(arch="64"):
is_private = check_private_build()
OUTPUT_DIR = os.path.join(
BASEDIR, "BUILD" + "-PRIVATE" if check_private_build() else ""
BASEDIR, "BUILD" + "-PRIVATE" if is_private else ""
)
if not os.path.isdir(OUTPUT_DIR):
@ -78,7 +79,7 @@ def compile(arch="64"):
PRODUCT_VERSION = _npbackup_version + ".0"
FILE_VERSION = _npbackup_version + ".0"
file_description = "{} P{}-{}".format(FILE_DESCRIPTION, sys.version_info[1], arch)
file_description = "{} P{}-{}{}".format(FILE_DESCRIPTION, sys.version_info[1], arch, 'priv' if is_private else '')
restic_source_file = get_restic_internal_binary(arch)
if not restic_source_file:

View file

@ -14,17 +14,17 @@ import sys
from ruamel.yaml import YAML
from logging import getLogger
from cryptidy import symmetric_encryption as enc
from customization import ID_STRING
from npbackup.customization import ID_STRING
# Try to import a private key, if not available, fallback to the default key
try:
from _private_secret_keys import AES_KEY, ADMIN_PASSWORD
from _private_revac import revac
from npbackup._private_secret_keys import AES_KEY, ADMIN_PASSWORD
from npbackup._private_revac import revac
AES_KEY = revac(AES_KEY)
except ImportError:
try:
from secret_keys import AES_KEY, ADMIN_PASSWORD
from npbackup.secret_keys import AES_KEY, ADMIN_PASSWORD
except ImportError:
print("No secret_keys file. Please read documentation.")
sys.exit(1)

View file

@ -14,7 +14,7 @@ import os
from logging import getLogger
from locale import getdefaultlocale
import i18n
from path_helper import BASEDIR
from npbackup.path_helper import BASEDIR
logger = getLogger(__intname__)

View file

@ -15,15 +15,15 @@ import os
from logging import getLogger
import queue
import datetime
import platform
from functools import wraps
from command_runner import command_runner
from ofunctions.platform import os_arch
from restic_metrics import restic_output_2_metrics, upload_metrics
from restic_wrapper import ResticRunner
import platform
from core.restic_source_binary import get_restic_internal_binary
from path_helper import CURRENT_DIR, BASEDIR
from version import NAME, VERSION
from npbackup.restic_metrics import restic_output_2_metrics, upload_metrics
from npbackup.restic_wrapper import ResticRunner
from npbackup.core.restic_source_binary import get_restic_internal_binary
from npbackup.path_helper import CURRENT_DIR, BASEDIR
from npbackup import __name__ as NAME, __version__ as VERSION
logger = getLogger(__intname__)

View file

@ -12,8 +12,8 @@ __build__ = "2023012601"
from logging import getLogger
import PySimpleGUI as sg
import configuration
from core.i18n_helper import _t
import npbackup.configuration as configuration
from npbackup.core.i18n_helper import _t
logger = getLogger(__intname__)

View file

@ -21,7 +21,7 @@ import PySimpleGUI as sg
from ofunctions.threading import threaded, Future
from threading import Thread
from ofunctions.misc import BytesConverter
from customization import (
from npbackup.customization import (
OEM_STRING,
OEM_LOGO,
loader_animation,
@ -30,9 +30,9 @@ from customization import (
LICENSE_TEXT,
LICENSE_FILE,
)
from gui.config import config_gui
from core.runner import NPBackupRunner
from core.i18n_helper import _t
from npbackup.gui.config import config_gui
from npbackup.core.runner import NPBackupRunner
from npbackup.core.i18n_helper import _t
logger = getLogger(__intname__)

View file

@ -1,9 +0,0 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is part of npbackup, and is really just a shortcut to npbackup.py for linux
from npbackup import *
if __name__ == "__main__":
main()

View file

@ -24,14 +24,19 @@ import pidfile
import ofunctions.logger_utils
from ofunctions.process import kill_childs
import PySimpleGUI as sg
from customization import PYSIMPLEGUI_THEME, OEM_ICON, LICENSE_TEXT, LICENSE_FILE
import configuration
from windows.task import create_scheduled_task
from gui.config import config_gui
from gui.main import main_gui
from core.runner import NPBackupRunner
from core.i18n_helper import _t
from path_helper import CURRENT_DIR, CURRENT_EXECUTABLE
sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(__file__), "..")))
from npbackup.customization import PYSIMPLEGUI_THEME, OEM_ICON, LICENSE_TEXT, LICENSE_FILE
import npbackup.configuration as configuration
from npbackup.windows.task import create_scheduled_task
from npbackup.gui.config import config_gui
from npbackup.gui.main import main_gui
from npbackup.core.runner import NPBackupRunner
from npbackup.core.i18n_helper import _t
from npbackup.path_helper import CURRENT_DIR, CURRENT_EXECUTABLE
del sys.path[0]
# Nuitka compat, see https://stackoverflow.com/a/74540217
try:

View file

@ -4,5 +4,5 @@
# This file is part of npbackup
NAME = "npbackup"
BUILD = "202301261"
BUILD = "2023012601"
VERSION = "2.1.0"

View file

@ -15,7 +15,7 @@ import os
from logging import getLogger
import tempfile
from command_runner import command_runner
from customization import PROGRAM_NAME
from npbackup.customization import PROGRAM_NAME
logger = getLogger(__intname__)