-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
40 lines (30 loc) · 1.07 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
import pickle as pickle
from twisted.internet import reactor, defer
from jasmin.managers.proxies import SMPPClientManagerPBProxy
from jasmin.routing.proxies import RouterPBProxy
from jasmin.routing.Routes import DefaultRoute
from jasmin.routing.jasminApi import User, Group
from twisted.internet.threads import blockingCallFromThread
@defer.inlineCallbacks
def runScenario():
proxy_router = RouterPBProxy()
try:
# Connect to Router PB proxy
print("Attempting to connect to Jasmin router pb...")
yield proxy_router.connect('127.0.0.1', 8988, 'radmin', 'rpwd')
print('Connected to Radmin')
g1 = Group("xxxxxxx")
g = yield proxy_router.group_add(g1)
return g
except Exception as e:
print("ERROR RUNNING SCENARIO: %s" % str(e))
def run():
d = runScenario()
d.addCallback(print_result)
d.addErrback(print_error)
def print_result(result):
print(f"Result of async_add: {result}")
def print_error(error):
print(f"Error occurred: {error}")
def execute():
blockingCallFromThread(reactor, run)