Created
August 22, 2023 14:29
-
-
Save HViktorTsoi/ea2164718e93f9f0210be55ddb3f3a95 to your computer and use it in GitHub Desktop.
Get the working dir of current rosbag process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
def get_process_cwd(process_name): | |
try: | |
pid = subprocess.check_output(['pgrep', '-f', process_name]).decode('utf-8').strip().split('\n')[0] | |
cwd = subprocess.check_output(['pwdx', pid]).decode('utf-8').strip().split(" ")[-1] | |
return cwd | |
except subprocess.CalledProcessError: | |
return None | |
dataset_rosbag_cwd = get_process_cwd(ROSBAG_PROCESS_NAME) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment