robot-folders 0.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- robot_folders/__init__.py +0 -0
- robot_folders/commands/__init__.py +0 -0
- robot_folders/commands/active_environment.py +46 -0
- robot_folders/commands/adapt_environment.py +415 -0
- robot_folders/commands/add_environment.py +416 -0
- robot_folders/commands/cd.py +93 -0
- robot_folders/commands/change_environment.py +98 -0
- robot_folders/commands/clean.py +81 -0
- robot_folders/commands/delete_environment.py +165 -0
- robot_folders/commands/get_checkout_base_dir.py +30 -0
- robot_folders/commands/make.py +86 -0
- robot_folders/commands/manage_underlays.py +50 -0
- robot_folders/commands/run.py +91 -0
- robot_folders/commands/scrape_environment.py +160 -0
- robot_folders/helpers/ConfigParser.py +74 -0
- robot_folders/helpers/__init__.py +0 -0
- robot_folders/helpers/build_helpers.py +313 -0
- robot_folders/helpers/clean_helpers.py +116 -0
- robot_folders/helpers/compilation_db_helpers.py +44 -0
- robot_folders/helpers/config_helpers.py +144 -0
- robot_folders/helpers/directory_helpers.py +247 -0
- robot_folders/helpers/environment_helpers.py +362 -0
- robot_folders/helpers/exceptions.py +35 -0
- robot_folders/helpers/repository_helpers.py +95 -0
- robot_folders/helpers/resources/__init__.py +0 -0
- robot_folders/helpers/resources/userconfig_distribute.yaml +37 -0
- robot_folders/helpers/ros_version_helpers.py +66 -0
- robot_folders/helpers/underlays.py +71 -0
- robot_folders/helpers/which.py +45 -0
- robot_folders/helpers/workspace_chooser.py +65 -0
- robot_folders/main.py +100 -0
- robot_folders-0.4.1.data/scripts/rob_folders-complete.sh +53 -0
- robot_folders-0.4.1.data/scripts/rob_folders_get_source_command.py +53 -0
- robot_folders-0.4.1.data/scripts/rob_folders_source.sh +199 -0
- robot_folders-0.4.1.data/scripts/source_environment.sh +266 -0
- robot_folders-0.4.1.dist-info/METADATA +83 -0
- robot_folders-0.4.1.dist-info/RECORD +40 -0
- robot_folders-0.4.1.dist-info/WHEEL +5 -0
- robot_folders-0.4.1.dist-info/entry_points.txt +2 -0
- robot_folders-0.4.1.dist-info/top_level.txt +1 -0
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2024 FZI Forschungszentrum Informatik
|
|
3
|
+
#
|
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
# furnished to do so, subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
|
12
|
+
# all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
17
|
+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
# THE SOFTWARE.
|
|
21
|
+
#
|
|
22
|
+
"""Prints the currently sourced environment"""
|
|
23
|
+
|
|
24
|
+
import click
|
|
25
|
+
from robot_folders.helpers.directory_helpers import (
|
|
26
|
+
get_active_env,
|
|
27
|
+
get_last_activated_env,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@click.command("active_environment")
|
|
32
|
+
def cli():
|
|
33
|
+
"""Prints out the current environment. If none
|
|
34
|
+
is sourced right now, it tells which was the last active
|
|
35
|
+
environment, which will be sourced by simply calling the
|
|
36
|
+
source command."""
|
|
37
|
+
|
|
38
|
+
active_env = get_active_env()
|
|
39
|
+
if active_env is None:
|
|
40
|
+
click.echo(
|
|
41
|
+
"No active environment. Last activated environment: {}".format(
|
|
42
|
+
get_last_activated_env()
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
else:
|
|
46
|
+
click.echo("Active environment: {}".format(active_env))
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2024 FZI Forschungszentrum Informatik
|
|
3
|
+
#
|
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
# furnished to do so, subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
|
12
|
+
# all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
17
|
+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
# THE SOFTWARE.
|
|
21
|
+
#
|
|
22
|
+
"""
|
|
23
|
+
This implements a command to adapt an environment with a config file.
|
|
24
|
+
"""
|
|
25
|
+
from __future__ import print_function
|
|
26
|
+
import os
|
|
27
|
+
import stat
|
|
28
|
+
import subprocess
|
|
29
|
+
import click
|
|
30
|
+
|
|
31
|
+
import robot_folders.helpers.directory_helpers as dir_helpers
|
|
32
|
+
from robot_folders.helpers.repository_helpers import create_rosinstall_entry
|
|
33
|
+
from robot_folders.helpers.ConfigParser import ConfigFileParser
|
|
34
|
+
import robot_folders.helpers.environment_helpers as environment_helpers
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class EnvironmentAdapter(click.Command):
|
|
38
|
+
"""
|
|
39
|
+
Implements a click command interface to adapt an environment.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
def __init__(self, name=None, **attrs):
|
|
43
|
+
click.Command.__init__(self, name, **attrs)
|
|
44
|
+
|
|
45
|
+
self.local_delete_policy = "ask"
|
|
46
|
+
self.local_override_policy = "ask"
|
|
47
|
+
self.ignore_catkin = False
|
|
48
|
+
self.ignore_colcon = False
|
|
49
|
+
self.ignore_misc = False
|
|
50
|
+
self.no_submodules = False
|
|
51
|
+
self.rosinstall = dict()
|
|
52
|
+
|
|
53
|
+
def invoke(self, ctx):
|
|
54
|
+
"""
|
|
55
|
+
This invokes the actual command.
|
|
56
|
+
"""
|
|
57
|
+
env_dir = os.path.join(dir_helpers.get_checkout_dir(), self.name)
|
|
58
|
+
catkin_dir = dir_helpers.get_catkin_dir(env_dir)
|
|
59
|
+
colcon_dir = dir_helpers.get_colcon_dir(env_dir)
|
|
60
|
+
catkin_src_dir = os.path.join(catkin_dir, "src")
|
|
61
|
+
colcon_src_dir = os.path.join(colcon_dir, "src")
|
|
62
|
+
misc_ws_dir = os.path.join(env_dir, "misc_ws")
|
|
63
|
+
demos_dir = os.path.join(env_dir, "demos")
|
|
64
|
+
|
|
65
|
+
self.local_delete_policy = ctx.parent.params["local_delete_policy"]
|
|
66
|
+
self.local_override_policy = ctx.parent.params["local_override_policy"]
|
|
67
|
+
self.ignore_catkin = ctx.parent.params["ignore_catkin"]
|
|
68
|
+
self.ignore_colcon = ctx.parent.params["ignore_colcon"]
|
|
69
|
+
self.ignore_misc = ctx.parent.params["ignore_misc"]
|
|
70
|
+
self.no_submodules = ctx.parent.params["no_submodules"]
|
|
71
|
+
|
|
72
|
+
config_file_parser = ConfigFileParser(ctx.params["in_file"])
|
|
73
|
+
has_catkin, ros_rosinstall = config_file_parser.parse_ros_config()
|
|
74
|
+
has_colcon, ros2_rosinstall = config_file_parser.parse_ros2_config()
|
|
75
|
+
has_misc_ws, misc_ws_rosinstall = config_file_parser.parse_misc_ws_config()
|
|
76
|
+
os.environ["ROB_FOLDERS_ACTIVE_ENV"] = self.name
|
|
77
|
+
|
|
78
|
+
if has_misc_ws and (not self.ignore_misc):
|
|
79
|
+
if os.path.isdir(misc_ws_dir):
|
|
80
|
+
click.echo("Adapting misc workspace")
|
|
81
|
+
self.rosinstall = dict()
|
|
82
|
+
self.parse_folder(misc_ws_dir)
|
|
83
|
+
if misc_ws_rosinstall:
|
|
84
|
+
self.adapt_rosinstall(misc_ws_rosinstall, misc_ws_dir)
|
|
85
|
+
else:
|
|
86
|
+
click.echo("Creating misc workspace")
|
|
87
|
+
has_nobackup = dir_helpers.check_nobackup()
|
|
88
|
+
build_base_dir = dir_helpers.get_build_base_dir(has_nobackup)
|
|
89
|
+
misc_ws_build_root = os.path.join(build_base_dir, self.name, "misc_ws")
|
|
90
|
+
|
|
91
|
+
environment_helpers.MiscCreator(
|
|
92
|
+
misc_ws_dir,
|
|
93
|
+
rosinstall=misc_ws_rosinstall,
|
|
94
|
+
build_root=misc_ws_build_root,
|
|
95
|
+
no_submodules=self.no_submodules,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
if has_catkin and (not self.ignore_catkin):
|
|
99
|
+
if os.path.isdir(catkin_src_dir):
|
|
100
|
+
click.echo("Adapting catkin workspace")
|
|
101
|
+
self.rosinstall = dict()
|
|
102
|
+
self.parse_folder(catkin_src_dir)
|
|
103
|
+
if ros_rosinstall:
|
|
104
|
+
self.adapt_rosinstall(ros_rosinstall, catkin_src_dir)
|
|
105
|
+
else:
|
|
106
|
+
click.echo("Creating catkin workspace")
|
|
107
|
+
has_nobackup = dir_helpers.check_nobackup()
|
|
108
|
+
catkin_dir = os.path.join(env_dir, "catkin_ws")
|
|
109
|
+
build_base_dir = dir_helpers.get_build_base_dir(has_nobackup)
|
|
110
|
+
catkin_build_dir = os.path.join(
|
|
111
|
+
build_base_dir, self.name, "catkin_ws", "build"
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
catkin_creator = environment_helpers.CatkinCreator(
|
|
115
|
+
catkin_directory=catkin_dir,
|
|
116
|
+
build_directory=catkin_build_dir,
|
|
117
|
+
rosinstall=ros_rosinstall,
|
|
118
|
+
no_submodules=self.no_submodules,
|
|
119
|
+
)
|
|
120
|
+
catkin_creator.create()
|
|
121
|
+
|
|
122
|
+
if has_colcon and (not self.ignore_colcon):
|
|
123
|
+
if os.path.isdir(colcon_src_dir):
|
|
124
|
+
click.echo("Adapting colcon workspace")
|
|
125
|
+
self.rosinstall = dict()
|
|
126
|
+
self.parse_folder(colcon_src_dir)
|
|
127
|
+
if ros2_rosinstall:
|
|
128
|
+
self.adapt_rosinstall(ros2_rosinstall, colcon_src_dir)
|
|
129
|
+
else:
|
|
130
|
+
click.echo("Creating colcon workspace")
|
|
131
|
+
has_nobackup = dir_helpers.check_nobackup()
|
|
132
|
+
colcon_dir = os.path.join(env_dir, "colcon_ws")
|
|
133
|
+
build_base_dir = dir_helpers.get_build_base_dir(has_nobackup)
|
|
134
|
+
colcon_build_dir = os.path.join(
|
|
135
|
+
build_base_dir, self.name, "colcon_ws", "build"
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
colcon_creator = environment_helpers.ColconCreator(
|
|
139
|
+
colcon_directory=colcon_dir,
|
|
140
|
+
build_directory=colcon_build_dir,
|
|
141
|
+
rosinstall=ros2_rosinstall,
|
|
142
|
+
no_submodules=self.no_submodules,
|
|
143
|
+
)
|
|
144
|
+
colcon_creator.create()
|
|
145
|
+
|
|
146
|
+
click.echo("Looking for demo scripts")
|
|
147
|
+
dir_helpers.mkdir_p(demos_dir)
|
|
148
|
+
scripts = config_file_parser.parse_demo_scripts()
|
|
149
|
+
for script in scripts:
|
|
150
|
+
click.echo(
|
|
151
|
+
"Found {} in config. Will be overwritten if file exists".format(script)
|
|
152
|
+
)
|
|
153
|
+
script_path = os.path.join(demos_dir, script)
|
|
154
|
+
with open(script_path, mode="w") as demo_script:
|
|
155
|
+
demo_script.write(scripts[script])
|
|
156
|
+
demo_script.close()
|
|
157
|
+
os.chmod(
|
|
158
|
+
script_path,
|
|
159
|
+
stat.S_IRWXU
|
|
160
|
+
| stat.S_IRGRP
|
|
161
|
+
| stat.S_IXGRP
|
|
162
|
+
| stat.S_IROTH
|
|
163
|
+
| stat.S_IXOTH,
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
def adapt_rosinstall(self, config_rosinstall, packages_dir, workspace_dir=""):
|
|
167
|
+
"""
|
|
168
|
+
Parses the given config rosinstall and compares it to the locally installed packages
|
|
169
|
+
"""
|
|
170
|
+
for repo in config_rosinstall:
|
|
171
|
+
local_version_exists = False
|
|
172
|
+
version_update_required = True
|
|
173
|
+
uri_update_required = True
|
|
174
|
+
local_name = ""
|
|
175
|
+
uri = ""
|
|
176
|
+
version = ""
|
|
177
|
+
|
|
178
|
+
if "local-name" in repo["git"]:
|
|
179
|
+
local_name = repo["git"]["local-name"]
|
|
180
|
+
else:
|
|
181
|
+
click.echo(
|
|
182
|
+
"No local-name given for package '{}'. "
|
|
183
|
+
"Skipping package".format(repo["git"])
|
|
184
|
+
)
|
|
185
|
+
continue
|
|
186
|
+
package_dir = os.path.join(packages_dir, local_name)
|
|
187
|
+
|
|
188
|
+
if "version" in repo["git"]:
|
|
189
|
+
version = repo["git"]["version"]
|
|
190
|
+
else:
|
|
191
|
+
click.echo(
|
|
192
|
+
"WARNING: No version tag given for package '{}'. "
|
|
193
|
+
"The local version will be kept or the master "
|
|
194
|
+
"version will be checked out for new package".format(local_name)
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
if "uri" in repo["git"]:
|
|
198
|
+
uri = repo["git"]["uri"]
|
|
199
|
+
else:
|
|
200
|
+
click.echo(
|
|
201
|
+
"WARNING: No uri given for package '{}'. "
|
|
202
|
+
"Skipping package".format(local_name)
|
|
203
|
+
)
|
|
204
|
+
continue
|
|
205
|
+
|
|
206
|
+
# compare the repos' versions and uris
|
|
207
|
+
if local_name in self.rosinstall.keys():
|
|
208
|
+
local_version_exists = True
|
|
209
|
+
local_repo = self.rosinstall[local_name]
|
|
210
|
+
if version == "" or version == local_repo["git"]["version"]:
|
|
211
|
+
version_update_required = False
|
|
212
|
+
elif self.local_override_policy == "keep_local":
|
|
213
|
+
version_update_required = False
|
|
214
|
+
elif self.local_override_policy == "override":
|
|
215
|
+
version_update_required = True
|
|
216
|
+
else:
|
|
217
|
+
click.echo(
|
|
218
|
+
"Package '{}' version differs from local version. ".format(
|
|
219
|
+
local_name
|
|
220
|
+
)
|
|
221
|
+
)
|
|
222
|
+
click.echo(
|
|
223
|
+
"1) local version: {}".format(local_repo["git"]["version"])
|
|
224
|
+
)
|
|
225
|
+
click.echo("2) config_file version: {}".format(version))
|
|
226
|
+
version_to_keep = click.prompt(
|
|
227
|
+
"Which version should be used?",
|
|
228
|
+
type=click.Choice(["1", "2"]),
|
|
229
|
+
default="1",
|
|
230
|
+
)
|
|
231
|
+
version_update_required = version_to_keep == "2"
|
|
232
|
+
|
|
233
|
+
if uri == local_repo["git"]["uri"]:
|
|
234
|
+
uri_update_required = False
|
|
235
|
+
elif self.local_override_policy == "keep_local":
|
|
236
|
+
uri_update_required = False
|
|
237
|
+
elif self.local_override_policy == "override":
|
|
238
|
+
uri_update_required = True
|
|
239
|
+
else:
|
|
240
|
+
click.echo(
|
|
241
|
+
"Package '{}' uri differs from local version. ".format(
|
|
242
|
+
local_name
|
|
243
|
+
)
|
|
244
|
+
)
|
|
245
|
+
click.echo("local version: {}".format(local_repo["git"]["uri"]))
|
|
246
|
+
click.echo("config_file version: {}".format(uri))
|
|
247
|
+
version_to_keep = click.prompt(
|
|
248
|
+
"Which uri should be used?",
|
|
249
|
+
type=click.Choice(["1", "2"]),
|
|
250
|
+
default="2",
|
|
251
|
+
)
|
|
252
|
+
uri_update_required = version_to_keep == "2"
|
|
253
|
+
|
|
254
|
+
else:
|
|
255
|
+
click.echo(
|
|
256
|
+
"Package '{}' does not exist in local structure. "
|
|
257
|
+
"Going to download.".format(local_name)
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
# Create repo if it does not exist yet.
|
|
261
|
+
if not local_version_exists:
|
|
262
|
+
if self.no_submodules:
|
|
263
|
+
subprocess.check_call(["git", "clone", uri, package_dir])
|
|
264
|
+
else:
|
|
265
|
+
subprocess.check_call(
|
|
266
|
+
["git", "clone", uri, package_dir, "--recurse-submodules"]
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
# Change the origin to the uri specified
|
|
270
|
+
if uri_update_required:
|
|
271
|
+
process = subprocess.check_call(
|
|
272
|
+
["git", "remote", "set-url", "origin", uri], cwd=package_dir
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
# Checkout the version specified
|
|
276
|
+
if version_update_required:
|
|
277
|
+
process = subprocess.check_call(["git", "fetch"], cwd=package_dir)
|
|
278
|
+
process = subprocess.check_call(
|
|
279
|
+
["git", "checkout", version], cwd=package_dir
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
config_name_list = [d["git"]["local-name"] for d in config_rosinstall]
|
|
283
|
+
|
|
284
|
+
for repo in self.rosinstall:
|
|
285
|
+
if repo not in config_name_list:
|
|
286
|
+
click.echo(
|
|
287
|
+
"Package '{}' found locally, but not in config.".format(repo)
|
|
288
|
+
)
|
|
289
|
+
local_name = self.rosinstall[repo]["git"]["local-name"]
|
|
290
|
+
package_dir = os.path.join(packages_dir, local_name)
|
|
291
|
+
if self.local_delete_policy == "delete_all":
|
|
292
|
+
dir_helpers.recursive_rmdir(package_dir)
|
|
293
|
+
click.echo("Deleted '{}'".format(repo))
|
|
294
|
+
elif self.local_delete_policy == "ask":
|
|
295
|
+
if click.confirm("Do you want to delete it?"):
|
|
296
|
+
dir_helpers.recursive_rmdir(package_dir)
|
|
297
|
+
click.echo("Deleted '{}'".format(repo))
|
|
298
|
+
elif self.local_delete_policy == "keep_all":
|
|
299
|
+
click.echo("Keeping repository as all should be kept")
|
|
300
|
+
|
|
301
|
+
def parse_folder(self, folder, prefix=""):
|
|
302
|
+
"""
|
|
303
|
+
Function to recursively find git repositories
|
|
304
|
+
"""
|
|
305
|
+
subfolders = os.listdir(folder)
|
|
306
|
+
for subfolder in subfolders:
|
|
307
|
+
subfolder_abs = os.path.join(folder, subfolder)
|
|
308
|
+
if os.path.isdir(subfolder_abs):
|
|
309
|
+
git_dir = os.path.join(subfolder_abs, ".git")
|
|
310
|
+
local_name = os.path.join(prefix, subfolder)
|
|
311
|
+
if os.path.isdir(git_dir):
|
|
312
|
+
click.echo(
|
|
313
|
+
"Found '{}' in local folder structure.".format(local_name)
|
|
314
|
+
)
|
|
315
|
+
entry = create_rosinstall_entry(subfolder_abs, local_name)
|
|
316
|
+
self.rosinstall[local_name] = entry
|
|
317
|
+
self.parse_folder(subfolder_abs, local_name)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
class EnvironmentChooser(click.MultiCommand):
|
|
321
|
+
"""Class to select an environment"""
|
|
322
|
+
|
|
323
|
+
def list_commands(self, ctx):
|
|
324
|
+
return dir_helpers.list_environments()
|
|
325
|
+
|
|
326
|
+
def get_command(self, ctx, name):
|
|
327
|
+
# return empty command with the correct name
|
|
328
|
+
if name in dir_helpers.list_environments():
|
|
329
|
+
cmd = EnvironmentAdapter(
|
|
330
|
+
name=name, params=[click.Argument(param_decls=["in_file"])]
|
|
331
|
+
)
|
|
332
|
+
return cmd
|
|
333
|
+
else:
|
|
334
|
+
click.echo("No environment with name < %s > found." % name)
|
|
335
|
+
return None
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
@click.command(
|
|
339
|
+
"adapt_environment",
|
|
340
|
+
cls=EnvironmentChooser,
|
|
341
|
+
short_help="Adapt an environment to a config file",
|
|
342
|
+
invoke_without_command=True,
|
|
343
|
+
)
|
|
344
|
+
@click.option(
|
|
345
|
+
"--local_delete_policy",
|
|
346
|
+
type=click.Choice(["delete_all", "keep_all", "ask"]),
|
|
347
|
+
default="ask",
|
|
348
|
+
help=(
|
|
349
|
+
"Defines whether repositories existing local, but NOT "
|
|
350
|
+
"in the config file should be kept or deleted. "
|
|
351
|
+
"Asking the user is the default behavior."
|
|
352
|
+
),
|
|
353
|
+
)
|
|
354
|
+
@click.option(
|
|
355
|
+
"--local_override_policy",
|
|
356
|
+
type=click.Choice(["keep_local", "override", "ask"]),
|
|
357
|
+
default="ask",
|
|
358
|
+
help=(
|
|
359
|
+
"Defines whether repositories existing locally AND "
|
|
360
|
+
"in different version or with different URI in the config file,"
|
|
361
|
+
"should be kept in local version or be overridden"
|
|
362
|
+
"Asking the user is the default behavior."
|
|
363
|
+
),
|
|
364
|
+
)
|
|
365
|
+
@click.option(
|
|
366
|
+
"--ignore_catkin",
|
|
367
|
+
default=False,
|
|
368
|
+
is_flag=True,
|
|
369
|
+
help="Prevent catkin workspace from getting adapted",
|
|
370
|
+
)
|
|
371
|
+
@click.option(
|
|
372
|
+
"--ignore_colcon",
|
|
373
|
+
default=False,
|
|
374
|
+
is_flag=True,
|
|
375
|
+
help="Prevent colcon workspace from getting adapted",
|
|
376
|
+
)
|
|
377
|
+
@click.option(
|
|
378
|
+
"--ignore_misc",
|
|
379
|
+
default=False,
|
|
380
|
+
is_flag=True,
|
|
381
|
+
help="Prevent misc workspace from getting adapted",
|
|
382
|
+
)
|
|
383
|
+
@click.option(
|
|
384
|
+
"--no_submodules",
|
|
385
|
+
default=False,
|
|
386
|
+
is_flag=True,
|
|
387
|
+
help="Prevent git submodules from being cloned",
|
|
388
|
+
)
|
|
389
|
+
@click.pass_context
|
|
390
|
+
def cli(
|
|
391
|
+
ctx,
|
|
392
|
+
local_delete_policy,
|
|
393
|
+
ignore_catkin,
|
|
394
|
+
ignore_colcon,
|
|
395
|
+
ignore_misc,
|
|
396
|
+
no_submodules,
|
|
397
|
+
local_override_policy,
|
|
398
|
+
):
|
|
399
|
+
"""Adapts an environment to given config file.
|
|
400
|
+
New repositories will be added, versions/branches will be changed and
|
|
401
|
+
deleted repositories will/may be removed.
|
|
402
|
+
Provide path to config file as [ARGS] after the environment name.
|
|
403
|
+
"""
|
|
404
|
+
|
|
405
|
+
print(
|
|
406
|
+
"The policy for deleting repos only existing locally is: '{}'".format(
|
|
407
|
+
local_delete_policy
|
|
408
|
+
)
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
if ctx.invoked_subcommand is None:
|
|
412
|
+
click.echo(
|
|
413
|
+
"No environment specified. Please choose one "
|
|
414
|
+
"of the available environments!"
|
|
415
|
+
)
|