medicafe 0.250909.0__py3-none-any.whl → 0.250912.0__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.
MediBot/__init__.py CHANGED
@@ -19,7 +19,7 @@ Smart Import Integration:
19
19
  medibot_main = get_components('medibot_main')
20
20
  """
21
21
 
22
- __version__ = "0.250909.0"
22
+ __version__ = "0.250912.0"
23
23
  __author__ = "Daniel Vidaud"
24
24
  __email__ = "daniel@personalizedtransformation.com"
25
25
 
MediCafe/__init__.py CHANGED
@@ -27,7 +27,7 @@ Smart Import System:
27
27
  api_suite = get_api_access()
28
28
  """
29
29
 
30
- __version__ = "0.250909.0"
30
+ __version__ = "0.250912.0"
31
31
  __author__ = "Daniel Vidaud"
32
32
  __email__ = "daniel@personalizedtransformation.com"
33
33
 
@@ -185,10 +185,30 @@ class RequestHandler(BaseHTTPRequestHandler):
185
185
  file_ids = [link.get('fileId', None) for link in links if link.get('fileId')]
186
186
  log("File IDs received from client: {}".format(file_ids))
187
187
  download_docx_files(links)
188
+ # Only delete files that actually downloaded successfully
189
+ downloaded_names = load_downloaded_emails()
190
+ successful_ids = []
191
+ try:
192
+ name_to_id = { (link.get('filename') or ''): link.get('fileId') for link in links if link.get('fileId') }
193
+ for name in downloaded_names:
194
+ fid = name_to_id.get(name)
195
+ if fid:
196
+ successful_ids.append(fid)
197
+ except Exception as e:
198
+ log("Error computing successful file IDs for cleanup: {}".format(e))
199
+ successful_ids = file_ids # Fallback: attempt all provided IDs
200
+ # Trigger cleanup in Apps Script with auth
201
+ try:
202
+ if successful_ids:
203
+ send_delete_request_to_gas(successful_ids)
204
+ else:
205
+ log("No successful file IDs to delete after download.")
206
+ except Exception as e:
207
+ log("Cleanup trigger failed: {}".format(e))
188
208
  self.send_response(200)
189
209
  self._set_headers()
190
210
  self.end_headers()
191
- response = json.dumps({"status": "success", "message": "All files downloaded", "fileIds": file_ids})
211
+ response = json.dumps({"status": "success", "message": "All files downloaded", "fileIds": successful_ids})
192
212
  self.wfile.write(response.encode('utf-8'))
193
213
  shutdown_event.set()
194
214
  bring_window_to_foreground()
@@ -437,6 +457,38 @@ def handle_post_response(url, payload, headers):
437
457
  log("Unexpected error during link retrieval initiation: {}".format(e))
438
458
  shutdown_event.set()
439
459
 
460
+ def send_delete_request_to_gas(file_ids):
461
+ """Send a delete_files action to the Apps Script web app for the provided Drive file IDs.
462
+ Relies on OAuth token previously obtained. Sends user notifications via GAS.
463
+ """
464
+ try:
465
+ medi = extract_medilink_config(config)
466
+ url = "https://script.google.com/macros/s/{}/exec".format(medi.get('webapp_deployment_id', ''))
467
+ access_token = get_access_token()
468
+ if not access_token:
469
+ log("Access token not found. Skipping cleanup request to GAS.")
470
+ return
471
+ headers = {'Authorization': 'Bearer {}'.format(access_token), 'Content-Type': 'application/json'}
472
+ payload = {"action": "delete_files", "fileIds": list(file_ids)}
473
+ log("Initiating cleanup request to GAS. Payload size: {} id(s)".format(len(file_ids)))
474
+ resp = requests.post(url, json=payload, headers=headers)
475
+ log("Cleanup response status: {}".format(resp.status_code))
476
+ # Print a concise console message
477
+ if resp.ok:
478
+ try:
479
+ body = resp.json()
480
+ msg = body.get('message', 'Files deleted successfully') if isinstance(body, dict) else 'Files deleted successfully'
481
+ except Exception:
482
+ msg = 'Files deleted successfully'
483
+ print("Cleanup complete: {} ({} file(s))".format(msg, len(file_ids)))
484
+ else:
485
+ print("Cleanup failed with status {}: {}".format(resp.status_code, resp.text))
486
+ if resp.status_code != 200:
487
+ raise RuntimeError("Cleanup request failed with status {}".format(resp.status_code))
488
+ except Exception as e:
489
+ log("Error sending delete request to GAS: {}".format(e))
490
+ print("Cleanup request error: {}".format(e))
491
+
440
492
  def inspect_token(access_token):
441
493
  return http_inspect_token(access_token, log, delete_token_file_fn=delete_token_file, stop_server_fn=stop_server)
442
494
 
MediLink/__init__.py CHANGED
@@ -22,7 +22,7 @@ Smart Import Integration:
22
22
  datamgmt = get_components('medilink_datamgmt')
23
23
  """
24
24
 
25
- __version__ = "0.250909.0"
25
+ __version__ = "0.250912.0"
26
26
  __author__ = "Daniel Vidaud"
27
27
  __email__ = "daniel@personalizedtransformation.com"
28
28
 
MediLink/webapp.html CHANGED
@@ -402,6 +402,7 @@
402
402
  links: downloadLinks.map(link => ({
403
403
  url: link.url,
404
404
  filename: link.filename,
405
+ fileId: link.fileId,
405
406
  }))
406
407
  }),
407
408
  mode: 'cors' // Ensure the request includes CORS headers
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: medicafe
3
- Version: 0.250909.0
3
+ Version: 0.250912.0
4
4
  Summary: MediCafe
5
5
  Home-page: https://github.com/katanada2/MediCafe
6
6
  Author: Daniel Vidaud
@@ -12,7 +12,7 @@ MediBot/MediBot_dataformat_library.py,sha256=D46fdPtxcgfWTzaLBtSvjtozzZBNqNiODgu
12
12
  MediBot/MediBot_debug.bat,sha256=F5Lfi3nFEEo4Ddx9EbX94u3fNAMgzMp3wsn-ULyASTM,6017
13
13
  MediBot/MediBot_docx_decoder.py,sha256=9BSjV-kB90VHnqfL_5iX4zl5u0HcHvHuL7YNfx3gXpQ,33143
14
14
  MediBot/MediBot_smart_import.py,sha256=Emvz7NwemHGCHvG5kZcUyXMcCheidbGKaPfOTg-YCEs,6684
15
- MediBot/__init__.py,sha256=S5Y80QAjAxFKJn6Uz9KNzNHXEHjCU0boj0joB8JcPlc,3192
15
+ MediBot/__init__.py,sha256=qQFD1nDqRTlonmhV8IKcQ_g4jX8uq-324WBnu6VPHkY,3192
16
16
  MediBot/clear_cache.bat,sha256=F6-VhETWw6xDdGWG2wUqvtXjCl3lY4sSUFqF90bM8-8,1860
17
17
  MediBot/crash_diagnostic.bat,sha256=j8kUtyBg6NOWbXpeFuEqIRHOkVzgUrLOqO3FBMfNxTo,9268
18
18
  MediBot/f_drive_diagnostic.bat,sha256=4572hZaiwZ5wVAarPcZJQxkOSTwAdDuT_X914noARak,6878
@@ -22,7 +22,7 @@ MediBot/process_csvs.bat,sha256=3tI7h1z9eRj8rUUL4wJ7dy-Qrak20lRmpAPtGbUMbVQ,3489
22
22
  MediBot/update_json.py,sha256=vvUF4mKCuaVly8MmoadDO59M231fCIInc0KI1EtDtPA,3704
23
23
  MediBot/update_medicafe.py,sha256=G1lyvVOHYuho1d-TJQNN6qaB4HBWaJ2PpXqemBoPlRQ,17937
24
24
  MediCafe/MediLink_ConfigLoader.py,sha256=zzI3cFe2_TdwgIW_UAVmY_LFFlLLdlmpCokouUqx6u0,10898
25
- MediCafe/__init__.py,sha256=U8Vg_cQIvjHI-ynz8513QPOIAUsTvWRlj0aYnbvSAWQ,5721
25
+ MediCafe/__init__.py,sha256=Mf3CjRb0clmeUsP85rpH75M-1q6ihAxK_d4LkIKXXo8,5721
26
26
  MediCafe/__main__.py,sha256=mRNyk3D9Ilnu2XhgVI_rut7r5Ro7UIKtwV871giAHI8,12992
27
27
  MediCafe/api_core.py,sha256=yNFfLO70bF91NNBLSUADYWZFkR5yh8NctxnT98fkAxk,78515
28
28
  MediCafe/api_factory.py,sha256=I5AeJoyu6m7oCrjc2OvVvO_4KSBRutTsR1riiWhTZV0,12086
@@ -50,7 +50,7 @@ MediLink/MediLink_Deductible.py,sha256=e_Oi5c55g4fTcPf-2hLnIRJ_Q_pBAyyXnTKiciQUL
50
50
  MediLink/MediLink_Deductible_Validator.py,sha256=1h5GJ9jbcVarxd6a-lKPEOhJYz4QkeeBlHw0Zdd9vUU,24855
51
51
  MediLink/MediLink_Display_Utils.py,sha256=a0t1VU9Mm_vhsXVTEA1EpUlElrnyie4XaCeif7GwRgw,21213
52
52
  MediLink/MediLink_Down.py,sha256=s4_z-RaqHYanjwbQCl-OSkg4XIpcIQ2Q6jXa8-q_QXw,28111
53
- MediLink/MediLink_Gmail.py,sha256=8iQjqcJMSa_Zfr5azR0dShKAQeXqt-9C-s8seYB9pic,23961
53
+ MediLink/MediLink_Gmail.py,sha256=muqZI3girXDu92KT5Nft7dLHtpnQAjH-QfvdcGo28_Y,26801
54
54
  MediLink/MediLink_Mailer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
55
  MediLink/MediLink_Parser.py,sha256=eRVZ4ckZ5gDOrcvtCUZP3DOd3Djly66rCIk0aYXLz14,12567
56
56
  MediLink/MediLink_PatientProcessor.py,sha256=9r2w4p45d30Tn0kbXL3j5574MYOehP83tDirNOw_Aek,19977
@@ -62,15 +62,15 @@ MediLink/MediLink_insurance_utils.py,sha256=g741Fj2K26cMy0JX5d_XavMw9LgkK6hjaUJY
62
62
  MediLink/MediLink_main.py,sha256=ZVK2UsgSxC9UqgIYfgVu95ugULcH6-11l67jsf4vdJc,22132
63
63
  MediLink/MediLink_smart_import.py,sha256=B5SfBn_4bYEWJJDolXbjnwKx_-MaqGZ76LyXQwWDV80,9838
64
64
  MediLink/Soumit_api.py,sha256=5JfOecK98ZC6NpZklZW2AkOzkjvrbYxpJpZNH3rFxDw,497
65
- MediLink/__init__.py,sha256=Lr3cT-xyO8eyyoxqaKxcjR2CHxNL340JEdIHe_l1rd4,3888
65
+ MediLink/__init__.py,sha256=s8VBEZWSbjoUjImTCaf1eehxniFqXzuxPuI1Liy7sqA,3888
66
66
  MediLink/gmail_http_utils.py,sha256=gtqCCrzJC7e8JFQzMNrf7EbK8na2h4sfTu-NMaZ_UHc,4006
67
67
  MediLink/gmail_oauth_utils.py,sha256=Ugr-DEqs4_RddRMSCJ_dbgA3TVeaxpbAor-dktcTIgY,3713
68
68
  MediLink/openssl.cnf,sha256=76VdcGCykf0Typyiv8Wd1mMVKixrQ5RraG6HnfKFqTo,887
69
69
  MediLink/test.py,sha256=DM_E8gEbhbVfTAm3wTMiNnK2GCD1e5eH6gwTk89QIc4,3116
70
- MediLink/webapp.html,sha256=JPKT559aFVBi1r42Hz7C77Jj0teZZRumPhBev8eSOLk,19806
71
- medicafe-0.250909.0.dist-info/LICENSE,sha256=65lb-vVujdQK7uMH3RRJSMwUW-WMrMEsc5sOaUn2xUk,1096
72
- medicafe-0.250909.0.dist-info/METADATA,sha256=cWgYebKSTCUb2V3c-2TnjmCtUiG0lX8KxVY8g6OlY1g,3414
73
- medicafe-0.250909.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
74
- medicafe-0.250909.0.dist-info/entry_points.txt,sha256=m3RBUBjr-xRwEkKJ5W4a7NlqHZP_1rllGtjZnrRqKe8,52
75
- medicafe-0.250909.0.dist-info/top_level.txt,sha256=U6-WBJ9RCEjyIs0BlzbQq_PwedCp_IV9n1616NNV5zA,26
76
- medicafe-0.250909.0.dist-info/RECORD,,
70
+ MediLink/webapp.html,sha256=MI9zZ4y1_h5Ji3nz2fmm6Q29AsPunks-wR-R8Ct73-w,19856
71
+ medicafe-0.250912.0.dist-info/LICENSE,sha256=65lb-vVujdQK7uMH3RRJSMwUW-WMrMEsc5sOaUn2xUk,1096
72
+ medicafe-0.250912.0.dist-info/METADATA,sha256=EUFHElKptRUnDI5Lm1SlonbI_wQZwNmLG0tfHpgjkEM,3414
73
+ medicafe-0.250912.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
74
+ medicafe-0.250912.0.dist-info/entry_points.txt,sha256=m3RBUBjr-xRwEkKJ5W4a7NlqHZP_1rllGtjZnrRqKe8,52
75
+ medicafe-0.250912.0.dist-info/top_level.txt,sha256=U6-WBJ9RCEjyIs0BlzbQq_PwedCp_IV9n1616NNV5zA,26
76
+ medicafe-0.250912.0.dist-info/RECORD,,