Last active
November 6, 2019 14:08
-
-
Save rondreas/af82ef693eac6bb693c840fdf456a754 to your computer and use it in GitHub Desktop.
Modo script to print all fire and forget scripts for the given kit to log.
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
| # python | |
| """ | |
| Modo script to print all fire and forget scripts for the given kit to log. | |
| Example:: | |
| @list_kit_scripts.py my_kit | |
| """ | |
| import os | |
| import re | |
| import lx | |
| def main(): | |
| try: | |
| kit_name, = lx.args() | |
| except: | |
| lx.out("Failed to unpack arguments.") | |
| return | |
| file_svc = lx.service.File() | |
| script_folder = file_svc.ToLocalAlias('kit_{}:scripts'.format(kit_name)) | |
| if not os.path.exists(script_folder): | |
| lx.out("Couldn't find the alias path {}".format('kit_' + kit_name)) | |
| return | |
| for f in os.listdir(script_folder): | |
| _, ext = os.path.splitext(f) | |
| if ext.lower() != '.py': | |
| continue | |
| path = os.path.join(script_folder, f) | |
| with open(path, 'r') as file_object: | |
| line = file_object.readline() | |
| if re.match('\#\s*python', line.strip()): | |
| print(f) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment