bug fixes
This commit is contained in:
56
prepare.py
56
prepare.py
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/env python
|
||||||
import random
|
import random
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
@@ -12,17 +12,12 @@ import configparser
|
|||||||
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
|
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
|
||||||
from pymediainfo import MediaInfo
|
from pymediainfo import MediaInfo
|
||||||
|
|
||||||
|
|
||||||
|
if not os.path.isdir(os.path.dirname(__file__) + 'log'):
|
||||||
|
os.makedirs(os.path.dirname(__file__) + 'log')
|
||||||
threading.current_thread().name = "main"
|
threading.current_thread().name = "main"
|
||||||
|
|
||||||
if not os.path.isdir('log'):
|
a = os.path.dirname(__file__) + '/log/' + str(time.strftime("%Y-%m-%d %H-%M-%S")) + '.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',
|
logging.basicConfig(filename=a, filemode='w', format='%(asctime)s - %(threadName)s - %(levelname)s - %(message)s',
|
||||||
level='INFO')
|
level='INFO')
|
||||||
|
|
||||||
@@ -43,8 +38,14 @@ class Args:
|
|||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
config = configparser.ConfigParser()
|
conf_file = os.path.dirname(__file__) + '/' + Args.args.config
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def write(config, conf_file):
|
||||||
|
with open(conf_file, 'w') as configfile:
|
||||||
|
config.write(configfile)
|
||||||
|
|
||||||
|
config = configparser.ConfigParser()
|
||||||
config.add_section('Output')
|
config.add_section('Output')
|
||||||
config.set('Output', 'Dir', str(pathlib.Path.home()) + '/sample/')
|
config.set('Output', 'Dir', str(pathlib.Path.home()) + '/sample/')
|
||||||
|
|
||||||
@@ -57,31 +58,25 @@ class Config:
|
|||||||
logging.error("Creation of the directory config failed")
|
logging.error("Creation of the directory config failed")
|
||||||
else:
|
else:
|
||||||
logging.info("Successfully created the config directory")
|
logging.info("Successfully created the config directory")
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
with open(Args.args.config, 'w') as conf:
|
if os.path.isfile(conf_file):
|
||||||
config.write(conf)
|
|
||||||
time.sleep(0.5)
|
|
||||||
|
|
||||||
if os.path.isfile(Args.args.config):
|
|
||||||
logging.info("Config is exist")
|
logging.info("Config is exist")
|
||||||
config2 = configparser.ConfigParser()
|
config2 = configparser.ConfigParser()
|
||||||
config2.read(Args.args.config)
|
config2.read(conf_file)
|
||||||
for section in config.sections():
|
for section in config.sections():
|
||||||
if config2.has_section(section):
|
if config2.has_section(section):
|
||||||
print(f'{section} is exist')
|
|
||||||
for option in config.options(section):
|
for option in config.options(section):
|
||||||
if config2.has_option(section, option):
|
if not config2.has_option(section, option):
|
||||||
print(f'{option} in {section} is exist')
|
|
||||||
else:
|
|
||||||
print(f'{option} in {section} isn`t exist')
|
|
||||||
config.set(section, option, config.get(section, option))
|
config.set(section, option, config.get(section, option))
|
||||||
|
write(config, conf_file)
|
||||||
else:
|
else:
|
||||||
config.add_section(section)
|
config.add_section(section)
|
||||||
print(f'{section} isn`t exist')
|
write(config, conf_file)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logging.info("Creating Config")
|
logging.info("Creating Config")
|
||||||
with open(Args.args.config, 'w') as configfile:
|
write(config, conf_file)
|
||||||
config.write(configfile)
|
|
||||||
|
|
||||||
|
|
||||||
class Head:
|
class Head:
|
||||||
@@ -90,15 +85,14 @@ class Head:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
if not Args.args.screens and not Args.args.sample and not Args.args.mediainfo:
|
||||||
|
Args.args.screens = Args.args.sample = Args.args.mediainfo = 1
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(Args.args.config)
|
config.read(os.path.dirname(__file__) + '/' + Args.args.config)
|
||||||
output = config["Output"]
|
output = config["Output"]
|
||||||
save_dir = output["dir"]
|
save_dir = output["dir"]
|
||||||
if config.has_section('testt'):
|
|
||||||
testt = output["testt"]
|
|
||||||
print(testt)
|
|
||||||
else:
|
|
||||||
print(config.options("Output"))
|
|
||||||
procs = []
|
procs = []
|
||||||
self.num_screen = 0
|
self.num_screen = 0
|
||||||
self.num_screen: int
|
self.num_screen: int
|
||||||
|
|||||||
Reference in New Issue
Block a user