diff --git a/msys-install.sh b/msys-install.sh index 34c6605..116ed24 100755 --- a/msys-install.sh +++ b/msys-install.sh @@ -3,6 +3,10 @@ SELF="$( realpath "$0" )" PROJECT_DIR="$( dirname "$SELF")" +: ${PYTHON_VENV_DIR:=$(cygpath "$USERPROFILE")/python-venv} +venv="${PYTHON_VENV_DIR}/sgbackup" +venv_bin="${venv}/bin" +wvenv_bin="$(cygpath -w "$venv_bin")" PACKAGES="gtk4 gobject-introspection python-pip python-gobject python-rapidfuzz" @@ -14,38 +18,59 @@ done pacman -Sy pacman -S --noconfirm $_install_pkg -cd $PROJECT_DIR -pip install --break-system-packages --verbose --user . - -bindir=$( realpath ~/bin ) -wbindir=$( cygpath -w "$bindir" ) -if [ ! -d "$bindir" ]; then - mkdir -p "$bindir" +if [ ! -f "$venv/bin/activate" ]; then + python -m venv --system-site-packages "$venv" fi -pythonpath="$( python -c 'import sys; print(sys.executable)' )" -pythonwpath="$( pythonw -c 'import sys; print(sys.executable)' )" -cat > "${bindir}/sgbackup" << EOF +. "$venv/bin/activate" + +cd $PROJECT_DIR +pip install --verbose --user . + +bindir=$( realpath "$venv/bin" ) +wbindir=$( cygpath -w "$bindir" ) + +pythonpath="$( python -c 'import sys; print(sys.executable.replace("/","\\"))' )" +pythonwpath="$( pythonw -c 'import sys; print(sys.executable.replace("/","\\"))' )" +cat > "${venv_bin}/sgbackup" << EOF #!/bin/bash +. "$venv_bin/activate" + python -m sgbackup "\$@" EOF -cat > "${bindir}/sgbackup.cmd" << EOF +cat > "${venv_bin}/sgbackup.cmd" << EOF @ECHO OFF -"$pythonpath" -m sgbackup %* +powershell -File "$wvenv_bin\\sgbackup.ps1" %* EOF -unix2dos "${bindir}/sgbackup.cmd" +unix2dos "${venv_bin}/sgbackup.cmd" -cat > "${bindir}/gsgbackup" << EOF +cat > "${venv_bin}/sgbackup.ps1" << EOF +Set-ExecutionPolicy Unrestricted -Scope Process -Force + +$wvenv_bin\\activate.ps1 + +$pythonpath -m sgbackup $args +EOF +unix2dos "$venv_bin/sgbackup.ps1" + +cat > "${venv_bin}/gsgbackup.ps1" << EOF +$wvenv_bin\\activate.ps1 +$pythonpath -m sgbackup.gui $args +EOF +unix2dos "$venv_bin/gsgbackup.ps1" + +cat > "${venv_bin}/gsgbackup" << EOF #!/bin/bash python -m sgbackup.gui "\$@" EOF -cat > "${bindir}/gsgbackup.cmd" << EOF +cat > "${venv_bin}/gsgbackup.cmd" << EOF @ECHO OFF -"$pythonpath" -m sgbackup.gui %* +cd $Env:userprofile +"$wvenv_bin\\gsgbackup.ps1" %* EOF unix2dos "${bindir}/gsgbackup.cmd" @@ -64,8 +89,8 @@ Copy-Item -Path "$wproject_dir\\sgbackup\\icons\\sgbackup.ico" -Destination "\$p foreach (\$dir in \$desktop_dir,\$startmenu_dir) { \$shell=New-Object -ComObject WScript.Shell \$shortcut=\$shell.CreateShortcut("\$dir\\sgbackup.lnk") - \$shortcut.TargetPath='$pythonpath' - \$shortcut.Arguments='-m sgbackup.gui' + \$shortcut.TargetPath='powershell' + \$shortcut.Arguments='-WindowStyle hidden -File "$wvenv_bin\\gsgbackup.ps1"' \$shortcut.IconLocation="\$picture_dir\\sgbackup.ico" \$shortcut.Save() } diff --git a/sgbackup/archiver/_archiver.py b/sgbackup/archiver/_archiver.py index e4a6410..c2d30d3 100644 --- a/sgbackup/archiver/_archiver.py +++ b/sgbackup/archiver/_archiver.py @@ -173,10 +173,11 @@ class ArchiverManager(GObject): game.savegame_name, game.savegame_type.value, game.savegame_subdir) - files=list(sorted(os.listdir(directory),reverse=True)) - if len(files) > settings.backup_versions: - for backup_file in files[settings.backup_versions:]: - self.remove_backup(game,backup_file) + if os.path.isdir(directory): + files=list(sorted(os.listdir(directory),reverse=True)) + if len(files) > settings.backup_versions: + for backup_file in files[settings.backup_versions:]: + self.remove_backup(game,backup_file) @Signal(name="backup-progress",return_type=None,arg_types=(float,),flags=SignalFlags.RUN_FIRST) def do_backup_progress(self,fraction): diff --git a/sgbackup/gui/_gamedialog.py b/sgbackup/gui/_gamedialog.py index 132831e..29d9c35 100644 --- a/sgbackup/gui/_gamedialog.py +++ b/sgbackup/gui/_gamedialog.py @@ -1129,7 +1129,7 @@ class GameDialog(Gtk.Dialog): if self.get_is_valid_savegame_type(SavegameType.STEAM_MACOS): data = get_steam_data(self.__steam.macos) if self.__game.steam.macos: - g = self.__game.steam_macos + g = self.__game.steam.macos g.savegame_root = data['sgroot'] g.savegame_dir = data['sgdir'] g.variables = data['variables'] diff --git a/sgbackup/logger.conf b/sgbackup/logger.conf index 1946320..4f994e5 100644 --- a/sgbackup/logger.conf +++ b/sgbackup/logger.conf @@ -2,25 +2,26 @@ keys=root [handlers] -keys=consoleHandler,fileHandler - +keys=consoleHandler +#keys=consoleHanlder,fileHandler [formatters] keys=consoleFormatter,fileFormatter [logger_root] level=DEBUG -handlers=consoleHandler,fileHandler +handlers=consoleHandler +#handlers=consoleHandler,fileHandler [handler_consoleHandler] class=StreamHandler formatter=consoleFormatter level=INFO -[handler_fileHandler] -class=handlers.RotatingFileHandler -args=('sgbackup.log','a',10485760,10,'UTF-8',False,) -formatter=fileFormatter -level=DEBUG +#[handler_fileHandler] +#class=handlers.RotatingFileHandler +#args=('sgbackup.log','a',10485760,10,'UTF-8',False) +#formatter=fileFormatter +#level=DEBUG [formatter_consoleFormatter] format=[%(levelname)s:%(name)s] %(message)s