-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtp_rigtoolkit_main.py
52 lines (41 loc) · 1.38 KB
/
tp_rigtoolkit_main.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
import os
import sys
# register environment variables
os.environ['TPDCC_ENV_DEV'] = 'True'
os.environ['TPDCC_TOOLS_ROOT'] = r'E:\tools\dev\tp-dcc\packages\tp-dcc-bootstrap'
os.environ['TPDCC_DEPS_ROOT'] = r'E:\tools\dev\tp-dcc\venv\Lib\site-packages'
os.environ['TRIGTOOLKIT_ENV_DEV'] = os.environ['TPDCC_ENV_DEV']
os.environ['TPRIGTOOLKIT_TOOLS_ROOT'] = r'E:\tools\dev\tp-rigtoolkit\packages\tp-rigtoolkit-bootstrap'
# make sure to update sys.path so tpDcc Tools package manager an dependencies are available
root_paths = [os.environ['TPDCC_TOOLS_ROOT'], os.environ['TPRIGTOOLKIT_TOOLS_ROOT']]
for root_path in root_paths:
if os.path.isdir(root_path) and root_path not in sys.path:
sys.path.append(root_path)
def reload_modules():
"""
Function that forces the reloading of all related modules
"""
modules_to_reload = ('tp')
for k in sys.modules.copy().keys():
found = False
for mod in modules_to_reload:
if mod == k:
del sys.modules[mod]
found = True
break
if found:
continue
if k.startswith(modules_to_reload):
del sys.modules[k]
import tp.rigtoolkit.bootstrap
try:
tp.rigtoolkit.bootstrap.shutdown()
except Exception:
pass
reload_modules()
# register environment variables after shutdown
os.environ['TPDCC_DEV'] = 'True'
os.environ['TRIGTOOLKIT_ENV_DEV'] = os.environ['TPDCC_ENV_DEV']
# load framework
import tp.rigtoolkit.bootstrap
tp.rigtoolkit.bootstrap.init()