aboutsummaryrefslogtreecommitdiffstats
path: root/test/testdata/fake_converter.py
blob: f9ef102ca4f227e7d80c2c7a54be0a974d569a1f (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
import time
import sys
import os
import json

filename, output = sys.argv[1:3]
if 'error' in filename:
    print json.dumps({'finished': True, 'error': 'test error'})
    sys.exit(1)

if os.path.exists(output):
    print json.dumps({'finished': True,
                      'error': '%r existed when we started' % (
                output,)})
    sys.exit(1)

time.sleep(0.5)
RANGE = 5
for i in range(RANGE):
    print json.dumps({
            'filename': filename,
            'output': output,
            'duration': RANGE,
            'progress': i,
            'eta': RANGE - i
            })
    time.sleep(0.1)

with file(output, 'w') as f:
    f.write('blank')
print json.dumps({'finished': True})