-
Notifications
You must be signed in to change notification settings - Fork 0
/
hashlistener.py
29 lines (22 loc) · 1.11 KB
/
hashlistener.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
import subprocess
from slingshot import Slingshot
class HashListener():
@staticmethod
def check_local_save_state():
result = Slingshot.runtime_settings['localHash']
return result.strip()
@staticmethod
def check_local_active_state():
result = subprocess.check_output('find ' + Slingshot.runtime_settings['localDir'] + ' ' + '-printf \"%T@ %p\n" | md5sum | cut -d " " -f 1', shell=True,stderr=subprocess.STDOUT)
return result.strip()
@staticmethod
def check_remote_save_state():
result = Slingshot.runtime_settings['remoteHash']
return result.strip()
@staticmethod
def check_remote_active_state():
user = Slingshot.runtime_settings['remoteSSHUser'] + "@" if Slingshot.key_exists(Slingshot.runtime_settings, 'remoteSSHUser') else ''
remote_command = 'find ' + Slingshot.runtime_settings['remoteDir'] + ' -printf "%T@ %p\n" | md5sum | cut -d " " -f 1'
cmd = ( 'ssh ' + user + Slingshot.runtime_settings['remoteSSHAddress'] + ' ' + remote_command)
result = subprocess.check_output(cmd.split())
return result.strip()