First commit
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
# 20260507 tak created gitignore
|
||||||
|
.DS_Store
|
||||||
|
.idea/
|
||||||
|
.venv
|
||||||
|
|
||||||
@@ -0,0 +1,224 @@
|
|||||||
|
# --- package ---
|
||||||
|
# --- custom_module ---
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# 20260507 tak will be check
|
||||||
|
#sys.path.append('C:/Users/Administrator/PycharmProjects/pythonProject/20230426/cmd/build_scripter')
|
||||||
|
|
||||||
|
# --- custom ---
|
||||||
|
from custom_lib import Custom_Lib as custom
|
||||||
|
|
||||||
|
# --- common ---
|
||||||
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
from pathlib import Path
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
def check_path(config_path):
|
||||||
|
try:
|
||||||
|
check_exit_flag = False
|
||||||
|
config_exit_flag = False
|
||||||
|
|
||||||
|
if os.path.isfile(f'{config_path}/user.config'):
|
||||||
|
while not check_exit_flag:
|
||||||
|
print(f'User config file already exists.\nDo you want to change the config (Yes/no)?')
|
||||||
|
|
||||||
|
check_config = input('> ')
|
||||||
|
|
||||||
|
if check_config.lower() == 'no' or check_config.lower() == 'exit':
|
||||||
|
check_exit_flag = True
|
||||||
|
config_exit_flag = True
|
||||||
|
break
|
||||||
|
|
||||||
|
elif check_config.lower() == 'yes':
|
||||||
|
break
|
||||||
|
|
||||||
|
else:
|
||||||
|
log.error(f'Option verification failed, please try again.')
|
||||||
|
|
||||||
|
elif not os.path.isfile(f'{config_path}/user.config'):
|
||||||
|
a = custom.my_file_config.save_config()
|
||||||
|
|
||||||
|
custom.my_file_config.write_config(a, config_path, f'{config_path}/user.config')
|
||||||
|
|
||||||
|
while not config_exit_flag:
|
||||||
|
print('Input PycharmProjects Path')
|
||||||
|
|
||||||
|
write_config = input('> ')
|
||||||
|
|
||||||
|
if write_config.lower() == 'exit':
|
||||||
|
config_exit_flag = True
|
||||||
|
break
|
||||||
|
|
||||||
|
elif os.path.exists(write_config):
|
||||||
|
a = custom.my_file_config.save_config()
|
||||||
|
|
||||||
|
a['pycharmprojects'] = {}
|
||||||
|
a['pycharmprojects']['path'] = write_config
|
||||||
|
|
||||||
|
custom.my_file_config.write_config(a, config_path, f'{config_path}/user.config')
|
||||||
|
config_exit_flag = True
|
||||||
|
break
|
||||||
|
|
||||||
|
else:
|
||||||
|
log.error(f'Path verification failed, please try again.')
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
log.error(e)
|
||||||
|
|
||||||
|
def main(config_path):
|
||||||
|
exit_flag = False
|
||||||
|
|
||||||
|
a = custom.my_file_config.read_config(f'{config_path}/user.config')
|
||||||
|
pythonproject_path = (a['pycharmprojects']['path'])
|
||||||
|
|
||||||
|
while not exit_flag:
|
||||||
|
print(f'\n[Exec]\n'
|
||||||
|
f'[1] {typ1}\n'
|
||||||
|
f'[2] {typ2}')
|
||||||
|
|
||||||
|
try:
|
||||||
|
input_exec = input('> ')
|
||||||
|
|
||||||
|
if input_exec == 'exit':
|
||||||
|
exit_flag = True
|
||||||
|
|
||||||
|
elif input_exec == '1':
|
||||||
|
while not exit_flag:
|
||||||
|
print(f'[{typ1}]\n[1] uuid1\n[4] uuid4\n[9] back')
|
||||||
|
|
||||||
|
input_exec1_1 = input('> ')
|
||||||
|
|
||||||
|
if input_exec1_1 == 'exit':
|
||||||
|
exit_flag = True
|
||||||
|
break
|
||||||
|
|
||||||
|
elif input_exec1_1 == '1' or input_exec1_1 == '4':
|
||||||
|
while not exit_flag:
|
||||||
|
print(f'[{typ1}]\nInput Program name\n[9] back')
|
||||||
|
|
||||||
|
input_exec1_2 = input('> ')
|
||||||
|
|
||||||
|
if input_exec1_2 == 'exit':
|
||||||
|
exit_flag = True
|
||||||
|
break
|
||||||
|
|
||||||
|
elif input_exec1_2 != 'exit' and input_exec1_2 != '9':
|
||||||
|
prm_uuid = custom.my_uuid.create_uuid(input_exec1_1)
|
||||||
|
log.info(f"{input_exec1_2}-{prm_uuid}")
|
||||||
|
|
||||||
|
elif input_exec1_2 == '9':
|
||||||
|
break
|
||||||
|
|
||||||
|
else:
|
||||||
|
log.error(f'Option verification failed, please try again.')
|
||||||
|
|
||||||
|
elif input_exec1_1 == '9':
|
||||||
|
break
|
||||||
|
|
||||||
|
else:
|
||||||
|
log.error(f'Option verification failed, please try again.')
|
||||||
|
|
||||||
|
elif input_exec == '2':
|
||||||
|
while not exit_flag:
|
||||||
|
print(f'[{typ2}]\nInput Build Script\n[9] back')
|
||||||
|
|
||||||
|
input_exec2_1 = input('> ')
|
||||||
|
|
||||||
|
if input_exec2_1 == 'exit':
|
||||||
|
exit_flag = True
|
||||||
|
break
|
||||||
|
|
||||||
|
elif '.py' in input_exec2_1 and input_exec2_1 != 'exit' and input_exec2_1 != '9':
|
||||||
|
build_scripts = input_exec2_1.split(' ')
|
||||||
|
|
||||||
|
for build_script in build_scripts:
|
||||||
|
if build_script.endswith('.py'):
|
||||||
|
source_name = os.path.splitext(os.path.basename(build_script))[0]
|
||||||
|
pythonproject_path_list = build_script.split("\\")[:int(len(pythonproject_path.split('\\'))+1)]
|
||||||
|
pjt_path = "\\".join(pythonproject_path_list)
|
||||||
|
|
||||||
|
for build_script in build_scripts:
|
||||||
|
if 'specpath=' in build_script:
|
||||||
|
spec_file = f'{pjt_path}{build_script.split("=")[1].replace(".", "")}{source_name}.spec'
|
||||||
|
if os.path.isfile(spec_file):
|
||||||
|
os.remove(spec_file)
|
||||||
|
|
||||||
|
elif 'distpath=' in build_script:
|
||||||
|
dist_path = f'{pjt_path}{build_script.split("=")[1].replace(".", "")}'
|
||||||
|
if os.path.isdir(f'{dist_path}{source_name}'):
|
||||||
|
shutil.rmtree(f'{dist_path}{source_name}')
|
||||||
|
|
||||||
|
elif 'workpath=' in build_script:
|
||||||
|
work_path = f'{pjt_path}{build_script.split("=")[1].replace(".", "")}'
|
||||||
|
if os.path.isdir(f'{work_path}{source_name}'):
|
||||||
|
shutil.rmtree(f'{work_path}{source_name}')
|
||||||
|
|
||||||
|
os.system(f'{pjt_path}\\venv\\Scripts\\activate.bat && cd {pjt_path} && {input_exec2_1}')
|
||||||
|
|
||||||
|
break
|
||||||
|
|
||||||
|
elif input_exec2_1 == '9':
|
||||||
|
break
|
||||||
|
|
||||||
|
else:
|
||||||
|
log.error(f'Build script verification failed, please try again.')
|
||||||
|
|
||||||
|
else:
|
||||||
|
log.error(f'Option verification failed, please try again.')
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
log.error(e)
|
||||||
|
|
||||||
|
# --- prm_info_variables ---
|
||||||
|
company_name = 'ATEC IoT'
|
||||||
|
prm_title = Path(os.path.basename(sys.argv[0])).stem.replace('_', ' ')
|
||||||
|
|
||||||
|
prm_renew_ver = 1
|
||||||
|
prm_modify_ver = 0
|
||||||
|
prm_bug_ver = 0
|
||||||
|
prm_ver = f'{prm_renew_ver}.{prm_modify_ver}.{prm_bug_ver}'
|
||||||
|
|
||||||
|
prm_uuid = 'a0dfdd50-dcbc-11ed-8864-0456e5df0ac9'
|
||||||
|
|
||||||
|
# --- type_variables ---
|
||||||
|
typ1 = 'Create UUID'
|
||||||
|
typ2 = 'Execute Build'
|
||||||
|
|
||||||
|
# --- path_variables ---
|
||||||
|
loc_path = os.getcwd()
|
||||||
|
|
||||||
|
home_dir = os.path.expanduser('~')
|
||||||
|
appdata_dir = os.path.join(home_dir, 'AppData', 'Local')
|
||||||
|
new_dir = f'{company_name.replace(" ", "")}/{prm_title}/{prm_ver}'
|
||||||
|
new_dir_path = os.path.join(appdata_dir, new_dir)
|
||||||
|
|
||||||
|
path_list = [new_dir_path]
|
||||||
|
|
||||||
|
# --- common_variables ---
|
||||||
|
datetime = datetime.now()
|
||||||
|
sys_date = datetime.strftime('%Y.%m.%d %H:%M:%S')
|
||||||
|
|
||||||
|
''' build command'''
|
||||||
|
# pyinstaller --specpath=.\20230426\app\spec\ --distpath=.\20230426\app\dist\ --workpath=.\20230426\app\build\ --name=Build_Scripter -c -F C:\Users\Administrator\PycharmProjects\pythonProject\20230426\cmd\build_scripter\Build_Scripter.py --hidden-import=configparser --hidden-import=uuid --hidden-import=logging
|
||||||
|
# pyinstaller --distpath=.\20230426\app\dist\ --workpath=.\20230426\app\build\ --onedir=C:\Users\Administrator\PycharmProjects\pythonProject\20230426\app\spec\Build_Scripter.spec
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
custom.init()
|
||||||
|
|
||||||
|
if prm_uuid != None:
|
||||||
|
log = custom.my_logger.logger()
|
||||||
|
print(f'{company_name} {prm_title} v {prm_ver}\n'
|
||||||
|
f'(c) {company_name}. All rights reserved.\n'
|
||||||
|
f'System information as of {sys_date}\n')
|
||||||
|
|
||||||
|
try:
|
||||||
|
for file_path in path_list:
|
||||||
|
if not os.path.isdir(file_path):
|
||||||
|
os.makedirs(file_path)
|
||||||
|
|
||||||
|
check_path(new_dir_path)
|
||||||
|
main(new_dir_path)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
log.error(e)
|
||||||
Binary file not shown.
@@ -0,0 +1,21 @@
|
|||||||
|
__version__ = "1.0.0"
|
||||||
|
|
||||||
|
# --- custom ---
|
||||||
|
from custom_lib import my_file_config
|
||||||
|
from custom_lib import my_logger
|
||||||
|
from custom_lib import my_uuid
|
||||||
|
|
||||||
|
MODULES = [
|
||||||
|
my_file_config,
|
||||||
|
my_logger,
|
||||||
|
my_uuid,
|
||||||
|
]
|
||||||
|
|
||||||
|
def print_versions():
|
||||||
|
for module in MODULES:
|
||||||
|
version = getattr(module, "__version__", "unknown")
|
||||||
|
print(f"[MODULE] {module.__name__} v{version}")
|
||||||
|
|
||||||
|
def init():
|
||||||
|
print(f"Custom_Lib v{__version__}")
|
||||||
|
print_versions()
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,31 @@
|
|||||||
|
__version__ = "1.0.0"
|
||||||
|
|
||||||
|
# --- package ---
|
||||||
|
# --- settings ---
|
||||||
|
import configparser
|
||||||
|
|
||||||
|
# --- common ---
|
||||||
|
import os
|
||||||
|
|
||||||
|
def save_config():
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
|
||||||
|
return config
|
||||||
|
|
||||||
|
def write_config(config, file_path, file_nm):
|
||||||
|
if not os.path.isdir(file_path):
|
||||||
|
os.makedirs(file_path)
|
||||||
|
|
||||||
|
with open(file_nm, 'w') as f:
|
||||||
|
config.write(f)
|
||||||
|
|
||||||
|
def read_config(file_nm):
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(file_nm)
|
||||||
|
|
||||||
|
return config
|
||||||
|
|
||||||
|
# if __name__ == '__main__':
|
||||||
|
#
|
||||||
|
# b = read_config('C:/Users/ATECAP/AppData/Local/AeroCodeZ/Weather Crawling/1.0.0/user.config')
|
||||||
|
# print(b['system']['ems_url'])
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
__version__ = "1.0.0"
|
||||||
|
|
||||||
|
# --- package ---
|
||||||
|
# --- log ---
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# --- common ---
|
||||||
|
from datetime import datetime
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def logger():
|
||||||
|
if not os.path.isdir(log_path):
|
||||||
|
os.makedirs(log_path)
|
||||||
|
# return log instance
|
||||||
|
logger = logging.getLogger('logger')
|
||||||
|
|
||||||
|
exec_nm = Path(os.path.basename(sys.argv[0])).stem
|
||||||
|
log_date = datetime.strftime('%y%m%d_%H%M%S')
|
||||||
|
|
||||||
|
# define log format
|
||||||
|
formatter = logging.Formatter('%(asctime)s-%(levelname)s-%(message)s')
|
||||||
|
|
||||||
|
# define handler
|
||||||
|
stream_handler = logging.StreamHandler()
|
||||||
|
file_handler = logging.FileHandler(f"{log_path}{exec_nm}_{log_date}.log")
|
||||||
|
|
||||||
|
# define handler format
|
||||||
|
stream_handler.setFormatter(formatter)
|
||||||
|
file_handler.setFormatter(formatter)
|
||||||
|
|
||||||
|
# insert handler into logger instance
|
||||||
|
logger.addHandler(stream_handler)
|
||||||
|
logger.addHandler(file_handler)
|
||||||
|
|
||||||
|
# define log level
|
||||||
|
logger.setLevel(level=logging.INFO)
|
||||||
|
|
||||||
|
# return logger
|
||||||
|
return logger
|
||||||
|
|
||||||
|
# --- path_variables ---
|
||||||
|
loc_path = os.getcwd()
|
||||||
|
log_path = f"{loc_path}/log/"
|
||||||
|
|
||||||
|
# --- common_variables ---
|
||||||
|
datetime = datetime.now()
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
__version__ = "1.0.0"
|
||||||
|
|
||||||
|
# --- package ---
|
||||||
|
# --- guid ---
|
||||||
|
import uuid
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
def create_uuid(uuid_ver):
|
||||||
|
# hostid, sequence, timestamp
|
||||||
|
if uuid_ver == '1':
|
||||||
|
return uuid.uuid1()
|
||||||
|
|
||||||
|
# namespace, md5
|
||||||
|
# elif uuid_ver == '3':
|
||||||
|
# return uuid.uuid3()
|
||||||
|
|
||||||
|
# random
|
||||||
|
elif uuid_ver == '4':
|
||||||
|
return uuid.uuid4()
|
||||||
|
|
||||||
|
# namespace, sha-1
|
||||||
|
# elif uuid_ver == '5':
|
||||||
|
# return uuid.uuid5()
|
||||||
|
|
||||||
|
else:
|
||||||
|
return f'{inspect.currentframe().f_code.co_name}-Not Found UUID'
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
2023-04-13 11:12:13,260-ERROR-name 'typ5' is not defined
|
||||||
|
2023-04-13 11:12:23,564-ERROR-Option verification failed, please try again.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 11:12:50,327-ERROR-Option verification failed, please try again.
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
2023-04-13 11:21:22,292-ERROR-Option verification failed, please try again.
|
||||||
|
2023-04-13 11:21:29,275-INFO-sd-prm_uuid
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 11:21:52,410-INFO-sdf-found uuid
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 11:22:15,699-INFO-adsf-01d38afc-d9a2-11ed-b548-0456e5df0ac9
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 11:22:53,074-INFO-asdf-found uuid
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 11:23:20,332-INFO-adf-found uuid
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 11:28:32,374-INFO-3-create_uuid-Not Found UUID
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
2023-04-13 11:29:08,489-ERROR-Option verification failed, please try again.
|
||||||
|
2023-04-13 11:29:12,236-ERROR-Option verification failed, please try again.
|
||||||
|
2023-04-13 11:29:14,644-INFO-adf-678f1c63-e88f-4137-a34a-0af25a604beb
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 13:42:46,714-ERROR-check_path() missing 1 required positional argument: 'config_path'
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 13:59:52,333-ERROR-name 'check_configlower' is not defined
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 14:11:39,683-ERROR-Option verification failed, please try again.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 14:12:10,273-ERROR-Option verification failed, please try again.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 14:12:41,747-ERROR-Path verification failed, please try again.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
2023-04-13 14:25:07,464-ERROR-Path verification failed, please try again.
|
||||||
|
2023-04-13 14:25:14,734-ERROR-Path verification failed, please try again.
|
||||||
|
2023-04-13 14:25:15,658-ERROR-Path verification failed, please try again.
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
2023-04-13 14:27:08,818-ERROR-Option verification failed, please try again.
|
||||||
|
2023-04-13 14:27:15,629-INFO-asdf-d9e6b497-d9bb-11ed-bcbe-0456e5df0ac9
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 14:45:41,631-ERROR-Path verification failed, please try again.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 14:59:30,085-ERROR-Option verification failed, please try again.
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
2023-04-13 15:09:20,323-ERROR-Option verification failed, please try again.
|
||||||
|
2023-04-13 15:09:31,254-ERROR-'in <string>' requires string as left operand, not bool
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 15:10:00,999-ERROR-Option verification failed, please try again.
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
2023-04-13 15:12:32,810-ERROR-Option verification failed, please try again.
|
||||||
|
2023-04-13 15:12:44,201-ERROR-Option verification failed, please try again.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 15:14:31,054-ERROR-Option verification failed, please try again.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 15:21:01,591-ERROR-list index out of range
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 15:25:36,949-ERROR-Option verification failed, please try again.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 15:41:28,161-ERROR-Option verification failed, please try again.
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
2023-04-13 16:08:05,280-ERROR-Option verification failed, please try again.
|
||||||
|
2023-04-13 16:08:06,410-ERROR-Option verification failed, please try again.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 16:17:31,485-ERROR-local variable 'spec_path' referenced before assignment
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
2023-04-13 16:20:13,719-ERROR-Option verification failed, please try again.
|
||||||
|
2023-04-13 16:20:15,924-ERROR-Option verification failed, please try again.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 16:22:20,345-ERROR-Option verification failed, please try again.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 16:23:10,325-ERROR-local variable 'build_scripts' referenced before assignment
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2023-04-13 16:25:17,086-ERROR-Option verification failed, please try again.
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user