-
-
Save Gribouillis/02f8e6213c3f6ed6be39094265b044a4 to your computer and use it in GitHub Desktop.
A script to watch files and automatically run a python script
This file contains 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
#!/usr/bin/env python3 | |
# -*-coding: utf8-*- | |
'''doc | |
''' | |
__version__ = '0.1.0' | |
from argparse import ArgumentParser | |
import sys | |
def task_AutoExecution(): | |
"""my doc""" | |
yield { | |
'basename': 'AutoExecution', | |
'actions': ['PYTHONIOENCODING="utf8" {python} {script}'.format(python=sys.executable, script=SCRIPT)], | |
'watch': [PROG] + WATCH, | |
'verbosity': 2, | |
} | |
if __name__ == '__main__': | |
parser = ArgumentParser(description='Automatically runs a python script every time it is changed on disk') | |
parser.add_argument('script', metavar='SCRIPT', help='python script to execute', action='store') | |
parser.add_argument('-w', '--watch', metavar='FILE', help='additional file to watch (end arglist with --)', nargs='*') | |
args = parser.parse_args() | |
SCRIPT = args.script | |
PROG = SCRIPT.strip().split()[0] | |
WATCH = args.watch or [] | |
sys.argv[1:] = ['auto',] | |
import doit | |
doit.run(globals()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment