Browse Source

execute Abe command non recursive

Tobias Simetsreiter 5 years ago
parent
commit
1dae7a873f
1 changed files with 19 additions and 15 deletions
  1. 19 15
      abe_setup.py

+ 19 - 15
abe_setup.py

@@ -15,18 +15,19 @@ def main():
 
     count_submodules = 0
 
-    for sub in abe_submodules( args.output_dir, args.source_url, args.tag):
-        count_submodules += 1
-        if DEBUG > 0:
-            print("Count:",count_submodules)
-
-        if args.abe_command:
-            executeAbeCommand( sub.path, args.execute_command )
-        else:
-            clone_repo_cached( sub, cache_dir=args.cache_dir, fetch_origin=(not args.no_fetch_origin))
-        if args.execute_command:
-            from subprocess import run
-            run(args.execute_command, shell=True,check=True, cwd=sub.path)
+    if args.abe_command:
+        executeAbeCommand( args.output_dir, args.abe_command )
+    else:
+        for sub in abe_submodules( args.output_dir, args.source_url, args.tag):
+            count_submodules += 1
+            if DEBUG > 0:
+                print("Count:",count_submodules)
+
+            if args.execute_command:
+                from subprocess import run
+                run(args.execute_command, shell=True,check=True, cwd=sub.fullpath)
+            else:
+                clone_repo_cached( sub, cache_dir=args.cache_dir, fetch_origin=(not args.no_fetch_origin))
 
 
 def parser():
@@ -45,11 +46,14 @@ def parser():
 
 def executeAbeCommand( repo_path, command_name ):
     import os
-    from subprocess import run
-    commandFileRel = os.path.join('.abe', 'commands', command_name)
+    from subprocess import run, CalledProcessError
+    commandFileRel = os.path.join('.abe', 'commands', command_name + ".cmd")
     commandFile = os.path.join(repo_path, commandFileRel)
     if os.path.isfile(commandFile):
-        run([ commandFileRel ], check=True, cwd=repo_path)
+        try:
+            proc = run([ 'bash', '-c', f"set -e;./{commandFileRel}" ], check=True, cwd=repo_path)
+        except CalledProcessError as err:
+            print(commandFileRel, 'in', repo_path, 'returned exitcode', err.returncode)
 
 
 def abe_submodules(path, remote, ref, parent=None):