berryworld 1.0.0.189396__py3-none-any.whl → 1.0.0.189823__py3-none-any.whl

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.
@@ -176,17 +176,36 @@ class PowerAutomate:
176
176
  :param account_type: Type of account to get the information from
177
177
  :param account_ids: IDs of the accounts to get the information from
178
178
  """
179
- graph_url = f'https://graph.microsoft.com/v1.0/{account_type.lower()}?$top=999'
180
-
181
179
  accounts_df = pd.DataFrame()
182
- if graph_url is not None:
183
- if account_ids is not None:
184
- graph_url = graph_url + '&$filter=' + ' or '.join([f'id eq \'{user_id}\'' for user_id in account_ids])
185
180
 
181
+ if account_ids is not None:
186
182
  headers = self.generate_bearer_token(grant_type='client_credentials',
187
183
  scope='https://graph.microsoft.com/.default')
188
184
 
189
- accounts_df = self.session_request("GET", graph_url, headers=headers)
185
+ remaining_ids = [user_id for user_id in account_ids if user_id]
186
+
187
+ while remaining_ids:
188
+ graph_url = f'https://graph.microsoft.com/v1.0/{account_type.lower()}?$top=999'
189
+ graph_url += '&$filter=' + ' or '.join([f"id eq '{user_id}'" for user_id in remaining_ids])
190
+
191
+ try:
192
+ result = self.session_request("GET", graph_url, headers=headers)
193
+ if isinstance(result, pd.DataFrame):
194
+ accounts_df = pd.concat([accounts_df, result], ignore_index=True)
195
+ else:
196
+ accounts_df = pd.concat([accounts_df, pd.DataFrame(result)], ignore_index=True)
197
+ break
198
+ except Exception as e:
199
+ error_message = str(e)
200
+ if '404' in error_message and 'Request_ResourceNotFound' in error_message and len(remaining_ids) > 1:
201
+ for user_id in remaining_ids.copy():
202
+ try:
203
+ single_url = f"https://graph.microsoft.com/v1.0/{account_type.lower()}?$filter=id eq '{user_id}'"
204
+ self.session_request("GET", single_url, headers=headers)
205
+ except Exception as error_message1:
206
+ if '404' in str(error_message1) and 'Request_ResourceNotFound' in error_message1:
207
+ remaining_ids.remove(user_id)
208
+ break
190
209
 
191
210
  return accounts_df
192
211
 
berryworld/sql_conn.py CHANGED
@@ -13,7 +13,7 @@ from .credentials import SQLCredentials
13
13
  class SQLConn:
14
14
  """ Connect to Microsoft SQL """
15
15
 
16
- def __init__(self, server_creds=None, master=False, trusted_certificate=True,
16
+ def __init__(self, server_creds=None, master=False, trusted_certificate=True, encrypt=True,
17
17
  multi_db=False, **kwargs):
18
18
  """ Initialize the class
19
19
  -----------------------------
@@ -31,6 +31,7 @@ class SQLConn:
31
31
  :param server_creds: Dictionary containing the info to connect to the Server
32
32
  :param master: Indicate whether the connection will be done to master or to a specific database
33
33
  :param trusted_certificate: Indicate whether the connection will be done using the TrustServerCertificate
34
+ :param encrypt: Indicate whether the connection will use SSL/TLS encryption
34
35
  :param multi_db: Indicate whether the connection will be done to a specific database or to multiple databases
35
36
  :param kwargs: Additional parameters to be passed to the connection
36
37
  """
@@ -43,6 +44,10 @@ class SQLConn:
43
44
  self.trusted_certificate = '&TrustServerCertificate=yes'
44
45
  else:
45
46
  self.trusted_certificate = ''
47
+ if encrypt:
48
+ self.encrypt = '&Encrypt=yes'
49
+ else:
50
+ self.encrypt = ''
46
51
 
47
52
  if kwargs != {}:
48
53
  try:
@@ -89,11 +94,12 @@ class SQLConn:
89
94
 
90
95
  if self.master:
91
96
  self.con_string = 'mssql+pyodbc://' + self.user_name + ':%s@' + self.server + '/master' + \
92
- '?driver=' + self.driver + '&trusted_connection=yes' + self.trusted_certificate
97
+ '?driver=' + self.driver + '&trusted_connection=yes' + self.trusted_certificate + \
98
+ self.encrypt
93
99
  self.engine = sa.create_engine(self.con_string % parse.quote_plus(self.password))
94
100
  else:
95
101
  self.con_string = 'mssql+pyodbc://' + self.user_name + ':%s@' + self.server + '/' + database + \
96
- '?driver=' + self.driver + self.trusted_certificate
102
+ '?driver=' + self.driver + self.trusted_certificate + self.encrypt
97
103
  self.engine = sa.create_engine(self.con_string % parse.quote_plus(self.password))
98
104
  if not commit_as_transaction:
99
105
  self.engine = self.engine.execution_options(isolation_level="AUTOCOMMIT")
@@ -105,7 +111,7 @@ class SQLConn:
105
111
  :return: The opened connection
106
112
  """
107
113
  constring = 'mssql+pyodbc://' + self.user_name + ':%s@' + self.server + '/' + self.db_name + \
108
- '?driver=' + self.driver + self.trusted_certificate
114
+ '?driver=' + self.driver + self.trusted_certificate + self.encrypt
109
115
  self.engine = sa.create_engine(constring % parse.quote_plus(self.password))
110
116
  if not commit_as_transaction:
111
117
  self.engine = self.engine.execution_options(isolation_level="AUTOCOMMIT")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: berryworld
3
- Version: 1.0.0.189396
3
+ Version: 1.0.0.189823
4
4
  Summary: Handy classes to improve ETL processes
5
5
  Home-page: https://www.berryworld.com
6
6
  Author: BerryWorld ltd
@@ -15,22 +15,22 @@ berryworld/logic_apps.py,sha256=a0uU4tNO3v2w7grdBv-OOx4hUf7VBIerJpwZ9U-29dQ,1459
15
15
  berryworld/microsoft_teams.py,sha256=8uPo0yku-euBj2VdzBoZCeX3IcsCCOqISLqaVZUVxfA,16030
16
16
  berryworld/persistent_storage.py,sha256=KQA57ez8eVTUCtudYkHPg_S5lcOEa_E7xXcaN1DYMMc,8601
17
17
  berryworld/pickle_management.py,sha256=5o6UuXBpTj23Jgpz6sj9V-vdcdWBK1xMEckWxT-Whj4,2436
18
- berryworld/power_automate.py,sha256=IWLXdc4-HPM0Eq9VwlaXcr17vQKh6LOmtqo-CztUzJY,26713
18
+ berryworld/power_automate.py,sha256=V86QEGG9H36DrDvod9Q6yp8OUu307hfYcXJhw06pYrA,27912
19
19
  berryworld/sharepoint_con.py,sha256=TuH-Vxk1VxjTi7x80KFssf_J8YPLRXpV27RBaFZi37U,22254
20
20
  berryworld/snowflake_conn.py,sha256=go5ZJjnhz5SkG83B0G0XZSwKgU6tg7AFTBso59oRG5M,2434
21
- berryworld/sql_conn.py,sha256=r2rAVRc3Mes0m6_62J4uFg5GLBNMr7Vkme9Ip6jT3aA,47283
21
+ berryworld/sql_conn.py,sha256=tYKgD8ja7NQuvLB1WBjdsJbPcm3eX1Y76QPTEgx8R8Q,47564
22
22
  berryworld/teams_logging.py,sha256=8NwXyWr4fLj7W6GzAm2nRQCGFDxibQpAHDHHD24FrP8,6997
23
23
  berryworld/transportation_solver.py,sha256=tNc1JJk71azIBccdWVHbqcvXWhalOdKffv6HmBD6tG0,5014
24
24
  berryworld/verify_keys.py,sha256=X4Nuz3o0XbRDYofbJGvxIDeN5gfWj19PN7lhO6T3hR8,4356
25
25
  berryworld/vivantio.py,sha256=QfZo0UKqkzVRg_LyiwivNd3aEup4TH57x4KxLZkCJwc,10627
26
26
  berryworld/vivantio_logging.py,sha256=ciy7gA4u3FrgUIpEBnMgocbNPp6jcu9TPoy-kLcrTZU,5736
27
27
  berryworld/xml_parser.py,sha256=HWD71NaTN3DaIOGT6Wzxs4CEsroFhGQwe9iPLIL80Co,957
28
- berryworld-1.0.0.189396.dist-info/licenses/LICENSE,sha256=vtkVCJM6E2af2gnsi2XxKPr4WY-uIbvzVLXieFND0UU,1074
28
+ berryworld-1.0.0.189823.dist-info/licenses/LICENSE,sha256=vtkVCJM6E2af2gnsi2XxKPr4WY-uIbvzVLXieFND0UU,1074
29
29
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  tests/test_allocation_config.py,sha256=e12l6fE9U57eSPS35g6ekJ_hol7-RHg89JV60_m1BlE,4633
31
31
  tests/test_handy_mix_config.py,sha256=Un56mz9KJmdn4K4OwzHAHLSRzDU1Xv2nFrONNuzOG04,2594
32
32
  tests/test_xml_parser.py,sha256=3QTlhFEd6KbK6nRFKZnc35tad6wqukTbe4QrFi8mr_8,859
33
- berryworld-1.0.0.189396.dist-info/METADATA,sha256=T8GbmSXFhWFhwvXBzh9W7XhduBes63nHmH_p5Bi4ZkI,1362
34
- berryworld-1.0.0.189396.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
35
- berryworld-1.0.0.189396.dist-info/top_level.txt,sha256=GIZ5qy-P5oxfEH755vA1IMFeTVdX3-40JxMe6nOe5I8,17
36
- berryworld-1.0.0.189396.dist-info/RECORD,,
33
+ berryworld-1.0.0.189823.dist-info/METADATA,sha256=0VIdQ1tBiCaDM3CHc3tHB7_jhAgG4h_EsZY0tFSaEVQ,1362
34
+ berryworld-1.0.0.189823.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
35
+ berryworld-1.0.0.189823.dist-info/top_level.txt,sha256=GIZ5qy-P5oxfEH755vA1IMFeTVdX3-40JxMe6nOe5I8,17
36
+ berryworld-1.0.0.189823.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.0.0)
2
+ Generator: setuptools (80.3.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5