Morpheus / Mbed OS mbed-Client-Morpheus-hg

Dependencies:   mbed-os

Revision:
67:c3b033f16424
Parent:
66:bfe0df4ef9f5
Child:
69:eb600c35d6ac
--- a/neo.py	Wed Mar 30 20:15:09 2016 -0500
+++ b/neo.py	Fri Apr 01 14:24:17 2016 +0100
@@ -19,10 +19,10 @@
 subparsers = parser.add_subparsers()
 
 def log(msg):
-    sys.stderr.write("---\n>>> "+msg+"\n")
+    sys.stderr.write("---\n"+msg+"\n")
 
 def error(msg, code):
-    sys.stderr.write("---\n>>> ERROR: "+msg+"---\n")
+    sys.stderr.write("---\nERROR: "+msg+"\n---\n")
     sys.exit(code)
     
 def subcommand(name, *args, **kwargs):
@@ -47,6 +47,11 @@
         return command
     return subcommand
 
+def repo_or_die():
+    repo = Repo.fromrepo()
+    if repo.scm is None:
+        error("Current folder is not a repository", -1)
+    
 # Process execution
 class ProcessException(Exception):
     pass
@@ -374,6 +379,7 @@
 @subcommand('publish',
     help='Publish working tree to remote repositories')
 def publish(always=True):
+    repo_or_die()
     repo = Repo.fromrepo()
     for lib in repo.libs:
         with cd(lib.path):
@@ -397,6 +403,7 @@
 @subcommand('update', 'ref?',
     help='Update current program or library and recursively update all libraries')
 def update(ref=None):
+    repo_or_die()
     repo = Repo.fromrepo()
     repo.scm.pull(ref)