-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
58 lines (40 loc) · 1.08 KB
/
test.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# You aren't really supposed to run this, I was just using it for development.
# -ab
from autolib import Autolib, ServerStore, AUTOLIB_SERVER
import tempfile, os, imp
class LocalStore(object):
def get_src(self, name):
if name not in self.dict:
raise AttributeError, "Library not found."
return self.dict[name]
def set_src(self, name, src):
if name in self.dict:
raise ValueError, "Library with that name already exists."
self.dict[name] = src
def list_modules(self):
return self.dict.keys()
def __init__(self):
self.dict = {}
a = Autolib(store=LocalStore())
fd, path = tempfile.mkstemp(suffix='.py')
f = os.fdopen(fd, 'w')
f.write("""
import math
en = enumerate
def foo():
return 3
def bar():
return math.exp(-1)
""")
f.close()
mod = imp.load_source('testmod', path)
a.tester = mod
print a.tester.foo()
print a.tester.bar()
print a.List()
ss = ServerStore(url='http://localhost:8000/autolib/')
b = Autolib(store=ss)
b.tester = mod
print b.tester.foo()
print b.tester.bar()
print b.List()