Package roslib :: Module rosenv
[frames] | no frames]

Module rosenv

source code

ROS environment variables as well as routines for determining configuration values that have environment overrides (e.g. ROS_LOG_DIR, ROS_HOME, ROS_TEST_RESULTS_DIR).

Classes
  ROSEnvException
Base class of roslib.rosenv errors.
Functions
 
get_ros_root(required=True, env=None) source code
 
get_ros_package_path(required=False, env=None) source code
 
get_master_uri(required=True, env=None, argv=None)
Get the ROS_MASTER_URI setting from the command-line args or environment, command-line args takes precedence.
source code
 
resolve_path(p) source code
 
resolve_paths(paths) source code
str
get_ros_home(env=None)
Get directory location of '.ros' directory (aka ROS home).
source code
str
get_log_dir(env=None)
Get directory to use for writing log files.
source code
str
get_test_results_dir(env=None)
Get directory to use for writing test result files.
source code
 
makedirs_with_parent_perms(p)
Create the directory using the permissions of the nearest (existing) parent directory.
source code
 
on_ros_path(p)
Check to see if filesystem path is on paths specified in ROS environment (ROS_ROOT, ROS_PACKAGE_PATH).
source code
Variables
  ROS_ROOT = 'ROS_ROOT'
  ROS_MASTER_URI = 'ROS_MASTER_URI'
  ROS_PACKAGE_PATH = 'ROS_PACKAGE_PATH'
  ROS_HOME = 'ROS_HOME'
  ROS_BINDEPS_PATH = 'ROS_BINDEPS_PATH'
  ROS_BOOST_ROOT = 'ROS_BOOST_ROOT'
  ROS_IP = 'ROS_IP'
  ROS_HOSTNAME = 'ROS_HOSTNAME'
  ROS_NAMESPACE = 'ROS_NAMESPACE'
  ROS_LOG_DIR = 'ROS_LOG_DIR'
  ROS_TEST_RESULTS_DIR = 'ROS_TEST_RESULTS_DIR'
  __package__ = 'roslib'
Function Details

get_ros_root(required=True, env=None)

source code 
Parameters:
  • required (bool) - (default True). If True, ROS_ROOT must be set and point to a valid directory.
  • env (dict) - override environment dictionary
Raises:

get_ros_package_path(required=False, env=None)

source code 
Parameters:
  • required (bool) - (default False) if True, ROS_PACKAGE_PATH must be set and point to a valid directory.
Raises:

get_master_uri(required=True, env=None, argv=None)

source code 

Get the ROS_MASTER_URI setting from the command-line args or environment, command-line args takes precedence.

Parameters:
  • required (bool) - if True, enables exception raising
  • env (dict) - override environment dictionary
  • argv ([str]) - override sys.argv
Raises:
  • ROSEnvException - if ROS_MASTER_URI value is invalidly specified or if required and ROS_MASTER_URI is not set

resolve_path(p)

source code 
Parameters:
  • path (str Catch-all utility routine for fixing ROS environment variables that are a single path (e.g. ROS_ROOT). Currently this just expands tildes to home directories, but in the future it may encode other behaviors.) - path string

resolve_paths(paths)

source code 
Parameters:
  • paths (str Catch-all utility routine for fixing ROS environment variables that are paths (e.g. ROS_PACKAGE_PATH). Currently this just expands tildes to home directories, but in the future it may encode other behaviors.) - path string with OS-defined separator (i.e. ':' for Linux)

get_ros_home(env=None)

source code 

Get directory location of '.ros' directory (aka ROS home). possible locations for this. The ROS_LOG_DIR environment variable has priority. If that is not set, then ROS_HOME/log is used. If ROS_HOME is not set, $HOME/.ros/log is used.

Parameters:
  • env (dict) - override os.environ dictionary
Returns: str
path to use use for log file directory

get_log_dir(env=None)

source code 

Get directory to use for writing log files. There are multiple possible locations for this. The ROS_LOG_DIR environment variable has priority. If that is not set, then ROS_HOME/log is used. If ROS_HOME is not set, $HOME/.ros/log is used.

Parameters:
  • env (dict) - override os.environ dictionary
Returns: str
path to use use for log file directory

get_test_results_dir(env=None)

source code 

Get directory to use for writing test result files. There are multiple possible locations for this. The ROS_TEST_RESULTS_DIR environment variable has priority. If that is set, ROS_TEST_RESULTS_DIR is returned. If ROS_TEST_RESULTS_DIR is not set, then ROS_HOME/test_results is used. If ROS_HOME is not set, $HOME/.ros/test_results is used.

Parameters:
  • env (dict) - environment dictionary (defaults to os.environ)
Returns: str
path to use use for log file directory

makedirs_with_parent_perms(p)

source code 

Create the directory using the permissions of the nearest (existing) parent directory. This is useful for logging, where a root process sometimes has to log in the user's space.

Parameters:
  • p (str) - directory to create

on_ros_path(p)

source code 

Check to see if filesystem path is on paths specified in ROS environment (ROS_ROOT, ROS_PACKAGE_PATH).

New in ROS 1.2.

Parameters:
  • p (str) - path
Returns:
True if p is on the ROS path (ROS_ROOT, ROS_PACKAGE_PATH)