summaryrefslogtreecommitdiffstats
path: root/module/gui
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2011-02-13 15:06:03 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2011-02-13 15:06:03 +0100
commit908c28bab89525250172a4013667319942846065 (patch)
tree73b85517ae12f8be4bc2071409136f181907795d /module/gui
parentcleanup (diff)
downloadpyload-908c28bab89525250172a4013667319942846065.tar.xz
fixes + improvements
Diffstat (limited to 'module/gui')
-rw-r--r--module/gui/ConnectionManager.py30
-rw-r--r--module/gui/Overview.py2
-rw-r--r--module/gui/Queue.py10
-rw-r--r--module/gui/connector.py40
4 files changed, 39 insertions, 43 deletions
diff --git a/module/gui/ConnectionManager.py b/module/gui/ConnectionManager.py
index c101a7add..51f39f2be 100644
--- a/module/gui/ConnectionManager.py
+++ b/module/gui/ConnectionManager.py
@@ -61,7 +61,6 @@ class ConnectionManager(QWidget):
form.setAlignment(Qt.AlignRight)
checkbox = QCheckBox()
- checkbox.setDisabled(True)
form.addRow(_("Use internal Core:"), checkbox)
boxLayout.addLayout(form)
@@ -110,7 +109,7 @@ class ConnectionManager(QWidget):
self.connList.setCurrentItem(item)
def slotNew(self):
- data = {"id":uuid().hex, "type":"remote", "default":False, "name":"", "host":"", "ssl":False, "port":"7227", "user":"admin", "password":""}
+ data = {"id":uuid().hex, "type":"remote", "default":False, "name":"", "host":"", "port":"7228", "user":"admin", "password":""}
self.edit.setData(data)
self.edit.show()
@@ -173,12 +172,14 @@ class ConnectionManager(QWidget):
class EditWindow(QWidget):
def __init__(self):
QWidget.__init__(self)
+
+ self.setWindowTitle(_("pyLoad ConnectionManager"))
+ self.setWindowIcon(QIcon(join(pypath, "icons","logo.png")))
grid = QGridLayout()
nameLabel = QLabel(_("Name:"))
hostLabel = QLabel(_("Host:"))
- sslLabel = QLabel(_("SSL:"))
localLabel = QLabel(_("Local:"))
userLabel = QLabel(_("User:"))
pwLabel = QLabel(_("Password:"))
@@ -186,7 +187,6 @@ class ConnectionManager(QWidget):
name = QLineEdit()
host = QLineEdit()
- ssl = QCheckBox()
local = QCheckBox()
user = QLineEdit()
password = QLineEdit()
@@ -205,20 +205,17 @@ class ConnectionManager(QWidget):
grid.addWidget(host, 2, 1)
grid.addWidget(portLabel, 3, 0)
grid.addWidget(port, 3, 1)
- grid.addWidget(sslLabel, 4, 0)
- grid.addWidget(ssl, 4, 1)
- grid.addWidget(userLabel, 5, 0)
- grid.addWidget(user, 5, 1)
- grid.addWidget(pwLabel, 6, 0)
- grid.addWidget(password, 6, 1)
- grid.addWidget(cancel, 7, 0)
- grid.addWidget(save, 7, 1)
+ grid.addWidget(userLabel, 4, 0)
+ grid.addWidget(user, 4, 1)
+ grid.addWidget(pwLabel, 5, 0)
+ grid.addWidget(password, 5, 1)
+ grid.addWidget(cancel, 6, 0)
+ grid.addWidget(save, 6, 1)
self.setLayout(grid)
self.controls = {}
self.controls["name"] = name
self.controls["host"] = host
- self.controls["ssl"] = ssl
self.controls["local"] = local
self.controls["user"] = user
self.controls["password"] = password
@@ -245,22 +242,18 @@ class ConnectionManager(QWidget):
data["local"] = False
self.controls["local"].setChecked(data["local"])
if not data["local"]:
- self.controls["ssl"].setChecked(data["ssl"])
self.controls["user"].setText(data["user"])
self.controls["password"].setText(data["password"])
self.controls["port"].setValue(int(data["port"]))
self.controls["host"].setText(data["host"])
- self.controls["ssl"].setDisabled(False)
self.controls["user"].setDisabled(False)
self.controls["password"].setDisabled(False)
self.controls["port"].setDisabled(False)
self.controls["host"].setDisabled(False)
else:
- self.controls["ssl"].setChecked(False)
self.controls["user"].setText("")
self.controls["port"].setValue(1)
self.controls["host"].setText("")
- self.controls["ssl"].setDisabled(True)
self.controls["user"].setDisabled(True)
self.controls["password"].setDisabled(True)
self.controls["port"].setDisabled(True)
@@ -268,13 +261,11 @@ class ConnectionManager(QWidget):
def slotLocalChanged(self, val):
if val == 2:
- self.controls["ssl"].setDisabled(True)
self.controls["user"].setDisabled(True)
self.controls["password"].setDisabled(True)
self.controls["port"].setDisabled(True)
self.controls["host"].setDisabled(True)
elif val == 0:
- self.controls["ssl"].setDisabled(False)
self.controls["user"].setDisabled(False)
self.controls["password"].setDisabled(False)
self.controls["port"].setDisabled(False)
@@ -286,7 +277,6 @@ class ConnectionManager(QWidget):
d["default"] = self.default
d["name"] = self.controls["name"].text()
d["local"] = self.controls["local"].isChecked()
- d["ssl"] = self.controls["ssl"].isChecked()
d["user"] = self.controls["user"].text()
d["password"] = self.controls["password"].text()
d["host"] = self.controls["host"].text()
diff --git a/module/gui/Overview.py b/module/gui/Overview.py
index ad63bf9fd..72daf2e46 100644
--- a/module/gui/Overview.py
+++ b/module/gui/Overview.py
@@ -28,7 +28,7 @@ def formatSpeed(speed):
while speed > 1000:
speed /= 1024.0
steps += 1
- return "%i %s" % (speed, sizes[steps])
+ return "%.2f %s" % (speed, sizes[steps])
class OverviewModel(QAbstractListModel):
PackageName = 10
diff --git a/module/gui/Queue.py b/module/gui/Queue.py
index 5acbf2eb3..977dd6e9a 100644
--- a/module/gui/Queue.py
+++ b/module/gui/Queue.py
@@ -44,7 +44,7 @@ def formatSpeed(speed):
while speed > 1000:
speed /= 1024.0
steps += 1
- return "%i %s" % (speed, sizes[steps])
+ return "%.2f %s" % (speed, sizes[steps])
class QueueModel(CollectorModel):
def __init__(self, view, connector):
@@ -95,6 +95,10 @@ class QueueModel(CollectorModel):
CollectorModel.removeEvent(self, event)
self.updateCount()
+ def updateEvent(self, event):
+ CollectorModel.updateEvent(self, event)
+ self.updateCount()
+
def updateCount(self):
packageCount = len(self._data)
fileCount = 0
@@ -308,9 +312,9 @@ class QueueView(CollectorView):
self.setColumnWidth(0, 300)
self.setColumnWidth(1, 100)
- self.setColumnWidth(2, 130)
+ self.setColumnWidth(2, 140)
self.setColumnWidth(3, 50)
- self.setColumnWidth(4, 120)
+ self.setColumnWidth(4, 130)
self.setColumnWidth(5, 70)
self.setEditTriggers(QAbstractItemView.NoEditTriggers)
diff --git a/module/gui/connector.py b/module/gui/connector.py
index a9cb0610c..5acfdfc8b 100644
--- a/module/gui/connector.py
+++ b/module/gui/connector.py
@@ -26,13 +26,8 @@ from PyQt4.QtGui import *
import socket
-from module.remote.thriftbackend.thriftgen.pyload import Pyload
-from module.remote.thriftbackend.thriftgen.pyload.ttypes import *
-from module.remote.thriftbackend.Socket import Socket
-from module.remote.thriftbackend.Protocol import Protocol
-
-from thrift import Thrift
-from thrift.transport import TTransport
+from module.remote.thriftbackend.ThriftClient import ThriftClient, WrongLogin, NoSSL, NoConnection
+from thrift.Thrift import TException
class Connector(QObject):
def __init__(self):
@@ -55,16 +50,17 @@ class Connector(QObject):
self.ssl = ssl
def connectProxy(self):
- transport = Socket(self.host, self.port, self.ssl)
- transport = TTransport.TBufferedTransport(transport)
- protocol = Protocol(transport)
- client = Pyload.Client(protocol)
-
- transport.open()
-
- if not client.login(self.user, self.password):
+ try:
+ client = ThriftClient(self.host, self.port, self.user, self.password)
+ except WrongLogin:
self.emit(SIGNAL("error_box"), "bad login credentials")
return False
+ except NoSSL:
+ self.emit(SIGNAL("error_box"), "no ssl support")
+ return False
+ except NoConnection:
+ self.emit(SIGNAL("connectionLost"))
+ return False
self.proxy = DispatchRPC(self.mutex, client)
self.connect(self.proxy, SIGNAL("proxy_error"), self._proxyError)
@@ -113,15 +109,21 @@ class DispatchRPC(QObject):
self.f = f
self.mutex = mutex
self.dispatcher = dispatcher
- self.error = True
def __call__(self, *args, **kwargs):
+ lost = False
+ error = False
try:
return self.f(*args, **kwargs)
except socket.error:
- self.dispatcher.emit(SIGNAL("connectionLost"))
+ lost = True
+ except TException:
+ lost = True
except Exception, e:
- if self.error:
- self.dispatcher.emit(SIGNAL("proxy_error"), self.dispatcher.fname, e)
+ err = e
finally:
self.mutex.unlock()
+ if lost:
+ self.dispatcher.emit(SIGNAL("connectionLost"))
+ if error:
+ self.dispatcher.emit(SIGNAL("proxy_error"), self.dispatcher.fname, error)