mbu-dev-shared-components 4.2.1__tar.gz → 4.2.2__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 (60) hide show
  1. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/PKG-INFO +1 -1
  2. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/msoffice365/sharepoint_api/files.py +42 -12
  3. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/application/edi_portal.py +30 -17
  4. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components.egg-info/PKG-INFO +1 -1
  5. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/pyproject.toml +1 -1
  6. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/LICENSE +0 -0
  7. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/README.md +0 -0
  8. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/database/__init__.py +0 -0
  9. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/database/connection.py +0 -0
  10. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/database/constants.py +0 -0
  11. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/database/logging.py +0 -0
  12. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/database/utility.py +0 -0
  13. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/getorganized/__init__.py +0 -0
  14. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/getorganized/auth.py +0 -0
  15. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/getorganized/cases.py +0 -0
  16. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/getorganized/contacts.py +0 -0
  17. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/getorganized/documents.py +0 -0
  18. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/getorganized/objects.py +0 -0
  19. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/google/__init__.py +0 -0
  20. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/google/api/__init__.py +0 -0
  21. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/google/api/auth.py +0 -0
  22. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/google/workspace/__init__.py +0 -0
  23. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/google/workspace/alerts.py +0 -0
  24. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/msoffice365/__init__.py +0 -0
  25. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/msoffice365/excel/__init__.py +0 -0
  26. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/msoffice365/excel/excel_reader.py +0 -0
  27. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/msoffice365/sharepoint_api/__init__.py +0 -0
  28. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/os2forms/__init__.py +0 -0
  29. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/os2forms/documents.py +0 -0
  30. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/os2forms/forms.py +0 -0
  31. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/romexis/__init__.py +0 -0
  32. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/romexis/db_handler.py +0 -0
  33. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/romexis/helper_functions.py +0 -0
  34. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/sap/__init__.py +0 -0
  35. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/sap/create_invoice.py +0 -0
  36. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/__init__.py +0 -0
  37. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/application/__init__.py +0 -0
  38. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/application/aftalebog.py +0 -0
  39. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/application/app_handler.py +0 -0
  40. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/application/appointment.py +0 -0
  41. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/application/base_ui.py +0 -0
  42. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/application/clinic.py +0 -0
  43. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/application/document.py +0 -0
  44. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/application/event.py +0 -0
  45. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/application/exceptions.py +0 -0
  46. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/application/handler_base.py +0 -0
  47. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/application/journal_note.py +0 -0
  48. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/application/patient.py +0 -0
  49. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/database/__init__.py +0 -0
  50. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/solteqtand/database/db_handler.py +0 -0
  51. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/utils/__init__.py +0 -0
  52. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/utils/db_stored_procedure_executor.py +0 -0
  53. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/utils/fernet_encryptor.py +0 -0
  54. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/utils/file_handler.py +0 -0
  55. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components/utils/json_handler.py +0 -0
  56. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components.egg-info/SOURCES.txt +0 -0
  57. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components.egg-info/dependency_links.txt +0 -0
  58. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components.egg-info/requires.txt +0 -0
  59. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/mbu_dev_shared_components.egg-info/top_level.txt +0 -0
  60. {mbu_dev_shared_components-4.2.1 → mbu_dev_shared_components-4.2.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mbu_dev_shared_components
3
- Version: 4.2.1
3
+ Version: 4.2.2
4
4
  Summary: Shared components to use in RPA projects
5
5
  Author-email: MBU <rpa@mbu.aarhus.dk>
6
6
  License-Expression: MIT
@@ -46,7 +46,6 @@ from openpyxl import load_workbook
46
46
 
47
47
  import pandas as pd
48
48
 
49
- from office365.runtime.auth.user_credential import UserCredential
50
49
  from office365.sharepoint.client_context import ClientContext
51
50
  from office365.sharepoint.files.file import File
52
51
 
@@ -57,25 +56,29 @@ class Sharepoint:
57
56
  downloading, uploading, and saving functionalities within a specified SharePoint document library.
58
57
 
59
58
  Attributes:
60
- username (str): Username for authentication.
61
- password (str): Password for authentication.
62
- site_url (str): URL of the SharePoint site.
63
- site_name (str): Name of the SharePoint site.
64
- document_library (str): Document library path.
59
+ tenant (str): Tenant name or domain (e.g. 'yourtenant.onmicrosoft.com').
60
+ client_id (str): The Azure AD application (client) ID.
61
+ thumbprint (str): The certificate thumbprint registered in Azure AD.
62
+ cert_path (str): Path to the PEM file containing the private key and certificate.
63
+ site_url (str): Base URL of the SharePoint tenant (e.g. 'https://contoso.sharepoint.com').
64
+ site_name (str): Name of the SharePoint site (e.g. 'MyTeamSite').
65
+ document_library (str): Name of the document library within the site.
65
66
  """
66
67
 
67
68
  def __init__(
68
- self, username: str, password: str, site_url: str, site_name: str, document_library: str
69
+ self, tenant: str, client_id: str, thumbprint: str, cert_path: str, site_url: str, site_name: str, document_library: str
69
70
  ):
70
71
  """Initializes the Sharepoint class with credentials and site details."""
71
- self.username = username
72
- self.password = password
72
+ self.tenant = tenant
73
+ self.client_id = client_id
74
+ self.thumbprint = thumbprint
75
+ self.cert_path = cert_path
73
76
  self.site_url = site_url
74
77
  self.site_name = site_name
75
78
  self.document_library = document_library
76
79
  self.ctx = self._auth()
77
80
 
78
- def _auth(self) -> Optional[ClientContext]:
81
+ def _auth(self):
79
82
  """
80
83
  Authenticates to the SharePoint site and returns the client context.
81
84
 
@@ -85,9 +88,20 @@ class Sharepoint:
85
88
  """
86
89
  try:
87
90
  site_full_url = f"{self.site_url}/teams/{self.site_name}"
88
- ctx = ClientContext(site_full_url).with_credentials(
89
- UserCredential(self.username, self.password)
91
+
92
+ ctx = ClientContext(site_full_url).with_client_certificate(
93
+ tenant=self.tenant,
94
+ client_id=self.client_id,
95
+ thumbprint=self.thumbprint,
96
+ cert_path=self.cert_path
90
97
  )
98
+
99
+ web = ctx.web
100
+ ctx.load(web)
101
+ ctx.execute_query()
102
+
103
+ print(f"Authenticated successfully. Site Title: {web.properties['Title']}")
104
+
91
105
  return ctx
92
106
  except Exception as e:
93
107
  print(f"Failed to authenticate: {e}")
@@ -108,13 +122,20 @@ class Sharepoint:
108
122
  folder_url = f"/teams/{self.site_name}/{self.document_library}/{folder_name}"
109
123
  folder = self.ctx.web.get_folder_by_server_relative_url(folder_url)
110
124
  files = folder.files
125
+
111
126
  self.ctx.load(files)
112
127
  self.ctx.execute_query()
128
+
113
129
  files_list = [{"Name": file.name} for file in files]
130
+
114
131
  return files_list
132
+
115
133
  except Exception as e:
134
+
116
135
  print(f"Error retrieving files: {e}")
136
+
117
137
  return None
138
+
118
139
  return None
119
140
 
120
141
  def fetch_file_content(self, file_name: str, folder_name: str) -> Optional[bytes]:
@@ -146,12 +167,18 @@ class Sharepoint:
146
167
  if self.ctx:
147
168
  try:
148
169
  file_url = f"/teams/{self.site_name}/{self.document_library}/{folder_name}/{file_name}"
170
+
149
171
  file_content = File.open_binary(self.ctx, file_url)
172
+
150
173
  return file_content.content
174
+
151
175
  except Exception:
152
176
  print("Failed to download file:")
177
+
153
178
  traceback.print_exc()
179
+
154
180
  return None
181
+
155
182
  return None
156
183
 
157
184
  def _write_file(self, folder_destination: str, file_name: str, file_content: bytes):
@@ -255,10 +282,13 @@ class Sharepoint:
255
282
  if self.ctx:
256
283
  try:
257
284
  folder_url = f"/teams/{self.site_name}/{self.document_library}/{folder_name}"
285
+
258
286
  target_folder = self.ctx.web.get_folder_by_server_relative_url(folder_url)
259
287
 
260
288
  target_folder.upload_file(file_name, binary_content).execute_query()
289
+
261
290
  print(f"File '{file_name}' uploaded successfully to '{folder_url}'.")
291
+
262
292
  except Exception as e:
263
293
  print(f"Failed to upload file '{file_name}': {e}")
264
294
 
@@ -1,5 +1,7 @@
1
1
  """This module contains the EDIHandler class for handling EDI portal interactions."""
2
+
2
3
  import time
4
+
3
5
  import uiautomation as auto
4
6
 
5
7
  from .handler_base import HandlerBase
@@ -18,13 +20,13 @@ class EDIHandler(HandlerBase):
18
20
  menu_edi_button = self.find_element_by_property(
19
21
  control=self.app_window,
20
22
  control_type=auto.ControlType.MenuItemControl,
21
- name="EDI Portal"
23
+ name="EDI Portal",
22
24
  )
23
25
  menu_edi_button.Click(simulateMove=False, waitTime=0)
24
26
  journalforsendelse_button = self.find_element_by_property(
25
27
  control=self.app_window,
26
28
  control_type=auto.ControlType.MenuItemControl,
27
- name="Opret journalforsendelse"
29
+ name="Opret journalforsendelse",
28
30
  )
29
31
  journalforsendelse_button.Click(simulateMove=False, waitTime=0)
30
32
 
@@ -62,9 +64,7 @@ class EDIHandler(HandlerBase):
62
64
 
63
65
  try:
64
66
  next_button = self.wait_for_control(
65
- auto.ButtonControl, {"Name": "Næste"},
66
- search_depth=50,
67
- timeout=5
67
+ auto.ButtonControl, {"Name": "Næste"}, search_depth=50, timeout=5
68
68
  )
69
69
  except TimeoutError:
70
70
  next_button = None
@@ -72,9 +72,10 @@ class EDIHandler(HandlerBase):
72
72
  if not next_button:
73
73
  try:
74
74
  next_button = self.wait_for_control(
75
- auto.ButtonControl, {"AutomationId": "patientInformationNextButton"},
75
+ auto.ButtonControl,
76
+ {"AutomationId": "patientInformationNextButton"},
76
77
  search_depth=50,
77
- timeout=5
78
+ timeout=5,
78
79
  )
79
80
  except TimeoutError:
80
81
  next_button = None
@@ -87,7 +88,9 @@ class EDIHandler(HandlerBase):
87
88
  print(f"Error while clicking next button in EDI Portal: {e}")
88
89
  raise
89
90
 
90
- def edi_portal_check_contractor_id(self, extern_clinic_data: dict, sleep_time: int = 5) -> dict:
91
+ def edi_portal_check_contractor_id(
92
+ self, extern_clinic_data: dict, sleep_time: int = 5
93
+ ) -> dict:
91
94
  """
92
95
  Checks if the contractor ID is valid in the EDI portal.
93
96
 
@@ -100,36 +103,46 @@ class EDIHandler(HandlerBase):
100
103
  """
101
104
  try:
102
105
  # Handle Hasle Torv Clinic special case
103
- if extern_clinic_data[0]["contractorId"] == "477052" or extern_clinic_data[0]["contractorId"] == "470678":
106
+ if (
107
+ extern_clinic_data[0]["contractorId"] == "477052"
108
+ or extern_clinic_data[0]["contractorId"] == "470678"
109
+ ):
104
110
  contractor_id = "485055"
105
111
  clinic_phone_number = "86135240"
106
112
  else:
107
113
  contractor_id = extern_clinic_data[0]["contractorId"]
108
114
  clinic_phone_number = extern_clinic_data[0]["phoneNumber"]
109
115
 
110
- self.edi_portal_click_next_button(sleep_time=2)
116
+ self.edi_portal_click_next_button(sleep_time=3)
117
+
118
+ root_web_area = self.wait_for_control(
119
+ auto.DocumentControl, {"AutomationId": "RootWebArea"}, search_depth=20
120
+ )
111
121
 
112
122
  class_options = [
113
123
  "form-control filter_search",
114
124
  "form-control filter_search valid",
115
125
  ]
116
-
126
+ search_box = None
117
127
  for class_name in class_options:
118
128
  try:
119
129
  search_box = self.wait_for_control(
120
- auto.EditControl,
130
+ root_web_area.EditControl,
121
131
  {"ClassName": class_name},
122
132
  search_depth=22,
123
- timeout=1,
133
+ timeout=2,
124
134
  )
125
135
  except TimeoutError:
126
136
  continue
127
137
  if search_box:
128
138
  break
129
- else:
130
- raise RuntimeError("Search box not found")
139
+ if not search_box:
140
+ raise RuntimeError("Search box not found")
141
+
131
142
  search_box.SetFocus()
132
- search_box_value_pattern = search_box.GetPattern(auto.PatternId.ValuePattern)
143
+ search_box_value_pattern = search_box.GetPattern(
144
+ auto.PatternId.ValuePattern
145
+ )
133
146
  search_box_value_pattern.SetValue(contractor_id)
134
147
  search_box.SendKeys("{ENTER}")
135
148
 
@@ -137,7 +150,7 @@ class EDIHandler(HandlerBase):
137
150
 
138
151
  table_dentists = self.wait_for_control(
139
152
  auto.TableControl,
140
- {'AutomationId': 'table_id1'},
153
+ {"AutomationId": "table_id1"},
141
154
  search_depth=25,
142
155
  )
143
156
  grid_pattern = table_dentists.GetPattern(auto.PatternId.GridPattern)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mbu_dev_shared_components
3
- Version: 4.2.1
3
+ Version: 4.2.2
4
4
  Summary: Shared components to use in RPA projects
5
5
  Author-email: MBU <rpa@mbu.aarhus.dk>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "mbu_dev_shared_components"
7
- version = "4.2.1"
7
+ version = "4.2.2"
8
8
  authors = [
9
9
  { name="MBU", email="rpa@mbu.aarhus.dk" },
10
10
  ]