|
29 | 29 |
|
30 | 30 | import _hal |
31 | 31 | from _hal import * |
32 | | -import warnings |
33 | | -import os |
34 | | - |
35 | | -def __getattr__(name): |
36 | | - if name == 'is_rt': |
37 | | - warnings.simplefilter('always', DeprecationWarning) |
38 | | - warnings.warn(f"{name} is deprecated, use get_realtime_type() instead", DeprecationWarning) |
39 | | - warnings.simplefilter('default', DeprecationWarning) |
40 | | - |
41 | | - #We the hal to be initialized to use get_realtime_type() |
42 | | - #If it is not initialized, create a component which will inizialize it |
43 | | - #It will be cleaned up imediately |
44 | | - comp_name=f"halpy{os.getpid()}" |
45 | | - if not is_initialized(): |
46 | | - c=component(comp_name); |
47 | | - |
48 | | - t = get_realtime_type() |
49 | | - if t == REALTIME_TYPE_UNINITIALIZED: |
50 | | - warnings.warn("Unable to check realtime status, not initialized", Warning) |
51 | | - return False |
52 | | - elif t == REALTIME_TYPE_NONE: |
53 | | - return False |
54 | | - else: |
55 | | - return True |
56 | | - if name == 'is_sim': |
57 | | - warnings.simplefilter('always', DeprecationWarning) |
58 | | - warnings.warn(f"{name} is deprecated, use get_realtime_type() instead", DeprecationWarning) |
59 | | - warnings.simplefilter('default', DeprecationWarning) |
60 | | - |
61 | | - #We the hal to be initialized to use get_realtime_type() |
62 | | - #If it is not initialized, create a component which will inizialize it |
63 | | - #It will be cleaned up imediately |
64 | | - comp_name=f"halpy{os.getpid()}" |
65 | | - if not is_initialized(): |
66 | | - c=component(comp_name); |
67 | | - |
68 | | - t = get_realtime_type() |
69 | | - if t == REALTIME_TYPE_UNINITIALIZED: |
70 | | - warnings.warn("Unable to check realtime status, not initialized", Warning) |
71 | | - return True |
72 | | - elif t == REALTIME_TYPE_NONE: |
73 | | - return True |
74 | | - else: |
75 | | - return False |
76 | | - raise AttributeError(f"module {__name__!r} has no attribute {name!r}") |
77 | 32 |
|
78 | 33 | class _ItemWrap(object): |
79 | 34 | def __new__(cls, item): |
|
0 commit comments