mirror of
https://github.com/FlipsideCrypto/web3.py.git
synced 2026-02-06 19:06:52 +00:00
32 lines
819 B
Python
Executable File
32 lines
819 B
Python
Executable File
import sys
|
|
|
|
|
|
if sys.platform != 'win32':
|
|
raise ImportError("This module should not be imported on non `win32` platforms")
|
|
|
|
|
|
import win32file # noqa: E402
|
|
import pywintypes # noqa: E402
|
|
|
|
|
|
class NamedPipe(object):
|
|
def __init__(self, ipc_path):
|
|
try:
|
|
self.handle = win32file.CreateFile(
|
|
ipc_path, win32file.GENERIC_READ | win32file.GENERIC_WRITE,
|
|
0, None, win32file.OPEN_EXISTING, 0, None)
|
|
except pywintypes.error as err:
|
|
raise IOError(err)
|
|
|
|
def recv(self, max_length):
|
|
(err, data) = win32file.ReadFile(self.handle, max_length)
|
|
if err:
|
|
raise IOError(err)
|
|
return data
|
|
|
|
def sendall(self, data):
|
|
return win32file.WriteFile(self.handle, data)
|
|
|
|
def close(self):
|
|
self.handle.close()
|