Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ロードするモジュールのパスに環境変数を設定可能にする #256

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions OpenRTM_aist/ModuleManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,26 @@ def load(self, file_name, init_func=None):
pathChanged = False
file_path = None

if OpenRTM_aist.isAbsolutePath(file_name):
name = OpenRTM_aist.replaceEnv(file_name)
if OpenRTM_aist.isAbsolutePath(name):
if not self._absoluteAllowed:
raise ModuleManager.NotAllowedOperation(
"Absolute path is not allowed")
else:
splitted_name = os.path.split(file_name)
splitted_name = os.path.split(name)
save_path = sys.path[:]
sys.path.append(splitted_name[0])

pathChanged = True
import_name = splitted_name[-1]
file_path = file_name
file_path = name

else:
file_path = self.findFile(file_name, self._loadPath)
paths = []
for path in self._loadPath:
paths.append(OpenRTM_aist.replaceEnv(path))
file_path = self.findFile(name, paths)

if not file_path:
raise ModuleManager.FileNotFound(file_name)

Expand Down Expand Up @@ -555,6 +560,7 @@ def getModuleList(self, lang, modules):
continue
self._rtcout.RTC_DEBUG("Module load path: %s", path)
flist = []
path = OpenRTM_aist.replaceEnv(path)
for suffix in suffixes:
suffix = OpenRTM_aist.eraseHeadBlank(suffix)

Expand Down