Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
ipa-rwu committed Feb 15, 2024
1 parent 3d08b52 commit 593fd74
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ros2model/verb/runtime_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import psutil
import sys


class RuntimeNodeVerb(VerbExtension):
"""Create .ros2 for each node in a runtime system"""

Expand Down Expand Up @@ -45,17 +46,17 @@ def name_component_file(self, grapg_name: ROSModel.GraphName):
else:
file_name = f"{grapg_name.namespace[1:]}__{n}"
return file_name

def find_process_by_node_name(self, node_name, namespace):
for process in psutil.process_iter(['pid', 'cmdline']):
for process in psutil.process_iter(["pid", "cmdline"]):
try:
cmdline = process.info['cmdline']
cmdline = process.info["cmdline"]
if namespace in str(cmdline) and node_name in str(cmdline):
cmdline_list = cmdline[0].split('/')
cmdline_list = cmdline[0].split("/")
return cmdline_list[-2], cmdline_list[-1]
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return 'TODO', 'TODO'
return "TODO", "TODO"

def main(self, *, args):
output_dir = Path(args.output_folder)
Expand All @@ -73,7 +74,9 @@ def main(self, *, args):
args.include_hidden_nodes,
args.include_hidden_interfaces,
)
package_name, artifact_name = self.find_process_by_node_name(n.name, n.namespace)
package_name, artifact_name = self.find_process_by_node_name(
n.name, n.namespace
)
runtime_pkg = ROSModel.Package(
name=package_name,
artifact=[ROSModel.Artifact(name=artifact_name, node=[node_instance])],
Expand Down

0 comments on commit 593fd74

Please sign in to comment.