use bitcoinrpc for "make local"
[bitcoin:spesmilo.git] / ipc.py
1 # -*- coding: utf-8 -*-
2 import sys
3 from PySide.QtCore import *
4
5 class ipc_handler(QThread):
6     have_uri = Signal(object)
7
8     def __init__(self, addr, *args, **kwargs):
9         QThread.__init__(self, *args, **kwargs)
10         self.setTerminationEnabled(True)
11         if sys.platform == 'win32':
12             addr = r'\\.\pipe\%s' % (addr,)
13         self._addr = addr
14
15     def run(self):
16         import multiprocessing.connection
17
18         srv = multiprocessing.connection.Listener(self._addr)
19         self._srv = srv
20
21         while True:
22             c = srv.accept()
23             arg = c.recv_bytes()
24             c.close()
25             self.have_uri.emit(arg)
26
27     def stop(self):
28         self.terminate()
29
30 def ipc_send(addr, arg):
31     import multiprocessing.connection
32
33     cln = multiprocessing.connection.Client(addr)
34     cln.send_bytes(arg)