def onDown(self, zeile, spalte, directory = None): if not directory: directory = (QtGui.QTableWidgetItem.text(self.tableWidget.item(zeile, 1))) contact_server = FileClient(host = self.host, port = self.port) res = contact_server.work("cd " + unicode(directory)) if not res: self.listWidget.addItem(self.trUtf8("Maybe server is not running?")) self.listWidget.scrollToBottom() elif res.startswith("Error:"): newitem = QtGui.QListWidgetItem(res.decode("utf-8")) newitem.setTextColor(QtGui.QColor("red")) self.listWidget.addItem(newitem) self.listWidget.addItem("-----------------------------------------------") self.listWidget.scrollToBottom() return res = contact_server.work("pwd") self.lineEditDirectory.setText(res.decode("utf-8")) if self.checkBoxHidden.checkState(): res = contact_server.work("ls -a") else: res = contact_server.work("ls") if res: self.filelist = res.split("\n") self.output_in_table() else: self.tableWidget.clearContents()
def onHidden(self, status): if status == 0: contact_server = FileClient(host = self.host, port = self.port) res = contact_server.work("ls") if res: self.filelist = res.split("\n") self.output_in_table() else: contact_server = FileClient(host = self.host, port = self.port) res = contact_server.work("ls -a") if res: self.filelist = res.split("\n") self.output_in_table()
def onDirectoryUp(self): contact_server = FileClient(host = self.host, port = self.port) contact_server.work("cd ..") res = contact_server.work("pwd") if res: self.lineEditDirectory.setText(res) if self.checkBoxHidden.checkState(): res = contact_server.work("ls -a") else: res = contact_server.work("ls") self.filelist = res.split("\n") self.output_in_table() else: self.listWidget.addItem(self.trUtf8("Maybe server is not running?")) self.listWidget.scrollToBottom()
def getFiles(self): items = self.tableWidget.selectedItems() for i in items: if i.column() == 1: befehl = self.trUtf8("Getting ") + i.text() + " ..." self.emit(QtCore.SIGNAL("add(QString)"), befehl) self.emit(QtCore.SIGNAL("cursorWait")) contact_server = FileClient(host = self.host, port = self.port, verzeichnis = self.lineEditDirectoryClient.text(), datei = i.text()) res = contact_server.work("get " + unicode(i.text())) if res: self.emit(QtCore.SIGNAL("add(QString)"), res) else: self.emit(QtCore.SIGNAL("add(QString)"), self.trUtf8("Maybe server is not running?")) self.emit(QtCore.SIGNAL("add(QString)"), "-----------------------------------------------") self.emit(QtCore.SIGNAL("cursorNormal"))
def onStopServer(self): contact_server = FileClient(host = self.host, port = self.port) contact_server.work("stop") self.listWidget.addItem(self.trUtf8("Server stopped")) self.listWidget.scrollToBottom()
def __init__(self): QtGui.QMainWindow.__init__(self) self.setupUi(self) # Slots einrichten self.connect(self.pushButtonDirClient, QtCore.SIGNAL("clicked()"), self.onDirectory) self.connect(self.pushButtonUp, QtCore.SIGNAL("clicked()"), self.onDirectoryUp) self.connect(self.pushButtonClear, QtCore.SIGNAL("clicked()"), self.onProtocolClear) self.connect(self.pushButtonGet, QtCore.SIGNAL("clicked()"), self.onGetFiles) self.connect(self.pushButtonStop, QtCore.SIGNAL("clicked()"), self.onStopServer) self.connect(self.tableWidget, QtCore.SIGNAL("cellDoubleClicked(int, int)"), self.onDown) self.connect(self.checkBoxHidden, QtCore.SIGNAL("stateChanged(int)"), self.onHidden) settings = QtCore.QSettings() window_size = settings.value("py_file_client/Size", QtCore.QVariant(QtCore.QSize(600, 500))).toSize() self.resize(window_size) window_position = settings.value("py_file_client/Position", QtCore.QVariant(QtCore.QPoint(0, 0))).toPoint() self.move(window_position) self.path = os.path.expanduser("~") self.config_path = self.path + os.sep + ".py_file_client" self.config_file = self.config_path + os.sep + "config" self.config = ConfigParser.RawConfigParser() while True: try: x = self.config.read(self.config_file) self.host = self.config.get("Section", "host") self.port = self.config.getint("Section", "port") self.path = self.config.get("Section", "dir") break except: self.config.add_section("Section") self.config.set("Section", "host", "192.168.1.100") self.config.set("Section", "port", "50007") self.config.set("Section", "dir", self.path) try: if not os.path.exists(self.config_path): os.mkdir(self.config_path) with open(self.config_file, "wb") as configfile: self.config.write(configfile) except: sys.exit() self.lineEditDirectoryClient.setText(self.path) self.lineEditIP.setText(self.host) self.lineEditPort.setText(str(self.port)) self.blksize = 1024 self.sockobj = None self.threadPool = [] contact_server = FileClient(host = self.host, port = self.port) res = contact_server.work("pwd") if res: self.lineEditDirectory.setText(res) contact_server = FileClient(host = self.host, port = self.port) res = contact_server.work("ls") if res: self.filelist = res.split("\n") self.output_in_table() else: self.listWidget.addItem(self.trUtf8("Maybe server is not running?")) self.listWidget.scrollToBottom()