Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable rosdep init to work with non-extant ROSDEP_SOURCE_PATH #911

Merged
merged 2 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/rosdep2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,11 +603,12 @@ def command_init(options):
print(e, file=sys.stderr)
return 4
# reuse path variable for error message
path = get_sources_list_dir()
path = get_sources_list_dir(strip_missing_dirs=False)
old_umask = os.umask(0o022)
try:
if not os.path.exists(path):
os.makedirs(path)
# Here path goes from directory name to file for more specific error message
path = get_default_sources_list_file()
if os.path.exists(path):
print('ERROR: default sources list file already exists:\n\t%s\nPlease delete if you wish to re-initialize' % (path), file=sys.stderr)
Expand Down
8 changes: 5 additions & 3 deletions src/rosdep2/sources_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,20 @@
SOURCE_PATH_ENV = 'ROSDEP_SOURCE_PATH'


def get_sources_list_dirs(source_list_dir):
def get_sources_list_dirs(source_list_dir, strip_missing_dirs=True):
if SOURCE_PATH_ENV in os.environ:
sdirs = os.environ[SOURCE_PATH_ENV].split(os.pathsep)
else:
sdirs = [source_list_dir]
if not strip_missing_dirs:
return sdirs
for p in list(sdirs):
if not os.path.exists(p):
sdirs.remove(p)
return sdirs


def get_sources_list_dir():
def get_sources_list_dir(strip_missing_dirs=True):
# base of where we read config files from
# TODO: windows
if 0:
Expand All @@ -97,7 +99,7 @@ def get_sources_list_dir():
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)
sources_list_dirs = get_sources_list_dirs(sys_sources_list_dir, strip_missing_dirs)
if sources_list_dirs:
return sources_list_dirs[0]
else:
Expand Down