"git@code.ihep.ac.cn:maxt/CEPCSW.git" did not exist on "c2b04751b5bba0cc2b507a604314127e97b62199"
Newer
Older
Markus Frank
committed
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
58
59
60
61
62
63
64
65
66
67
68
from ROOT import gSystem
gSystem.Load('libDDPython')
from ROOT import DD4hep as Core
name_space = __import__(__name__)
def import_namespace_item(ns,nam):
scope = getattr(name_space,ns)
attr = getattr(scope,nam)
setattr(name_space,nam,attr)
return attr
def a_func():
print 'Hello world'
return 1
class a_class:
def __init__(self):
pass
def fcn(self):
print 'Hello world from member function fcn'
return 1
def fcn_except(self,args,aa):
print 'Hello world from member function fcn1 a1=',args,' a2=',aa
raise RuntimeError('Exception from python test object a_class')
return 6
py = import_namespace_item('Core','DDPython')
print '+++++ Test: Execute statements in python with C++ indirection'
py.instance().execute('import sys')
py.instance().execute('print "Arguments:", sys.argv')
print '\n'
obj=a_class()
import sys, traceback
print '+++++ Test: simple function call'
ret = py.instance().call(a_func,None)
print 'ret:',ret
print '\n'
print '+++++ Test: object method call'
ret = py.instance().call(obj.fcn,None)
print 'ret:',ret
print '\n'
print '+++++ Test: object method call with non callable'
try:
ret = py.instance().call(1,None)
print 'ret:',ret
except:
traceback.print_exc()
print '\n'
print '+++++ Test: object method call with exception in python callback'
try:
ret = py.instance().call(obj.fcn_except,(1,[1,2,3,4,5,6],))
print 'ret:',ret
except:
traceback.print_exc()
print '\n'
print '+++++ All Done....\n\n'
#py.instance().prompt()
sys.exit(0)