Skip to content

Commit 2ff46e2

Browse files
committed
Update dev version
Update dev version * Update logging
1 parent 2e7417e commit 2ff46e2

File tree

5 files changed

+34
-17
lines changed

5 files changed

+34
-17
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

automation_file/local/file/file_process.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@
66
from automation_file.utils.logging.loggin_instance import file_automation_logger
77

88

9-
def copy_file(file_path: str, target_path: str) -> bool:
9+
def copy_file(file_path: str, target_path: str, copy_metadata: bool = True) -> bool:
1010
"""
1111
:param file_path: which file do we want to copy (str path)
1212
:param target_path: put copy file on target path
13+
:param copy_metadata: copy file metadata or not
1314
:return: True if success else False
1415
"""
1516
file_path = Path(file_path)
1617
if file_path.is_file() and file_path.exists():
1718
try:
18-
shutil.copy2(file_path, target_path)
19+
if copy_metadata:
20+
shutil.copy2(file_path, target_path)
21+
else:
22+
shutil.copy(file_path, target_path)
1923
file_automation_logger.info(f"Copy file origin path: {file_path}, target path : {target_path}")
2024
return True
2125
except shutil.Error as error:
@@ -25,17 +29,19 @@ def copy_file(file_path: str, target_path: str) -> bool:
2529
return False
2630

2731

28-
def copy_specify_extension_file(file_dir_path: str, target_extension: str, target_path: str) -> bool:
32+
def copy_specify_extension_file(
33+
file_dir_path: str, target_extension: str, target_path: str, copy_metadata: bool = True) -> bool:
2934
"""
3035
:param file_dir_path: which dir do we want to search
3136
:param target_extension: what extension we will search
3237
:param target_path: copy file to target path
38+
:param copy_metadata: copy file metadata or not
3339
:return: True if success else False
3440
"""
3541
file_dir_path = Path(file_dir_path)
3642
if file_dir_path.exists() and file_dir_path.is_dir():
3743
for file in file_dir_path.glob(f"**/*.{target_extension}"):
38-
copy_file(str(file), target_path)
44+
copy_file(str(file), target_path, copy_metadata=copy_metadata)
3945
file_automation_logger.info(
4046
f"Copy specify extension file on dir"
4147
f"origin dir path: {file_dir_path}, target extension: {target_extension}, "
Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
import logging
2-
import sys
32

3+
logging.root.setLevel(logging.DEBUG)
44
file_automation_logger = logging.getLogger("File Automation")
5-
file_automation_logger.setLevel(logging.INFO)
65
formatter = logging.Formatter('%(asctime)s | %(name)s | %(levelname)s | %(message)s')
7-
# Stream handler
8-
stream_handler = logging.StreamHandler(stream=sys.stderr)
9-
stream_handler.setFormatter(formatter)
10-
stream_handler.setLevel(logging.WARNING)
11-
file_automation_logger.addHandler(stream_handler)
126
# File handler
13-
file_handler = logging.FileHandler(filename="FileAutomation.log", mode="w+")
7+
file_handler = logging.FileHandler(filename="AutoControlGUI.log", mode="w")
148
file_handler.setFormatter(formatter)
159
file_automation_logger.addHandler(file_handler)
1610

11+
class APITestkaLoggingHandler(logging.Handler):
12+
13+
# redirect logging stderr output to queue
14+
15+
def __init__(self):
16+
super().__init__()
17+
self.formatter = formatter
18+
self.setLevel(logging.DEBUG)
19+
20+
def emit(self, record: logging.LogRecord) -> None:
21+
print(self.format(record))
22+
23+
24+
# Stream handler
25+
file_automation_logger.addHandler(APITestkaLoggingHandler())
26+
27+

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ requires = ["setuptools>=61.0"]
55
build-backend = "setuptools.build_meta"
66

77
[project]
8-
name = "automation_file"
9-
version = "0.0.21"
8+
name = "automation_file_dev"
9+
version = "0.0.24"
1010
authors = [
1111
{ name = "JE-Chen", email = "[email protected]" },
1212
]

dev.toml renamed to stable.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ requires = ["setuptools>=61.0"]
55
build-backend = "setuptools.build_meta"
66

77
[project]
8-
name = "automation_file_dev"
9-
version = "0.0.23"
8+
name = "automation_file"
9+
version = "0.0.21"
1010
authors = [
1111
{ name = "JE-Chen", email = "[email protected]" },
1212
]

0 commit comments

Comments
 (0)