QuLab 2.10.10__cp313-cp313-macosx_10_13_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qulab/__init__.py +33 -0
- qulab/__main__.py +4 -0
- qulab/cli/__init__.py +0 -0
- qulab/cli/commands.py +30 -0
- qulab/cli/config.py +170 -0
- qulab/cli/decorators.py +28 -0
- qulab/dicttree.py +523 -0
- qulab/executor/__init__.py +5 -0
- qulab/executor/analyze.py +188 -0
- qulab/executor/cli.py +434 -0
- qulab/executor/load.py +563 -0
- qulab/executor/registry.py +185 -0
- qulab/executor/schedule.py +543 -0
- qulab/executor/storage.py +615 -0
- qulab/executor/template.py +259 -0
- qulab/executor/utils.py +194 -0
- qulab/expression.py +827 -0
- qulab/fun.cpython-313-darwin.so +0 -0
- qulab/monitor/__init__.py +1 -0
- qulab/monitor/__main__.py +8 -0
- qulab/monitor/config.py +41 -0
- qulab/monitor/dataset.py +77 -0
- qulab/monitor/event_queue.py +54 -0
- qulab/monitor/mainwindow.py +234 -0
- qulab/monitor/monitor.py +115 -0
- qulab/monitor/ploter.py +123 -0
- qulab/monitor/qt_compat.py +16 -0
- qulab/monitor/toolbar.py +265 -0
- qulab/scan/__init__.py +2 -0
- qulab/scan/curd.py +221 -0
- qulab/scan/models.py +554 -0
- qulab/scan/optimize.py +76 -0
- qulab/scan/query.py +387 -0
- qulab/scan/record.py +603 -0
- qulab/scan/scan.py +1166 -0
- qulab/scan/server.py +450 -0
- qulab/scan/space.py +213 -0
- qulab/scan/utils.py +234 -0
- qulab/storage/__init__.py +0 -0
- qulab/storage/__main__.py +51 -0
- qulab/storage/backend/__init__.py +0 -0
- qulab/storage/backend/redis.py +204 -0
- qulab/storage/base_dataset.py +352 -0
- qulab/storage/chunk.py +60 -0
- qulab/storage/dataset.py +127 -0
- qulab/storage/file.py +273 -0
- qulab/storage/models/__init__.py +22 -0
- qulab/storage/models/base.py +4 -0
- qulab/storage/models/config.py +28 -0
- qulab/storage/models/file.py +89 -0
- qulab/storage/models/ipy.py +58 -0
- qulab/storage/models/models.py +88 -0
- qulab/storage/models/record.py +161 -0
- qulab/storage/models/report.py +22 -0
- qulab/storage/models/tag.py +93 -0
- qulab/storage/storage.py +95 -0
- qulab/sys/__init__.py +2 -0
- qulab/sys/chat.py +688 -0
- qulab/sys/device/__init__.py +3 -0
- qulab/sys/device/basedevice.py +255 -0
- qulab/sys/device/loader.py +86 -0
- qulab/sys/device/utils.py +79 -0
- qulab/sys/drivers/FakeInstrument.py +68 -0
- qulab/sys/drivers/__init__.py +0 -0
- qulab/sys/ipy_events.py +125 -0
- qulab/sys/net/__init__.py +0 -0
- qulab/sys/net/bencoder.py +205 -0
- qulab/sys/net/cli.py +169 -0
- qulab/sys/net/dhcp.py +543 -0
- qulab/sys/net/dhcpd.py +176 -0
- qulab/sys/net/kad.py +1142 -0
- qulab/sys/net/kcp.py +192 -0
- qulab/sys/net/nginx.py +194 -0
- qulab/sys/progress.py +190 -0
- qulab/sys/rpc/__init__.py +0 -0
- qulab/sys/rpc/client.py +0 -0
- qulab/sys/rpc/exceptions.py +96 -0
- qulab/sys/rpc/msgpack.py +1052 -0
- qulab/sys/rpc/msgpack.pyi +41 -0
- qulab/sys/rpc/router.py +35 -0
- qulab/sys/rpc/rpc.py +412 -0
- qulab/sys/rpc/serialize.py +139 -0
- qulab/sys/rpc/server.py +29 -0
- qulab/sys/rpc/socket.py +29 -0
- qulab/sys/rpc/utils.py +25 -0
- qulab/sys/rpc/worker.py +0 -0
- qulab/sys/rpc/zmq_socket.py +227 -0
- qulab/tools/__init__.py +0 -0
- qulab/tools/connection_helper.py +39 -0
- qulab/typing.py +2 -0
- qulab/utils.py +95 -0
- qulab/version.py +1 -0
- qulab/visualization/__init__.py +188 -0
- qulab/visualization/__main__.py +71 -0
- qulab/visualization/_autoplot.py +464 -0
- qulab/visualization/plot_circ.py +319 -0
- qulab/visualization/plot_layout.py +408 -0
- qulab/visualization/plot_seq.py +242 -0
- qulab/visualization/qdat.py +152 -0
- qulab/visualization/rot3d.py +23 -0
- qulab/visualization/widgets.py +86 -0
- qulab-2.10.10.dist-info/METADATA +110 -0
- qulab-2.10.10.dist-info/RECORD +107 -0
- qulab-2.10.10.dist-info/WHEEL +5 -0
- qulab-2.10.10.dist-info/entry_points.txt +2 -0
- qulab-2.10.10.dist-info/licenses/LICENSE +21 -0
- qulab-2.10.10.dist-info/top_level.txt +1 -0
qulab/sys/net/dhcpd.py
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
#
|
2
|
+
# Packet format
|
3
|
+
# -------------
|
4
|
+
#
|
5
|
+
# Offset Length Notes
|
6
|
+
# ------ ------ -----
|
7
|
+
#
|
8
|
+
# 0 1 Operation code with 1 being request and 2 being response
|
9
|
+
# 1 1 Hardware type with 1 being "Ethernet 10Mb"
|
10
|
+
# 2 1 Hardware address length with 6 for Ethernet
|
11
|
+
# 3 1 Hops - usually 0 unless DHCP relaying in operation
|
12
|
+
# 4-7 4 Transaction ID (selected randomly by client)
|
13
|
+
# 8-9 2 Seconds - might be used by a server to prioritise requests
|
14
|
+
# 10-11 2 Flags (only most significan bit used for broadcast)
|
15
|
+
# 12-15 4 Client Internet address (might be requested by client)
|
16
|
+
# 16-19 4 Your Internet address (the IP assigned by the server)
|
17
|
+
# 20-23 4 Server Internet address (the IP of the server)
|
18
|
+
# 24-27 4 Gateway Internet address (if DHCP relaying in operation)
|
19
|
+
# 28-43 16 Client hardware address - only first 6 bytes used for Ethernet
|
20
|
+
# 44-107 64 Text name of server (optional)
|
21
|
+
# 108-235 128 Boot file name (optional - used for PXE booting)
|
22
|
+
# 236-239 4 Magic cookie (decimal values 99, 130, 83, 99 )
|
23
|
+
#
|
24
|
+
|
25
|
+
#
|
26
|
+
# DHCP option codes
|
27
|
+
# -----------------
|
28
|
+
#
|
29
|
+
# 1 - Subnet mask
|
30
|
+
# 3 - Router(s)
|
31
|
+
# 6 - DNS name server(s)
|
32
|
+
# 12 - Hostname
|
33
|
+
# 15 - Domain name
|
34
|
+
# 28 - Broadcast address
|
35
|
+
# 33 - Static route
|
36
|
+
# 42 - Network time protocol servers
|
37
|
+
# 51 - IP address lease time
|
38
|
+
# 53 - DHCP Message Type (DHCPDISCOVER, DHCPOFFER, etc)
|
39
|
+
# 54 - Server identifier
|
40
|
+
# 55 - Parameter Request List
|
41
|
+
# 57 - Maximum DHCP Message Size
|
42
|
+
# 58 - Renewal (T1) time value
|
43
|
+
# 59 - Renewal (T2) time value
|
44
|
+
# 60 - Vendor Class Identifier
|
45
|
+
# 61 - Client Identifier
|
46
|
+
# 67 - Boot file name (e.g. PXE booting)
|
47
|
+
# 80 -
|
48
|
+
# 116 -
|
49
|
+
# 119 -
|
50
|
+
# 145 -
|
51
|
+
# 167 -
|
52
|
+
# 171 -
|
53
|
+
#
|
54
|
+
|
55
|
+
import asyncio
|
56
|
+
import logging
|
57
|
+
import socket
|
58
|
+
from typing import NamedTuple
|
59
|
+
|
60
|
+
from waveforms.sys.net.dhcp import (MAGIC_COOKIE, DHCPMessageType, DHCPOption,
|
61
|
+
DHCPPacket)
|
62
|
+
|
63
|
+
logger = logging.getLogger(__name__)
|
64
|
+
|
65
|
+
|
66
|
+
class DHCPServerProtocol:
|
67
|
+
|
68
|
+
def connection_made(self, transport):
|
69
|
+
self.transport = transport
|
70
|
+
address, port = self.transport.get_extra_info('sockname')
|
71
|
+
self.server_ip = '192.168.254.1'
|
72
|
+
|
73
|
+
def connection_lost(self, exc):
|
74
|
+
pass
|
75
|
+
|
76
|
+
def datagram_received(self, data, addr):
|
77
|
+
try:
|
78
|
+
received = DHCPPacket.decode(data)
|
79
|
+
except ValueError as e:
|
80
|
+
logger.error("Error decoding DHCP packet: %s", e)
|
81
|
+
return
|
82
|
+
|
83
|
+
print("\nReceived DHCP packet from %s:%d" % (addr[0], addr[1]))
|
84
|
+
print(received)
|
85
|
+
|
86
|
+
# see if there is a DHCP message type option
|
87
|
+
if 53 not in received.options:
|
88
|
+
return
|
89
|
+
|
90
|
+
messagetype = received.get_option(DHCPOption.DHCP_MSG_TYPE)
|
91
|
+
if (messagetype != DHCPMessageType.DISCOVER) and (
|
92
|
+
messagetype != DHCPMessageType.REQUEST):
|
93
|
+
logger.error(
|
94
|
+
"ignoring: DHCP message type not supported by this implementation"
|
95
|
+
)
|
96
|
+
return
|
97
|
+
|
98
|
+
try:
|
99
|
+
assigned_ip, subnet, gateway = get_ip_from_mac(received.chaddr)
|
100
|
+
except:
|
101
|
+
return
|
102
|
+
|
103
|
+
response = DHCPPacket()
|
104
|
+
response.op = 2
|
105
|
+
response.xid = received.xid
|
106
|
+
response.flags = received.flags
|
107
|
+
response.chaddr = received.chaddr
|
108
|
+
response.yiaddr = assigned_ip
|
109
|
+
response.siaddr = self.server_ip
|
110
|
+
|
111
|
+
if messagetype == DHCPMessageType.DISCOVER:
|
112
|
+
# DHCPOFFER
|
113
|
+
response.set_option(DHCPOption.DHCP_MSG_TYPE,
|
114
|
+
DHCPMessageType.OFFER)
|
115
|
+
elif messagetype == DHCPMessageType.REQUEST:
|
116
|
+
# DHCPACK
|
117
|
+
response.set_option(DHCPOption.DHCP_MSG_TYPE, DHCPMessageType.ACK)
|
118
|
+
else:
|
119
|
+
return
|
120
|
+
|
121
|
+
lease_time = 86400
|
122
|
+
response.set_option(DHCPOption.SUBNET_MASK, subnet)
|
123
|
+
response.set_option(DHCPOption.ROUTER, gateway)
|
124
|
+
response.set_option(DHCPOption.IP_LEASE_TIME, lease_time)
|
125
|
+
response.set_option(DHCPOption.SERVER_ID, self.server_ip)
|
126
|
+
|
127
|
+
response_packet = response.encode()
|
128
|
+
|
129
|
+
# send it
|
130
|
+
print("\nSending DHCP packet to %s:%d" % (addr[0], addr[1]))
|
131
|
+
print(DHCPPacket.decode(response_packet))
|
132
|
+
self.send_packet(response_packet, addr)
|
133
|
+
|
134
|
+
def send_packet(self, packet, addr):
|
135
|
+
if addr == ('0.0.0.0', 68):
|
136
|
+
send_address = ('255.255.255.255', 68)
|
137
|
+
else:
|
138
|
+
send_address = addr
|
139
|
+
self.transport.sendto(packet, send_address)
|
140
|
+
|
141
|
+
|
142
|
+
class IPConfig(NamedTuple):
|
143
|
+
ip: str
|
144
|
+
subnet: str
|
145
|
+
gateway: str
|
146
|
+
|
147
|
+
|
148
|
+
ip_table = {
|
149
|
+
'00:19:AF:04:92:C4':
|
150
|
+
IPConfig(ip='192.168.254.150', subnet='255.255.255.0', gateway='0.0.0.0')
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
def get_ip_from_mac(macaddr):
|
155
|
+
ip_config = ip_table.get(macaddr, None)
|
156
|
+
return ip_config.ip, ip_config.subnet, ip_config.gateway
|
157
|
+
|
158
|
+
|
159
|
+
async def main(server_ip='0.0.0.0'):
|
160
|
+
loop = asyncio.get_running_loop()
|
161
|
+
|
162
|
+
transport, protocol = await loop.create_datagram_endpoint(
|
163
|
+
lambda: DHCPServerProtocol(),
|
164
|
+
local_addr=(server_ip, 67),
|
165
|
+
allow_broadcast=True)
|
166
|
+
|
167
|
+
# print('start', server_ip)
|
168
|
+
|
169
|
+
try:
|
170
|
+
await asyncio.sleep(3600) # Serve for 1 hour.
|
171
|
+
finally:
|
172
|
+
transport.close()
|
173
|
+
|
174
|
+
|
175
|
+
if __name__ == '__main__':
|
176
|
+
asyncio.run(main(server_ip='0.0.0.0'))
|