Esempio n. 1
0
 def run(self):
     comm = Communicator(self.port)
     try:
         comm.bind()
         self.response = comm.acceptObject()
     except SocketOpenError, error:
         sys.stderr.write("%d\n%s\n%s\n" % (self.port, traceback(error), error))
Esempio n. 2
0
 def insert_refs(self, widget, data=None):
     refs = self.table.getSelected()
     comm = Communicator(self.REF_LISTEN_PORT)
     nfailed = 0
     sent = False
     try:
         comm.sendObject(refs)
         comm.close()
         sent = True
     except Exception, error:
         pass
Esempio n. 3
0
 def run(self, obj):
     answer = self.answer_t()
     comm = Communicator(self.request_port)
     try:
         comm.open()
         answer.start()
         time.sleep(1)
         comm.sendObject(obj)
     except SocketOpenError, error:
         sys.stderr.write("%d\n%s\n%s\n" % (self.request_port, traceback(error), error))
         self.close_answer(answer)
         return #thread is already dead
Esempio n. 4
0
    def __init__(self, citation):

        self.citation = citation
        self.stopthread = threading.Event()
        self.server = Communicator(CiteManager.REF_LISTEN_PORT)
        self.server.bind()

        threading.Thread.__init__(self)
Esempio n. 5
0
 def write(self, text):
     try:
         comm = Communicator(gtkserver.REQUEST_PORT)
         comm.open()
         comm.sendObject(text)
         comm.close()
     except:
         pass
Esempio n. 6
0
 def close_answer(self, answer):
     try:
         comm = Communicator(answer.port)
         comm.open()
         comm.sendObject("die!")
         comm.close()
     except Exception, error:
         sys.stderr.write("%d\n%s\n%s\n" % (self.request_port, traceback(error), error))
Esempio n. 7
0
class CiteThread(threading.Thread):
    def __init__(self, citation):

        self.citation = citation
        self.stopthread = threading.Event()
        self.server = Communicator(CiteManager.REF_LISTEN_PORT)
        self.server.bind()

        threading.Thread.__init__(self)

    def run(self):
        while not self.stopthread.isSet():
            try:
                objlist = self.server.acceptObject()
                if objlist:  # if we got a list of objects
                    self.citation.addReferences(objlist)
            except Exception, exc:
                pass

        self.server.close()
Esempio n. 8
0
class Server:

    def __init__(self, request_port, answer_port = None):
        self.answer_port = answer_port
        self.request_port = request_port
        self.server = Communicator(self.request_port)
        self.server.bind()
        self.bib = Bibliography()

    def report(self):
        from pygui.gtkserver import report 
        report()

    def run(self):
        while 1:
            ret = ""
            try:
                obj = self.server.acceptObject()
                if isinstance(obj, ServerStop): #end
                    self.stop()
                    return

                ret = self.process(obj)
            except SocketDie:
                return
            except Exception, error:
                sys.stderr.write("%s\n%s\n" % (traceback(error), error))


            try:
                if self.answer_port:
                    comm = Communicator(self.answer_port)
                    comm.open()
                    comm.sendObject(ret)
                    comm.close()
            except SocketOpenError, error:
                sys.stderr.write("%d\n%s\n%s\n" % (self.answer_port, traceback(error), error))
            except Exception, error:
                sys.stderr.write("%s\n%s\n" % (traceback(error), error))
Esempio n. 9
0
 def display_report(cls):
     try:
         import inspect
         frame = inspect.currentframe().f_back.f_back.f_back
         info = inspect.getframeinfo(frame)
         framestr = "%s" % str(info)
         comm = Communicator(cls.port)
         comm.open()
         comm.sendObject(framestr)
         comm.close()
     except Exception, error:
         sys.stderr.write("%s\n" % error)
Esempio n. 10
0
    def run(self):
        while 1:
            ret = ""
            try:
                obj = self.server.acceptObject()
                if isinstance(obj, ServerStop): #end
                    self.stop()
                    return

                ret = self.process(obj)
            except SocketDie:
                return
            except Exception, error:
                sys.stderr.write("%s\n%s\n" % (traceback(error), error))


            try:
                if self.answer_port:
                    comm = Communicator(self.answer_port)
                    comm.open()
                    comm.sendObject(ret)
                    comm.close()
            except SocketOpenError, error:
                sys.stderr.write("%d\n%s\n%s\n" % (self.answer_port, traceback(error), error))
Esempio n. 11
0
 def stop(self):
     self.stopthread.set()
     comm = Communicator(CiteManager.REF_LISTEN_PORT)
     comm.sendObject([])  # send blank array to bring down thread
Esempio n. 12
0
 def __init__(self, request_port, answer_port = None):
     self.answer_port = answer_port
     self.request_port = request_port
     self.server = Communicator(self.request_port)
     self.server.bind()
     self.bib = Bibliography()
Esempio n. 13
0
 def stop(self):
     comm = Communicator(self.server.request_port)
     comm.open()
     comm.sendObject(ServerStop())
     comm.close()
     self.thr.join()