|
@@ -1,25 +1,20 @@
|
|
|
-import csv
|
|
|
-import os
|
|
|
-import re
|
|
|
-import datetime
|
|
|
-import argparse
|
|
|
+import csv, os, re, sys, argparse
|
|
|
from logger import *
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
parse = argparse.ArgumentParser(
|
|
|
description="Программа для сбора информации из csv файлов")
|
|
|
parse.add_argument('-p', '--path', help='Указать в какой директории искать',
|
|
|
- default=os.path.dirname(__file__))
|
|
|
+ default=os.path.dirname(sys.argv[0]))
|
|
|
parse.add_argument('-e', '--encoding',
|
|
|
- help='Указать в какой кодировке сохранять', default='utf-8')
|
|
|
+ help='Указать в какой кодировке сохранять', default='windows-1251')
|
|
|
parse.add_argument('-s', '--open_encoding',
|
|
|
help='Указать в какой кодировке открывать', default='utf-16')
|
|
|
args = parse.parse_args()
|
|
|
|
|
|
print(args)
|
|
|
-# DIR_WORK = "./sbor"
|
|
|
LIST_BAD_ADAPTER = ['Wireless', 'Bluetooth', 'Wireless', 'WiFi',
|
|
|
'Kaspersky', 'VirtualBox', 'TAP-Windows',
|
|
|
'Wintun', '802.11', 'VMware', 'VPN', 'Wi-Fi',
|
|
@@ -42,6 +37,7 @@ class ObjectReady:
|
|
|
return ';'.join((self.frame, self.cabinet))
|
|
|
|
|
|
dic = self.__dict__
|
|
|
+ # print(dic)
|
|
|
try:
|
|
|
row_interface = ';'.join(
|
|
|
[';'.join((dic.get(F"ip{i}"), dic.get(F"mac{i}"))) for i in range(self.count_interface)
|
|
@@ -113,7 +109,7 @@ def get_ready_information() -> list[ObjectReady]:
|
|
|
for path in get_paths():
|
|
|
|
|
|
obj = ObjectReady()
|
|
|
- obj.frame = path.split('/')[-2]
|
|
|
+ obj.frame = os.path.basename(os.path.dirname(path))
|
|
|
obj.cabinet = re.findall(
|
|
|
r"\/([\w+?\ ?[а-яА-Я]+\ ?|\w+?\ ?[a-zA-Z]+\ ?|\d+])[\.|\,]", path)[-1]
|
|
|
|
|
@@ -138,9 +134,16 @@ def create_csv(list_obj: list[ObjectReady]) -> None:
|
|
|
f.write(header_csv)
|
|
|
|
|
|
for obj in list_obj:
|
|
|
+ row = obj.get_csv_row()
|
|
|
+ logger.info(row)
|
|
|
f.write(obj.get_csv_row())
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
create_logger()
|
|
|
+
|
|
|
+ logger.info("Start programm")
|
|
|
+ logger.info(F"Base dir: {args.path}")
|
|
|
+
|
|
|
create_csv(get_ready_information())
|
|
|
+ logger.info("Stop programm")
|