Skip to content

Commit 51515d0

Browse files
authored
Merge pull request #83 from Integrated-Testing-Environment/dev
Dev
2 parents 679fe42 + 0b1e468 commit 51515d0

File tree

10 files changed

+71
-33
lines changed

10 files changed

+71
-33
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.

.idea/workspace.xml

Lines changed: 15 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66

77
[project]
88
name = "je_auto_control_dev"
9-
version = "0.0.66"
9+
version = "0.0.68"
1010
authors = [
1111
{ name = "JE-Chen", email = "[email protected]" },
1212
]

je_auto_control/__main__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from je_auto_control.utils.file_process.get_dir_file_list import \
1212
get_dir_files_as_list
1313
from je_auto_control.utils.json.json_file import read_action_json
14+
from je_auto_control.utils.project.create_project_structure import create_project_dir
1415

1516
if __name__ == "__main__":
1617
try:
@@ -25,6 +26,7 @@ def preprocess_execute_files(file_path: str):
2526
argparse_event_dict = {
2627
"execute_file": preprocess_execute_action,
2728
"execute_dir": preprocess_execute_files,
29+
"create_project": create_project_dir
2830
}
2931
parser = argparse.ArgumentParser()
3032
parser.add_argument(
@@ -35,6 +37,10 @@ def preprocess_execute_files(file_path: str):
3537
"-d", "--execute_dir",
3638
type=str, help="choose dir include action file to execute"
3739
)
40+
parser.add_argument(
41+
"-c", "--create_project",
42+
type=str, help="create project with template"
43+
)
3844
args = parser.parse_args()
3945
args = vars(args)
4046
for key, value in args.items():
Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from pathlib import Path
21
from os import getcwd
2+
from pathlib import Path
33
from threading import Lock
44

55
from je_auto_control.utils.json.json_file import write_action_json
66
from je_auto_control.utils.project.template.template_executor import executor_template_1, \
7-
executor_template_2
7+
executor_template_2, bad_executor_template_1
88
from je_auto_control.utils.project.template.template_keyword import template_keyword_1, \
9-
template_keyword_2
9+
template_keyword_2, bad_template_1
1010

1111

1212
def create_dir(dir_name: str) -> None:
@@ -20,35 +20,47 @@ def create_dir(dir_name: str) -> None:
2020
)
2121

2222

23-
def create_template(parent_name: str) -> None:
24-
keyword_dir_path = Path(getcwd() + "/" + parent_name + "/keyword")
25-
executor_dir_path = Path(getcwd() + "/" + parent_name + "/executor")
23+
def create_template(parent_name: str, project_path: str = None) -> None:
24+
if project_path is None:
25+
project_path = getcwd()
26+
keyword_dir_path = Path(project_path + "/" + parent_name + "/keyword")
27+
executor_dir_path = Path(project_path + "/" + parent_name + "/executor")
2628
lock = Lock()
2729
if keyword_dir_path.exists() and keyword_dir_path.is_dir():
28-
write_action_json(getcwd() + "/" + parent_name + "/keyword/keyword1.json", template_keyword_1)
29-
write_action_json(getcwd() + "/" + parent_name + "/keyword/keyword2.json", template_keyword_2)
30+
write_action_json(project_path + "/" + parent_name + "/keyword/keyword1.json", template_keyword_1)
31+
write_action_json(project_path + "/" + parent_name + "/keyword/keyword2.json", template_keyword_2)
32+
write_action_json(project_path + "/" + parent_name + "/keyword/bad_keyword_1.json", bad_template_1)
3033
if executor_dir_path.exists() and keyword_dir_path.is_dir():
3134
lock.acquire()
3235
try:
33-
with open(getcwd() + "/" + parent_name + "/executor/executor_one_file.py", "w+") as file:
36+
with open(project_path + "/" + parent_name + "/executor/executor_one_file.py", "w+") as file:
3437
file.write(
3538
executor_template_1.replace(
3639
"{temp}",
37-
getcwd() + "/" + parent_name + "/keyword/keyword1.json"
40+
project_path + "/" + parent_name + "/keyword/keyword1.json"
41+
)
42+
)
43+
with open(project_path + "/" + parent_name + "/executor/executor_bad_file.py", "w+") as file:
44+
file.write(
45+
bad_executor_template_1.replace(
46+
"{temp}",
47+
project_path + "/" + parent_name + "/keyword/bad_keyword_1.json"
3848
)
3949
)
40-
with open(getcwd() + "/" + parent_name + "/executor/executor_folder.py", "w+") as file:
50+
with open(project_path + "/" + parent_name + "/executor/executor_folder.py", "w+") as file:
4151
file.write(
4252
executor_template_2.replace(
4353
"{temp}",
44-
getcwd() + "/" + parent_name + "/keyword"
54+
project_path + "/" + parent_name + "/keyword"
4555
)
4656
)
4757
finally:
4858
lock.release()
4959

5060

51-
def create_project_dir(parent_name: str) -> None:
52-
create_dir(getcwd() + "/" + parent_name + "/keyword")
53-
create_dir(getcwd() + "/" + parent_name + "/executor")
61+
def create_project_dir(project_path: str = None, parent_name: str = "AutoControl") -> None:
62+
if project_path is None:
63+
project_path = getcwd()
64+
create_dir(project_path + "/" + parent_name + "/keyword")
65+
create_dir(project_path + "/" + parent_name + "/executor")
5466
create_template(parent_name)

je_auto_control/utils/project/template/template_executor.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,15 @@
1717
)
1818
)
1919
"""
20+
21+
bad_executor_template_1: str = \
22+
"""
23+
# This example is primarily intended to remind users of the importance of verifying input.
24+
from je_auto_control import execute_action, read_action_json
25+
26+
execute_action(
27+
read_action_json(
28+
r"{temp}"
29+
)
30+
)
31+
"""

je_auto_control/utils/project/template/template_keyword.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,9 @@
4848
["generate_json_report"]
4949
]
5050

51+
bad_template_1 = [
52+
["set_record_enable", [True]],
53+
["add_package_to_executor", ["os"]],
54+
["os_system", ["python --version"]],
55+
["os_system", ["python -m pip --version"]],
56+
]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66

77
[project]
88
name = "je_auto_control"
9-
version = "0.0.130"
9+
version = "0.0.133"
1010
authors = [
1111
{ name = "JE-Chen", email = "[email protected]" },
1212
]

test/unit_test/argparse/argparse_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
os.system("cd " + os.getcwd())
66
os.system("python je_auto_control --execute_file " + os.getcwd() + r"/test/unit_test/argparse/test1.json")
77
os.system("python je_auto_control --execute_dir " + os.getcwd() + r"/test/unit_test/argparse")
8+
os.system("python je_auto_control --create_project " + os.getcwd())
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from je_auto_control import create_project_dir
22

3-
create_project_dir("My Test Project")
3+
create_project_dir()

0 commit comments

Comments
 (0)