-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexchangedl.py
More file actions
29 lines (25 loc) · 728 Bytes
/
Copy pathexchangedl.py
File metadata and controls
29 lines (25 loc) · 728 Bytes
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 sys
import os
import splunk.Intersplunk
import subprocess
import copy
def _expand(mail):
e = copy.deepcopy(os.environ)
e.pop("PYTHONPATH")
p = subprocess.Popen(["/opt/exchdl.py", mail], stdout = subprocess.PIPE, stderr = subprocess.PIPE, env = e)
out = p.communicate()
sys.stderr.write(out[1])
if p.returncode: exit(p.returncode)
return out[0].decode()
results, _, settings = splunk.Intersplunk.getOrganizedResults()
newresults = []
for result in results:
r = result["recipients"].split(" ")
r2 = []
r2 += _expand(" ".join(r)).split(" ")
r2 = list(set(r2))
r2.sort()
result["recipients"] = "\n".join(r2)
result["recnum"] = len(r2)
newresults.append(result)
splunk.Intersplunk.outputResults(newresults)