You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mbed/mbed.py
+40-17Lines changed: 40 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -573,7 +573,9 @@ def fromrepo(cls, path=None):
573
573
ifpathisNone:
574
574
path=Repo.findrepo(os.getcwd())
575
575
ifpathisNone:
576
-
error('Cannot find the program or library in the current path \"%s\".\nPlease change your working directory to a different location or use command \"new\" to create a new program.'%os.getcwd(), 1)
576
+
error(
577
+
"Cannot find the program or library in the current path \"%s\".\n"
578
+
"Please change your working directory to a different location or use \"mbed new\" to create a new program."%os.getcwd(), 1)
577
579
578
580
repo.path=os.path.abspath(path)
579
581
repo.name=os.path.basename(repo.path)
@@ -741,29 +743,42 @@ def rm_untracked(self):
741
743
os.remove(file)
742
744
743
745
defcan_update(self, clean, force):
746
+
err=None
744
747
if (self.is_localorself.urlisNone) andnotforce:
745
-
returnFalse, "Preserving local library \"%s\" in \"%s\".\nPlease publish this library to a remote URL to be able to restore it at any time.\nYou can use --ignore switch to ignore all local libraries and update only the published ones.\nYou can also use --force switch to remove all local libraries. WARNING: This action cannot be undone."% (self.name, self.path)
748
+
err= (
749
+
"Preserving local library \"%s\" in \"%s\".\nPlease publish this library to a remote URL to be able to restore it at any time."
750
+
"You can use --ignore switch to ignore all local libraries and update only the published ones.\n"
751
+
"You can also use --force switch to remove all local libraries. WARNING: This action cannot be undone."% (self.name, self.path))
746
752
ifnotcleanandself.scm.dirty():
747
-
returnFalse, "Uncommitted changes in \"%s\" in \"%s\".\nPlease discard or stash them first and then retry update.\nYou can also use --clean switch to discard all uncommitted changes. WARNING: This action cannot be undone."% (self.name, self.path)
753
+
err= (
754
+
"Uncommitted changes in \"%s\" in \"%s\".\nPlease discard or stash them first and then retry update.\n"
755
+
"You can also use --clean switch to discard all uncommitted changes. WARNING: This action cannot be undone."% (self.name, self.path))
748
756
ifnotforceandself.scm.outgoing():
749
-
returnFalse, "Unpublished changes in \"%s\" in \"%s\".\nPlease publish them first using the \"publish\" command.\nYou can also use --force to discard all local commits and replace the library with the one included in this revision. WARNING: This action cannot be undone."% (self.name, self.path)
757
+
err= (
758
+
"Unpublished changes in \"%s\" in \"%s\".\nPlease publish them first using the \"publish\" command.\n"
759
+
"You can also use --force to discard all local commits and replace the library with the one included in this revision. WARNING: This action cannot be undone."% (self.name, self.path))
750
760
751
-
returnTrue, "OK"
761
+
return(False, err) iferrelse (True, "OK")
752
762
753
763
defcheck_repo(self, show_warning=None):
764
+
err=None
754
765
ifnotos.path.isdir(self.path):
755
-
ifshow_warning:
756
-
warning("Library reference \"%s\" points to non-existing library in \"%s\"\nYou can use \"deploy\" command to import the missing libraries.\nYou can also use \"sync\" command to synchronize and remove all invalid library references."% (os.path.basename(self.lib), self.path))
757
-
else:
758
-
error("Library reference \"%s\" points to non-existing library in \"%s\"\nYou can use \"deploy\" command to import the missing libraries\nYou can also use \"sync\" command to synchronize and remove all invalid library references."% (os.path.basename(self.lib), self.path), 1)
759
-
returnFalse
766
+
err= (
767
+
"Library reference \"%s\" points to non-existing library in \"%s\"\n"
768
+
"You can use \"mbed deploy\" to import the missing libraries.\n"
769
+
"You can also use \"mbed sync\" to synchronize and remove all invalid library references."% (os.path.basename(self.lib), self.path))
760
770
elifnotself.isrepo(self.path):
771
+
err= (
772
+
"Library reference \"%s\" points to a folder \"%s\", which is not a valid repository.\n"
773
+
"You can remove the conflicting folder manually and use \"mbed deploy\" to import the missing libraries\n"
774
+
"You can also remove library reference \"%s\" and use \"mbed sync\" again."% (os.path.basename(self.lib), self.path, self.lib))
775
+
776
+
iferr:
761
777
ifshow_warning:
762
-
warning("Library reference \"%s\" points to a folder \"%s\", which is not a valid repository.\nYou can remove the conflicting folder manually and use \"deploy\" command to import the missing libraries\nYou can also remove library reference \"%s\" and use the \"sync\" command again."% (os.path.basename(self.lib), self.path, self.lib))
778
+
warning(err)
763
779
else:
764
-
error("Library reference \"%s\" points to a folder \"%s\", which is not a valid repository.\nYou can remove the conflicting folder manually and use \"deploy\" command to import the missing libraries\nYou can also remove library reference \"%s\" and use the \"sync\" command again."% (os.path.basename(self.lib), self.path, self.lib), 1)
error("Cannot import program in the specified location \"%s\" because it's already part of a program.\nPlease change your working directory to a different location or use command \"mbed add\" to import the URL as a library."%os.path.abspath(repo.path), 1)
910
+
error("Cannot import program in the specified location \"%s\" because it's already part of a program.\n"
911
+
"Please change your working directory to a different location or use \"mbed add\" to import the URL as a library."%os.path.abspath(repo.path), 1)
error("%s \"%s\" in \"%s\" is a local repository.\nPlease associate it with a remote repository URL before attempting to publish.\nRead more about %s repositories here:\nhttp://developer.mbed.org/handbook/how-to-publish-with-%s/"% ("Program"iftopelse"Library", repo.name, repo.path, repo.scm.name, repo.scm.name), 1)
1009
+
error(
1010
+
"%s \"%s\" in \"%s\" is a local repository.\nPlease associate it with a remote repository URL before attempting to publish.\n"
1011
+
"Read more about %s repositories here:\nhttp://developer.mbed.org/handbook/how-to-publish-with-%s/"% ("Program"iftopelse"Library", repo.name, repo.path, repo.scm.name, repo.scm.name), 1)
error("This %s is in detached HEAD state, and you won't be able to receive updates from the remote repository until you either checkout a branch or create a new one.\nYou can checkout a branch using \"%s checkout <branch_name>\" command before running \"mbed update\"."% (cwd_type, repo.scm.name), 1)
1051
+
error(
1052
+
"This %s is in detached HEAD state, and you won't be able to receive updates from the remote repository until you either checkout a branch or create a new one.\n"
1053
+
"You can checkout a branch using \"%s checkout <branch_name>\" command before running \"mbed update\"."% (cwd_type, repo.scm.name), 1)
1034
1054
1035
1055
# Fetch from remote repo
1036
1056
action("Updating %s \"%s\" to %s"% (
@@ -1387,7 +1407,10 @@ def toolchain(name=None):
1387
1407
error('Subrocess exit with error code %d'%e[0], e[0])
1388
1408
exceptOSErrorase:
1389
1409
ife[0] ==2:
1390
-
error('Could not detect one of the command-line tools.\nPlease verify that you have Git and Mercurial installed and accessible from your current path by executing commands "git" and "hg".\nHint: check the last executed command above.', e[0])
1410
+
error(
1411
+
"Could not detect one of the command-line tools.\n"
1412
+
"Please verify that you have Git and Mercurial installed and accessible from your current path by executing commands \"git\" and \"hg\".\n"
1413
+
"Hint: check the last executed command above.", e[0])
0 commit comments