Exemple #1
0
    def __init__(self, parent=True):
        super(TaskManager, self).__init__(parent)

        self.parent = parent
        self.setWindowTitle('Task Manager')
        self.layout = VBoxLayout()
        line1 = HBoxLayout()
        line2 = HBoxLayout()

        self.infoGrp = GroupBox('Task Info')
        self.taskInfo = TaskInfo(self)
        self.infoGrp.setLayout(self.taskInfo)
        line1.addWidget(self.infoGrp)

        self.detailsGrp = GroupBox('Details')
        self.taskDetails = TaskDetails(self)
        self.detailsGrp.setLayout(self.taskDetails)
        line1.addWidget(self.detailsGrp)

        self.layout.addLayout(line1)
        self.layout.addLayout(line2)

        self.okButton = Button({'txt': 'Ok', 'cl': self.executeTask})
        self.cancelButton = Button({'txt': 'Cancel', 'cl': self.hideEvent})
        line2.addWidget(self.okButton)
        line2.addWidget(self.cancelButton)

        self.setLayout(self.layout)
        self.setMinimumWidth(750)
Exemple #2
0
class Browser(Widget):

    key = 'Browser'

    def __init__(self, url='vnexpress.net', parent=None):
        super(Browser, self).__init__(parent)

        self.url = url

        self.layout = VBoxLayout()
        self.buildUI()
        self.setLayout(self.layout)

    def buildUI(self):
        self.viewer = WebBrowser(self.url)
        self.viewer.setProg.connect(self.adjustTitle)
        self.layout.addWidget(self.viewer)

        self.statusBar = QStatusBar(self)
        self.layout.addWidget(self.statusBar)

    def setUrl(self, url):
        return self.viewer.view.load(QUrl(url))

    def adjustTitle(self, param):
        if 0 < param < 100:
            self.setWindowTitle("Browser ({0}%)".format(param))
        else:
            self.setWindowTitle("Browser")
Exemple #3
0
    def __init__(self, parent=None):
        super(ServerConfig, self).__init__(parent)

        serverLabel             = Label({'txt':"Server:"})
        serverCombo             = ComboBox({'items': ['Local: {}'.format(__localServer__), 'Global: {}'.format(__globalServer__)]})
        serverLayout            = HBoxLayout({'addWidget': [serverLabel, serverCombo]})
        serverConfigLayout      = VBoxLayout({'addLayout': [serverLayout]})
        serverConfigGroup       = GroupBox("Server configuration", [serverConfigLayout], 'setLayout')

        projectLabel            = Label({'txt': "Set Project:"})
        projectPath             = LineEdit()
        projectBtn              = Button({'txt': 'Set Path'})
        projectLayout           = HBoxLayout({'addWidget': [projectLabel, projectPath, projectBtn]})
        projectConfigLayout     = VBoxLayout({'addLayout': [projectLayout]})
        projectConfigGroup      = GroupBox("Project configuration", [projectConfigLayout], 'setLayout')

        teamtLabel              = Label({'txt': "Set Team:"})
        teamPath                = LineEdit()
        teamBtn                 = Button({'txt': 'Set Team'})
        teamLayout              = HBoxLayout({'addWidget': [teamtLabel, teamPath, teamBtn]})
        teamConfigLayout        = VBoxLayout({'addLayout': [teamLayout]})
        TeamConfigGroup         = GroupBox("Project configuration", [teamConfigLayout], 'setLayout')

        mainLayout              = VBoxLayout({'addWidget': [serverConfigGroup, projectConfigGroup, TeamConfigGroup], 'addStretch': 1})

        self.setLayout(mainLayout)
Exemple #4
0
class ShortcutCommand(Widget):

    key = 'ShortcutCommand'

    def __init__(self, parent=None):
        super(ShortcutCommand, self).__init__(parent)

        self.parent = parent
        self.setWindowTitle('Shortcut Command')

        self.layout = VBoxLayout()
        self.commandLine = PlainTextEdit()
        self.layout.addWidget(self.commandLine)
        self.setLayout(self.layout)
        self.commandLine.setFixedSize(250, 25)

    def eventFilter(self, source, event):
        if source == self.commandLine:
            if event.key() == Qt.Key_Return:
                self.run()
                return True

    def run(self):
        print('run')
        pass


# -------------------------------------------------------------------------------------------------------------
# Created by panda on 11/11/2019 - 5:30 PM
# © 2017 - 2018 DAMGteam. All rights reserved
Exemple #5
0
class Preferences(Widget):

    key = 'Preferences'

    _msg_user_not_set = "Not configured yet, will be set with the first message received"

    def __init__(self, parent=None):
        super(Preferences, self).__init__(parent)

        # self.resize(200, 100)
        self.setWindowIcon(AppIcon(32, self.key))
        self.setWindowTitle(self.key)
        # self.layout = GeneralSetting(self)
        self.layout = VBoxLayout()
        self.headerGrid = HeaderCheckBoxes(self)
        self.header = GroupBox('Header', parent=self)
        self.header.setLayout(self.headerGrid)

        self.bodyGrid = BodyCheckBoxes(self)
        self.body = GroupBox('Body', parent=self)
        self.body.setLayout(self.bodyGrid)

        self.layout.addWidget(self.header)
        self.layout.addWidget(self.body)

        self.setLayout(self.layout)
Exemple #6
0
    def __init__(self, url='vnexpress.net', parent=None):
        super(Browser, self).__init__(parent)

        self.url = url

        self.layout = VBoxLayout()
        self.buildUI()
        self.setLayout(self.layout)
Exemple #7
0
    def __init__(self, parent=None):
        super(ShortcutCommand, self).__init__(parent)

        self.parent = parent
        self.setWindowTitle('Shortcut Command')

        self.layout = VBoxLayout()
        self.commandLine = PlainTextEdit()
        self.layout.addWidget(self.commandLine)
        self.setLayout(self.layout)
        self.commandLine.setFixedSize(250, 25)
Exemple #8
0
    def __init__(self, buttonManager, parent=None):
        super(TopTap3, self).__init__(parent)

        self.buttonManager = buttonManager
        self.parent = parent

        self.layout = VBoxLayout()

        self.buildUI()
        # QApplication.setCursorFlashTime(1000)
        self.setLayout(self.layout)
        self.setStyleSheet(mystylesheet(self))
Exemple #9
0
    def __init__(self, task):
        super(TaskInfo, self).__init__()

        with open(task, 'r') as f:
            self._data = json.load(f)

        self.setTitle(self._data['id'])
        self.layout = VBoxLayout()

        self._id = self._data['id']
        self.key = self._id
        self._name = self._data['name']
        self._mode = self._data['mode']
        self._type = self._data['type']

        self._project = self._data['project']
        self._organisation = self._data['organisation']
        self._details = self._data['details']

        self._hour = int(self._data['endtime'].split(':')[0])
        self._minute = int(self._data['endtime'].split(':')[1])
        self._second = int(self._data['endtime'].split(':')[2])

        self._day = int(self._data['enddate'].split('/')[0])
        self._month = int(self._data['enddate'].split('/')[1])
        self._year = int(self._data['enddate'].split('/')[2])

        self.duetime = duetime(self._hour, self._minute, self._second)
        self.duedate = duedate(self._day, self._month, self._year)

        self.task = Task(self._id, self._name, self._mode, self._type, self._project, self._organisation,
                         self.duetime, self.duedate, self._details)

        self._countdown = '{0}:{1}:{2}'.format(self.task.hours, self.task.minutes, self.task.seconds)
        self.task.countdown.connect(self.update_countdown)

        self.task_status = Label({'txt': '{0}'.format(self.task.status)})
        self.task_duedate = Label({'txt': '{0}'.format(self.task._enddate)})
        self.task_duetime = Label({'txt': '{0}'.format(self.task._endtime)})
        self.task_countdown = Label({'txt': '{0}'.format(self._countdown)})

        self.layout.addWidget(self.task_status)
        self.layout.addWidget(self.task_duedate)
        self.layout.addWidget(self.task_duetime)
        self.layout.addWidget(self.task_countdown)

        self.setLayout(self.layout)
        self.setMaximumSize(100, 100)
Exemple #10
0
    def __init__(self, parent=None):
        super(BotTab, self).__init__(parent)

        self.parent = parent
        self.layout = VBoxLayout()
        self.buildUI()
        self.setLayout(self.layout)
Exemple #11
0
    def __init__(self, buttonManager, parent=None):
        super(TopTab, self).__init__(parent)

        self.parent = parent
        self.layout = VBoxLayout()
        self.buttonManager = buttonManager
        self.mode = self.parent.mode
        self.buildUI()
        self.setLayout(self.layout)
Exemple #12
0
    def __init__(self, parent=None):
        super(Preferences, self).__init__(parent)

        # self.resize(200, 100)
        self.setWindowIcon(AppIcon(32, self.key))
        self.setWindowTitle(self.key)
        # self.layout = GeneralSetting(self)
        self.layout = VBoxLayout()
        self.headerGrid = HeaderCheckBoxes(self)
        self.header = GroupBox('Header', parent=self)
        self.header.setLayout(self.headerGrid)

        self.bodyGrid = BodyCheckBoxes(self)
        self.body = GroupBox('Body', parent=self)
        self.body.setLayout(self.bodyGrid)

        self.layout.addWidget(self.header)
        self.layout.addWidget(self.body)

        self.setLayout(self.layout)
Exemple #13
0
    def styleGB(self, title="", tl="grid"):
        if title == "":
            grpBox = QGroupBox()
        else:
            grpBox = QGroupBox(title)

        if tl.lower() == "grid":
            layout = GridLayout()
        elif tl.lower() == "hbox":
            layout = HBoxLayout()
        elif tl.lower() == "vbox":
            layout = VBoxLayout()

        grpBox.setLayout(layout)

        return grpBox, layout
Exemple #14
0
    def __init__(self, parent=None):
        super(UpdatePage, self).__init__(parent)

        updateGroup         = GroupBox("Package selection")
        systemCheckBox      = CheckBox("Update system")
        appsCheckBox        = CheckBox("Update applications")
        docsCheckBox        = CheckBox("Update documentation")

        packageGroup        = GroupBox("Existing packages")

        packageList         = QListWidget()
        qtItem              = QListWidgetItem(packageList)
        qtItem.setText("Qt")

        qsaItem             = QListWidgetItem(packageList)
        qsaItem.setText("QSA")

        teamBuilderItem     = QListWidgetItem(packageList)
        teamBuilderItem.setText("Teambuilder")

        startUpdateButton   = Button({'txt':"Start update"})

        updateLayout        = VBoxLayout({'addWidget': [systemCheckBox, appsCheckBox, docsCheckBox]})
        # updateLayout.addWidget(systemCheckBox)
        # updateLayout.addWidget(appsCheckBox)
        # updateLayout.addWidget(docsCheckBox)
        updateGroup.setLayout(updateLayout)

        packageLayout       = QVBoxLayout()
        packageLayout.addWidget(packageList)
        packageGroup.setLayout(packageLayout)

        mainLayout          = QVBoxLayout()
        mainLayout.addWidget(updateGroup)
        mainLayout.addWidget(packageGroup)
        mainLayout.addSpacing(12)
        mainLayout.addWidget(startUpdateButton)
        mainLayout.addStretch(1)

        self.setLayout(mainLayout)
Exemple #15
0
    def step2_layout(self):

        step2_groupBox = GroupBox("Step 2")
        step2_layout = VBoxLayout()
        step2_groupBox.setLayout(step2_layout)

        self.question1 = Label({'txt': "Question 1"})
        self.question2 = Label({'txt': "Question 2"})

        self.answer1 = LineEdit()
        self.answer2 = LineEdit()

        step2_btn_box = QDialogButtonBox(QDialogButtonBox.Ok
                                         | QDialogButtonBox.Cancel)
        step2_btn_box.accepted.connect(self.on_step2_btn_clicked)
        step2_btn_box.rejected.connect(self.close)

        step2_layout.addWidget(self.question1)
        step2_layout.addWidget(self.answer1)
        step2_layout.addWidget(self.question2)
        step2_layout.addWidget(self.answer2)
        step2_layout.addWidget(step2_btn_box)

        return step2_groupBox
Exemple #16
0
class TaskInfo(GroupBox):

    key = 'TaskInfo'

    def __init__(self, task):
        super(TaskInfo, self).__init__()

        with open(task, 'r') as f:
            self._data = json.load(f)

        self.setTitle(self._data['id'])
        self.layout = VBoxLayout()

        self._id = self._data['id']
        self.key = self._id
        self._name = self._data['name']
        self._mode = self._data['mode']
        self._type = self._data['type']

        self._project = self._data['project']
        self._organisation = self._data['organisation']
        self._details = self._data['details']

        self._hour = int(self._data['endtime'].split(':')[0])
        self._minute = int(self._data['endtime'].split(':')[1])
        self._second = int(self._data['endtime'].split(':')[2])

        self._day = int(self._data['enddate'].split('/')[0])
        self._month = int(self._data['enddate'].split('/')[1])
        self._year = int(self._data['enddate'].split('/')[2])

        self.duetime = duetime(self._hour, self._minute, self._second)
        self.duedate = duedate(self._day, self._month, self._year)

        self.task = Task(self._id, self._name, self._mode, self._type, self._project, self._organisation,
                         self.duetime, self.duedate, self._details)

        self._countdown = '{0}:{1}:{2}'.format(self.task.hours, self.task.minutes, self.task.seconds)
        self.task.countdown.connect(self.update_countdown)

        self.task_status = Label({'txt': '{0}'.format(self.task.status)})
        self.task_duedate = Label({'txt': '{0}'.format(self.task._enddate)})
        self.task_duetime = Label({'txt': '{0}'.format(self.task._endtime)})
        self.task_countdown = Label({'txt': '{0}'.format(self._countdown)})

        self.layout.addWidget(self.task_status)
        self.layout.addWidget(self.task_duedate)
        self.layout.addWidget(self.task_duetime)
        self.layout.addWidget(self.task_countdown)

        self.setLayout(self.layout)
        self.setMaximumSize(100, 100)

    def update_countdown(self, val):
        if self.task.status == 'Overdued':
            self.task_status.setStyleSheet('color: red')
        elif self.task.status == 'Urgent':
            self.task_status.setStyleSheet('color: orange')
        else:
            self.task_status.setStyleSheet('color: green')

        return self.task_countdown.setText(val)

    @property
    def id(self):
        return self._id

    @property
    def mode(self):
        return self._mode

    @property
    def type(self):
        return self._type

    @property
    def project(self):
        return self._project

    @property
    def organisation(self):
        return self._organisation

    @property
    def hour(self):
        return self._hour

    @property
    def minute(self):
        return self._minute

    @property
    def second(self):
        return self._second

    @property
    def day(self):
        return self._day

    @property
    def month(self):
        return self._month

    @property
    def year(self):
        return self._year

    @id.setter
    def id(self, val):
        self._id = val

    @mode.setter
    def mode(self, val):
        self._mode = val

    @type.setter
    def type(self, val):
        self._type = val

    @project.setter
    def project(self, val):
        self._project = val

    @organisation.setter
    def organisation(self, val):
        self._organisation = val

    @hour.setter
    def hour(self, val):
        self._hour = val

    @minute.setter
    def minute(self, val):
        self._minute = val

    @second.setter
    def second(self, val):
        self._second = val

    @day.setter
    def day(self, val):
        self._day = val

    @month.setter
    def month(self, val):
        self._month = val

    @year.setter
    def year(self, val):
        self._year = val
Exemple #17
0
class TaskManager(Widget):

    key = 'TaskManager'

    def __init__(self, parent=True):
        super(TaskManager, self).__init__(parent)

        self.parent = parent
        self.setWindowTitle('Task Manager')
        self.layout = VBoxLayout()
        line1 = HBoxLayout()
        line2 = HBoxLayout()

        self.infoGrp = GroupBox('Task Info')
        self.taskInfo = TaskInfo(self)
        self.infoGrp.setLayout(self.taskInfo)
        line1.addWidget(self.infoGrp)

        self.detailsGrp = GroupBox('Details')
        self.taskDetails = TaskDetails(self)
        self.detailsGrp.setLayout(self.taskDetails)
        line1.addWidget(self.detailsGrp)

        self.layout.addLayout(line1)
        self.layout.addLayout(line2)

        self.okButton = Button({'txt': 'Ok', 'cl': self.executeTask})
        self.cancelButton = Button({'txt': 'Cancel', 'cl': self.hideEvent})
        line2.addWidget(self.okButton)
        line2.addWidget(self.cancelButton)

        self.setLayout(self.layout)
        self.setMinimumWidth(750)

    def executeTask(self):

        h = int(self.taskInfo.hour.text())
        m = int(self.taskInfo.minute.text())
        s = int(self.taskInfo.second.text())
        self.duetime = duetime(h, m, s)

        y = int(self.taskInfo.year.text())
        mo = int(self.taskInfo.month.text())
        d = int(self.taskInfo.day.text())
        self.duedate = duedate(d, mo, y)

        id = self.taskInfo.taskID.text()
        name = self.taskInfo.taskName.text()
        type = self.taskDetails.taskType
        mode = self.taskDetails.taskMode
        project = [
            self.taskInfo.projectID.text(),
            self.taskInfo.projectName.text()
        ]
        organisation = [
            self.taskInfo.organisationID.text(),
            self.taskInfo.organisationName.text()
        ]
        details = self.taskDetails.taskDetails.toPlainText()

        Task(id, name, mode, type, project, organisation, self.duetime,
             self.duedate, details)
        self.parent.topTabUI.tab1.update_tasks()

    def resizeEvent(self, event):
        w = int(self.width())
        self.infoGrp.setMaximumWidth(w / 3)


# -------------------------------------------------------------------------------------------------------------
# Created by panda on 19/11/2019 - 12:48 AM
# © 2017 - 2018 DAMGteam. All rights reserved
Exemple #18
0
class TopTap3(Widget):

    key = 'TerminalLayout'
    _name = 'TerminalLayout'

    commands = DAMGLIST()
    shotcuts = DAMGLIST()
    tracker = 0
    _cwd = os.getcwd().replace('\\', '/')
    _user = getpass.getuser()
    _host = socket.gethostname()

    def __init__(self, buttonManager, parent=None):
        super(TopTap3, self).__init__(parent)

        self.buttonManager = buttonManager
        self.parent = parent

        self.layout = VBoxLayout()

        self.buildUI()
        # QApplication.setCursorFlashTime(1000)
        self.setLayout(self.layout)
        self.setStyleSheet(mystylesheet(self))

    def buildUI(self):
        self.process = Process(self.dataReady, self.onError, self.onOutput,
                               self.isFinished, self)
        self.cmdField = PlainTextEdit({
            'lwm': QPlainTextEdit.NoWrap,
            'sfh': 25,
            'vsbp': SCROLLBAROFF,
            'adr': True
        })
        self.textWindow = PlainTextEdit({'rol': True}, self)
        self.cursor = self.cmdField.textCursor()
        self.copySelectedTextAction = ShortCut('Copy', 'Copy', 'Shift+Ctrl+c',
                                               self.copyText, self)
        self.cancelAction = ShortCut('Cancel', 'Cancel', 'Ctrl+c',
                                     self.killProcess, self)
        self.pasteTextAction = ShortCut('Paste', 'Paste', 'Shift+Ctrl+v',
                                        self.pasteText, self)
        self.textWindow.addActions(
            [self.cancelAction, self.copySelectedTextAction])
        self.cmdField.addAction(self.pasteTextAction)
        self.cmdField.installEventFilter(self)
        self.cursorEnd()
        sysinfo = QSysInfo()
        myMachine = "CPU Architecture: {0}***{1}***{2}***{3}".format(
            sysinfo.currentCpuArchitecture(), sysinfo.prettyProductName(),
            sysinfo.kernelType(), sysinfo.kernelVersion())
        self.statusBar = StatusBar(self)
        self.statusBar.showMessage(myMachine, 0)
        self.layout.addWidget(self.textWindow)
        self.layout.addWidget(self.cmdField)
        self.layout.addWidget(self.statusBar)

    def getUsername(self):
        return "{0}@{1}:{2}$".format(self._user, self._host, self._cwd)

    def cursorEnd(self):
        self.cmdField.setPlainText(self.getUsername())
        self.cursor.movePosition(11, 0)
        self.cmdField.setTextCursor(self.cursor)
        self.cmdField.setFocus()

    def eventFilter(self, source, event):
        if source == self.cmdField:
            if (event.type() == QEvent.DragEnter):
                event.accept()
                return True
            elif (event.type() == QEvent.Drop):
                # print('Drop')
                self.setDropEvent(event)
                return True
            elif (event.type() == QEvent.KeyPress):
                cursor = self.cmdField.textCursor()
                # print('key press:', (event.key(), event.text()))
                if event.key() == Qt.Key_Backspace:
                    if cursor.positionInBlock() <= len(self.getUsername()):
                        return True
                    else:
                        return False

                elif event.key() == Qt.Key_Return:
                    self.run()
                    return True

                elif event.key() == Qt.Key_Left:
                    if cursor.positionInBlock() <= len(self.getUsername()):
                        return True
                    else:
                        return False

                elif event.key() == Qt.Key_Delete:
                    if cursor.positionInBlock() <= len(self.getUsername()) - 1:
                        return True
                    else:
                        return False

                elif event.modifiers() == Qt.ControlModifier and event.key(
                ) == Qt.Key_C:
                    self.killProcess()
                    return True

                elif event.key() == Qt.Key_Up:
                    try:
                        if self.tracker != 0:
                            cursor.select(QTextCursor.BlockUnderCursor)
                            cursor.removeSelectedText()
                            self.cmdField.appendPlainText(self.getUsername())

                        self.cmdField.insertPlainText(
                            self.commands[self.tracker])
                        self.tracker -= 1

                    except IndexError:
                        self.tracker = 0
                    return True

                elif event.key() == Qt.Key_Down:
                    try:
                        if self.tracker != 0:
                            cursor.select(QTextCursor.BlockUnderCursor)
                            cursor.removeSelectedText()
                            self.cmdField.appendPlainText(self.getUsername())

                        self.cmdField.insertPlainText(
                            self.commands[self.tracker])
                        self.tracker += 1

                    except IndexError:
                        self.tracker = 0
                    return True

                else:
                    return False
            else:
                return False
        else:
            return False

    def copyText(self):
        self.textWindow.copy()

    def pasteText(self):
        self.cmdField.paste()

    def killProcess(self):
        # print("cancelled")
        self.process.kill()
        self.textWindow.appendPlainText("cancelled")
        self.cursorEnd()

    def setDropEvent(self, event):
        self.cmdField.setFocus()
        if event.mimeData().hasUrls():
            f = str(event.mimeData().urls()[0].toLocalFile())
            # print("is file:", f)
            if " " in f:
                self.cmdField.insertPlainText("'{}'".format(f))
            else:
                self.cmdField.insertPlainText(f)
            event.accept()
        elif event.mimeData().hasText():
            ft = event.mimeData().text()
            # print("is text:", ft)
            if " " in ft:
                self.cmdField.insertPlainText("'{}'".format(ft))
            else:
                self.cmdField.insertPlainText(ft)
        else:
            event.ignore()

    def run(self):

        self.textWindow.setFocus()
        self.textWindow.appendPlainText(self.cmdField.toPlainText())
        cli = shlex.split(self.cmdField.toPlainText().replace(
            self.getUsername(), '').replace("'", '"'),
                          posix=False)
        cmd = str(cli[0])  ### is the executable

        if cmd == "exit":
            quit()
        elif 'cd' in cmd:
            if len(cli) == 1:
                command_argument = cmd.split('cd')[1]
            else:
                command_argument = cli[1]

            if cmd == 'cd' or cmd == 'cd.':
                if len(cli) == 1:
                    pass
                else:
                    if os.path.isdir(command_argument):
                        # print('{0} is dir'.format(command_argument))
                        check = True
                        for char in command_argument:
                            if not char == '.':
                                check = False
                                break
                        if not check:
                            pth = os.path.join(self._cwd, command_argument)
                            if os.path.exists(pth):
                                self._cwd = pth
                            else:
                                self.command_not_found(cmd)
                        else:
                            # print('{0} is not dir'.format(command_argument))
                            pass
                    else:
                        if os.path.exists(command_argument):
                            # print('{0} is path'.format(command_argument))
                            self._cwd = command_argument
                        else:
                            # print('{0} is path but not exists'.format(command_argument))
                            pth = os.path.join(self._cwd, command_argument)
                            # print(pth, self._cwd)
                            if os.path.exists(pth):
                                self._cwd = pth
                            else:
                                self.command_not_found(cmd)
            else:
                if len(command_argument) <= 1:
                    if command_argument == '/' or command_argument == '\\':
                        self._cwd = os.path.splitdrive(self._cwd)[0] + '/'
                    else:
                        self.command_not_found()
                elif len(command_argument) >= 2:
                    if command_argument[0:2] == '..':
                        check = True
                        for char in command_argument:
                            if not char == '.':
                                check = False
                        if check:
                            for i in range(len(command_argument) - 1):
                                self._cwd = os.path.dirname(self._cwd)
                        else:
                            self.command_not_found(cmd)
                    else:
                        self.command_not_found(cmd)
                else:
                    self.command_not_found(cmd)

            self.updateWorkingDirectory(self._cwd)
        else:
            if (QStandardPaths.findExecutable(cmd)):
                self.commands.append(self.cmdField.toPlainText().replace(
                    self.getUsername(), ""))
                # print("command", cmd, "found")
                t = " ".join(cli)
                if self.process.state() != 2:
                    self.process.waitForStarted()
                    self.process.waitForFinished()
                    if "|" in t or ">" in t or "<" in t:
                        # print("special characters")
                        self.process.start('sh -c "' + cmd + ' ' + t + '"')
                        # print("running", ('sh -c "' + cmd + ' ' + t + '"'))
                    else:
                        self.process.start(cmd + " " + t)
                        # print("running", (cmd + " " + t))
            else:
                self.command_not_found(cmd)

    def command_not_found(self, cmd):
        self.textWindow.appendPlainText("command not found: {0}".format(cmd))
        self.cursorEnd()

    def dataReady(self):
        try:
            out = str(self.process.readAll(), encoding='utf8').rstrip()
        except TypeError:
            out = str(self.process.readAll()).rstrip()
            self.textWindow.moveCursor(self.cursor.Start)  ### changed
        self.textWindow.appendPlainText(out)

    def onError(self):
        self.error = self.process.readAllStandardError().data().decode()
        self.textWindow.appendPlainText(self.error.strip('\n'))
        self.cursorEnd()

    def onOutput(self):
        self.result = self.process.readAllStandardOutput().data().decode()
        self.textWindow.appendPlainText(self.result.strip('\n'))
        self.cursorEnd()
        self.state = self.process.state()
        # print(self.state)

    def isFinished(self):
        # print("finished")
        self.cmdField.setPlainText(self.getUsername())
        self.cursorEnd()

    def updateWorkingDirectory(self, pth=os.getcwd()):
        # print('Working Dir: {0}'.format(pth))
        fixName = os.path.basename(pth)
        fixPath = os.path.dirname(pth)
        self._cwd = os.path.join(fixPath, fixName).replace('\\', '/')
        self.process.setWorkingDirectory(self._cwd)
        self.cursorEnd()
Exemple #19
0
class ForgotPassword(Widget):

    key = 'ForgotPassword'

    def __init__(self, parent=None):
        super(ForgotPassword, self).__init__(parent)

        self.layout = VBoxLayout()
        self.buildUI()
        self.setLayout(self.layout)

    def buildUI(self):

        self.step1_form = self.step1_layout()
        self.step2_form = self.step2_layout()
        self.step2_form.setVisible(False)

        self.layout.addWidget(self.step1_form)
        self.layout.addWidget(self.step2_form)

    def step1_layout(self):

        step1_groupBox = QGroupBox("Step 1")
        step1_layout = QFormLayout()
        step1_groupBox.setLayout(step1_layout)

        self.user_account = QLineEdit()
        self.user_email = QLineEdit()

        step1_btn_box = QDialogButtonBox(QDialogButtonBox.Ok
                                         | QDialogButtonBox.Cancel)
        step1_btn_box.accepted.connect(self.on_step1_btn_clicked)
        step1_btn_box.rejected.connect(self.close)

        step1_layout.addRow(Label({'txt': "Username: "******"Email adress: "}), self.user_email)
        step1_layout.addRow(step1_btn_box)

        return step1_groupBox

    def step2_layout(self):

        step2_groupBox = GroupBox("Step 2")
        step2_layout = VBoxLayout()
        step2_groupBox.setLayout(step2_layout)

        self.question1 = Label({'txt': "Question 1"})
        self.question2 = Label({'txt': "Question 2"})

        self.answer1 = LineEdit()
        self.answer2 = LineEdit()

        step2_btn_box = QDialogButtonBox(QDialogButtonBox.Ok
                                         | QDialogButtonBox.Cancel)
        step2_btn_box.accepted.connect(self.on_step2_btn_clicked)
        step2_btn_box.rejected.connect(self.close)

        step2_layout.addWidget(self.question1)
        step2_layout.addWidget(self.answer1)
        step2_layout.addWidget(self.question2)
        step2_layout.addWidget(self.answer2)
        step2_layout.addWidget(step2_btn_box)

        return step2_groupBox

    def on_step1_btn_clicked(self):

        question1 = "What is the question 1"
        question2 = "What is the question 2"

        self.question1.setText(question1)
        self.question2.setText(question2)

        self.step1_form.setDisabled(True)
        self.step2_form.setVisible(True)

        # username = self.user_account.text()
        #
        # if len(username) == 0:
        #     QMessageBox.critical(self, 'Failed', mess.USER_BLANK)
        # else:
        #     checkUserExists = usql.check_data_exists(username)
        #     if not checkUserExists:
        #         QMessageBox.critical(self, 'Failed', mess.USER_NOT_EXSIST)
        #         question1, question2 = usql.query_user_security_question(username)
        #
        #         self.question1.setText(question1)
        #         self.question2.setText(question2)
        #
        #         self.step1_form.setDisabled(True)
        #         self.step2_form.setVisible(True)

    def on_step2_btn_clicked(self):
        pass

    def loginChanged(self, login):
        self._login = login

    @property
    def login(self):
        return self._login

    @login.setter
    def login(self, newVal):
        self._login = newVal
Exemple #20
0
    def __init__(self, parent=None):
        super(ForgotPassword, self).__init__(parent)

        self.layout = VBoxLayout()
        self.buildUI()
        self.setLayout(self.layout)