-
Notifications
You must be signed in to change notification settings - Fork 1
/
diffbatch.py
55 lines (26 loc) · 974 Bytes
/
diffbatch.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
__author__ = 'Caritasem'
import os, re, subprocess, sys
import xml.etree.ElementTree as etree
from config import work_dir, filezilla_sites, filezilla_config, exam
from function import diff, run_cmd, notify
filezilla_log = ""
configxml = etree.parse( filezilla_config )
configroot = configxml.getroot()
configlog = configroot.find(".//*[@name='Logging file']")
if (configlog is None):
notify("Filezilla", "Logging file location not set")
sys.exit()
filezilla_log = configlog.text
remote_str = ""
exam_server = run_cmd("grep Connected %s | tail -1 | awk '{ print $8}'" % ( filezilla_log ))
lastlog = run_cmd("grep local:%s %s | tail -1" % (exam, filezilla_log))
m = re.search( "remote\:(.*?)=", lastlog )
remote_file = m.group(1)
tree = etree.parse( filezilla_sites )
root = tree.getroot()
for server in root.iter('Server'):
host = server.find("Host").text
if host != exam_server:
continue
diff(server, remote_file)
print( "done" )