blob: 2b740cd06a3fc12fe285932532b07115b89c7b0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
from http.client import HTTPConnection
import os
import socket
import sys
import xmlrpc.client
class UnixStreamHTTPConnection(HTTPConnection):
def connect(self):
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.sock.connect(self.host)
class UnixStreamTransport(xmlrpc.client.Transport, object):
def __init__(self, socket_path):
self.socket_path = socket_path
super().__init__()
def make_connection(self, host):
return UnixStreamHTTPConnection(self.socket_path)
proxy = xmlrpc.client.ServerProxy(
"http://localhost", transport=UnixStreamTransport("search.sock")
)
res = proxy.search(sys.argv[1], sys.argv[2])
print("\n".join(res))
if len(sys.argv) > 3:
for path in os.listdir():
if path.startswith("res"):
os.unlink(path)
for i, path in enumerate(res):
os.symlink(path, f"res{i}")
|