This commit is contained in:
2022-02-17 22:27:21 +03:00
parent 737fe3b0df
commit 05577091b4
2 changed files with 23 additions and 5 deletions

View File

@@ -15,9 +15,14 @@ from pymediainfo import MediaInfo
threading.current_thread().name = "main"
if not os.path.isdir('log'):
os.makedirs('log')
os.makedir('log')
print('Create log dir')
else:
print('log dir exist')
a = 'log/' + str(time.strftime("%Y-%m-%d %H:%M:%S")) + '.log'
print(a)
f = open(a, 'w')
logging.basicConfig(filename=a, filemode='w', format='%(asctime)s - %(threadName)s - %(levelname)s - %(message)s',
level='INFO')
@@ -43,9 +48,6 @@ class Config:
config.add_section('Output')
config.set('Output', 'Dir', str(pathlib.Path.home()) + '/sample/')
with open(Args.args.config, 'w') as configfile:
config.write(configfile)
if os.path.isdir('config'):
logging.info("Config dir is exist")
else:
@@ -56,19 +58,26 @@ class Config:
else:
logging.info("Successfully created the config directory")
with open(Args.args.config, 'w') as conf:
config.write(conf)
time.sleep(0.5)
if os.path.isfile(Args.args.config):
logging.info("Config is exist")
config2 = configparser.ConfigParser()
config2.read(Args.args.config)
for section in config.sections():
if config2.has_section(section):
print(f'{section} is exist')
for option in config.options(section):
if config2.has_option(section, option):
pass
print(f'{option} in {section} is exist')
else:
print(f'{option} in {section} isn`t exist')
config.set(section, option, config.get(section, option))
else:
config.add_section(section)
print(f'{section} isn`t exist')
else:
logging.info("Creating Config")
with open(Args.args.config, 'w') as configfile:

9
test.py Normal file
View File

@@ -0,0 +1,9 @@
import time
import os
if os.path.isdir('log'):
print('log dir exist')
a = 'log/' + str(time.strftime("%Y-%m-%d %H:%M:%S")) + '.log'
print(a)
f = open(a, 'w')