This repository was archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
66 lines (48 loc) · 1.37 KB
/
test.py
File metadata and controls
66 lines (48 loc) · 1.37 KB
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 ctypes
import os
import tempfile
from datetime import datetime
from signal import SIGINT
from time import sleep
from fuse import FUSE, fuse_exit
from threading import Thread
from main import Passthrough
def fuse_exit():
"""
srced from https://github.com/fusepy/fusepy/issues/116#issuecomment-391090718
"""
os.kill(os.getpid(), SIGINT)
def walk(path, pref=''):
if os.path.isdir(path):
for i in os.listdir(path):
yield from walk(os.path.join(path, i), pref + '> ')
else:
print(f'{pref}{path}')
yield path
def test(mountpoint):
try:
sleep(0.5)
print('Starting tests')
times = []
for x in range(5):
times.append(datetime.utcnow())
print([*walk(mountpoint)])
last = datetime.utcnow()
for i, x in enumerate(times):
print(i, '--', last - x)
print('All tests done')
finally:
fuse_exit()
def main():
token = open('token.txt').read().strip()
with tempfile.TemporaryDirectory() as mountpoint:
print('mountpoint = ', mountpoint)
ops = Passthrough(token)
t = Thread(target=test, args=(mountpoint, ))
t.start()
print('FUSE starting')
FUSE(ops, mountpoint, debug=True)
print('FUSE exited', flush=True)
t.join()
if __name__ == '__main__':
main()