def __init__(self, con, parent=None, **kwargs): super().__init__(parent, **kwargs) if con == "SSH": self.device = SshDevice() else: self.device = TelnetDevice() self.done_signal.connect(self.exit_process)
class Threaded(QtCore.QObject): text_signal = QtCore.pyqtSignal(str) bar_signal = QtCore.pyqtSignal(int) label_signal = QtCore.pyqtSignal(str) done_signal = QtCore.pyqtSignal() def __init__(self, con, parent=None, **kwargs): super().__init__(parent, **kwargs) if con == "SSH": self.device = SshDevice() else: self.device = TelnetDevice() self.done_signal.connect(self.exit_process) @QtCore.pyqtSlot() def start(self): print("Thread started") @QtCore.pyqtSlot(list) def automate_config(self, args): """ self.ips, self.commands, self.get_mode(), self.privilege_check.isChecked(), self.add_check.isChecked(), self.silent_check.isChecked( ), self.backup_check.isChecked, self.backup_path_input.text(), [self.loading_bar, self.loading_label, self.display_text], funct = self.getInputs """ increment = [ self.bar_signal, self.label_signal, self.text_signal, self.done_signal ] self.device.automate(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], increment) @QtCore.pyqtSlot() def exit_process(self): print("Thread stopped")
class Threaded(QtCore.QObject): text_signal = QtCore.pyqtSignal(str) bar_signal = QtCore.pyqtSignal(int) label_signal = QtCore.pyqtSignal(str) done_signal = QtCore.pyqtSignal() def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.device = TelnetDevice() self.done_signal.connect(self.exit_process) @QtCore.pyqtSlot() def start(self): print("Thread started") @QtCore.pyqtSlot(list) def automate_config(self, args): """ self.ips, name_list, funct = self.getInputs """ increment = [ self.bar_signal, self.label_signal, self.text_signal, self.done_signal ] self.device.rename(args[0], args[1], args[2], increment) @QtCore.pyqtSlot() def exit_process(self): print("Thread stopped")
class Threaded(QtCore.QObject): text_signal = QtCore.pyqtSignal(str) bar_signal = QtCore.pyqtSignal(int) label_signal = QtCore.pyqtSignal(str) done_signal = QtCore.pyqtSignal() def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.device = TelnetDevice() self.done_signal.connect(self.exit_process) @QtCore.pyqtSlot() def start(self): print("Thread started") @QtCore.pyqtSlot(list) def automate_config(self, args): increment = [self.bar_signal, self.label_signal, self.text_signal, self.done_signal] if args[3].currentText() == 'Restore': self.device.restore(args[0], args[1], args[2], increment) elif args[3].currentText() == 'Merge': self.device.mergeConfig(args[0], args[1], args[2], increment) @QtCore.pyqtSlot() def exit_process(self): print("Thread stopped")
def __init__(self, ips, con): """create the script dialog object""" self.ips = ips self.commands = [] if con == 'SSH': self.device = SshDevice() else: self.device = TelnetDevice() QtWidgets.QDialog.__init__( self, None, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowMinimizeButtonHint) self._thread = QtCore.QThread() self.work = Threaded( con, text_signal=self.change_display, label_signal=self.change_label, bar_signal=self.change_bar, done_signal=self._thread.quit, ) self.request.connect(self.work.automate_config) self._thread.started.connect(self.work.start) self._thread.finished.connect(self.after_work) self.work.moveToThread(self._thread) QtWidgets.qApp.aboutToQuit.connect(self._thread.quit) self.setupUi(self)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.device = TelnetDevice() self.done_signal.connect(self.exit_process)