Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Petit modif #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
#!/usr/bin/env python3

import sys
Expand All @@ -12,6 +13,7 @@
from PyQt4.QtGui import *

from client import SuperClient
import zmq
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il trouve pas zmq sinon...


usage = "usage: %prog [options]"
parser = optparse.OptionParser(usage,version="%prog 0.0.1")
Expand All @@ -23,7 +25,7 @@

class QtSpyWindow(QMainWindow):
def __init__(self, connect_addr):
super(MyWindow, self).__init__()
super(QMainWindow, self).__init__()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

il trouve pas MyWindow...je sais pas si c'est QMainWindow qui doit prendre la place...


self.ctx = zmq.Context()
self.receiver = self.ctx.socket(zmq.SUB)
Expand All @@ -37,7 +39,7 @@ def __init__(self, connect_addr):
self.requests = {}

self.services_views = {}
self.services = SuperClient(ctx)
self.services = SuperClient(self.ctx)

self.__init_gui()

Expand Down Expand Up @@ -90,8 +92,8 @@ def get_textedit(self, nom):

def on_console_send(self, *args):
order = self.console.text()
#Le but est de récupérer le nom du service, la méthode a appeler et les arguments
#on découpe d'abord en trois morceaux avec un regex
#Le but est de recuperer le nom du service, la methode a appeler et les arguments
#on decoupe d'abord en trois morceaux avec un regex
res = re.findall(r"([a-zA-Z_\-]*\.)?([a-zA-Z0-9\-_]+) ?\((.*)\)", order)
service = res[0][0]
if service == '':
Expand All @@ -100,7 +102,7 @@ def on_console_send(self, *args):
service = service[:-1]
method = res[0][1]

#Pour récupérer les arguments comme objets python on va utiliser eval
#Pour recuperer les arguments comme objets python on va utiliser eval
#en remplaçant le dict 'locals' par un contenant seulement la fonctione 'identity'
arguments = "a(%s)" % res[0][2]
def identity(*args, **kwargs):
Expand Down
6 changes: 5 additions & 1 deletion client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# -*- coding: utf-8 -*-
import sys
sys.path.append("/mnt/hgfs/siqi/Documents/Coding/zerobot/python3")

import zerobot
import zmq
import threading
Expand All @@ -23,7 +27,7 @@ def call(self, service, method, args, kwargs):
def add_client(self, service):
if not(service in self.clients.keys()):
client = zerobot.Client("QtSpy-%s" % service, self.connect, service, self.ctx)
client.start(False)
client.start(True)
try:
client.ping(-42, timeout=1, block=False)
except Exception:
Expand Down