Exemple #1
0
    def __init__(self, server, config, noautologin):
        super().__init__()

        self.server = server
        self.config = config
        lg = QtWidgets.QGridLayout()
        self.setLayout(lg)
        l0 = QtWidgets.QLabel('User name:')

        l1 = QtWidgets.QLabel('Password:'******'users']
        luser = config['last user']
        if users:
            completer = QtWidgets.QCompleter(users)
            e0.setCompleter(completer)
            if luser is None:
                luser = users[0]
            e0.setText(luser)
            e1.setFocus()

        self.btn = b0 = QtWidgets.QPushButton("Login")
        self.btn.clicked.connect(self.login)
        
        btn_forgot = QtWidgets.QPushButton('Forgot login details?')
        btn_forgot.clicked.connect(self._forgotClicked)
        btn_forgot.setFlat(True)
        btn_forgot.setStyleSheet("""QPushButton {
    text-decoration: underline;
    text-align:right;}""")

        if luser and not noautologin:
            # try to auto login in case password file exists:
            fpwd = PATH.join(luser, 'pwd')
            if fpwd.exists():
                with open(fpwd, 'rb') as f:
                    self.ePwd.setText(base64.b64decode(f.read()).decode())
                QtCore.QTimer.singleShot(0, self.login)
        self.btn.setEnabled(False)

        lg.addWidget(l0, 0, 0)
        lg.addWidget(l1, 1, 0)
        lg.addWidget(e0, 0, 1)
        lg.addWidget(e1, 1, 1)
        lg.addWidget(b0, 2, 0)
        lg.addWidget(btn_forgot, 2, 1, alignment=QtCore.Qt.AlignRight)

        e0.textChanged.connect(self.checkInput)
        e1.textChanged.connect(self.checkInput)

        self.fields = (e0, e1)

        QtCore.QTimer.singleShot(100, self._setFocus)
Exemple #2
0
    def __init__(self):
        super().__init__()
        self.path = PATH.join("config.txt")

        try:
            with open(self.path, 'r') as f:
                try:
                    self.update(json.loads(f.read()))
                except Exception:
                    print('config file broken')
                    raise FileNotFoundError()
        except FileNotFoundError:
            self.update({'users': [], 'last user': None})
Exemple #3
0
    def __init__(self, gui=None):
        super().__init__()
        self.setWindowTitle('Write mail to admin')
        self.resize(400, 250)
        if gui:
            self.setWindowIcon(gui.windowIcon())
        self.gui = gui

        l0 = QtWidgets.QVBoxLayout()
        self.setLayout(l0)

        self.btnSubmit = QtWidgets.QPushButton("Submit")
        self.btnSubmit.setEnabled(False)
        self.btnSubmit.clicked.connect(self._submit)

        self.editor = FwMinimalTextEditor()
        self.editor.text.setPlaceholderText('''Your message.
Please include information on ...
* Module ID
* Measurement number and current

The nature of the problem e.g.: 
* features are always detected wrong
* image correction looks odd
* no image visible
* error occurs 

You can add a screenshot of your problem using the <Snipping tool> (top right)'''
                                            )
        self.editor.text.textChanged.connect(self._checkSubmit)
        self.editor
        l1 = QtWidgets.QHBoxLayout()
        self.subject = QtWidgets.QLineEdit()
        self.subject.setPlaceholderText("Subject")
        self.subject.textChanged.connect(self._checkSubmit)

        l1.addWidget(self.subject)
        l1.addSpacing(1)
        l1.addWidget(self.btnSubmit)

        l0.addLayout(l1)
        l0.addWidget((self.editor))

        self._chLog = QtWidgets.QCheckBox('Include log files')
        self.logsfolder = PATH.join('logs')
        self._chLog.setToolTip('''Check, to also submit error log files. 
This can be helpful, in case your issue refers to a software bug.
You can find the logs file at %s''' % self.logsfolder)
        l0.addWidget(self._chLog)
Exemple #4
0
    def __init__(self, gui=None):
        super().__init__()
        self.setWindowTitle('Write mail to admin')
        self.resize(355, 480)
        if gui:
            self.setWindowIcon(gui.windowIcon())
        self.gui = gui

        l0 = QtWidgets.QVBoxLayout()
        self.setLayout(l0)

        self.btnSubmit = QtWidgets.QPushButton("Submit")
        self.btnSubmit.setEnabled(False)
        self.btnSubmit.clicked.connect(self._submit)

        self.editor = FwMinimalTextEditor()
        self.editor.text.setPlaceholderText('Your message')
        self.editor.text.textChanged.connect(self._checkSubmit)
        l1 = QtWidgets.QHBoxLayout()
        self.subject = QtWidgets.QLineEdit()
        self.subject.setPlaceholderText("Subject")
        self.subject.textChanged.connect(self._checkSubmit)

        l1.addWidget(self.subject)
        l1.addSpacing(1)
        l1.addWidget(self.btnSubmit)

        l0.addLayout(l1)
        l0.addWidget((self.editor))

        self._chLog = QtWidgets.QCheckBox('Include log files')
        self.logsfolder = PATH.join('logs')
        self._chLog.setToolTip('''Check, to also submit error log files. 
This can be helpful, in case your issue refers to a software bug.
You can find the logs file at %s''' % self.logsfolder)
        l0.addWidget(self._chLog)
Exemple #5
0
from fancytools.utils.Logger import Logger

# LOCAL:
from client import ICON, PATH
from client.widgets.About import About
from client.widgets.MainWindow import MainWindow
from client.dialogs import LineEditPassword, LineEditPhoneNumber, LineEditMail, ForgotAccess

#######################
# temporary fix: app crack doesnt through exception
# https://stackoverflow.com/questions/38020020/pyqt5-app-exits-on-error-where-pyqt4-app-would-not
sys.excepthook = lambda t, v, b: sys.__excepthook__(t, v, b)
#######################

MAXLOGS = 7
flogs = PATH.mkdir('logs')
fils = list(flogs.files())
try:
    if len(fils) > MAXLOGS:
        # remove some old logs
        for f in fils[-MAXLOGS::-1]:
            f.remove()
except PermissionError:
    # could not remove old log, because another client is open
    pass
else:
    sys.stderr = Logger(sys.stderr,
                        flogs.join(time.strftime("%Y_%m_d__%H_%M_%S",
                                                 time.localtime()) + '.txt'))