Morpheus / Mbed OS mbed-Client-Morpheus-hg

Dependencies:   mbed-os

Revision:
11:ab6a9a482a1d
Parent:
10:dc8f1363b424
Child:
13:3ae12fe3354a
--- a/neo.py	Wed Mar 30 01:00:44 2016 -0500
+++ b/neo.py	Wed Mar 30 01:51:29 2016 -0500
@@ -131,7 +131,7 @@
                 self.repo = temp.repo
 
     def gettype(self):
-        for type, dir in [('git', '.git'), ('hg', '.hg')]:
+        for type, dir in [('hg', '.hg'), ('git', '.git')]:
             if os.path.isdir(os.path.join(self.path, dir)):
                 return type
 
@@ -148,7 +148,7 @@
 def import_(url, name=None):
     repo = Repo.fromurl(url, name)
 
-    for type in ['git', 'hg']:
+    for type in ['hg', 'git']:
         try:
             popen([type, 'clone', repo.repo, repo.path])
             break
@@ -200,6 +200,23 @@
 
     popen(['rm', '-rf', repo.path])
 
+# Publish command
+@subcommand('publish',
+    help='recursively publish changes to remote repositories')
+def publish():
+    cwd = Repo()
+
+    for url, lib in iterlibs():
+        if os.path.isdir(lib):
+            with cd(lib):
+                publish()
+
+#    if cwd.type == 'git':
+#        if pquery(['git'
+#
+#    if (cwd.type == 'git' and pquery(['git', 'diff', '--name-only', 'HEAD']))
+    print 'DONT WORK YET'
+
 # Synch command
 @subcommand('synch',
     help='synchronize lib files')
@@ -223,6 +240,10 @@
 def compile(args):
     cwd = Repo()
 
+    if not os.path.isdir('mbed-os'):
+        sys.stderr.write('Warning! mbed-os not found?')
+        sys.exit(-1)
+
     if not os.path.isfile('mbed_settings.py'):
         shutil.copy('mbed-os/tools/settings.py', 'mbed_settings.py')
 
@@ -239,6 +260,22 @@
         + args,
         env=env)
 
+# Export command
+@subcommand('export', 'args*',
+    help='generate project files')
+def export(args):
+    cwd = Repo()
+
+    if not os.path.isdir('mbed-os'):
+        sys.stderr.write('Warning! mbed-os not found?')
+        sys.exit(-1)
+
+    if not os.path.isfile('mbed_settings.py'):
+        shutil.copy('mbed-os/tools/settings.py', 'mbed_settings.py')
+
+    popen(['python', 'mbed-os/tools/project.py',
+           '--source=%s' % cwd.path])
+
 # Parse/run command
 args, remainder = parser.parse_known_args()
 status = args.command(args)