retracesoftware-proxy 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.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.
- retracesoftware/install/patcher.py +21 -2
- retracesoftware/install/record.py +7 -0
- retracesoftware/install/tracer.py +16 -14
- retracesoftware/proxy/gateway.py +3 -112
- retracesoftware/proxy/proxyfactory.py +194 -194
- retracesoftware/proxy/proxysystem.py +88 -67
- retracesoftware/proxy/proxytype.py +213 -85
- retracesoftware/proxy/record.py +80 -83
- retracesoftware/proxy/replay.py +57 -33
- retracesoftware/proxy/stubfactory.py +141 -0
- retracesoftware/proxy/thread.py +1 -1
- {retracesoftware_proxy-0.1.1.dist-info → retracesoftware_proxy-0.1.2.dist-info}/METADATA +1 -1
- retracesoftware_proxy-0.1.2.dist-info/RECORD +27 -0
- retracesoftware_proxy-0.1.1.dist-info/RECORD +0 -26
- {retracesoftware_proxy-0.1.1.dist-info → retracesoftware_proxy-0.1.2.dist-info}/WHEEL +0 -0
- {retracesoftware_proxy-0.1.1.dist-info → retracesoftware_proxy-0.1.2.dist-info}/top_level.txt +0 -0
retracesoftware/proxy/record.py
CHANGED
|
@@ -1,41 +1,24 @@
|
|
|
1
1
|
import retracesoftware.functional as functional
|
|
2
|
-
import
|
|
2
|
+
import retracesoftware.utils as utils
|
|
3
3
|
import retracesoftware.stream as stream
|
|
4
4
|
|
|
5
|
-
from retracesoftware.proxy.proxytype import
|
|
5
|
+
from retracesoftware.proxy.proxytype import *
|
|
6
6
|
# from retracesoftware.proxy.gateway import gateway_pair
|
|
7
7
|
from retracesoftware.proxy.proxysystem import ProxySystem
|
|
8
8
|
from retracesoftware.proxy.thread import write_thread_switch
|
|
9
9
|
from retracesoftware.install.tracer import Tracer
|
|
10
|
+
from retracesoftware.proxy.stubfactory import StubRef, ExtendedRef
|
|
11
|
+
|
|
10
12
|
import sys
|
|
11
13
|
import os
|
|
12
14
|
import types
|
|
15
|
+
import gc
|
|
13
16
|
|
|
14
17
|
class Placeholder:
|
|
15
18
|
__slots__ = ['id', '__weakref__']
|
|
16
19
|
|
|
17
20
|
def __init__(self, id):
|
|
18
21
|
self.id = id
|
|
19
|
-
|
|
20
|
-
class ExtendedProxy:
|
|
21
|
-
__slots__ = []
|
|
22
|
-
|
|
23
|
-
class ProxyRef:
|
|
24
|
-
def __init__(self, module, name):
|
|
25
|
-
self.module = module
|
|
26
|
-
self.name = name
|
|
27
|
-
|
|
28
|
-
def resolve(self):
|
|
29
|
-
return getattr(sys.modules[self.module], self.name)
|
|
30
|
-
|
|
31
|
-
class ProxySpec(ProxyRef):
|
|
32
|
-
def __init__(self, module, name, methods, members):
|
|
33
|
-
super().__init__(module, name)
|
|
34
|
-
self.methods = methods
|
|
35
|
-
self.members = members
|
|
36
|
-
|
|
37
|
-
def __str__(self):
|
|
38
|
-
return f'ProxySpec(module = {self.module}, name = {self.name}, methods = {self.methods}, members = {self.members})'
|
|
39
22
|
|
|
40
23
|
def keys_where_value(pred, dict):
|
|
41
24
|
for key,value in dict.items():
|
|
@@ -116,17 +99,7 @@ class RecordProxySystem(ProxySystem):
|
|
|
116
99
|
utils.thread_switch_monitor(
|
|
117
100
|
functional.repeatedly(functional.sequence(utils.thread_id, self.writer)))
|
|
118
101
|
|
|
119
|
-
# self.sync = lambda function: functional.observer(on_call = functional.always(writer.handle('SYNC')), function = function)
|
|
120
102
|
self.sync = lambda function: functional.firstof(thread_switch_monitor, functional.always(self.writer.handle('SYNC')), function)
|
|
121
|
-
|
|
122
|
-
# trace_handle = writer.handle('TRACE')
|
|
123
|
-
# tracer = Tracer(tracing_config, writer = trace_handle)
|
|
124
|
-
|
|
125
|
-
# on_ext_result = writer.handle('RESULT')
|
|
126
|
-
# on_ext_result = functional.if_then_else(
|
|
127
|
-
# functional.isinstanceof(str), self.writer.handle('RESULT'), functional.sequence(serialize, self.writer))
|
|
128
|
-
|
|
129
|
-
# on_int_call = functional.mapargs(transform = serialize, function = self.writer.handle('CALL'))
|
|
130
103
|
|
|
131
104
|
error = self.writer.handle('ERROR')
|
|
132
105
|
|
|
@@ -139,24 +112,6 @@ class RecordProxySystem(ProxySystem):
|
|
|
139
112
|
|
|
140
113
|
tracer = Tracer(tracing_config, writer = trace_writer)
|
|
141
114
|
|
|
142
|
-
# def wrap_int_to_ext(self, obj): return obj
|
|
143
|
-
# def wrap_ext_to_int(self, obj): return obj
|
|
144
|
-
|
|
145
|
-
# def on_int_call(self, func, *args, **kwargs):
|
|
146
|
-
# pass
|
|
147
|
-
|
|
148
|
-
# def on_ext_result(self, result):
|
|
149
|
-
# pass
|
|
150
|
-
|
|
151
|
-
# def on_ext_error(self, err_type, err_value, err_tarceback):
|
|
152
|
-
# pass
|
|
153
|
-
|
|
154
|
-
# def ext_apply(self, func, *args, **kwargs):
|
|
155
|
-
# return func(*args, **kwargs)
|
|
156
|
-
|
|
157
|
-
# def int_apply(self, func, *args, **kwargs):
|
|
158
|
-
# return func(*args, **kwargs)
|
|
159
|
-
|
|
160
115
|
self.wrap_int_to_ext = watch
|
|
161
116
|
|
|
162
117
|
self.on_int_call = functional.mapargs(transform = serialize, function = self.writer.handle('CALL'))
|
|
@@ -171,22 +126,50 @@ class RecordProxySystem(ProxySystem):
|
|
|
171
126
|
self.ext_apply = self.int_apply = functional.apply
|
|
172
127
|
|
|
173
128
|
super().__init__(thread_state = thread_state, tracer = tracer, immutable_types = immutable_types)
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
# on_ext_result = on_ext_result,
|
|
177
|
-
# on_ext_error = write_error)
|
|
129
|
+
|
|
130
|
+
def dynamic_ext_proxytype(self, cls):
|
|
178
131
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
132
|
+
proxytype = super().dynamic_ext_proxytype(cls)
|
|
133
|
+
|
|
134
|
+
blacklist = ['__class__', '__dict__', '__module__', '__doc__']
|
|
135
|
+
|
|
136
|
+
methods = []
|
|
137
|
+
members = []
|
|
138
|
+
|
|
139
|
+
for key,value in proxytype.__dict__.items():
|
|
140
|
+
if key not in blacklist:
|
|
141
|
+
if utils.is_method_descriptor(value):
|
|
142
|
+
methods.append(key)
|
|
143
|
+
elif not key.startswith("__retrace"):
|
|
144
|
+
members.append(key)
|
|
145
|
+
|
|
146
|
+
ref = self.writer.handle(StubRef(
|
|
147
|
+
name = cls.__name__,
|
|
148
|
+
module = cls.__module__,
|
|
149
|
+
methods = methods,
|
|
150
|
+
members = members))
|
|
151
|
+
|
|
152
|
+
# list(proxytype.__dict__.keys())
|
|
153
|
+
|
|
154
|
+
# if resolveable_name(cls):
|
|
155
|
+
# module, name = resolveable_name(cls)
|
|
156
|
+
# ref = self.writer.handle(StubRef(type = 'dynamic', name = name, module = module))
|
|
157
|
+
# else:
|
|
158
|
+
# blacklist = ['__getattribute__']
|
|
159
|
+
# descriptors = {k: v for k,v in superdict(cls).items() if k not in blacklist and is_descriptor(v) }
|
|
160
|
+
|
|
161
|
+
# methods = [k for k, v in descriptors.items() if utils.is_method_descriptor(v)]
|
|
162
|
+
# members = [k for k, v in descriptors.items() if not utils.is_method_descriptor(v)]
|
|
163
|
+
|
|
164
|
+
# ref = self.writer.handle(ProxySpec(name = cls.__name__,
|
|
165
|
+
# module = cls.__module__,
|
|
166
|
+
# methods = methods,
|
|
167
|
+
# members = members))
|
|
168
|
+
|
|
169
|
+
self.writer.type_serializer[proxytype] = functional.constantly(ref)
|
|
170
|
+
|
|
171
|
+
return proxytype
|
|
172
|
+
|
|
190
173
|
def ext_proxytype(self, cls):
|
|
191
174
|
assert isinstance(cls, type), f"record.proxytype requires a type but was passed: {cls}"
|
|
192
175
|
|
|
@@ -194,31 +177,45 @@ class RecordProxySystem(ProxySystem):
|
|
|
194
177
|
|
|
195
178
|
proxytype = super().ext_proxytype(cls)
|
|
196
179
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
blacklist = ['__getattribute__']
|
|
202
|
-
descriptors = {k: v for k,v in superdict(cls).items() if k not in blacklist and is_descriptor(v) }
|
|
180
|
+
assert resolve(cls) is cls
|
|
181
|
+
|
|
182
|
+
# ref = self.writer.handle(StubRef(name = cls.__name__,
|
|
183
|
+
# module = cls.__module__))
|
|
203
184
|
|
|
204
|
-
|
|
205
|
-
|
|
185
|
+
# if resolveable_name(cls):
|
|
186
|
+
# module, name = resolveable_name(cls)
|
|
187
|
+
# ref = self.writer.handle(StubRef(name = cls.__name__, module = cls.__module__))
|
|
188
|
+
# else:
|
|
189
|
+
# blacklist = ['__getattribute__']
|
|
190
|
+
# descriptors = {k: v for k,v in superdict(cls).items() if k not in blacklist and is_descriptor(v) }
|
|
206
191
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
192
|
+
# methods = [k for k, v in descriptors.items() if utils.is_method_descriptor(v)]
|
|
193
|
+
# members = [k for k, v in descriptors.items() if not utils.is_method_descriptor(v)]
|
|
194
|
+
|
|
195
|
+
# ref = self.writer.handle(ProxySpec(name = cls.__name__,
|
|
196
|
+
# module = cls.__module__,
|
|
197
|
+
# methods = methods,
|
|
198
|
+
# members = members))
|
|
211
199
|
|
|
212
|
-
self.writer.type_serializer[proxytype] = functional.constantly(ref)
|
|
200
|
+
# self.writer.type_serializer[proxytype] = functional.constantly(ref)
|
|
213
201
|
return proxytype
|
|
214
202
|
|
|
215
|
-
def extend_type(self, base):
|
|
216
203
|
|
|
217
|
-
|
|
218
|
-
return self.extended_types[base]
|
|
204
|
+
def extend_type(self, cls):
|
|
219
205
|
|
|
220
|
-
|
|
206
|
+
if cls in self.extended_types:
|
|
207
|
+
return self.extended_types[cls]
|
|
208
|
+
|
|
209
|
+
extended = super().extend_type(cls)
|
|
221
210
|
|
|
222
|
-
self.extended_types[
|
|
211
|
+
self.extended_types[cls] = extended
|
|
212
|
+
|
|
213
|
+
ref = self.writer.handle(ExtendedRef(name = cls.__name__,
|
|
214
|
+
module = cls.__module__))
|
|
215
|
+
|
|
216
|
+
# for binding?
|
|
217
|
+
# self.writer(ref)
|
|
218
|
+
|
|
219
|
+
self.writer.type_serializer[extended] = functional.constantly(ref)
|
|
223
220
|
|
|
224
221
|
return extended
|
retracesoftware/proxy/replay.py
CHANGED
|
@@ -4,34 +4,42 @@ import retracesoftware.stream as stream
|
|
|
4
4
|
|
|
5
5
|
from retracesoftware.install.tracer import Tracer
|
|
6
6
|
from retracesoftware.proxy.thread import per_thread_messages
|
|
7
|
-
from retracesoftware.proxy.proxytype import
|
|
7
|
+
from retracesoftware.proxy.proxytype import *
|
|
8
8
|
# from retracesoftware.proxy.gateway import gateway_pair
|
|
9
|
-
from retracesoftware.proxy.record import
|
|
10
|
-
from retracesoftware.proxy.proxysystem import ProxySystem
|
|
9
|
+
from retracesoftware.proxy.record import StubRef, Placeholder
|
|
10
|
+
from retracesoftware.proxy.proxysystem import ProxySystem, RetraceError
|
|
11
|
+
from retracesoftware.proxy.stubfactory import StubFactory, StubFunction
|
|
11
12
|
|
|
12
13
|
import os
|
|
13
14
|
import weakref
|
|
15
|
+
import traceback
|
|
14
16
|
# we can have a dummy method descriptor, its has a __name__ and when called, returns the next element
|
|
15
17
|
|
|
16
18
|
# for types, we can patch the __new__ method
|
|
17
19
|
# do it from C and immutable types can be patched too
|
|
18
20
|
# patch the tp_new pointer?
|
|
19
21
|
|
|
22
|
+
class ReplayError(RetraceError):
|
|
23
|
+
pass
|
|
24
|
+
|
|
20
25
|
class ReplayProxySystem(ProxySystem):
|
|
21
26
|
|
|
22
27
|
def stubtype(self, cls):
|
|
28
|
+
print(f'In stubtype, class: {cls}')
|
|
29
|
+
assert not issubclass(cls, Proxy)
|
|
30
|
+
|
|
23
31
|
return dynamic_proxytype(handler = self.ext_handler, cls = cls)
|
|
24
32
|
|
|
25
33
|
def create_stub(self): return True
|
|
26
34
|
|
|
27
|
-
def stubtype_from_spec(self, spec):
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
# def stubtype_from_spec(self, spec):
|
|
36
|
+
# print (f'FOOO!!! {spec}')
|
|
37
|
+
# return stubtype_from_spec(
|
|
38
|
+
# handler = self.ext_handler,
|
|
39
|
+
# module = spec.module,
|
|
40
|
+
# name = spec.name,
|
|
41
|
+
# methods = spec.methods,
|
|
42
|
+
# members = spec.members)
|
|
35
43
|
|
|
36
44
|
@utils.striptraceback
|
|
37
45
|
def next_result(self):
|
|
@@ -55,7 +63,8 @@ class ReplayProxySystem(ProxySystem):
|
|
|
55
63
|
err_value = self.messages()
|
|
56
64
|
utils.raise_exception(err_type, err_value)
|
|
57
65
|
else:
|
|
58
|
-
|
|
66
|
+
if type(next) is str: print('FOOBAR!!!!')
|
|
67
|
+
assert type(next) is not str
|
|
59
68
|
return next
|
|
60
69
|
|
|
61
70
|
def bind(self, obj):
|
|
@@ -78,6 +87,15 @@ class ReplayProxySystem(ProxySystem):
|
|
|
78
87
|
self.reader.path = self.new_child_path(self.reader.path)
|
|
79
88
|
super().after_fork_in_child()
|
|
80
89
|
|
|
90
|
+
# def dynamic_ext_proxytype(self, cls):
|
|
91
|
+
# raise Exception('dynamic_ext_proxytype should not be called in replay')
|
|
92
|
+
|
|
93
|
+
def proxy_function(self, obj):
|
|
94
|
+
func = functional.repeatedly(self.next_result)
|
|
95
|
+
func.__name__ = obj.__name__
|
|
96
|
+
|
|
97
|
+
return super().proxy_function(func)
|
|
98
|
+
|
|
81
99
|
def __init__(self,
|
|
82
100
|
thread_state,
|
|
83
101
|
immutable_types,
|
|
@@ -96,15 +114,19 @@ class ReplayProxySystem(ProxySystem):
|
|
|
96
114
|
|
|
97
115
|
self.messages = functional.sequence(per_thread_messages(reader), deserialize)
|
|
98
116
|
|
|
117
|
+
self.stub_factory = StubFactory(thread_state = thread_state, next_result = self.next_result)
|
|
118
|
+
|
|
99
119
|
# messages = reader
|
|
100
120
|
|
|
101
121
|
def readnext():
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
122
|
+
with thread_state.select('disabled'):
|
|
123
|
+
try:
|
|
124
|
+
return self.messages()
|
|
125
|
+
except Exception as error:
|
|
126
|
+
# print(f'Error reading stream: {error}')
|
|
127
|
+
traceback.print_exc()
|
|
128
|
+
|
|
129
|
+
os._exit(1)
|
|
108
130
|
|
|
109
131
|
# print(f'read: {obj}')
|
|
110
132
|
# return obj
|
|
@@ -119,7 +141,7 @@ class ReplayProxySystem(ProxySystem):
|
|
|
119
141
|
def read_required(required):
|
|
120
142
|
obj = readnext()
|
|
121
143
|
if obj != required:
|
|
122
|
-
print(f'
|
|
144
|
+
print(f'Replay: {required} Record: {obj}')
|
|
123
145
|
for i in range(5):
|
|
124
146
|
print(readnext())
|
|
125
147
|
|
|
@@ -128,13 +150,14 @@ class ReplayProxySystem(ProxySystem):
|
|
|
128
150
|
raise Exception(f'Expected: {required} but got: {obj}')
|
|
129
151
|
|
|
130
152
|
def trace_writer(name, *args):
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
153
|
+
with thread_state.select('disabled'):
|
|
154
|
+
print(f'Trace: {name} {args}')
|
|
155
|
+
|
|
156
|
+
read_required('TRACE')
|
|
157
|
+
read_required(name)
|
|
135
158
|
|
|
136
|
-
|
|
137
|
-
|
|
159
|
+
for arg in args:
|
|
160
|
+
read_required(arg)
|
|
138
161
|
|
|
139
162
|
# self.tracer = Tracer(tracing_config, writer = trace_writer)
|
|
140
163
|
# self.immutable_types = immutable_types
|
|
@@ -147,10 +170,12 @@ class ReplayProxySystem(ProxySystem):
|
|
|
147
170
|
# immutable_types.add(cls)
|
|
148
171
|
|
|
149
172
|
# add_stubtype = functional.side_effect(foo)
|
|
150
|
-
add_stubtype = functional.side_effect(immutable_types.add)
|
|
173
|
+
# add_stubtype = functional.side_effect(immutable_types.add)
|
|
174
|
+
|
|
175
|
+
# reader.type_deserializer[ProxyRef] = functional.sequence(lambda ref: ref.resolve(), self.stubtype, add_stubtype)
|
|
151
176
|
|
|
152
|
-
reader.type_deserializer[
|
|
153
|
-
reader.type_deserializer[ProxySpec] = functional.sequence(self.stubtype_from_spec, add_stubtype)
|
|
177
|
+
reader.type_deserializer[StubRef] = self.stub_factory
|
|
178
|
+
# reader.type_deserializer[ProxySpec] = functional.sequence(self.stubtype_from_spec, add_stubtype)
|
|
154
179
|
|
|
155
180
|
# on_ext_result = functional.if_then_else(
|
|
156
181
|
# functional.is_instanceof(str), writer.handle('RESULT'), writer)
|
|
@@ -158,12 +183,11 @@ class ReplayProxySystem(ProxySystem):
|
|
|
158
183
|
# def int_proxytype(gateway):
|
|
159
184
|
# return lambda cls: dynamic_int_proxytype(handler = gateway, cls = cls, bind = self.bind)
|
|
160
185
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
create_stubs = functional.walker(functional.when(is_stub_type, lambda cls: cls()))
|
|
186
|
+
# create_stubs = functional.walker(functional.when(is_stub_ref, lambda stub: stub.create()))
|
|
187
|
+
# create_stubs = functional.walker(functional.when(is_stub_type, lambda cls: cls()))
|
|
165
188
|
|
|
166
|
-
self.ext_apply = functional.repeatedly(functional.sequence(self.next_result, create_stubs))
|
|
189
|
+
# self.ext_apply = functional.repeatedly(functional.sequence(self.next_result, create_stubs))
|
|
190
|
+
# self.ext_apply = functional.repeatedly(self.next_result)
|
|
167
191
|
|
|
168
192
|
def read_sync(): read_required('SYNC')
|
|
169
193
|
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
import retracesoftware.functional as functional
|
|
5
|
+
import retracesoftware.utils as utils
|
|
6
|
+
|
|
7
|
+
class Stub:
|
|
8
|
+
__slots__ = []
|
|
9
|
+
|
|
10
|
+
class ExtendedRef:
|
|
11
|
+
def __init__(self, module, name):
|
|
12
|
+
self.type = type
|
|
13
|
+
self.module = module
|
|
14
|
+
|
|
15
|
+
class StubRef:
|
|
16
|
+
def __init__(self, module, name, methods, members):
|
|
17
|
+
self.name = name
|
|
18
|
+
self.module = module
|
|
19
|
+
self.methods = methods
|
|
20
|
+
self.members = members
|
|
21
|
+
|
|
22
|
+
def __str__(self):
|
|
23
|
+
return f'StubRef(module = {self.module}, name = {self.name}, methods = {self.methods}, members = {self.members})'
|
|
24
|
+
|
|
25
|
+
def resolve(module, name):
|
|
26
|
+
try:
|
|
27
|
+
return getattr(sys.modules[module], name)
|
|
28
|
+
except:
|
|
29
|
+
return None
|
|
30
|
+
|
|
31
|
+
class StubMethodDescriptor(functional.repeatedly):
|
|
32
|
+
def __init__(self, name, next_result):
|
|
33
|
+
super().__init__(next_result)
|
|
34
|
+
self.__name__ = name
|
|
35
|
+
|
|
36
|
+
def __str__(self):
|
|
37
|
+
return f"stub - {__name__}"
|
|
38
|
+
|
|
39
|
+
class StubMemberDescriptor:
|
|
40
|
+
def __init__(self, name, next_result):
|
|
41
|
+
self.next_result = next_result
|
|
42
|
+
self.__name__ = name
|
|
43
|
+
|
|
44
|
+
def __get__(self, instance, owner):
|
|
45
|
+
if instance is None:
|
|
46
|
+
return self
|
|
47
|
+
|
|
48
|
+
return self.next_result()
|
|
49
|
+
|
|
50
|
+
def __set__(self, instance, value):
|
|
51
|
+
return self.next_result()
|
|
52
|
+
|
|
53
|
+
def __delete__(self, instance):
|
|
54
|
+
return self.next_result()
|
|
55
|
+
|
|
56
|
+
def __str__(self):
|
|
57
|
+
return f"stub member - {__name__}"
|
|
58
|
+
|
|
59
|
+
class StubFunction(functional.repeatedly):
|
|
60
|
+
def __init__(self, name, next_result):
|
|
61
|
+
super().__init__(next_result)
|
|
62
|
+
self.__name__ = name
|
|
63
|
+
|
|
64
|
+
def __str__(self):
|
|
65
|
+
return f"stub function - {__name__}"
|
|
66
|
+
|
|
67
|
+
class StubFactory:
|
|
68
|
+
|
|
69
|
+
__slots__ = ['next_result', 'thread_state', 'cache']
|
|
70
|
+
|
|
71
|
+
def __init__(self, thread_state, next_result):
|
|
72
|
+
self.next_result = next_result
|
|
73
|
+
self.thread_state = thread_state
|
|
74
|
+
self.cache = {}
|
|
75
|
+
|
|
76
|
+
def create_member(self, name):
|
|
77
|
+
def disabled(*args, **kwargs):
|
|
78
|
+
if self.thread_state.value == 'disabled' and name == '__repr__':
|
|
79
|
+
return f"stub member - {name}"
|
|
80
|
+
else:
|
|
81
|
+
print(f'Error trying to call member descriptor: {name} {args} {kwargs}, retrace mode: {self.thread_state.value}')
|
|
82
|
+
utils.sigtrap(None)
|
|
83
|
+
os._exit(1)
|
|
84
|
+
|
|
85
|
+
next_result = self.thread_state.dispatch(disabled, external = self.next_result)
|
|
86
|
+
|
|
87
|
+
return StubMemberDescriptor(name = name, next_result = next_result)
|
|
88
|
+
|
|
89
|
+
def create_method(self, name):
|
|
90
|
+
|
|
91
|
+
def disabled(*args, **kwargs):
|
|
92
|
+
if self.thread_state.value == 'disabled' and name == '__repr__':
|
|
93
|
+
return f"stub - {name}"
|
|
94
|
+
else:
|
|
95
|
+
print(f'Error trying to call descriptor: {name} {args} {kwargs}, retrace mode: {self.thread_state.value}')
|
|
96
|
+
utils.sigtrap(None)
|
|
97
|
+
os._exit(1)
|
|
98
|
+
|
|
99
|
+
next_result = self.thread_state.dispatch(disabled, external = self.next_result)
|
|
100
|
+
|
|
101
|
+
func = functional.repeatedly(next_result)
|
|
102
|
+
func.__name__ = name
|
|
103
|
+
|
|
104
|
+
return func
|
|
105
|
+
|
|
106
|
+
def create_stubtype(self, spec):
|
|
107
|
+
|
|
108
|
+
print(f'FOOO: {spec.module}')
|
|
109
|
+
slots = {
|
|
110
|
+
'__module__': spec.module,
|
|
111
|
+
'__qualname__': spec.name,
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
for method in spec.methods:
|
|
115
|
+
slots[method] = self.create_method(method)
|
|
116
|
+
assert utils.is_method_descriptor(slots[method])
|
|
117
|
+
|
|
118
|
+
for member in spec.members:
|
|
119
|
+
slots[member] = self.create_member(member)
|
|
120
|
+
|
|
121
|
+
resolved = resolve(spec.module, spec.name)
|
|
122
|
+
|
|
123
|
+
if isinstance(resolved, type):
|
|
124
|
+
slots['__class__'] = property(functional.repeatedly(resolved))
|
|
125
|
+
|
|
126
|
+
stubtype = type(spec.name, (Stub, ), slots)
|
|
127
|
+
|
|
128
|
+
for method in spec.methods:
|
|
129
|
+
slots[method].__objclass__ = stubtype
|
|
130
|
+
|
|
131
|
+
return stubtype
|
|
132
|
+
|
|
133
|
+
def __call__(self, spec):
|
|
134
|
+
print(f'In stubFactory.__call__ {spec}')
|
|
135
|
+
if spec not in self.cache:
|
|
136
|
+
self.cache[spec] = self.create_stubtype(spec)
|
|
137
|
+
|
|
138
|
+
stubtype = self.cache[spec]
|
|
139
|
+
stub = stubtype.__new__(stubtype)
|
|
140
|
+
print(f'In stubFactory created new')
|
|
141
|
+
return stub
|
retracesoftware/proxy/thread.py
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
retracesoftware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
retracesoftware/config.json,sha256=zhi3DZKG0pIT3Mh2EUXlzQai-U6YrknueOjMJLwNKxY,8281
|
|
3
|
+
retracesoftware/install/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
retracesoftware/install/config.py,sha256=EzE5ifQF2lo--hu2njI4T0FJ-zlnWDJV6i7x0DMkVTw,1364
|
|
5
|
+
retracesoftware/install/edgecases.py,sha256=NR3lyvad9sRsyeDv_Ya8V4xMgPsMPOi9rMcnFOJGOEA,6330
|
|
6
|
+
retracesoftware/install/globals.py,sha256=F8XvIoZQQ10gSRalk30dvdKllxlwxkaggYY6FogLDxY,510
|
|
7
|
+
retracesoftware/install/install.py,sha256=nHnXjLnZDcY2untKR7BsPJEAcwoHfvXqgCmdHLiwRPE,5104
|
|
8
|
+
retracesoftware/install/patcher.py,sha256=Bqr1uwo7Kh4a1VASUfiAd0N7CI40GGyxuH6Zv9c5ir8,17259
|
|
9
|
+
retracesoftware/install/predicate.py,sha256=tX7NQc0rGkyyHYO3mduYHcJHbw1wczT53m_Dpkzo6do,2679
|
|
10
|
+
retracesoftware/install/record.py,sha256=tseF_jV4k4HLPTgBPJdjcahl4EQqagoiisMAdGNC52Q,3257
|
|
11
|
+
retracesoftware/install/references.py,sha256=0nUY_9BkeFz2imcw97rcJNq2jqISCB8dysBbCrh1eCo,1623
|
|
12
|
+
retracesoftware/install/replay.py,sha256=SV7-k05xZFiNfBaxrlLrqbB8-i01IPvnJQjRj9zuinI,1828
|
|
13
|
+
retracesoftware/install/tracer.py,sha256=NFilwwtopDrEXjh4ZLkwyIgvPvzApQYC6BA78B11WTQ,4675
|
|
14
|
+
retracesoftware/install/typeutils.py,sha256=_a1PuwdCsYjG1Nkd77V-flqYtwbD4RkJVKn6Z-xABL4,1813
|
|
15
|
+
retracesoftware/proxy/__init__.py,sha256=ZlDZIuUmKFsE9Tvfd2EKGabTepqv8nrbr5pQhCM3IKc,193
|
|
16
|
+
retracesoftware/proxy/gateway.py,sha256=xESohWXkiNm4ZutU0RgWUwxjxcBWRQ4rQyxIGQXv_F4,1590
|
|
17
|
+
retracesoftware/proxy/proxyfactory.py,sha256=qhOqDfMJnLDNkQs26JqDB431MwjjRhGQi8xupJ45asg,12272
|
|
18
|
+
retracesoftware/proxy/proxysystem.py,sha256=JZmi5EWI3B_l5zbq2KsFUTcD9bEsF3EjBhck_IiBmmE,6966
|
|
19
|
+
retracesoftware/proxy/proxytype.py,sha256=XiCFDn6DeMoZ9tOq-VDZnsskkCfhJPSxrguIBxLWmws,13622
|
|
20
|
+
retracesoftware/proxy/record.py,sha256=BGcYEzTXikHPIJXxhfITKA1uz0FcWIv92xfBheK-KCo,7480
|
|
21
|
+
retracesoftware/proxy/replay.py,sha256=GHoXfCr-k23aKCOSjv0TH-nV-bJJ9l279dyTn5-982w,7949
|
|
22
|
+
retracesoftware/proxy/stubfactory.py,sha256=RH4Xw9BTh_mPz81j6lmoRXfXm7RukxCxzk_H3se_shk,4152
|
|
23
|
+
retracesoftware/proxy/thread.py,sha256=-SvnyVbANkmX2lLRpOvFtkpdpAoF6DhnnYdOOs7Q8vo,1379
|
|
24
|
+
retracesoftware_proxy-0.1.2.dist-info/METADATA,sha256=C2ZwqWsiW4Hs0HPbadhuecKiDB8etu9dfBGYrt7Q4q0,202
|
|
25
|
+
retracesoftware_proxy-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
26
|
+
retracesoftware_proxy-0.1.2.dist-info/top_level.txt,sha256=hYHsR6txLidmqvjBMITpIHvmJJbmoCAgr76-IpZPRz8,16
|
|
27
|
+
retracesoftware_proxy-0.1.2.dist-info/RECORD,,
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
retracesoftware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
retracesoftware/config.json,sha256=zhi3DZKG0pIT3Mh2EUXlzQai-U6YrknueOjMJLwNKxY,8281
|
|
3
|
-
retracesoftware/install/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
retracesoftware/install/config.py,sha256=EzE5ifQF2lo--hu2njI4T0FJ-zlnWDJV6i7x0DMkVTw,1364
|
|
5
|
-
retracesoftware/install/edgecases.py,sha256=NR3lyvad9sRsyeDv_Ya8V4xMgPsMPOi9rMcnFOJGOEA,6330
|
|
6
|
-
retracesoftware/install/globals.py,sha256=F8XvIoZQQ10gSRalk30dvdKllxlwxkaggYY6FogLDxY,510
|
|
7
|
-
retracesoftware/install/install.py,sha256=nHnXjLnZDcY2untKR7BsPJEAcwoHfvXqgCmdHLiwRPE,5104
|
|
8
|
-
retracesoftware/install/patcher.py,sha256=PY4j3aXzu5l5fOGiChT8Y54nzhVpnHkWTGcxPtpe5mo,16773
|
|
9
|
-
retracesoftware/install/predicate.py,sha256=tX7NQc0rGkyyHYO3mduYHcJHbw1wczT53m_Dpkzo6do,2679
|
|
10
|
-
retracesoftware/install/record.py,sha256=Y-vDuUP_ZVzMC8PGhZP2fp8gLkIa5FJPhMKTBUSXi_o,3113
|
|
11
|
-
retracesoftware/install/references.py,sha256=0nUY_9BkeFz2imcw97rcJNq2jqISCB8dysBbCrh1eCo,1623
|
|
12
|
-
retracesoftware/install/replay.py,sha256=SV7-k05xZFiNfBaxrlLrqbB8-i01IPvnJQjRj9zuinI,1828
|
|
13
|
-
retracesoftware/install/tracer.py,sha256=UUVzBD_Nd91VH4iTs7ZDzaIbp_WeiOCSQnSe76dmfjM,4588
|
|
14
|
-
retracesoftware/install/typeutils.py,sha256=_a1PuwdCsYjG1Nkd77V-flqYtwbD4RkJVKn6Z-xABL4,1813
|
|
15
|
-
retracesoftware/proxy/__init__.py,sha256=ZlDZIuUmKFsE9Tvfd2EKGabTepqv8nrbr5pQhCM3IKc,193
|
|
16
|
-
retracesoftware/proxy/gateway.py,sha256=qRaE1xIdbRy6kBWmvvrBh-xKRmywWybO01yi1ppVdu8,6062
|
|
17
|
-
retracesoftware/proxy/proxyfactory.py,sha256=2PgC0NtDbRmhmU--caTiQDsaF8s1h9tavQxvPIow_bM,11912
|
|
18
|
-
retracesoftware/proxy/proxysystem.py,sha256=aX5bYqL2yf7mSgbjtDh1-n8dQ98nHZLT55kSLdVMy_c,6442
|
|
19
|
-
retracesoftware/proxy/proxytype.py,sha256=RuZL0xl48hfSnOFMum74FXdde-UNJ1Urz-ILBNMs4Ts,9398
|
|
20
|
-
retracesoftware/proxy/record.py,sha256=ShQrPSiNvZ9hckW6eaOoHj-w7_-X1o7R6zlaZkV_zdI,7687
|
|
21
|
-
retracesoftware/proxy/replay.py,sha256=jsg0DZTe1TBU5kjRt9weqLpHl8AlDQeqakNddYhBE2E,7111
|
|
22
|
-
retracesoftware/proxy/thread.py,sha256=zAqzLDJuhZxieMPtHzipTbuZ8WSO4nmRBgDBs7kPQy0,1373
|
|
23
|
-
retracesoftware_proxy-0.1.1.dist-info/METADATA,sha256=QuPCODtdgePy3CzNyVoMpLZAVbScOYpeHPfpTOwTIrQ,202
|
|
24
|
-
retracesoftware_proxy-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
-
retracesoftware_proxy-0.1.1.dist-info/top_level.txt,sha256=hYHsR6txLidmqvjBMITpIHvmJJbmoCAgr76-IpZPRz8,16
|
|
26
|
-
retracesoftware_proxy-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
{retracesoftware_proxy-0.1.1.dist-info → retracesoftware_proxy-0.1.2.dist-info}/top_level.txt
RENAMED
|
File without changes
|