-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.py
42 lines (29 loc) · 919 Bytes
/
sync.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
#!/usr/bin/env python3
import time
import subprocess
import os
def set_identity(name, email):
subprocess.check_call(
'git config --global user.name "{}"'.format(name).split())
subprocess.check_call(
'git config --global user.email "{}"'.format(email).split())
def mode():
output = subprocess.check_output('git annx info'.split()).decode()
return output.splitlines()[0].split(':')[1].strip()
def _do_sync():
os.chdir('/data')
subprocess.check_call(
'git annex add .'.split())
if mode() == 'indirect':
subprocess.call(
'git commit -a -m'.split() +
['"from {}"'.format(os.uname().nodename)])
subprocess.check_call('git annex sync'.split())
def sync(every=60):
while True:
_do_sync()
time.sleep(every)
main = sync
if __name__ == '__main__':
set_identity('test user', '[email protected]')
main()