-
Notifications
You must be signed in to change notification settings - Fork 2
/
get_complete.py
executable file
·47 lines (34 loc) · 983 Bytes
/
get_complete.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
#! /usr/bin/python
import csv
import sys
def get_log_lines(log_path):
log_file = open(log_path, 'rb')
log = log_file.read()
log_file.close()
log = log.split('\n')
if '' in log:
log.remove('')
return log
def get_completed_user_list_from_log(log_path):
log_lines = get_log_lines(log_path)
completed_users = []
for line in log_lines:
if 'Finish migrating user' in line:
tmp = line.split(' ')
for txt in tmp:
if '@' in txt:
completed_users.append(txt)
return completed_users
def list_to_csv(list_data, csv_path):
csv_file = open(csv_path, 'wb')
writer = csv.writer(csv_file, dialect='excel')
for data in list_data:
writer.writerow([data])
csv_file.close()
def export_completed_users_to_csv(log_path, csv_path):
completed_users = get_completed_user_list_from_log(log_path)
list_to_csv(completed_users, csv_path)
if __name__ == "__main__":
log_path = sys.argv[1]
csv_path = sys.argv[2]
export_completed_users_to_csv(log_path, csv_path)