diff options
Diffstat (limited to 'module/gui/connector.py')
-rw-r--r-- | module/gui/connector.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/module/gui/connector.py b/module/gui/connector.py index c16ccd08e..68cc531ce 100644 --- a/module/gui/connector.py +++ b/module/gui/connector.py @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>. - + @author: mkaay """ @@ -33,9 +33,9 @@ class Connector(QObject): """ manages the connection to the pyload core via thrift """ - + firstAttempt = True - + def __init__(self): QObject.__init__(self) self.mutex = QMutex() @@ -48,7 +48,7 @@ class Connector(QObject): self.running = True self.internal = False self.proxy = self.Dummy() - + def setConnectionData(self, host, port, user, password, ssl=False): """ set connection data for connection attempt, called from slotConnect @@ -58,7 +58,7 @@ class Connector(QObject): self.user = user self.password = password self.ssl = ssl - + def connectProxy(self): """ initialize thrift rpc client, @@ -83,25 +83,25 @@ class Connector(QObject): self.emit(SIGNAL("errorBox"), err) Connector.firstAttempt = False return False - + self.proxy = DispatchRPC(self.mutex, client) self.connect(self.proxy, SIGNAL("connectionLost"), self, SIGNAL("connectionLost")) - + server_version = self.proxy.getServerVersion() self.connectionID = uuid().hex - + if not server_version == SERVER_VERSION: self.emit(SIGNAL("errorBox"), _("server is version %(new)s client accepts version %(current)s") % { "new": server_version, "current": SERVER_VERSION}) return False - + return True - + def __getattr__(self, attr): """ redirect rpc calls to dispatcher """ return getattr(self.proxy, attr) - + class Dummy(object): """ dummy rpc proxy, to prevent errors @@ -119,12 +119,12 @@ class DispatchRPC(QObject): wraps the thrift client, to catch critical exceptions (connection lost) adds thread safety """ - + def __init__(self, mutex, server): QObject.__init__(self) self.mutex = mutex self.server = server - + def __getattr__(self, attr): """ redirect and wrap call in Wrapper instance, locks dispatcher @@ -133,17 +133,17 @@ class DispatchRPC(QObject): self.fname = attr f = self.Wrapper(getattr(self.server, attr), self.mutex, self) return f - + class Wrapper(object): """ represents a rpc call """ - + def __init__(self, f, mutex, dispatcher): self.f = f self.mutex = mutex self.dispatcher = dispatcher - + def __call__(self, *args, **kwargs): """ instance is called, rpc is executed |