Created
February 24, 2014 04:54
-
-
Save boseji/9182144 to your computer and use it in GitHub Desktop.
Runner function for executing Python scripts from inside a Python script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os,sys,importlib | |
from os import path | |
def Runner(sRootPath): | |
''' Runs all the scripts in lower directories | |
@param sRootPath Specifies the Path from which Script Running should start | |
@return None | |
''' | |
try: | |
for root, dirs, files in os.walk(sRootPath): | |
#bypass dir with _ and __ , Process only if some files | |
if (root.endswith('_') == False) and (len(files) > 0 ) and \ | |
(root != sRootPath) and (root.find("__")==-1): | |
print("-" * 20) | |
print(" Root: ",root) | |
print("-" * 20) | |
for name in files: | |
#check for scripts but avoid packages | |
if name.endswith(".py") and (root.find("__")==-1): | |
print(" Running Script : ",name) | |
#RunScript(root,name) | |
print() | |
except Exception as p: | |
print("\nProblem in Runner :",p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment