diff options
author | mkaay <mkaay@mkaay.de> | 2009-12-16 17:13:46 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2009-12-16 17:13:46 +0100 |
commit | f89a0fcfbcca01067175ba7a67c14eb95bd60d6f (patch) | |
tree | 8de765342ec8e967e5e8b2b4ee453f3239d85032 | |
parent | merged (diff) | |
download | pyload-f89a0fcfbcca01067175ba7a67c14eb95bd60d6f.tar.xz |
gui server status
-rw-r--r-- | module/file_list.py | 4 | ||||
-rwxr-xr-x | pyLoadCore.py | 11 | ||||
-rw-r--r-- | pyLoadQtGui.py | 48 |
3 files changed, 51 insertions, 12 deletions
diff --git a/module/file_list.py b/module/file_list.py index ea4fd5767..ae168900b 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -132,6 +132,9 @@ class File_List(object): files.append(pyfile) return files + def countDownloads(self): + return len(self.getDownloadList()) + def getFileInfo(self, id): try: n, pyfile = self.collector._getFileFromID(id) @@ -147,6 +150,7 @@ class File_List(object): info["status_filename"] = pyfile.status.filename info["status_error"] = pyfile.status.error info["active"] = pyfile.active + info["plugin"] = pyfile.plugin.props['name'] return info class pyLoadCollector(): diff --git a/pyLoadCore.py b/pyLoadCore.py index 72f938c37..3d399a0c2 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -129,7 +129,7 @@ class Core(object): script_folders = ['scripts/download_preparing/', 'scripts/download_finished/', 'scripts/package_finished/', 'scripts/reconnected/'] self.check_file(script_folders, _("folders for scripts"), True) if self.config['ssl']['activated']: - self.check_install("OpenSSL", "OpenSLL for secure connection", True) + self.check_install("OpenSSL", "OpenSSL for secure connection", True) self.check_file(self.config['ssl']['cert'], _("ssl certificate"), False, True) self.check_file(self.config['ssl']['key'], _("ssl key"), False, True) @@ -155,6 +155,8 @@ class Core(object): self.logger.info(_("Downloadtime: %s") % self.server_methods.is_time_download()) # debug only #read url list @mkaay: pid, lid? + # pid = package id + # lid = link/file id linkFile = self.config['general']['link_file'] pid = self.file_list.packager.addNewPackage(package_name=linkFile) lid = self.file_list.collector.addLink(linkFile) @@ -195,14 +197,9 @@ class Core(object): def init_logger(self, level): - - console = logging.StreamHandler(stdout) - frm = logging.Formatter("%(asctime)s: %(levelname)-8s %(message)s", "%d.%m.%Y %H:%M:%S") - console.setFormatter(frm) - self.logger = logging.getLogger("log") # settable in config if self.config['log']['file_log']: @@ -378,7 +375,7 @@ class ServerMethods(): def status_server(self): status = {} status['pause'] = self.core.thread_list.pause - status['queue'] = len(self.core.file_list.data['queue']) + status['queue'] = self.core.file_list.countDownloads() status['speed'] = 0 for pyfile in self.core.thread_list.py_downloading: diff --git a/pyLoadQtGui.py b/pyLoadQtGui.py index b3f206bd1..8d214a9b6 100644 --- a/pyLoadQtGui.py +++ b/pyLoadQtGui.py @@ -39,11 +39,13 @@ class main(QObject): self.app = QApplication(sys.argv) self.mainWindow = mainWindow() self.connector = connector() + self.mainloop = self.Loop(self) self.connector.start() sleep(1) self.mainWindow.show() self.testStuff() + self.mainloop.start() def connectSignals(self): """ @@ -114,13 +116,36 @@ class main(QObject): view.setColumnCount(3) view.setHeaderLabels(["Name", "Status", "Fortschritt"]) view.setColumnWidth(0, 300) - view.setColumnWidth(1, 100) + view.setColumnWidth(1, 200) view.setColumnWidth(2, 100) self.queue = Queue(view, self.connector) delegate = QueueProgressBarDelegate(view, self.queue) view.setItemDelegateForColumn(2, delegate) #view.setup(self.queue) self.queue.start() + + def refreshServerStatus(self): + status = self.connector.getServerStatus() + if status["pause"]: + status["status"] = "Paused" + else: + status["status"] = "Running" + text = "Status: %(status)s | Speed: %(speed)s kb/s" % status + self.mainWindow.serverStatus.setText(text) + + class Loop(QThread): + def __init__(self, parent): + QThread.__init__(self) + self.parent = parent + self.running = True + + def run(self): + while self.running: + sleep(1) + self.update() + + def update(self): + self.parent.refreshServerStatus() class connector(QThread): def __init__(self): @@ -225,6 +250,16 @@ class connector(QThread): return self.proxy.status_downloads() finally: self.mutex.unlock() + + def getServerStatus(self): + """ + return server status + """ + self.mutex.lock() + try: + return self.proxy.status_server() + finally: + self.mutex.unlock() class mainWindow(QMainWindow): def __init__(self): @@ -235,7 +270,7 @@ class mainWindow(QMainWindow): #window stuff self.setWindowTitle("pyLoad Client") self.setWindowIcon(QIcon("icons/logo.png")) - self.resize(600,500) + self.resize(750,500) #central widget, layout self.masterlayout = QVBoxLayout() @@ -246,6 +281,8 @@ class mainWindow(QMainWindow): #set menubar and statusbar self.menubar = self.menuBar() self.statusbar = self.statusBar() + self.serverStatus = QLabel("Status: Not Connected") + self.statusbar.addPermanentWidget(self.serverStatus) #menu self.menus = {} @@ -402,9 +439,9 @@ class Queue(QThread): val = 100 perc_sum += val if count == 0: - return None + return 0 return perc_sum/count - return None + return 0 class QueuePack(): def __init__(self, queue): @@ -431,8 +468,9 @@ class Queue(QThread): if not item: item = QTreeWidgetItem() parent.insertChild(pos, item) + status = "%s (%s)" % (newChild.getData()["status_type"], newChild.getData()["plugin"]) item.setData(0, Qt.DisplayRole, QVariant(newChild.getData()["filename"])) - item.setData(1, Qt.DisplayRole, QVariant(newChild.getData()["status_type"])) + item.setData(1, Qt.DisplayRole, QVariant(status)) item.setData(0, Qt.UserRole, QVariant(cid)) item.setData(2, Qt.UserRole, QVariant(newChild)) |