berryworld 1.0.0.178885__py3-none-any.whl → 1.0.0.179097__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.
berryworld/email_con.py CHANGED
@@ -275,8 +275,7 @@ class EmailConnection:
275
275
  return emails_df.shape[0] != 0
276
276
 
277
277
  except Exception as e:
278
- print(traceback.format_exc())
279
- raise Exception(e)
278
+ print(e)
280
279
 
281
280
  @staticmethod
282
281
  def get_mimetype(file_path):
@@ -284,8 +283,6 @@ class EmailConnection:
284
283
  :param file_path: Path of the file to be attached
285
284
  """
286
285
  # Get mimetype
287
- mimetype = None
288
- extension = None
289
286
  if ('.jpg' in file_path) | ('.jpeg' in file_path):
290
287
  mimetype = "image/jpeg"
291
288
  extension = '.jpeg'
berryworld/logic_apps.py CHANGED
@@ -5,6 +5,56 @@ from requests.adapters import HTTPAdapter
5
5
  from urllib3.util.retry import Retry
6
6
 
7
7
 
8
+ def format_create_payload(payload):
9
+ """ Format the payload to create a workflow in Azure Portal
10
+ :param payload: Properties and Definition of the workflow
11
+ """
12
+ # Reshape the payload to fit the required format
13
+ json_dict = json.loads(payload)
14
+
15
+ # Check if definition key is in json payload
16
+ if not ('definition' in json_dict['properties'].keys()):
17
+ json_dict = {
18
+ "properties": {
19
+ "definition": json_dict['properties']
20
+ }
21
+ }
22
+
23
+ # Check if location key is in json payload
24
+ location_flag = False
25
+ location_dict = {}
26
+ if 'location' in json_dict['properties']['definition'].keys():
27
+ location_dict = json_dict['properties']['definition']['location']
28
+ json_dict = {
29
+ "properties": {
30
+ "definition": {key: val for key, val in json_dict['properties']['definition'].items() if
31
+ key != 'location'}
32
+ }
33
+ }
34
+ location_flag = True
35
+
36
+ # Check if tags key is in json payload
37
+ tags_flag = False
38
+ tags_dict = {}
39
+ if 'tags' in json_dict['properties']['definition'].keys():
40
+ tags_dict = json_dict['properties']['definition']['tags']
41
+ json_dict = {
42
+ "properties": {
43
+ "definition": {key: val for key, val in json_dict['properties']['definition'].items() if
44
+ key != 'tags'}
45
+ }
46
+ }
47
+ tags_flag = True
48
+ json_dict = {**json_dict, **{'tags': tags_dict}}
49
+
50
+ if tags_flag:
51
+ json_dict = {**json_dict, **{'tags': tags_dict}}
52
+ if location_flag:
53
+ json_dict = {**json_dict, **{'location': location_dict}}
54
+
55
+ return json.dumps(json_dict)
56
+
57
+
8
58
  class LogicApps:
9
59
  def __init__(self, **kwargs):
10
60
  """
@@ -187,7 +237,8 @@ class LogicApps:
187
237
  :param resource_group: Resource group Name to get the workflows from
188
238
  :param workflow_name: New name of the workflow
189
239
  :param payload: Payload to create the workflow. It usually comes under properties in the workflow response
190
- which we must add "location" and "tags" keys.
240
+ which we must add "location" and "tags" keys. It should be in the same format that the Logic Apps are stored in
241
+ the Azure DevOps repository.
191
242
  Payload example:
192
243
  {
193
244
  "properties": {
@@ -246,6 +297,11 @@ class LogicApps:
246
297
  f"providers/Microsoft.Logic/workflows/{workflow_name}?" + self.api_version
247
298
  headers_ = self.headers
248
299
  headers_['Content-Type'] = 'application/json'
300
+
249
301
  create_resp = req.put(create_url, headers=self.headers, data=payload)
250
- if create_resp.status_code != 200:
251
- raise Exception(f'Cannot create the workflow {workflow_name}. Error: {create_resp.text}')
302
+ if not str(create_resp.status_code).startswith('2'):
303
+ print('Try to reform the payload to fit the required format in the Azure Portal')
304
+ payload = format_create_payload(payload)
305
+ create_resp = req.put(create_url, headers=self.headers, data=payload)
306
+ if not str(create_resp.status_code).startswith('2'):
307
+ raise Exception(f'Cannot create the workflow {workflow_name}. Error: {create_resp.text}')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: berryworld
3
- Version: 1.0.0.178885
3
+ Version: 1.0.0.179097
4
4
  Summary: Handy classes to improve ETL processes
5
5
  Home-page: https://www.berryworld.com
6
6
  Author: BerryWorld ltd
@@ -6,11 +6,11 @@ berryworld/app_logs_query.py,sha256=U94b-z3X9cuY_KFozupUcfaYciXWBn7p_RHkoRsfROU,
6
6
  berryworld/cache_data.py,sha256=2cStWbFQHimon_lHMbcM_0vU7lt-FCge96D-T9YXaxQ,2242
7
7
  berryworld/credentials.py,sha256=Knxo4gssLT7sbaBjOTFe3mX5k70G2e0M_6CdtlddjtA,10200
8
8
  berryworld/devops.py,sha256=BAsVonVwCXoApUOovkt-BCzwc6KnXjxRDGff_ejSGw8,9719
9
- berryworld/email_con.py,sha256=lAadyJCTXdXJQeS9WDaTErtKxT1c9DKPJ-LpWNmWa98,14549
9
+ berryworld/email_con.py,sha256=uSBzs_Ijz9pUPWt9e7U3TCB7i6q7hU1bB5vhsTB_tmw,14448
10
10
  berryworld/email_logging.py,sha256=ebZ-PHZ9tCU3q-vkNnOT3-mTG7pCAmewnzzJZ9lnOjI,4476
11
11
  berryworld/generate_env.py,sha256=Tk9Z_u7cA4Ve8YYTyLH2qwmLVAuYoTIWoFc0h8Va8lY,7842
12
12
  berryworld/handy_mix.py,sha256=SLCAdl2xaWEewWkECzcVFUDODDEkvUgpmJjTiccyVwU,9771
13
- berryworld/logic_apps.py,sha256=hFi4wAOTgL9xirU6cR4rkOYTFBdDNes_aU3-aS9MsN0,12457
13
+ berryworld/logic_apps.py,sha256=a0uU4tNO3v2w7grdBv-OOx4hUf7VBIerJpwZ9U-29dQ,14591
14
14
  berryworld/microsoft_teams.py,sha256=Mhj83-tQWRR58YfBUPUTQKQ-qJD1Y5FBPpjU70gP6UU,15964
15
15
  berryworld/persistent_storage.py,sha256=_lGdXa7IyxfMF3xNF9y26X_z9RDb2Ah7R0oF61HR8Gc,5764
16
16
  berryworld/pickle_management.py,sha256=O49ojVtTqYCT510rVRTbZWWaur_-5q3HSVG03Azn8mQ,2393
@@ -28,8 +28,8 @@ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  tests/test_allocation_config.py,sha256=e12l6fE9U57eSPS35g6ekJ_hol7-RHg89JV60_m1BlE,4633
29
29
  tests/test_handy_mix_config.py,sha256=Un56mz9KJmdn4K4OwzHAHLSRzDU1Xv2nFrONNuzOG04,2594
30
30
  tests/test_xml_parser.py,sha256=3QTlhFEd6KbK6nRFKZnc35tad6wqukTbe4QrFi8mr_8,859
31
- berryworld-1.0.0.178885.dist-info/LICENSE,sha256=vtkVCJM6E2af2gnsi2XxKPr4WY-uIbvzVLXieFND0UU,1074
32
- berryworld-1.0.0.178885.dist-info/METADATA,sha256=f8pKCUKdq0Dtk7T1jmtepXYhbh1I1LIuaem2lzNDKkw,1091
33
- berryworld-1.0.0.178885.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
34
- berryworld-1.0.0.178885.dist-info/top_level.txt,sha256=GIZ5qy-P5oxfEH755vA1IMFeTVdX3-40JxMe6nOe5I8,17
35
- berryworld-1.0.0.178885.dist-info/RECORD,,
31
+ berryworld-1.0.0.179097.dist-info/LICENSE,sha256=vtkVCJM6E2af2gnsi2XxKPr4WY-uIbvzVLXieFND0UU,1074
32
+ berryworld-1.0.0.179097.dist-info/METADATA,sha256=E9GLcy3lZWJ9HNHqXqx_56WHvu5RUqoW8qy-4w7Qxes,1091
33
+ berryworld-1.0.0.179097.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
34
+ berryworld-1.0.0.179097.dist-info/top_level.txt,sha256=GIZ5qy-P5oxfEH755vA1IMFeTVdX3-40JxMe6nOe5I8,17
35
+ berryworld-1.0.0.179097.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (73.0.1)
2
+ Generator: setuptools (74.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5