Skip to content

Instantly share code, notes, and snippets.

@rondreas
Last active November 6, 2019 14:08
Show Gist options
  • Select an option

  • Save rondreas/af82ef693eac6bb693c840fdf456a754 to your computer and use it in GitHub Desktop.

Select an option

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.
# 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