ITK-dev-shared-components 1.2.0__tar.gz → 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/PKG-INFO +1 -2
  2. itk_dev_shared_components-1.3.0/itk_dev_shared_components/sap/fmcacov.py +76 -0
  3. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/sap/gridview_util.py +3 -1
  4. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/sap/opret_kundekontakt.py +2 -6
  5. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/sap/sap_login.py +0 -52
  6. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components.egg-info/PKG-INFO +1 -2
  7. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components.egg-info/SOURCES.txt +1 -0
  8. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components.egg-info/requires.txt +0 -1
  9. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/pyproject.toml +1 -2
  10. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/LICENSE +0 -0
  11. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/README.md +0 -0
  12. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/__init__.py +0 -0
  13. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/graph/__init__.py +0 -0
  14. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/graph/authentication.py +0 -0
  15. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/graph/mail.py +0 -0
  16. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/kmd_nova/__init__.py +0 -0
  17. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/kmd_nova/authentication.py +0 -0
  18. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/kmd_nova/cpr.py +0 -0
  19. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/kmd_nova/nova_cases.py +0 -0
  20. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/kmd_nova/nova_documents.py +0 -0
  21. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/kmd_nova/nova_objects.py +0 -0
  22. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/kmd_nova/nova_tasks.py +0 -0
  23. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/kmd_nova/util.py +0 -0
  24. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/misc/__init__.py +0 -0
  25. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/misc/cpr_util.py +0 -0
  26. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/sap/__init__.py +0 -0
  27. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/sap/multi_session.py +0 -0
  28. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/sap/sap_util.py +0 -0
  29. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components/sap/tree_util.py +0 -0
  30. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components.egg-info/dependency_links.txt +0 -0
  31. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/itk_dev_shared_components.egg-info/top_level.txt +0 -0
  32. {itk_dev_shared_components-1.2.0 → itk_dev_shared_components-1.3.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: itk_dev_shared_components
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: Shared components to use in RPA projects
5
5
  Author-email: ITK Development <itk-rpa@mkb.aarhus.dk>
6
6
  Project-URL: Homepage, https://github.com/itk-dev-rpa/itk-dev-shared-components
@@ -12,7 +12,6 @@ Requires-Python: >=3.7
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: pywin32>=306
15
- Requires-Dist: selenium>=4.10.0
16
15
  Requires-Dist: msal>=1.24.1
17
16
  Requires-Dist: requests>=2.31.0
18
17
  Requires-Dist: beautifulsoup4>=4.12.2
@@ -0,0 +1,76 @@
1
+ """This module contains functions to help with actions in the fmcacov transaction."""
2
+
3
+
4
+ def open_forretningspartner(session, fp: str) -> None:
5
+ """Start the transaction FMCACOV and open the given forretningspartner.
6
+ If the fp-number also matches a cvr-number the fp-number will be opened.
7
+
8
+ Args:
9
+ session: The SAP session to perform the action.
10
+ fp: The forretningspartner number.
11
+
12
+ Raises:
13
+ ValueError: If the forretningspartner wasn't found.
14
+ """
15
+ session.StartTransaction('fmcacov')
16
+
17
+ # Find forretningspartner
18
+ session.findById("wnd[0]/usr/ctxtGPART_DYN").text = fp
19
+ session.findById("wnd[0]").sendVKey(0)
20
+
21
+ # Detect window "Forretningspartner * Entries"
22
+ if session.findById('wnd[1]/usr', False) is not None:
23
+ # Pop-up detected
24
+ for row_id in range(3, 5):
25
+ fp_row = session.FindById(f'wnd[1]/usr/lbl[103,{row_id}]')
26
+ if fp_row.text == fp:
27
+ fp_row.SetFocus()
28
+ # Press 'Accept' button.
29
+ session.FindById('wnd[1]/tbar[0]/btn[0]').press()
30
+ break
31
+ else:
32
+ # Range exhausted
33
+ raise ValueError(f"Forretningspartner '{fp}' was not found in pop-up.")
34
+
35
+
36
+ def dismiss_key_popup(session, fp: str = "25564617") -> None:
37
+ """Once a day a popup appears asking to generate a new "afstemningsnøgle".
38
+ This function forces it to appear and clicks "Ja" on it.
39
+ This is done by pretending to do "Kontovedligehold" on the given forretningspartner.
40
+ The function should start and end at the home screen.
41
+
42
+ Args:
43
+ session: The SAP session object.
44
+ fp: The forretningspartner to used. Defaults to "25564617" a fictional person in AAK.
45
+
46
+ Raises:
47
+ RuntimeError: If a popup other than the expected ones appear.
48
+ """
49
+ open_forretningspartner(session, fp)
50
+
51
+ # Right click the first row in the postliste and click "Kontovedligehold med filter"
52
+ postliste = session.findById("wnd[0]/usr/tabsDATA_DISP/tabpDATA_DISP_FC1/ssubDATA_DISP_SCA:RFMCA_COV:0202/cntlRFMCA_COV_0100_CONT5/shellcont/shell")
53
+ postliste.setCurrentCell(0, "VTREF")
54
+ postliste.contextMenu()
55
+ postliste.selectContextMenuItem("ACC_MAINT_FILTER")
56
+
57
+ # Check if the key popup appeared
58
+ popup = session.findbyid("wnd[1]", False)
59
+ if popup:
60
+ if popup.text == "Kontrol af afstemningsnøgle":
61
+ # Press "Ja"
62
+ session.findbyid("wnd[1]/usr/btnSPOP-OPTION1").press()
63
+ else:
64
+ raise RuntimeError(f"Another popup is blocking: {popup.text}")
65
+
66
+ # Check and dismiss confirmation dialog
67
+ confirmation_text = session.findbyid("wnd[1]/usr/txtMESSTXT1").text
68
+ if 'oprettet' in confirmation_text:
69
+ session.findById("wnd[1]/tbar[0]/btn[0]").press()
70
+ else:
71
+ raise RuntimeError(f"Confirmation dialog wasn't as expected: {confirmation_text}.")
72
+
73
+ # Go back to home screen (Afbryd x 3)
74
+ session.findById("wnd[0]/tbar[0]/btn[12]").press()
75
+ session.findById("wnd[0]/tbar[0]/btn[12]").press()
76
+ session.findById("wnd[0]/tbar[0]/btn[12]").press()
@@ -1,5 +1,7 @@
1
1
  """This module provides static functions to perform common tasks with SAP GuiGridView COM objects."""
2
2
 
3
+ from typing import Iterator
4
+
3
5
 
4
6
  def scroll_entire_table(grid_view, return_to_top=False) -> None:
5
7
  """This function scrolls through the entire table to load all cells.
@@ -72,7 +74,7 @@ def get_row(grid_view, row: int, scroll_to_row=False) -> tuple[str]:
72
74
  return tuple(row_data)
73
75
 
74
76
 
75
- def iterate_rows(grid_view) -> tuple[str]:
77
+ def iterate_rows(grid_view) -> Iterator[tuple[str]]:
76
78
  """This generator yields each row of the table in order.
77
79
  This is preferable to loading all rows as this will only load a row when it's needed.
78
80
  As a side effect this function scrolls the yielded row into view, so the
@@ -5,7 +5,7 @@ from datetime import date
5
5
 
6
6
  import win32clipboard
7
7
 
8
- from itk_dev_shared_components.sap import tree_util
8
+ from itk_dev_shared_components.sap import tree_util, fmcacov
9
9
 
10
10
 
11
11
  def opret_kundekontakter(session, fp: str, aftaler: list[str] | None,
@@ -24,11 +24,7 @@ def opret_kundekontakter(session, fp: str, aftaler: list[str] | None,
24
24
  Raises:
25
25
  RuntimeError: If the kundekontakt wasn't created.
26
26
  """
27
- session.StartTransaction('fmcacov')
28
-
29
- # Find forretningspartner
30
- session.findById("wnd[0]/usr/ctxtGPART_DYN").text = fp
31
- session.findById("wnd[0]").sendVKey(0)
27
+ fmcacov.open_forretningspartner(session, fp)
32
28
 
33
29
  # Click 'Opret kundekontakt-flere
34
30
  session.findById("wnd[0]/shellcont/shell").nodeContextMenu("GP0000000001")
@@ -2,67 +2,15 @@
2
2
  as well as a function to change user passwords."""
3
3
 
4
4
  import os
5
- import pathlib
6
5
  import subprocess
7
6
  import time
8
7
 
9
- from selenium import webdriver
10
- from selenium.webdriver.common.by import By
11
8
  import pywintypes
12
9
  import win32com.client
13
10
 
14
11
  from itk_dev_shared_components.sap import multi_session
15
12
 
16
13
 
17
- def login_using_portal(username: str, password: str):
18
- """Open KMD Portal in Edge, login and start SAP GUI.
19
- Args:
20
- user: KMD Portal username.
21
- password: KMD Portal password.
22
- """
23
- driver = webdriver.Chrome()
24
- driver.implicitly_wait(10)
25
- driver.get('https://portal.kmd.dk/irj/portal')
26
- driver.maximize_window()
27
-
28
- # Login
29
- user_field = driver.find_element(By.ID, 'logonuidfield')
30
- pass_field = driver.find_element(By.ID, 'logonpassfield')
31
- login_button = driver.find_element(By.ID, 'buttonLogon')
32
- user_field.clear()
33
- user_field.send_keys(username)
34
- pass_field.clear()
35
- pass_field.send_keys(password)
36
- login_button.click()
37
-
38
- # Opus
39
- mine_genveje = driver.find_element(By.CSS_SELECTOR, "div[title='Mine Genveje']")
40
- mine_genveje.click()
41
-
42
- # Wait for download and launch file
43
- _wait_for_download()
44
-
45
- driver.quit()
46
- _wait_for_sap_session(10)
47
-
48
-
49
- def _wait_for_download():
50
- """Private function that checks if the SAP.erp file has been downloaded.
51
- Raises:
52
- TimeoutError: If the file hasn't been downloaded within 5 seconds.
53
- """
54
- downloads_folder = str(pathlib.Path.home() / "Downloads")
55
- for _ in range(10):
56
- for file in os.listdir(downloads_folder):
57
- if file.endswith(".sap"):
58
- path = os.path.join(downloads_folder, file)
59
- os.startfile(path)
60
- return
61
-
62
- time.sleep(0.5)
63
- raise TimeoutError(f".sap file not found in {downloads_folder}")
64
-
65
-
66
14
  def login_using_cli(username: str, password: str, client: str = '751', system: str = 'P02', timeout: int = 10) -> None:
67
15
  """Open and login to SAP with commandline expressions.
68
16
  Args:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: itk_dev_shared_components
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: Shared components to use in RPA projects
5
5
  Author-email: ITK Development <itk-rpa@mkb.aarhus.dk>
6
6
  Project-URL: Homepage, https://github.com/itk-dev-rpa/itk-dev-shared-components
@@ -12,7 +12,6 @@ Requires-Python: >=3.7
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: pywin32>=306
15
- Requires-Dist: selenium>=4.10.0
16
15
  Requires-Dist: msal>=1.24.1
17
16
  Requires-Dist: requests>=2.31.0
18
17
  Requires-Dist: beautifulsoup4>=4.12.2
@@ -21,6 +21,7 @@ itk_dev_shared_components/kmd_nova/util.py
21
21
  itk_dev_shared_components/misc/__init__.py
22
22
  itk_dev_shared_components/misc/cpr_util.py
23
23
  itk_dev_shared_components/sap/__init__.py
24
+ itk_dev_shared_components/sap/fmcacov.py
24
25
  itk_dev_shared_components/sap/gridview_util.py
25
26
  itk_dev_shared_components/sap/multi_session.py
26
27
  itk_dev_shared_components/sap/opret_kundekontakt.py
@@ -1,5 +1,4 @@
1
1
  pywin32>=306
2
- selenium>=4.10.0
3
2
  msal>=1.24.1
4
3
  requests>=2.31.0
5
4
  beautifulsoup4>=4.12.2
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "itk_dev_shared_components"
7
- version = "1.2.0"
7
+ version = "1.3.0"
8
8
  authors = [
9
9
  { name="ITK Development", email="itk-rpa@mkb.aarhus.dk" },
10
10
  ]
@@ -18,7 +18,6 @@ classifiers = [
18
18
  ]
19
19
  dependencies = [
20
20
  "pywin32 >= 306",
21
- "selenium >= 4.10.0",
22
21
  "msal >= 1.24.1",
23
22
  "requests >= 2.31.0",
24
23
  "beautifulsoup4 >= 4.12.2"