Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ src/vorta/i18n/ts/vorta.en.ts
src/vorta/i18n/ts/vorta.en_US.ts
flatpak/app/
flatpak/.flatpak-builder/
package/borg.exe
Binary file added package/icon.ico
Binary file not shown.
101 changes: 59 additions & 42 deletions package/vorta.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ APP_APPCAST_URL = 'https://borgbase.github.io/vorta/appcast.xml'
# it is assumed that the cwd is the git repo dir:
SRC_DIR = os.path.join(os.getcwd(), 'src', 'vorta')

datas = [(os.path.join(SRC_DIR, 'assets/UI/*'), 'assets/UI'),
(os.path.join(SRC_DIR, 'assets/icons/*'), 'assets/icons'),
(os.path.join(SRC_DIR, 'i18n/qm/*'), 'vorta/i18n/qm'),]

if sys.platform == "win32":
datas += [(os.path.join(os.getcwd(), 'package/borg.exe'), 'borg-dir')]

a = Analysis([os.path.join(SRC_DIR, '__main__.py')],
pathex=[SRC_DIR],
binaries=[],
datas=[
(os.path.join(SRC_DIR, 'assets/UI/*'), 'assets/UI'),
(os.path.join(SRC_DIR, 'assets/icons/*'), 'assets/icons'),
(os.path.join(SRC_DIR, 'i18n/qm/*'), 'vorta/i18n/qm'),
],
datas=datas,
hiddenimports=[
'vorta.keyring.darwin',
'vorta.keyring.kwallet',
Expand All @@ -41,43 +44,57 @@ a = Analysis([os.path.join(SRC_DIR, '__main__.py')],

pyz = PYZ(a.pure, a.zipped_data, cipher=BLOCK_CIPHER)

exe = EXE(pyz,
if sys.platform == "darwin":
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name=f"vorta-{sys.platform}",
bootloader_ignore_signals=True,
console=False,
debug=False,
strip=False,
upx=True)

coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
debug=False,
strip=False,
upx=False,
name='vorta')

app = BUNDLE(coll,
name='Vorta.app',
icon='icon.icns',
bundle_identifier=None,
info_plist={
'CFBundleName': APP_NAME,
'CFBundleDisplayName': APP_NAME,
'CFBundleIdentifier': APP_ID_DARWIN,
'NSHighResolutionCapable': 'True',
'LSAppNapIsDisabled': 'True',
'NSRequiresAquaSystemAppearance': 'False',
'LSUIElement': '1',
'LSMinimumSystemVersion': '10.14',
'CFBundleShortVersionString': APP_VERSION,
'CFBundleVersion': APP_VERSION,
'SUFeedURL': APP_APPCAST_URL,
'LSEnvironment': {
'LC_CTYPE': 'en_US.UTF-8',
'PATH': '/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin'
}
})
elif sys.platform == "win32":
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name=f"vorta-{sys.platform}",
bootloader_ignore_signals=True,
console=False,
a.binaries,
a.zipfiles,
a.datas,
name='vorta.exe',
debug=False,
strip=False,
upx=True)

coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
debug=False,
strip=False,
upx=False,
name='vorta')

app = BUNDLE(coll,
name='Vorta.app',
icon='icon.icns',
bundle_identifier=None,
info_plist={
'CFBundleName': APP_NAME,
'CFBundleDisplayName': APP_NAME,
'CFBundleIdentifier': APP_ID_DARWIN,
'NSHighResolutionCapable': 'True',
'LSAppNapIsDisabled': 'True',
'NSRequiresAquaSystemAppearance': 'False',
'LSUIElement': '1',
'LSMinimumSystemVersion': '10.14',
'CFBundleShortVersionString': APP_VERSION,
'CFBundleVersion': APP_VERSION,
'SUFeedURL': APP_APPCAST_URL,
'LSEnvironment': {
'LC_CTYPE': 'en_US.UTF-8',
'PATH': '/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin'
}
})
console=False,
upx=True,
icon="icon.ico"
)
17 changes: 13 additions & 4 deletions src/vorta/borg/borg_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import time
from collections import namedtuple
from datetime import datetime as dt
from subprocess import PIPE, Popen, TimeoutExpired
from subprocess import PIPE, Popen, TimeoutExpired, CREATE_NO_WINDOW
from threading import Lock
from PyQt5 import QtCore
from PyQt5.QtWidgets import QApplication
Expand Down Expand Up @@ -214,6 +214,12 @@ def prepare_bin(cls):
bundled_borg = os.path.join(mainBundle.bundlePath(), 'Contents', 'Resources', 'borg-dir', 'borg.exe')
if os.path.isfile(bundled_borg):
return bundled_borg
elif sys.platform == 'win32':
# Windows: Look in pyinstaller temporary directory
if hasattr(sys, '_MEIPASS'):
bundled_borg = os.path.join(sys._MEIPASS, 'borg-dir', 'borg.exe')
if os.path.isfile(bundled_borg):
return bundled_borg
return None

def run(self):
Expand All @@ -236,14 +242,16 @@ def run(self):
env=self.env,
cwd=self.cwd,
start_new_session=True,
creationflags=CREATE_NO_WINDOW,
)
error_messages = [] # List of error messages included in the result

self.process = p

# Prevent blocking of stdout/err. Via https://stackoverflow.com/a/7730201/3983708
os.set_blocking(p.stdout.fileno(), False)
os.set_blocking(p.stderr.fileno(), False)
if sys.platform != "win32":
os.set_blocking(p.stdout.fileno(), False)
os.set_blocking(p.stderr.fileno(), False)

def read_async(fd):
try:
Expand All @@ -254,7 +262,8 @@ def read_async(fd):
stdout = []
while True:
# Wait for new output
select.select([p.stdout, p.stderr], [], [], 0.1)
if sys.platform != "win32":
select.select([p.stdout, p.stderr], [], [], 0.1)

stdout.append(read_async(p.stdout))
stderr = read_async(p.stderr)
Expand Down
2 changes: 1 addition & 1 deletion src/vorta/borg/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def prepare(cls, profile, archive_name, model: ExtractTree, destination_folder):
# dialog.
# Unselected (and excluded) parent folders will be restored by borg
# but without the metadata stored in the archive.
pattern_file = tempfile.NamedTemporaryFile('w', delete=True)
pattern_file = tempfile.NamedTemporaryFile('w', delete=False)
pattern_file.write("P fm\n")

indexes = [QModelIndex()]
Expand Down