2021-05-06 17:40:07 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""
|
|
|
|
project: Backuppy
|
2021-05-07 10:08:33 +00:00
|
|
|
version: 0.8
|
2021-05-06 17:40:07 +00:00
|
|
|
file: install_gui.py
|
2021-05-07 10:08:33 +00:00
|
|
|
summary: python installer-script in GUI-mode (needs PySide2)
|
2021-05-06 17:40:07 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
# Standard library imports
|
|
|
|
import os
|
|
|
|
|
|
|
|
# Third party imports
|
|
|
|
from PySide2 import QtWidgets
|
|
|
|
|
|
|
|
# local imports
|
|
|
|
from install import *
|
|
|
|
|
|
|
|
class BackuppyWizard(QtWidgets.QWizard):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super().__init__(parent)
|
|
|
|
|
2021-05-07 10:08:33 +00:00
|
|
|
self.setWindowTitle(get_lang_text("intromsg1"))
|
|
|
|
|
2021-05-06 17:40:07 +00:00
|
|
|
self.addPage(Page01(self))
|
|
|
|
self.addPage(Page02(self))
|
|
|
|
self.addPage(Page03(self))
|
|
|
|
self.addPage(Page04(self))
|
|
|
|
self.addPage(Page05(self))
|
|
|
|
self.addPage(Page06(self))
|
|
|
|
self.addPage(Page07(self))
|
|
|
|
self.addPage(Page08(self))
|
|
|
|
self.addPage(Page09(self))
|
|
|
|
self.addPage(Page10(self))
|
2021-05-07 10:08:33 +00:00
|
|
|
|
2021-05-06 17:40:07 +00:00
|
|
|
self.resize(640, 480)
|
|
|
|
|
2021-05-07 10:08:33 +00:00
|
|
|
|
2021-05-06 17:40:07 +00:00
|
|
|
class Page01(QtWidgets.QWizardPage):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super().__init__(parent)
|
|
|
|
self.label = QtWidgets.QLabel("Hello, first of all, which language do you prefer: English or German?")
|
2021-05-07 10:08:33 +00:00
|
|
|
|
2021-05-06 17:40:07 +00:00
|
|
|
self.comboBox = QtWidgets.QComboBox(self)
|
|
|
|
self.comboBox.addItem(LANG_EN, LANG_EN)
|
|
|
|
self.comboBox.addItem(LANG_DE, LANG_DE)
|
|
|
|
|
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
|
|
layout.addWidget(self.label)
|
|
|
|
layout.addWidget(self.comboBox)
|
|
|
|
self.setLayout(layout)
|
|
|
|
|
|
|
|
def validatePage(self):
|
|
|
|
if self.comboBox.currentText() == LANG_DE:
|
|
|
|
set_language(LANG_DE)
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
class Page02(QtWidgets.QWizardPage):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super().__init__(parent)
|
|
|
|
self.label1 = QtWidgets.QLabel()
|
|
|
|
self.label2 = QtWidgets.QLabel()
|
|
|
|
|
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
|
|
layout.addWidget(self.label1)
|
|
|
|
layout.addWidget(self.label2)
|
|
|
|
self.setLayout(layout)
|
|
|
|
|
|
|
|
def initializePage(self):
|
2021-05-07 10:08:33 +00:00
|
|
|
self.setWindowTitle(get_lang_text("intromsg1"))
|
|
|
|
|
2021-05-06 17:40:07 +00:00
|
|
|
self.label1.setText(get_lang_text("languagepack"))
|
|
|
|
self.label2.setText(get_lang_text("intromsg2"))
|
|
|
|
|
|
|
|
|
|
|
|
class Page03(QtWidgets.QWizardPage):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super().__init__(parent)
|
|
|
|
self.label = QtWidgets.QLabel()
|
|
|
|
self.groupbox = QtWidgets.QGroupBox()
|
|
|
|
self.groupbox.setFlat(True)
|
|
|
|
self.radio1 = QtWidgets.QRadioButton()
|
|
|
|
self.radio2 = QtWidgets.QRadioButton()
|
|
|
|
|
|
|
|
vbox = QtWidgets.QVBoxLayout()
|
|
|
|
vbox.addWidget(self.radio1)
|
|
|
|
vbox.addWidget(self.radio2)
|
|
|
|
vbox.addStretch(1)
|
|
|
|
self.groupbox.setLayout(vbox)
|
|
|
|
|
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
|
|
layout.addWidget(self.label)
|
|
|
|
layout.addWidget(self.groupbox)
|
|
|
|
self.setLayout(layout)
|
|
|
|
|
|
|
|
def initializePage(self):
|
|
|
|
self.label.setText(get_lang_text("excludefile1"))
|
|
|
|
self.radio1.setText(get_lang_text("Yes"))
|
|
|
|
self.radio2.setText(get_lang_text("No"))
|
|
|
|
self.radio1.setChecked(True)
|
|
|
|
|
|
|
|
def validatePage(self):
|
|
|
|
if self.radio1.isChecked():
|
2021-05-07 10:08:33 +00:00
|
|
|
set_exclude(True)
|
2021-05-06 17:40:07 +00:00
|
|
|
else:
|
2021-05-07 10:08:33 +00:00
|
|
|
set_exclude(False)
|
2021-05-06 17:40:07 +00:00
|
|
|
return True
|
|
|
|
|
2021-05-07 10:08:33 +00:00
|
|
|
|
2021-05-06 17:40:07 +00:00
|
|
|
class Page04(QtWidgets.QWizardPage):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super().__init__(parent)
|
|
|
|
self.label = QtWidgets.QLabel()
|
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
|
|
layout.addWidget(self.label)
|
|
|
|
self.setLayout(layout)
|
|
|
|
|
|
|
|
def initializePage(self):
|
|
|
|
global EXCLUDE
|
|
|
|
if EXCLUDE:
|
|
|
|
self.label.setText(get_lang_text("excludefile2"))
|
|
|
|
else:
|
|
|
|
self.label.setText(get_lang_text("excludefile3"))
|
|
|
|
|
|
|
|
class Page05(QtWidgets.QWizardPage):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super().__init__(parent)
|
|
|
|
self.label1 = QtWidgets.QLabel()
|
|
|
|
self.label2 = QtWidgets.QLabel()
|
2021-05-07 10:08:33 +00:00
|
|
|
self.efSourceDir = QtWidgets.QLineEdit()
|
|
|
|
self.pbBrowse = QtWidgets.QPushButton("Browse")
|
|
|
|
self.pbBrowse.clicked.connect(self.on_pbBrowse_clicked)
|
2021-05-06 17:40:07 +00:00
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
|
|
layout.addWidget(self.label1)
|
|
|
|
layout.addWidget(self.label2)
|
2021-05-07 10:08:33 +00:00
|
|
|
|
|
|
|
hLayout = QtWidgets.QHBoxLayout()
|
|
|
|
hLayout.addWidget(self.efSourceDir)
|
|
|
|
hLayout.addWidget(self.pbBrowse)
|
|
|
|
|
|
|
|
layout.addLayout(hLayout)
|
|
|
|
|
2021-05-06 17:40:07 +00:00
|
|
|
self.setLayout(layout)
|
|
|
|
|
|
|
|
def initializePage(self):
|
|
|
|
self.label1.setText(get_lang_text("srcdir1"))
|
|
|
|
self.label2.setText(get_lang_text("srcdir2"))
|
|
|
|
|
2021-05-07 10:08:33 +00:00
|
|
|
def on_pbBrowse_clicked(self):
|
|
|
|
options = QtWidgets.QFileDialog.Options() | QtWidgets.QFileDialog.ShowDirsOnly
|
|
|
|
dirName = QtWidgets.QFileDialog.getExistingDirectory(self, "Select Directory", None, options)
|
|
|
|
self.efSourceDir.setText(dirName)
|
|
|
|
|
2021-05-06 17:40:07 +00:00
|
|
|
def validatePage(self):
|
|
|
|
global SOURCEDIR
|
2021-05-07 10:08:33 +00:00
|
|
|
SOURCEDIR = self.efSourceDir.text()
|
2021-05-06 17:40:07 +00:00
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
class Page06(QtWidgets.QWizardPage):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super().__init__(parent)
|
|
|
|
self.label1 = QtWidgets.QLabel()
|
|
|
|
self.label2 = QtWidgets.QLabel()
|
|
|
|
self.label3 = QtWidgets.QLabel()
|
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
|
|
layout.addWidget(self.label1)
|
|
|
|
layout.addWidget(self.label2)
|
|
|
|
layout.addWidget(self.label3)
|
|
|
|
self.setLayout(layout)
|
|
|
|
|
|
|
|
def initializePage(self):
|
|
|
|
self.label1.setText(get_lang_text("srcdir3_1"))
|
|
|
|
bold_text = f"<p><strong>{SOURCEDIR}</strong></p>"
|
|
|
|
self.label2.setText(bold_text)
|
|
|
|
self.label3.setText(get_lang_text("srcdir3_2"))
|
|
|
|
|
|
|
|
|
|
|
|
class Page07(QtWidgets.QWizardPage):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super().__init__(parent)
|
|
|
|
self.label1 = QtWidgets.QLabel()
|
2021-05-07 10:08:33 +00:00
|
|
|
self.efTargetDir = QtWidgets.QLineEdit()
|
|
|
|
self.pbBrowse = QtWidgets.QPushButton("Browse")
|
|
|
|
self.pbBrowse.clicked.connect(self.on_pbBrowse_clicked)
|
2021-05-06 17:40:07 +00:00
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
|
|
layout.addWidget(self.label1)
|
2021-05-07 10:08:33 +00:00
|
|
|
|
|
|
|
hLayout = QtWidgets.QHBoxLayout()
|
|
|
|
hLayout.addWidget(self.efTargetDir)
|
|
|
|
hLayout.addWidget(self.pbBrowse)
|
|
|
|
|
|
|
|
layout.addLayout(hLayout)
|
|
|
|
|
2021-05-06 17:40:07 +00:00
|
|
|
self.setLayout(layout)
|
|
|
|
|
|
|
|
def initializePage(self):
|
|
|
|
self.label1.setText(get_lang_text("targetdir1"))
|
|
|
|
|
2021-05-07 10:08:33 +00:00
|
|
|
def on_pbBrowse_clicked(self):
|
|
|
|
options = QtWidgets.QFileDialog.Options() | QtWidgets.QFileDialog.ShowDirsOnly
|
|
|
|
dirName = QtWidgets.QFileDialog.getExistingDirectory(self, "Select Directory", None, options)
|
|
|
|
self.efTargetDir.setText(dirName)
|
|
|
|
|
2021-05-06 17:40:07 +00:00
|
|
|
def validatePage(self):
|
|
|
|
global TARGETDIR
|
2021-05-07 10:08:33 +00:00
|
|
|
TARGETDIR = self.efTargetDir.text()
|
2021-05-06 17:40:07 +00:00
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
class Page08(QtWidgets.QWizardPage):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super().__init__(parent)
|
|
|
|
self.label1 = QtWidgets.QLabel()
|
|
|
|
self.label2 = QtWidgets.QLabel()
|
|
|
|
self.label3 = QtWidgets.QLabel()
|
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
|
|
layout.addWidget(self.label1)
|
|
|
|
layout.addWidget(self.label2)
|
|
|
|
layout.addWidget(self.label3)
|
|
|
|
self.setLayout(layout)
|
|
|
|
|
|
|
|
def initializePage(self):
|
|
|
|
self.label1.setText(get_lang_text("targetdir2_1"))
|
|
|
|
bold_text = f"<p><strong>{TARGETDIR}</strong></p>"
|
|
|
|
self.label2.setText(bold_text)
|
|
|
|
self.label3.setText(get_lang_text("targetdir2_2"))
|
|
|
|
|
|
|
|
def validatePage(self):
|
|
|
|
global RSYNC_CMD, MYDIR, SOURCEDIR, TARGETDIR
|
|
|
|
exclude_file = os.path.join(MYDIR, EXCLUDE_FILE)
|
|
|
|
|
|
|
|
RSYNC_CMD = f"rsync -aqp --exclude-from={exclude_file} {SOURCEDIR} {TARGETDIR}"
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
class Page09(QtWidgets.QWizardPage):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super().__init__(parent)
|
|
|
|
self.label1 = QtWidgets.QLabel()
|
|
|
|
self.label2 = QtWidgets.QLabel()
|
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
|
|
layout.addWidget(self.label1)
|
|
|
|
layout.addWidget(self.label2)
|
|
|
|
self.setLayout(layout)
|
|
|
|
|
|
|
|
def initializePage(self):
|
|
|
|
self.label1.setText(get_lang_text("collect"))
|
|
|
|
global RSYNC_CMD
|
|
|
|
#self.label2.setText(f"{RSYNC_CMD}")
|
|
|
|
bold_text = f"<p><strong>{RSYNC_CMD}</strong></p>"
|
|
|
|
self.label2.setText(bold_text)
|
|
|
|
|
|
|
|
|
|
|
|
class Page10(QtWidgets.QWizardPage):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super().__init__(parent)
|
|
|
|
self.label1 = QtWidgets.QLabel()
|
|
|
|
self.label2 = QtWidgets.QLabel()
|
|
|
|
self.label3 = QtWidgets.QLabel()
|
|
|
|
layout = QtWidgets.QVBoxLayout()
|
|
|
|
layout.addWidget(self.label1)
|
|
|
|
layout.addWidget(self.label2)
|
|
|
|
layout.addWidget(self.label3)
|
|
|
|
self.setLayout(layout)
|
2021-05-07 10:08:33 +00:00
|
|
|
|
2021-05-06 17:40:07 +00:00
|
|
|
self.setFinalPage(True)
|
|
|
|
|
|
|
|
def initializePage(self):
|
|
|
|
self.label1.setText(get_lang_text("outro1"))
|
|
|
|
self.label2.setText(get_lang_text("outro2"))
|
|
|
|
urlLink = f"<a href='mailto: {EMAIL}'>{EMAIL}</a>"
|
|
|
|
self.label3.setText(urlLink)
|
|
|
|
self.label3.setOpenExternalLinks(True)
|
|
|
|
|
2021-05-07 10:08:33 +00:00
|
|
|
def validatePage(self):
|
|
|
|
return True, EXCLUDE, RSYNC_CMD
|
|
|
|
|
2021-05-06 17:40:07 +00:00
|
|
|
|
2021-05-07 10:08:33 +00:00
|
|
|
def main_install_gui():
|
2021-05-06 17:40:07 +00:00
|
|
|
app = QtWidgets.QApplication()
|
|
|
|
wizard = BackuppyWizard()
|
|
|
|
wizard.show()
|
|
|
|
|
|
|
|
app.exec_()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2021-05-07 10:08:33 +00:00
|
|
|
main_install_gui()
|