From 3da367e0de6a00d2188135d01d9e07d929f38931 Mon Sep 17 00:00:00 2001 From: heweilin Date: Mon, 21 Aug 2023 09:57:41 +0800 Subject: [PATCH] add a logTest-heweilin.py --- it-support-engineer/logTest-heweilin.py | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 it-support-engineer/logTest-heweilin.py diff --git a/it-support-engineer/logTest-heweilin.py b/it-support-engineer/logTest-heweilin.py new file mode 100644 index 000000000..b75a0f171 --- /dev/null +++ b/it-support-engineer/logTest-heweilin.py @@ -0,0 +1,37 @@ +import re +import requests + + +def getTime_DeviceName_processName(line): + strs = line.split(' ') + return strs[2], strs[3], strs[4] + + +def setList(dictParam, index, value): + if dictParam[index].__contains__(value): + pass + else: + dictParam[index].append(value) + + +if __name__ == '__main__': + file = open("./interview_data_set") + result = {'deviceName': [], 'description': [], 'processName': [], 'processId': [], 'timeWindow': [], + 'numberOfOccurrence': 0} + for line in file: + if line.__contains__(": Could not find uid"): + start = line.find(': Could not find uid') + description = line[start + 1:] + setList(result, 'description', description) + if line.__contains__(": Service exited with"): + content = re.findall(r'\((.*?)\)', line)[0] + processId = re.findall(r'\[(.*?)\]', content)[0] + time, deviceName, processName = getTime_DeviceName_processName(line) + setList(result, 'deviceName', deviceName) + setList(result, 'processName', processName) + result['numberOfOccurrence'] += 1 + result['timeWindow'].append(time) + result['processId'].append(processId) + print(result) # {'deviceName': ['BBAOMACBOOKAIR2'], 'description': [' Could not find uid associated with service: 0: Undefined error: 0 501\n'], 'processName': ['com.apple.xpc.launchd[1]'], 'processId': ['12513', '12535', '12536', '12555', '12556', '12560', '12610', '12622', '12633', '12636', '12637', '12698', '12734', '12738', '12741', '12745', '12746', '12765', '12771', '12777', '12802', '12822', '12834', '12844', '12860', '12879', '12898', '12945', '12949', '12974', '12975', '12976', '12980', '12992', '13002', '13003', '13017', '13021', '13027', '13043', '13044', '13080', '20333', '24366', '35854', '41579', '48653', '52293', '52294', '52295', '52297', '52299', '52305', '52308', '52309', '52313', '52323', '52324', '52325', '52349', '52366', '52376', '52377', '52382', '52419', '52420', '52424', '52443', '52444', '52459', '52463', '52478', '52484', '52486', '52503', '52515', '52516', '52523', '52561', '52570', '52575', '52591', '52606', '52609', '52616', '52629', '52635', '52636', '52638', '52665', '52668', '52675', '52677', '52682', '52684', '52687', '52704', '52715', '52716', '52717', '52721', '52725', '52735', '52760', '52761', '52764', '52772', '52774', '52777', '52781', '52792', '52796', '52812', '52817', '52824', '52825', '52841', '52845', '52846', '52851', '52874', '52876', '52879', '52881', '52882', '52888', '52889', '52915', '52916', '52917', '52927', '52928', '52932', '52935', '52936', '52937', '52974', '52990', '53004', '53006', '53014', '53019', '53020', '53021', '3491', '53131', '53136', '53143', '53138', '53149', '53167', '53184', '53189', '53208', '53211', '53221', '53314', '53319', '53360', '53361', '53364', '53365', '53366', '53367', '53369', '53380', '53396', '53401', '53403', '53412', '53414', '53417', '53419', '53436', '53452', '53453', '53457', '53476', '53480', '53488', '53497', '53500', '53530', '53537', '53541', '53542', '53585', '53620', '53648', '53687', '53691', '53708', '53714', '53743', '53771', '53776', '53788', '53805', '53829', '53853', '53898', '53901', '53903', '53914', '53927', '53931', '53937', '53950', '53953', '53972', '53999', '54008', '54014', '54029', '54043', '54044', '54048', '54061', '54064', '54093', '54095', '54099', '54113', '54115', '54117', '54118', '54119', '54291', '54363', '54365', '54369', '54370', '54375', '54385', '54392', '54398', '54401', '54404', '54441', '54506', '54605', '54610', '54612', '54615', '54618', '54620', '54629', '54666', '54679', '54706', '54708', '54709', '54711', '54713', '54745', '54808', '54853', '54873', '54889', '54897', '54900', '54904', '54907', '54921', '54928', '54942', '54951', '54970', '54972', '54977', '54981', '54988', '54992', '55000', '55001', '55004', '55019', '55024', '55041', '55049', '55055', '55059', '55061', '55062', '55077', '55079', '55099', '55108', '55123', '55128', '56066', '56088', '56100', '56101', '56103', '56122', '56147', '56162', '56176', '56211', '56220', '56231', '56232', '56279', '56300', '56302', '56303', '56316', '56340', '56353', '56381'], 'timeWindow': ['00:01:58', '00:05:58', '00:09:58', '00:17:59', '00:19:59', '00:21:59', '00:29:49', '00:31:49', '00:35:49', '00:37:49', '00:39:49', '00:43:49', '00:47:49', '00:49:49', '00:53:49', '00:57:49', '00:59:50', '01:03:50', '01:07:50', '01:09:50', '01:13:50', '01:17:50', '01:19:50', '01:23:50', '01:27:50', '01:29:50', '01:33:50', '01:37:50', '01:39:50', '01:43:50', '01:47:50', '01:49:50', '01:53:50', '01:57:50', '02:01:21', '02:05:21', '02:07:21', '02:09:21', '02:13:21', '02:17:22', '02:19:22', '02:23:22', '02:27:22', '02:29:22', '02:33:22', '02:36:45', '02:38:45', '02:44:55', '02:46:55', '02:48:55', '02:51:29', '02:52:55', '02:56:04', '02:58:04', '03:02:04', '03:04:04', '03:07:30', '03:11:30', '03:12:30', '03:14:30', '03:18:32', '03:22:32', '03:24:32', '03:28:32', '03:36:32', '03:38:32', '03:42:32', '03:46:32', '03:50:32', '03:59:53', '04:00:53', '04:02:53', '04:06:53', '04:10:54', '04:14:54', '04:22:54', '04:24:54', '04:28:54', '04:32:54', '04:40:54', '04:42:54', '04:44:54', '04:48:54', '04:52:54', '04:56:54', '05:04:54', '05:06:54', '05:08:54', '05:12:54', '05:16:54', '05:20:54', '05:28:54', '05:30:54', '05:32:54', '05:36:54', '05:40:54', '05:44:54', '05:52:54', '05:54:54', '05:56:54', '06:00:54', '06:04:54', '06:08:54', '06:16:54', '06:18:54', '06:20:54', '06:21:45', '06:24:54', '06:28:54', '06:32:54', '06:40:54', '06:42:54', '06:44:54', '06:48:54', '06:52:55', '06:56:55', '07:04:55', '07:06:55', '07:08:55', '07:12:55', '07:16:55', '07:20:55', '07:28:55', '07:30:55', '07:32:55', '07:36:55', '07:40:55', '07:48:24', '07:50:24', '07:52:24', '07:58:11', '07:59:11', '08:01:11', '08:05:11', '08:07:11', '08:09:11', '08:14:23', '08:19:56', '08:26:21', '08:28:21', '08:32:21', '08:36:21', '08:38:21', '08:42:21', '08:47:27', '08:48:13', '08:52:13', '08:56:13', '08:56:29', '09:00:13', '09:08:13', '09:10:13', '09:12:13', '09:16:13', '09:20:13', '09:24:13', '09:32:14', '09:34:14', '09:36:14', '09:40:14', '09:44:14', '09:48:14', '09:52:01', '09:56:14', '09:58:14', '10:00:14', '10:04:14', '10:08:14', '10:12:14', '10:20:14', '10:22:14', '10:24:14', '10:28:15', '10:32:15', '10:38:58', '10:40:58', '10:42:58', '10:46:59', '10:48:59', '10:50:59', '10:54:59', '10:58:59', '11:02:52', '11:06:52', '11:08:52', '11:10:52', '11:14:52', '11:18:52', '11:20:52', '11:24:52', '11:28:52', '11:30:52', '11:34:52', '11:38:52', '11:40:52', '11:44:52', '11:48:53', '11:50:53', '11:54:53', '11:58:53', '12:00:53', '12:04:53', '12:08:53', '12:10:53', '12:14:53', '12:18:53', '12:20:54', '12:24:54', '12:28:54', '12:30:54', '12:34:53', '12:38:53', '12:42:06', '12:46:06', '12:48:06', '12:50:06', '12:54:06', '12:58:06', '13:00:06', '13:04:06', '13:08:06', '13:10:06', '13:14:06', '13:18:06', '13:20:06', '13:22:18', '13:24:06', '14:27:36', '14:33:00', '14:35:00', '14:36:00', '14:38:01', '14:42:01', '14:44:01', '14:46:01', '14:50:01', '14:54:01', '14:56:01', '15:00:04', '15:07:39', '15:19:57', '15:21:57', '15:25:57', '15:29:57', '15:31:57', '15:35:57', '15:39:57', '15:41:57', '15:45:57', '15:49:57', '15:51:57', '15:55:57', '15:59:57', '16:01:58', '16:05:58', '16:10:12', '16:12:13', '16:16:13', '16:20:13', '16:22:13', '16:26:13', '16:30:13', '16:32:13', '16:36:13', '16:40:13', '16:42:13', '16:46:13', '16:50:14', '16:52:14', '16:56:14', '17:00:14', '17:02:14', '17:06:14', '17:10:14', '17:12:14', '17:16:14', '17:20:14', '17:22:14', '17:27:37', '17:29:37', '17:31:37', '17:35:37', '17:37:37', '17:39:37', '17:43:37', '17:47:37', '17:49:37', '17:53:37', '17:55:27', '17:55:59', '22:55:01', '22:57:01', '23:01:01', '23:03:01', '23:05:01', '23:09:01', '23:13:02', '23:15:02', '23:19:02', '23:23:06', '23:26:26', '23:30:26', '23:32:26', '23:34:26', '23:38:26', '23:42:26', '23:44:26', '23:48:26', '23:52:26', '23:54:26', '23:58:26'], 'numberOfOccurrence': 311} + response = requests.post('https://foo.com/bar', json=result) + print(response.text)