diff options
author | Guido van Rossum <guido@python.org> | 1992-09-08 15:17:02 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-09-08 15:17:02 (GMT) |
commit | 5c1797ac23d4e8faec6f255593dc0c4b76213efe (patch) | |
tree | dd57020292d65dcade9b5bfaee070d3a9fa4dc68 /Demo | |
parent | 269b2a2eb7c5d63bdfb7989a9c9626e8940aafd4 (diff) | |
download | cpython-5c1797ac23d4e8faec6f255593dc0c4b76213efe.zip cpython-5c1797ac23d4e8faec6f255593dc0c4b76213efe.tar.gz cpython-5c1797ac23d4e8faec6f255593dc0c4b76213efe.tar.bz2 |
Utility to add a cached index to an existing movie file.
Diffstat (limited to 'Demo')
-rwxr-xr-x | Demo/sgi/video/Vaddcache.py | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/Demo/sgi/video/Vaddcache.py b/Demo/sgi/video/Vaddcache.py new file mode 100755 index 0000000..191d6ea --- /dev/null +++ b/Demo/sgi/video/Vaddcache.py @@ -0,0 +1,79 @@ +#! /usr/local/python + +# Add a cache to each of the files given as command line arguments + + +# Usage: +# +# Vaddcache [file] ... + + +# Options: +# +# file ... : file(s) to inspect; default film.video + + +import sys +sys.path.append('/ufs/guido/src/video') +import VFile +import getopt + + +# Global options + +# None + + +# Main program -- mostly command line parsing + +def main(): + opts, args = getopt.getopt(sys.argv[1:], '') + if not args: + args = ['film.video'] + sts = 0 + for filename in args: + if process(filename): + sts = 1 + sys.exit(sts) + + +# Process one file + +def process(filename): + try: + fp = open(filename, 'r+') + vin = VFile.RandomVinFile().initfp(fp, filename) + except IOError, msg: + sys.stderr.write(filename + ': I/O error: ' + `msg` + '\n') + return 1 + except VFile.Error, msg: + sys.stderr.write(msg + '\n') + return 1 + except EOFError: + sys.stderr.write(filename + ': EOF in video file\n') + return 1 + + try: + vin.readcache() + hascache = 1 + except VFile.Error: + hascache = 0 + + if hascache: + sys.stderr.write(filename + ': already has a cache\n') + vin.close() + return 1 + + vin.printinfo() + vin.warmcache() + vin.writecache() + vin.close() + return 0 + + +# Don't forget to call the main program + +try: + main() +except KeyboardInterrupt: + print '[Interrupt]' |