forked from sxyazi/free-hls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
66 lines (54 loc) · 1.5 KB
/
test.py
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
import os, tempfile, time
from os import getenv as _
from utils import uploader
from dotenv import load_dotenv
load_dotenv()
os.environ['UPLOAD_DRIVE'] = os.sys.argv[1]
handle, params = uploader().handle, uploader().params()
def upload(size):
fd, path = tempfile.mkstemp()
with open(path, 'wb') as f:
f.write(os.urandom(size * 1048576 - params['padding']))
r = handle(path)
os.close(fd)
os.unlink(path)
return r
def test(curr, step):
maps = {}
reve = False
reve_inc = None
print('Starting test %s:' % _('UPLOAD_DRIVE'))
while True:
if curr in maps:
result = maps[curr]
else:
result = maps[curr] = upload(curr)
print('%dM\t%s\t%s' % (curr, 'OK' if result else 'FAIL', result))
if not result:
reve = True
if not reve and curr > 20:
step = 20
if not reve and curr > 50:
step = 30
if not result and not reve_inc == None:
print('\n---\nFinally ... %dM' % reve_inc)
exit(0)
if reve and result:
reve_inc = curr
curr += 1
elif reve and not result:
if (curr - 1) % 5 == 0:
curr -= 1
else:
step //= 2
curr -= max(1, step)
if curr < 1:
curr = 1
reve_inc = 0
elif not reve:
curr += step
if __name__ == '__main__':
# print(handle('/Users/ika/Desktop/test/9913509E9DE4492E0E903B4C2C66E98D.gif'))
# print(handle('/Users/ika/Desktop/test/ACFC928140EE4FA072F4D6EB7CB35245.jpg'))
# print(handle('/Users/ika/Desktop/test/out00006.ts'))
test(1, 10)