Skip to content

Commit c29467c

Browse files
author
Kamil Democko
committed
added langauge flag to launch
1 parent 10c2b89 commit c29467c

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Documentation = "https://kamildemocko.github.io/pysapscript/"
1616

1717
[tool.poetry]
1818
name = "pysapscript"
19-
version = "3.0.2"
19+
version = "3.0.3"
2020
description = "Automate SAP with python!"
2121
authors = ["Kamil Democko <[email protected]>"]
2222
readme = "README.md"

pysapscript/pysapscript.py

+20-8
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@ def __repr__(self) -> str:
3232
def __str__(self) -> str:
3333
return f"Sapscript(default_window_title={self.default_window_title})"
3434

35-
def launch_sap(self, *, root_sap_dir: Path = Path(r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui"),
36-
sid: str, client: str,
37-
user: str, password: str,
38-
maximise: bool = True, quit_auto: bool = True) -> None:
35+
def launch_sap(self,
36+
sid: str,
37+
client: str,
38+
user: str,
39+
password: str,
40+
*,
41+
root_sap_dir: Path = Path(r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui"),
42+
maximise: bool = True,
43+
language: str = "en",
44+
quit_auto: bool = True) -> None:
3945
"""
4046
Launches SAP and waits for it to load
4147
@@ -46,6 +52,7 @@ def launch_sap(self, *, root_sap_dir: Path = Path(r"C:\Program Files (x86)\SAP\F
4652
user (str): SAP user
4753
password (str): SAP password
4854
maximise (bool): maximises window after start if True
55+
language (str): SAP language
4956
quit_auto (bool): quits automatically on SAP exit if True
5057
5158
Raises:
@@ -67,7 +74,8 @@ def launch_sap(self, *, root_sap_dir: Path = Path(r"C:\Program Files (x86)\SAP\F
6774
client,
6875
user,
6976
password,
70-
maximise
77+
maximise,
78+
language
7179
)
7280

7381
time.sleep(5)
@@ -165,7 +173,7 @@ def open_new_window(self, window_to_handle_opening: window.Window) -> None:
165173
utils.wait_for_window_title(self.default_window_title)
166174

167175
def _launch(self, working_dir: Path, sid: str, client: str,
168-
user: str, password: str, maximise: bool) -> None:
176+
user: str, password: str, maximise: bool, language: str) -> None:
169177
"""
170178
launches sap from sapshcut.exe
171179
"""
@@ -174,8 +182,12 @@ def _launch(self, working_dir: Path, sid: str, client: str,
174182
sap_executable = working_dir.joinpath("sapshcut.exe")
175183

176184
maximise_sap = "-max" if maximise else ""
177-
command = f"-system={sid} -client={client} "\
178-
f"-user={user} -pw={password} {maximise_sap}"
185+
language_sap = f"-language={language}" if language else ""
186+
187+
additional_args = " ".join([maximise_sap, language_sap])
188+
command = " ".join([f"-system={sid} -client={client} "
189+
f"-user={user} -pw={password}",
190+
additional_args])
179191

180192
tryouts = 2
181193
while tryouts > 0:

readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ additional parameters:
4141

4242
`root_sap_dir = Path(r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui")`
4343
`maximise = True`
44+
`language = "de"`
4445
`quit_auto = True`
4546

4647
## Attach to an already opened window:

tests/manual_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def __init__(self):
1616
client="006",
1717
user="robot01_t",
1818
password=str(pwd),
19-
quit_auto=False
19+
quit_auto=False,
20+
language="sk"
2021
)
2122

2223
self.window = self.pss.attach_window(0, 0)
@@ -69,7 +70,6 @@ def test_runs(self):
6970
window2.start_transaction("SQVI")
7071
window2.close_window()
7172

72-
# Quitting
7373
self.pss.quit()
7474

7575

0 commit comments

Comments
 (0)