blob: 4e5f0c30825df48c7fca0f9fdf995c99106a8495 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#! /ufs/guido/bin/sgi/python
# Add a cache to each of the files given as command line arguments
# Usage:
#
# Vaddcache [file] ...
# Options:
#
# file ... : file(s) to modify; 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]'
|