Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_roscore_filename():
# precedence: look for version in /etc/ros. If it's not there, fall back to roslaunch package
filename = os.path.join(rospkg.get_etc_ros_dir(), 'roscore.xml')
if os.path.isfile(filename):
return filename
r = rospkg.RosPack()
return os.path.join(r.get_path('roslaunch'), 'resources', 'roscore.xml')
# the log dir itself should not be symlinked as latest
if logfile_dir != log_dir:
if sys.platform not in ['win32']:
try:
success = renew_latest_logdir(logfile_dir)
if not success:
sys.stderr.write("INFO: cannot create a symlink to latest log directory\n")
except OSError as e:
sys.stderr.write("INFO: cannot create a symlink to latest log directory: %s\n" % e)
config_file = os.environ.get('ROS_PYTHON_LOG_CONFIG_FILE')
if not config_file:
# search for logging config file in ROS_HOME, ROS_ETC_DIR or relative
# to the rosgraph package directory.
config_dirs = [os.path.join(rospkg.get_ros_home(), 'config'),
rospkg.get_etc_ros_dir()]
try:
config_dirs.append(os.path.join(
rospkg.RosPack().get_path('rosgraph'), 'conf'))
except rospkg.common.ResourceNotFound:
pass
for config_dir in config_dirs:
for extension in ('conf', 'yaml'):
f = os.path.join(config_dir,
'python_logging{}{}'.format(os.path.extsep,
extension))
if os.path.isfile(f):
config_file = f
break
if config_file is not None:
break
def get_sources_list_dir():
# base of where we read config files from
# TODO: windows
if 0:
# we can't use etc/ros because environment config does not carry over under sudo
etc_ros = rospkg.get_etc_ros_dir()
else:
etc_ros = '/etc/ros'
# compute default system wide sources directory
sys_sources_list_dir = os.path.join(etc_ros, 'rosdep', SOURCES_LIST_DIR)
sources_list_dirs = get_sources_list_dirs(sys_sources_list_dir)
if sources_list_dirs:
return sources_list_dirs[0]
else:
return sys_sources_list_dir