Skip to content

Instantly share code, notes, and snippets.

@HViktorTsoi
Created August 22, 2023 14:29
Show Gist options
  • Save HViktorTsoi/ea2164718e93f9f0210be55ddb3f3a95 to your computer and use it in GitHub Desktop.
Save HViktorTsoi/ea2164718e93f9f0210be55ddb3f3a95 to your computer and use it in GitHub Desktop.
Get the working dir of current rosbag process
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