-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAnonymize.py.bak
More file actions
54 lines (42 loc) · 2.05 KB
/
Anonymize.py.bak
File metadata and controls
54 lines (42 loc) · 2.05 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
import argparse
import config
import os
import subprocess
import sys
from utility import utility
parser = argparse.ArgumentParser("This script creates an anonymous dataset from the rawLogData.")
parser.add_argument("--ignoreLock", "-i", help="Ignore locked file and "
+ "execute anyways", action="store_true")
parser.add_argument("--threads", "-t", default=10, type=int, help="The number "
+ "of threads to run the java program with (default 7).")
parser.add_argument("--logging", "-l", help="Enables file logging.",
action="store_true")
parser.add_argument("--monthsFolder", "-m", default=config.monthsFolder,
type=str,
help="The folder in which the months directory are "
+ "residing.")
parser.add_argument("--unanonymizedStringLength", "-u", default=10, type=int,
help="Strings of this length or lower should not be anonymized. Default is ten.")
parser.add_argument("months", type=str, help="The months to be processed")
if (len(sys.argv[1:]) == 0):
parser.print_help()
parser.exit()
args = parser.parse_args()
for monthName in args.months.split(","):
mavenCall = ['mvn', 'exec:java@Anonymizer']
month = utility.addMissingSlash(os.path.abspath(utility.addMissingSlash(args.monthsFolder) + utility.addMissingSlash(monthName)))
mavenArguments = '-Dexec.args=-w ' + month + ' -n ' + str(args.threads) + ' -u ' + str(args.unanonymizedStringLength)
if args.logging:
mavenArguments += " -l"
mavenCall.append(mavenArguments)
owd = os.getcwd()
os.chdir("..")
print "Starting data processing using Anonymizer for " + monthName + "."
if subprocess.call(['mvn', 'clean', 'package']) != 0:
print "ERROR: Could not package the java application."
sys.exit(1)
if subprocess.call(mavenCall) != 0:
print("ERROR: Could not execute the java application. Check the logs "
+ "for details or rerun this script with -l to generate logs.")
sys.exit(1)
os.chdir(owd)