-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
44 lines (38 loc) · 1.6 KB
/
setup.py
File metadata and controls
44 lines (38 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import shutil
import logging # Import logging module
# Set up logging
logging.basicConfig(
filename='MX_Signer.log', # Log file path
level=logging.DEBUG, # Set the level of logging
format='%(asctime)s - %(levelname)s - %(message)s', # Log format
datefmt='%d-%b-%Y %H:%M:%S' # Date and time format
)
def setup_directories_and_files():
"""Set up required directories and copy necessary files."""
# Define the paths for the directories and files
directories = ['static', 'templates', 'fonts']
files = {
'static': ['logo.ico'],
'templates': ['404.html', 'email.html'],
'fonts': ['Helvetica.ttf']
}
# Check and create directories if they do not exist
for dir in directories:
if not os.path.exists(dir):
os.makedirs(dir)
logging.info(f"Directory {dir} created.")
else:
logging.info(f"Directory {dir} already exists.")
# Copy files to their respective directories and delete original files
for dir, file_list in files.items():
for file in file_list:
if os.path.exists(file): # Check if the file exists
dest_path = os.path.join(dir, file)
shutil.copy(file, dest_path) # Copy the file instead of moving
logging.info(f"Copied {file} to {dir}.")
# Delete the original file after copying
os.remove(file)
logging.info(f"Original file {file} removed.")
else:
logging.error(f"File {file} not found. Please ensure it is available.")