summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-12-27 14:45:22 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-12-27 14:45:22 +0100
commit757f025247d77b085b6168d5f625d2bbfa7c4c0d (patch)
tree5458f45d3c45d6e7da4945a376df8433ccf1e5bf
parentFixed reconnect loop (easy doing) (diff)
downloadpyload-757f025247d77b085b6168d5f625d2bbfa7c4c0d.tar.xz
stop button works, closes #59
-rw-r--r--module/gui/MainWindow.py24
-rw-r--r--module/gui/connector.py24
-rwxr-xr-xpyLoadCore.py15
-rwxr-xr-xpyLoadGui.py21
4 files changed, 80 insertions, 4 deletions
diff --git a/module/gui/MainWindow.py b/module/gui/MainWindow.py
index 744518adb..74bf00b51 100644
--- a/module/gui/MainWindow.py
+++ b/module/gui/MainWindow.py
@@ -79,8 +79,13 @@ class MainWindow(QMainWindow):
self.tabs = {}
self.tabs["queue"] = {"w":QWidget()}
self.tabs["collector"] = {"w":QWidget()}
+ self.tabs["settings"] = {"w":QWidget()}
+ self.tabs["log"] = {"w":QWidget()}
self.tabw.addTab(self.tabs["queue"]["w"], "Queue")
self.tabw.addTab(self.tabs["collector"]["w"], "Collector")
+ self.tabw.addTab(self.tabs["settings"]["w"], "Settings")
+ self.tabw.addTab(self.tabs["log"]["w"], "Log")
+ self.tabw.setTabEnabled(2, False)
#init tabs
self.init_tabs()
@@ -159,6 +164,21 @@ class MainWindow(QMainWindow):
self.tabs["collector"]["package_view"].setContextMenuPolicy(Qt.CustomContextMenu)
self.tabs["collector"]["link_view"].setContextMenuPolicy(Qt.CustomContextMenu)
self.tabs["queue"]["view"].setContextMenuPolicy(Qt.CustomContextMenu)
+
+ #settings
+ self.tabs["settings"]["l"] = QGridLayout()
+ self.tabs["settings"]["w"].setLayout(self.tabs["settings"]["l"])
+ #self.tabs["settings"]["view"] = QTreeWidget()
+ #self.tabs["settings"]["l"].addWidget(self.tabs["settings"]["view"])
+
+ #log
+ self.tabs["log"]["l"] = QGridLayout()
+ self.tabs["log"]["w"].setLayout(self.tabs["log"]["l"])
+ self.tabs["log"]["text"] = QTextEdit()
+ self.tabs["log"]["text"].logOffset = 0
+ self.tabs["log"]["text"].setReadOnly(True)
+ self.connect(self.tabs["log"]["text"], SIGNAL("append(QString)"), self.tabs["log"]["text"].append)
+ self.tabs["log"]["l"].addWidget(self.tabs["log"]["text"])
def init_context(self):
"""
@@ -183,10 +203,8 @@ class MainWindow(QMainWindow):
def slotStatusStop(self):
"""
stop button (toolbar)
-
- dummy
"""
- print "stop!"
+ self.emit(SIGNAL("stopAllDownloads"))
def slotAdd(self):
"""
diff --git a/module/gui/connector.py b/module/gui/connector.py
index e52cf42ff..64c05ba8c 100644
--- a/module/gui/connector.py
+++ b/module/gui/connector.py
@@ -316,4 +316,28 @@ class connector(QThread):
self.emit(SIGNAL("proxy_error"), "uploadContainer")
finally:
self.mutex.unlock()
+
+ def getLog(self, offset):
+ """
+ get log
+ """
+ self.mutex.lock()
+ try:
+ return self.proxy.get_log(offset)
+ except:
+ self.emit(SIGNAL("proxy_error"), "getLog")
+ finally:
+ self.mutex.unlock()
+
+ def stopAllDownloads(self):
+ """
+ get log
+ """
+ self.mutex.lock()
+ try:
+ self.proxy.stop_downloads()
+ except:
+ self.emit(SIGNAL("proxy_error"), "stopAllDownloads")
+ finally:
+ self.mutex.unlock()
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 5890c6e9a..979abaf44 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -508,7 +508,20 @@ class ServerMethods():
pid = self.core.file_list.packager.addNewPackage(filename)
cid = self.core.file_list.collector.addLink(path)
self.move_file_2_package(cid, pid)
- self.core.file_list.save()
+ self.core.file_list.save()
+
+ def get_log(self, offset=0):
+ filename = self.core.config['log']['log_folder'] + sep + 'log.txt'
+ fh = open(filename, "r")
+ content = fh.read()
+ fh.close()
+ lines = content.splitlines()
+ if offset >= len(lines):
+ return None
+ return lines[offset:]
+
+ def stop_downloads(self):
+ self.core.thread_list.stopAllDownloads()
#def move_urls_up(self, ids):
# for id in ids:
diff --git a/pyLoadGui.py b/pyLoadGui.py
index f075db710..0f76e6429 100755
--- a/pyLoadGui.py
+++ b/pyLoadGui.py
@@ -112,6 +112,7 @@ class main(QObject):
self.connect(self.mainWindow, SIGNAL("restartDownload"), self.slotRestartDownload)
self.connect(self.mainWindow, SIGNAL("removeDownload"), self.slotRemoveDownload)
self.connect(self.mainWindow, SIGNAL("addContainer"), self.slotAddContainer)
+ self.connect(self.mainWindow, SIGNAL("stopAllDownloads"), self.slotStopAllDownloads)
def slotShowConnector(self):
"""
@@ -215,6 +216,18 @@ class main(QObject):
self.mainWindow.actions["toggle_status"].setChecked(not status["pause"])
self.mainWindow.serverStatus.setText(text)
+ def refreshLog(self):
+ offset = self.mainWindow.tabs["log"]["text"].logOffset
+ lines = self.connector.getLog(offset)
+ if not lines:
+ return
+ self.mainWindow.tabs["log"]["text"].logOffset += len(lines)
+ for line in lines:
+ self.mainWindow.tabs["log"]["text"].emit(SIGNAL("append(QString)"), line)
+ cursor = self.mainWindow.tabs["log"]["text"].textCursor()
+ cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor)
+ self.mainWindow.tabs["log"]["text"].setTextCursor(cursor)
+
def getConnections(self):
"""
parse all connections in the config file
@@ -453,6 +466,13 @@ class main(QObject):
else:
self.connector.removeFile(id)
+ def slotStopAllDownloads(self):
+ """
+ emitted from main window
+ stop all running downloads
+ """
+ self.connector.stopAllDownloads()
+
class Loop(QThread):
"""
main loop (not application loop)
@@ -473,6 +493,7 @@ class main(QObject):
methods to call
"""
self.parent.refreshServerStatus()
+ self.parent.refreshLog()
def stop(self):
self.running = False