Skip to content

Commit 59c57db

Browse files
Merge pull request #730 from SamCHogg/update-no-requirements-option
Add an optional flag --no-requirements to update command
2 parents f91eaae + 82eff5e commit 59c57db

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

mbed/mbed.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ def check_requirements(self, show_warning=False):
15191519

15201520

15211521
# Routines after cloning mbed-os
1522-
def post_action(self):
1522+
def post_action(self, check_reqs=True):
15231523
mbed_tools_path = self.get_tools_dir()
15241524

15251525
if not mbed_tools_path and self.is_classic:
@@ -1534,7 +1534,8 @@ def post_action(self):
15341534
os.path.isfile(os.path.join(mbed_tools_path, 'default_settings.py'))):
15351535
shutil.copy(os.path.join(mbed_tools_path, 'default_settings.py'), os.path.join(self.path, 'mbed_settings.py'))
15361536

1537-
self.check_requirements(True)
1537+
if check_reqs:
1538+
self.check_requirements(True)
15381539

15391540
def add_tools(self, path):
15401541
if not os.path.exists(path):
@@ -1876,13 +1877,14 @@ def thunk(parsed_args):
18761877
dict(name='--depth', nargs='?', help='Number of revisions to fetch the mbed OS repository when creating new program. Default: all revisions.'),
18771878
dict(name='--protocol', nargs='?', help='Transport protocol when fetching the mbed OS repository when creating new program. Supported: https, http, ssh, git. Default: inferred from URL.'),
18781879
dict(name='--offline', action='store_true', help='Offline mode will force the use of locally cached repositories and prevent requests to remote repositories.'),
1880+
dict(name='--no-requirements', action='store_true', help='Disables checking for and installing any requirements.'),
18791881
help='Create new mbed program or library',
18801882
description=(
18811883
"Creates a new mbed program if executed within a non-program location.\n"
18821884
"Alternatively creates an mbed library if executed within an existing program.\n"
18831885
"When creating new program, the latest mbed-os release will be downloaded/added\n unless --create-only is specified.\n"
18841886
"Supported source control management: git, hg"))
1885-
def new(name, scm='git', program=False, library=False, mbedlib=False, create_only=False, depth=None, protocol=None, offline=False):
1887+
def new(name, scm='git', program=False, library=False, mbedlib=False, create_only=False, depth=None, protocol=None, offline=False, no_requirements=False):
18861888
global cwd_root
18871889
offline_warning(offline)
18881890

@@ -1950,7 +1952,7 @@ def new(name, scm='git', program=False, library=False, mbedlib=False, create_onl
19501952
with cd(p_path):
19511953
sync()
19521954

1953-
Program(d_path).post_action()
1955+
Program(d_path).post_action(not no_requirements)
19541956

19551957

19561958
# Import command
@@ -1962,13 +1964,14 @@ def new(name, scm='git', program=False, library=False, mbedlib=False, create_onl
19621964
dict(name='--protocol', nargs='?', help='Transport protocol for the source control management. Supported: https, http, ssh, git. Default: inferred from URL.'),
19631965
dict(name='--insecure', action='store_true', help='Allow insecure repository URLs. By default mbed CLI imports only "safe" URLs, e.g. based on standard ports - 80, 443 and 22. This option enables the use of arbitrary URLs/ports.'),
19641966
dict(name='--offline', action='store_true', help='Offline mode will force the use of locally cached repositories and prevent requests to remote repositories.'),
1967+
dict(name='--no-requirements', action='store_true', help='Disables checking for and installing any requirements.'),
19651968
hidden_aliases=['im', 'imp'],
19661969
help='Import program from URL',
19671970
description=(
19681971
"Imports mbed program and its dependencies from a source control based URL\n"
19691972
"(GitHub, Bitbucket, mbed.org) into the current directory or specified\npath.\n"
19701973
"Use \"mbed add <URL>\" to add a library into an existing program."))
1971-
def import_(url, path=None, ignore=False, depth=None, protocol=None, insecure=False, offline=False, top=True):
1974+
def import_(url, path=None, ignore=False, depth=None, protocol=None, insecure=False, offline=False, no_requirements=False, top=True):
19721975
global cwd_root
19731976
offline_warning(offline, top)
19741977

@@ -2028,7 +2031,7 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, insecure=Fa
20282031
deploy(ignore=ignore, depth=depth, protocol=protocol, insecure=insecure, offline=offline, top=False)
20292032

20302033
if top:
2031-
Program(repo.path).post_action()
2034+
Program(repo.path).post_action(not no_requirements)
20322035

20332036

20342037
# Add library command
@@ -2040,13 +2043,14 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, insecure=Fa
20402043
dict(name='--protocol', nargs='?', help='Transport protocol for the source control management. Supported: https, http, ssh, git. Default: inferred from URL.'),
20412044
dict(name='--insecure', action='store_true', help='Allow insecure repository URLs. By default mbed CLI imports only "safe" URLs, e.g. based on standard ports - 80, 443 and 22. This option enables the use of arbitrary URLs/ports.'),
20422045
dict(name='--offline', action='store_true', help='Offline mode will force the use of locally cached repositories and prevent requests to remote repositories.'),
2046+
dict(name='--no-requirements', action='store_true', help='Disables checking for and installing any requirements.'),
20432047
hidden_aliases=['ad'],
20442048
help='Add library from URL',
20452049
description=(
20462050
"Adds mbed library and its dependencies from a source control based URL\n"
20472051
"(GitHub, Bitbucket, mbed.org) into an existing program.\n"
20482052
"Use \"mbed import <URL>\" to import as a program"))
2049-
def add(url, path=None, ignore=False, depth=None, protocol=None, insecure=False, offline=False, top=True):
2053+
def add(url, path=None, ignore=False, depth=None, protocol=None, insecure=False, offline=False, no_requirements=False, top=True):
20502054
offline_warning(offline, top)
20512055

20522056
repo = Repo.fromrepo()
@@ -2059,7 +2063,7 @@ def add(url, path=None, ignore=False, depth=None, protocol=None, insecure=False,
20592063
repo.add(lib.lib)
20602064

20612065
if top:
2062-
Program(repo.path).post_action()
2066+
Program(repo.path).post_action(not no_requirements)
20632067

20642068

20652069
# Remove library
@@ -2089,12 +2093,13 @@ def remove(path):
20892093
dict(name='--protocol', nargs='?', help='Transport protocol for the source control management. Supported: https, http, ssh, git. Default: inferred from URL.'),
20902094
dict(name='--insecure', action='store_true', help='Allow insecure repository URLs. By default mbed CLI imports only "safe" URLs, e.g. based on standard ports - 80, 443 and 22. This option enables the use of arbitrary URLs/ports.'),
20912095
dict(name='--offline', action='store_true', help='Offline mode will force the use of locally cached repositories and prevent requests to remote repositories.'),
2096+
dict(name='--no-requirements', action='store_true', help='Disables checking for and installing any requirements.'),
20922097
help='Find and add missing libraries',
20932098
description=(
20942099
"Import missing dependencies in an existing program or library.\n"
20952100
"Hint: Use \"mbed import <URL>\" and \"mbed add <URL>\" instead of cloning\n"
20962101
"manually and then running \"mbed deploy\""))
2097-
def deploy(ignore=False, depth=None, protocol=None, insecure=False, offline=False, top=True):
2102+
def deploy(ignore=False, depth=None, protocol=None, insecure=False, offline=False, no_requirements=False, top=True):
20982103
offline_warning(offline, top)
20992104

21002105
repo = Repo.fromrepo()
@@ -2110,7 +2115,7 @@ def deploy(ignore=False, depth=None, protocol=None, insecure=False, offline=Fals
21102115

21112116
if top:
21122117
program = Program(repo.path)
2113-
program.post_action()
2118+
program.post_action(not no_requirements)
21142119
if program.is_classic:
21152120
program.update_tools(os.path.join(getcwd(), '.temp'))
21162121

@@ -2177,13 +2182,14 @@ def publish(all_refs=None, msg=None, top=True):
21772182
dict(name='--insecure', action='store_true', help='Allow insecure repository URLs. By default mbed CLI imports only "safe" URLs, e.g. based on standard ports - 80, 443 and 22. This option enables the use of arbitrary URLs/ports.'),
21782183
dict(name='--offline', action='store_true', help='Offline mode will force the use of locally cached repositories and prevent requests to remote repositories.'),
21792184
dict(name=['-l', '--latest-deps'], action='store_true', help='Update all dependencies to the latest revision of their current branch. WARNING: Ignores lib files'),
2185+
dict(name='--no-requirements', action='store_true', help='Disables checking for and installing any requirements.'),
21802186
hidden_aliases=['up'],
21812187
help='Update to branch, tag, revision or latest',
21822188
description=(
21832189
"Updates the current program or library and its dependencies to specified\nbranch, tag or revision.\n"
21842190
"Alternatively fetches from associated remote repository URL and updates to the\n"
21852191
"latest revision in the current branch."))
2186-
def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=False, depth=None, protocol=None, insecure=False, offline=False, latest_deps=False, top=True):
2192+
def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=False, depth=None, protocol=None, insecure=False, offline=False, latest_deps=False, no_requirements=False, top=True):
21872193
offline_warning(offline, top)
21882194

21892195
if top and clean:
@@ -2284,7 +2290,7 @@ def update(rev=None, clean=False, clean_files=False, clean_deps=False, ignore=Fa
22842290
if top:
22852291
program = Program(repo.path)
22862292
program.set_root()
2287-
program.post_action()
2293+
program.post_action(not no_requirements)
22882294
if program.is_classic:
22892295
program.update_tools(os.path.join(getcwd(), '.temp'))
22902296

0 commit comments

Comments
 (0)