From 0fbef134cede8d1f7fe5bb7337803cc01702984f Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Sat, 9 Oct 2010 16:00:22 +0200 Subject: [PATCH] first commit, command still hardcoded in --- .gitignore | 45 +++++++++++++++++++++++++++++++++++++++++++++ runonsave.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 .gitignore create mode 100644 runonsave.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2e1901d --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +syntax: glob + +# build directories and files +**/build/* +build/* +target/**.* #hg syntax +target #git syntax +dist/**.* +*.pyc + + +#Eclipse +.settings/*.** +.classpath +.project + +# Netbeans +nb-configuration.xml +nbactions.xml + +# Backup files left behind by the Emacs editor. +*~ +# Lock files used by the Emacs editor. +.\#* +# Temporary files used by TestMate +._* +# XCode user data +**.pbxuser +**.mode?v? +**.perspectivev? +# documentation +**.docset/* +# for those crazies using svn and hg at the same time +*.svn* +*.swp + +# Random OS stuff +.DS_Store +Thumbs.db + +# temporary folders +syntax: regexp +.*/te?mp/.* +# Temporary files used by the vim editor. +.*.swp diff --git a/runonsave.py b/runonsave.py new file mode 100644 index 0000000..44e37b8 --- /dev/null +++ b/runonsave.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +""" +SYNOPSIS + + TODO helloworld [-h,--help] [-v,--verbose] [--version] + +DESCRIPTION + + Runs a command when a file in the current working directory is changed + +EXAMPLES + + TODO: Show some examples of how to use this script. + +EXIT STATUS + + TODO: List exit codes + +AUTHOR + + Leonard Ehrenfried + +""" + +import os +import subprocess +import time +import re + +SCAN_INTERVAL=10 + +def main (): + cwd = os.getcwd() + last_run=os.path.getmtime(cwd) + while(True): + last_modified=os.path.getmtime(cwd) + if (last_modified > last_run): + print "*** Save detected - running command ***" + subprocess.Popen(['pdflatex', 'cv.tex', ]) + last_run=last_modified + time.sleep(SCAN_INTERVAL) + +if __name__ == '__main__': + main() +