medicafe 0.250810.3__tar.gz → 0.250810.5__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.
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/MediBot.bat +0 -2
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/update_medicafe.py +149 -168
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediCafe/__main__.py +30 -37
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediCafe/core_utils.py +12 -8
- {medicafe-0.250810.3 → medicafe-0.250810.5}/PKG-INFO +1 -1
- {medicafe-0.250810.3 → medicafe-0.250810.5}/medicafe.egg-info/PKG-INFO +1 -1
- {medicafe-0.250810.3 → medicafe-0.250810.5}/setup.py +1 -1
- {medicafe-0.250810.3 → medicafe-0.250810.5}/LICENSE +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MANIFEST.in +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/MediBot.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/MediBot_Charges.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/MediBot_Crosswalk_Library.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/MediBot_Crosswalk_Utils.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/MediBot_Post.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/MediBot_Preprocessor.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/MediBot_Preprocessor_lib.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/MediBot_UI.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/MediBot_dataformat_library.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/MediBot_docx_decoder.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/MediBot_smart_import.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/__init__.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/get_medicafe_version.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediBot/update_json.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediCafe/MediLink_ConfigLoader.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediCafe/__init__.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediCafe/api_core.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediCafe/api_core_backup.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediCafe/api_factory.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediCafe/api_utils.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediCafe/graphql_utils.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediCafe/logging_config.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediCafe/logging_demo.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediCafe/migration_helpers.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediCafe/smart_import.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_837p_cob_library.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_837p_encoder.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_837p_encoder_library.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_837p_utilities.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_API_Generator.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_Azure.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_ClaimStatus.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_DataMgmt.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_Decoder.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_Deductible.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_Deductible_Validator.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_Display_Utils.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_Down.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_Gmail.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_Mailer.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_Parser.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_PatientProcessor.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_Scan.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_Scheduler.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_UI.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_Up.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_insurance_utils.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_main.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/MediLink_smart_import.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/Soumit_api.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/__init__.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/insurance_type_integration_test.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/openssl.cnf +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/test.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/test_cob_library.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/test_timing.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/test_validation.py +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/MediLink/webapp.html +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/medicafe.egg-info/SOURCES.txt +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/medicafe.egg-info/dependency_links.txt +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/medicafe.egg-info/entry_points.txt +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/medicafe.egg-info/not-zip-safe +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/medicafe.egg-info/requires.txt +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/medicafe.egg-info/top_level.txt +0 -0
- {medicafe-0.250810.3 → medicafe-0.250810.5}/setup.cfg +0 -0
@@ -84,6 +84,18 @@ def print_final_result(success, message):
|
|
84
84
|
|
85
85
|
def get_installed_version(package):
|
86
86
|
try:
|
87
|
+
# First try using pkg_resources directly (more reliable for Python 3.4)
|
88
|
+
if pkg_resources:
|
89
|
+
try:
|
90
|
+
version = pkg_resources.get_distribution(package).version
|
91
|
+
return version
|
92
|
+
except pkg_resources.DistributionNotFound:
|
93
|
+
return None
|
94
|
+
except Exception as e:
|
95
|
+
print("Warning: pkg_resources failed: {}".format(e))
|
96
|
+
# Fall through to pip method
|
97
|
+
|
98
|
+
# Fallback to pip show (may fail on Python 3.4 due to packaging issues)
|
87
99
|
process = subprocess.Popen(
|
88
100
|
[sys.executable, '-m', 'pip', 'show', package],
|
89
101
|
stdout=subprocess.PIPE,
|
@@ -114,30 +126,29 @@ def get_latest_version(package, retries=3, delay=1):
|
|
114
126
|
data = response.json()
|
115
127
|
latest_version = data['info']['version']
|
116
128
|
|
117
|
-
# Print the version with attempt information
|
118
|
-
if
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
print("Latest available version: {} ({} attempt)".format(latest_version, attempt))
|
129
|
+
# Print the version with attempt information
|
130
|
+
if attempt == 1:
|
131
|
+
print("Latest available version: {}".format(latest_version))
|
132
|
+
else:
|
133
|
+
print("Latest available version: {} ({} attempt)".format(latest_version, attempt))
|
123
134
|
|
124
135
|
# Check if the latest version is different from the current version
|
125
136
|
current_version = get_installed_version(package)
|
126
137
|
if current_version and compare_versions(latest_version, current_version) == 0:
|
127
|
-
# If the versions are the same, perform a second request
|
138
|
+
# If the versions are the same, perform a second request to ensure we have the latest
|
128
139
|
time.sleep(delay)
|
129
140
|
response = requests.get("https://pypi.org/pypi/{}/json".format(package), timeout=10)
|
130
141
|
response.raise_for_status()
|
131
142
|
data = response.json()
|
132
143
|
latest_version = data['info']['version']
|
144
|
+
print("Double-checked latest version: {}".format(latest_version))
|
133
145
|
|
134
146
|
return latest_version # Return the version after the check
|
135
147
|
except requests.RequestException as e:
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
time.sleep(delay)
|
148
|
+
print("Attempt {}: Error fetching latest version: {}".format(attempt, e))
|
149
|
+
if attempt < retries:
|
150
|
+
print("Retrying in {} seconds...".format(delay))
|
151
|
+
time.sleep(delay)
|
141
152
|
return None
|
142
153
|
|
143
154
|
def check_internet_connection():
|
@@ -159,8 +170,7 @@ def clear_python_cache(workspace_path=None):
|
|
159
170
|
bool: True if cache was cleared successfully, False otherwise
|
160
171
|
"""
|
161
172
|
try:
|
162
|
-
|
163
|
-
print_status("Clearing Python bytecode cache...", "INFO")
|
173
|
+
print_status("Clearing Python bytecode cache...", "INFO")
|
164
174
|
|
165
175
|
# If no workspace path provided, try to detect it
|
166
176
|
if not workspace_path:
|
@@ -181,12 +191,10 @@ def clear_python_cache(workspace_path=None):
|
|
181
191
|
break
|
182
192
|
|
183
193
|
if not workspace_path:
|
184
|
-
|
185
|
-
print_status("Could not detect workspace path. Cache clearing skipped.", "WARNING")
|
194
|
+
print_status("Could not detect workspace path. Cache clearing skipped.", "WARNING")
|
186
195
|
return False
|
187
196
|
|
188
|
-
|
189
|
-
print("Workspace path: {}".format(workspace_path))
|
197
|
+
print("Workspace path: {}".format(workspace_path))
|
190
198
|
|
191
199
|
# Directories to clear cache from
|
192
200
|
cache_dirs = [
|
@@ -204,12 +212,10 @@ def clear_python_cache(workspace_path=None):
|
|
204
212
|
if os.path.exists(pycache_path):
|
205
213
|
try:
|
206
214
|
shutil.rmtree(pycache_path)
|
207
|
-
|
208
|
-
print("Cleared cache: {}".format(pycache_path))
|
215
|
+
print("Cleared cache: {}".format(pycache_path))
|
209
216
|
cleared_count += 1
|
210
217
|
except Exception as e:
|
211
|
-
|
212
|
-
print("Warning: Could not clear cache at {}: {}".format(pycache_path, e))
|
218
|
+
print("Warning: Could not clear cache at {}: {}".format(pycache_path, e))
|
213
219
|
|
214
220
|
# Remove .pyc files
|
215
221
|
for root, dirs, files in os.walk(cache_dir):
|
@@ -217,25 +223,20 @@ def clear_python_cache(workspace_path=None):
|
|
217
223
|
if file.endswith('.pyc'):
|
218
224
|
try:
|
219
225
|
os.remove(os.path.join(root, file))
|
220
|
-
|
221
|
-
print("Removed .pyc file: {}".format(os.path.join(root, file)))
|
226
|
+
print("Removed .pyc file: {}".format(os.path.join(root, file)))
|
222
227
|
cleared_count += 1
|
223
228
|
except Exception as e:
|
224
|
-
|
225
|
-
print("Warning: Could not remove .pyc file {}: {}".format(file, e))
|
229
|
+
print("Warning: Could not remove .pyc file {}: {}".format(file, e))
|
226
230
|
|
227
231
|
if cleared_count > 0:
|
228
|
-
|
229
|
-
print_status("Successfully cleared {} cache items".format(cleared_count), "SUCCESS")
|
232
|
+
print_status("Successfully cleared {} cache items".format(cleared_count), "SUCCESS")
|
230
233
|
return True
|
231
234
|
else:
|
232
|
-
|
233
|
-
print_status("No cache files found to clear", "INFO")
|
235
|
+
print_status("No cache files found to clear", "INFO")
|
234
236
|
return True
|
235
237
|
|
236
238
|
except Exception as e:
|
237
|
-
|
238
|
-
print_status("Error clearing cache: {}".format(e), "ERROR")
|
239
|
+
print_status("Error clearing cache: {}".format(e), "ERROR")
|
239
240
|
return False
|
240
241
|
|
241
242
|
def compare_versions(version1, version2):
|
@@ -252,22 +253,20 @@ def upgrade_package(package, retries=3, delay=2): # Updated retries to 3
|
|
252
253
|
print_final_result(False, "No internet connection available")
|
253
254
|
|
254
255
|
for attempt in range(1, retries + 1):
|
255
|
-
|
256
|
-
print("Attempt {} to upgrade {}...".format(attempt, package))
|
257
|
-
process = subprocess.Popen(
|
258
|
-
[
|
259
|
-
sys.executable, '-m', 'pip', 'install', '--upgrade',
|
260
|
-
package, '--no-cache-dir', '--disable-pip-version-check', '-q'
|
261
|
-
],
|
262
|
-
stdout=subprocess.PIPE,
|
263
|
-
stderr=subprocess.PIPE
|
264
|
-
)
|
256
|
+
print("Attempt {} to upgrade {}...".format(attempt, package))
|
265
257
|
|
258
|
+
# Use a more compatible approach for Python 3.4
|
259
|
+
# Try with --no-deps first to avoid dependency resolution issues
|
260
|
+
cmd = [
|
261
|
+
sys.executable, '-m', 'pip', 'install', '--upgrade',
|
262
|
+
'--no-deps', '--no-cache-dir', '--disable-pip-version-check', '-q', package
|
263
|
+
]
|
264
|
+
|
265
|
+
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
266
266
|
stdout, stderr = process.communicate()
|
267
267
|
|
268
268
|
if process.returncode == 0:
|
269
|
-
|
270
|
-
print(stdout.decode().strip())
|
269
|
+
print(stdout.decode().strip())
|
271
270
|
new_version = get_installed_version(package) # Get new version after upgrade
|
272
271
|
if compare_versions(new_version, get_latest_version(package)) >= 0: # Compare versions
|
273
272
|
if attempt == 1:
|
@@ -279,17 +278,39 @@ def upgrade_package(package, retries=3, delay=2): # Updated retries to 3
|
|
279
278
|
else:
|
280
279
|
print_status("Upgrade failed. Current version remains: {}".format(new_version), "WARNING")
|
281
280
|
if attempt < retries:
|
282
|
-
|
283
|
-
print("Retrying in {} seconds...".format(delay))
|
281
|
+
print("Retrying in {} seconds...".format(delay))
|
284
282
|
time.sleep(delay)
|
285
283
|
else:
|
286
|
-
|
287
|
-
|
288
|
-
|
284
|
+
print(stderr.decode().strip())
|
285
|
+
print_status("Attempt {}: Upgrade failed with --no-deps.".format(attempt), "WARNING")
|
286
|
+
|
287
|
+
# If --no-deps failed, try with --force-reinstall to bypass dependency issues
|
289
288
|
if attempt < retries:
|
290
|
-
|
289
|
+
print("Retrying with --force-reinstall...")
|
290
|
+
cmd = [
|
291
|
+
sys.executable, '-m', 'pip', 'install', '--upgrade',
|
292
|
+
'--force-reinstall', '--no-cache-dir', '--disable-pip-version-check', '-q', package
|
293
|
+
]
|
294
|
+
|
295
|
+
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
296
|
+
stdout, stderr = process.communicate()
|
297
|
+
|
298
|
+
if process.returncode == 0:
|
299
|
+
print(stdout.decode().strip())
|
300
|
+
new_version = get_installed_version(package)
|
301
|
+
if compare_versions(new_version, get_latest_version(package)) >= 0:
|
302
|
+
print_status("Attempt {}: Upgrade succeeded with --force-reinstall!".format(attempt), "SUCCESS")
|
303
|
+
time.sleep(delay)
|
304
|
+
return True
|
305
|
+
else:
|
306
|
+
print_status("Upgrade failed. Current version remains: {}".format(new_version), "WARNING")
|
307
|
+
else:
|
308
|
+
print(stderr.decode().strip())
|
309
|
+
print_status("Attempt {}: Upgrade failed with --force-reinstall.".format(attempt), "WARNING")
|
310
|
+
|
311
|
+
if attempt < retries:
|
291
312
|
print("Retrying in {} seconds...".format(delay))
|
292
|
-
|
313
|
+
time.sleep(delay)
|
293
314
|
|
294
315
|
print_status("All upgrade attempts failed.", "ERROR")
|
295
316
|
return False
|
@@ -402,170 +423,130 @@ def main():
|
|
402
423
|
# Enable debug mode if requested via CLI or environment
|
403
424
|
DEBUG_MODE = ('--debug' in sys.argv) or (os.environ.get('MEDICAFE_DEBUG', '0') in ['1', 'true', 'TRUE'])
|
404
425
|
|
405
|
-
|
406
|
-
print("
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
print("Python Executable: {}".format(sys.executable))
|
421
|
-
print()
|
422
|
-
|
423
|
-
# STEP 2: Check Python and pip (always verify)
|
424
|
-
print("STEP 2: Python Environment")
|
425
|
-
print("-" * 40)
|
426
|
+
print_status("MediCafe Update Utility", "INFO")
|
427
|
+
print("Starting update process...")
|
428
|
+
|
429
|
+
# STEP 1: Environment Information
|
430
|
+
debug_step(1, "Environment Information",
|
431
|
+
"Python version: {}\n"
|
432
|
+
"Platform: {}\n"
|
433
|
+
"Current working directory: {}\n"
|
434
|
+
"Script location: {}\n"
|
435
|
+
"sys.executable: {}".format(
|
436
|
+
sys.version, platform.platform(), os.getcwd(),
|
437
|
+
__file__, sys.executable))
|
438
|
+
|
439
|
+
# STEP 2: Check Python and pip
|
440
|
+
debug_step(2, "Python and pip Verification")
|
426
441
|
print("Checking Python installation...")
|
427
442
|
try:
|
428
|
-
process = subprocess.Popen([sys.executable, '--version'],
|
443
|
+
process = subprocess.Popen([sys.executable, '--version'],
|
429
444
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
430
445
|
stdout, stderr = process.communicate()
|
431
446
|
if process.returncode == 0:
|
432
|
-
print("Python: {}".format(stdout.decode().strip()))
|
447
|
+
print("Python version: {}".format(stdout.decode().strip()))
|
433
448
|
else:
|
434
|
-
print("Python:
|
435
|
-
print_final_result(False, "Python installation check failed")
|
449
|
+
print("Error checking Python: {}".format(stderr.decode().strip()))
|
436
450
|
except Exception as e:
|
437
|
-
print("Python:
|
438
|
-
|
439
|
-
|
440
|
-
print("Checking pip installation...")
|
451
|
+
print("Error checking Python: {}".format(e))
|
452
|
+
|
453
|
+
print("\nChecking pip installation...")
|
441
454
|
try:
|
442
|
-
process = subprocess.Popen([sys.executable, '-m', 'pip', '--version'],
|
455
|
+
process = subprocess.Popen([sys.executable, '-m', 'pip', '--version'],
|
443
456
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
444
457
|
stdout, stderr = process.communicate()
|
445
458
|
if process.returncode == 0:
|
446
|
-
print("pip: {}".format(stdout.decode().strip()))
|
459
|
+
print("pip version: {}".format(stdout.decode().strip()))
|
447
460
|
else:
|
448
|
-
print("pip:
|
449
|
-
print_final_result(False, "pip installation check failed")
|
461
|
+
print("Error checking pip: {}".format(stderr.decode().strip()))
|
450
462
|
except Exception as e:
|
451
|
-
print("pip:
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
# STEP 3: Check MediCafe package (always check)
|
456
|
-
print("STEP 3: MediCafe Package")
|
457
|
-
print("-" * 40)
|
463
|
+
print("Error checking pip: {}".format(e))
|
464
|
+
|
465
|
+
# STEP 3: Check MediCafe package
|
466
|
+
debug_step(3, "MediCafe Package Check")
|
458
467
|
package = "medicafe"
|
459
468
|
current_version = get_installed_version(package)
|
460
469
|
if current_version:
|
461
|
-
print("Current
|
470
|
+
print("Current MediCafe version: {}".format(current_version))
|
462
471
|
else:
|
463
|
-
print("MediCafe
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
if current_version:
|
468
|
-
print("MediCafe installed successfully: {}".format(current_version))
|
469
|
-
else:
|
470
|
-
print_final_result(False, "Failed to install MediCafe")
|
471
|
-
else:
|
472
|
-
print_final_result(False, "Failed to install MediCafe")
|
473
|
-
print()
|
474
|
-
|
475
|
-
# STEP 4: Internet connectivity (always check)
|
476
|
-
print("STEP 4: Internet Connection")
|
477
|
-
print("-" * 40)
|
478
|
-
print("Testing internet connectivity...")
|
472
|
+
print("MediCafe package not found or not accessible")
|
473
|
+
|
474
|
+
# STEP 4: Internet connectivity
|
475
|
+
debug_step(4, "Internet Connectivity Test")
|
479
476
|
if check_internet_connection():
|
480
|
-
print("Internet:
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
print("PyPI: ERROR - {}".format(e))
|
477
|
+
print("Internet connection: OK")
|
478
|
+
print("Testing PyPI connectivity...")
|
479
|
+
try:
|
480
|
+
response = requests.get("https://pypi.org/pypi/medicafe/json", timeout=10)
|
481
|
+
print("PyPI connectivity: OK (Status: {})".format(response.status_code))
|
482
|
+
except Exception as e:
|
483
|
+
print("PyPI connectivity: FAILED - {}".format(e))
|
488
484
|
else:
|
489
|
-
print("Internet:
|
485
|
+
print("Internet connection: FAILED")
|
490
486
|
print_final_result(False, "No internet connection available")
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
print("STEP 5: Version Check")
|
495
|
-
print("-" * 40)
|
487
|
+
|
488
|
+
# STEP 5: Check for updates
|
489
|
+
debug_step(5, "Version Comparison")
|
496
490
|
latest_version = get_latest_version(package)
|
497
491
|
if latest_version:
|
498
|
-
print("Latest
|
492
|
+
print("Latest available version: {}".format(latest_version))
|
499
493
|
if current_version:
|
500
494
|
comparison = compare_versions(latest_version, current_version)
|
501
495
|
if comparison > 0:
|
502
|
-
print("
|
503
|
-
print("Current: {} -> Latest: {}".format(current_version, latest_version))
|
496
|
+
print("Update needed: Current ({}) < Latest ({})".format(current_version, latest_version))
|
504
497
|
elif comparison == 0:
|
505
|
-
print("
|
506
|
-
print("Current: {} = Latest: {}".format(current_version, latest_version))
|
498
|
+
print("Already up to date: Current ({}) = Latest ({})".format(current_version, latest_version))
|
507
499
|
else:
|
508
|
-
print("
|
509
|
-
print("Current: {} > Latest: {}".format(current_version, latest_version))
|
500
|
+
print("Version mismatch: Current ({}) > Latest ({})".format(current_version, latest_version))
|
510
501
|
else:
|
511
|
-
print("
|
512
|
-
print("Current version not available")
|
502
|
+
print("Cannot compare versions - current version not available")
|
513
503
|
else:
|
514
|
-
print("
|
515
|
-
print("Could not retrieve latest version")
|
504
|
+
print("Could not retrieve latest version information")
|
516
505
|
print_final_result(False, "Unable to fetch latest version")
|
517
|
-
|
518
|
-
|
519
|
-
|
506
|
+
|
507
|
+
# STEP 6: Dependencies check (skipped by default in streamlined mode)
|
508
|
+
debug_step(6, "Dependencies Check")
|
520
509
|
if DEBUG_MODE:
|
521
|
-
|
522
|
-
print("-" * 40)
|
523
|
-
response = input("Check dependencies? (y/n, default=n): ").strip().lower()
|
510
|
+
response = input("Do you want to check dependencies? (yes/no, default/enter is no): ").strip().lower()
|
524
511
|
if response in ['yes', 'y']:
|
525
512
|
ensure_dependencies()
|
526
513
|
else:
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
514
|
+
print_status("Skipping dependency check.", "INFO")
|
515
|
+
else:
|
516
|
+
print_status("Skipping dependency check (streamlined mode).", "INFO")
|
517
|
+
|
518
|
+
# STEP 7: Perform update
|
519
|
+
debug_step(7, "Update Execution")
|
533
520
|
if current_version and latest_version and compare_versions(latest_version, current_version) > 0:
|
534
|
-
|
535
|
-
print("
|
536
|
-
print()
|
537
|
-
|
521
|
+
print_status("A newer version is available. Proceeding with upgrade.", "INFO")
|
522
|
+
print("Current version: {}".format(current_version))
|
523
|
+
print("Target version: {}".format(latest_version))
|
524
|
+
|
538
525
|
if upgrade_package(package):
|
539
526
|
# STEP 8: Verify upgrade
|
540
|
-
|
541
|
-
print("-" * 40)
|
527
|
+
debug_step(8, "Upgrade Verification")
|
542
528
|
new_version = get_installed_version(package)
|
543
|
-
print("New
|
544
|
-
|
529
|
+
print("New installed version: {}".format(new_version))
|
530
|
+
|
545
531
|
if compare_versions(new_version, latest_version) >= 0:
|
546
|
-
|
547
|
-
|
548
|
-
# STEP 9: Clear cache
|
549
|
-
|
550
|
-
|
551
|
-
print("Clearing Python cache...")
|
532
|
+
print_status("Upgrade successful. New version: {}".format(new_version), "SUCCESS")
|
533
|
+
|
534
|
+
# DEBUG STEP 9: Clear cache
|
535
|
+
debug_step(9, "Cache Clearing")
|
536
|
+
print_status("Clearing Python cache to prevent import issues...", "INFO")
|
552
537
|
if clear_python_cache():
|
553
|
-
|
538
|
+
print_status("Cache cleared successfully. Update complete.", "SUCCESS")
|
554
539
|
else:
|
555
|
-
|
556
|
-
|
540
|
+
print_status("Cache clearing failed, but update was successful.", "WARNING")
|
541
|
+
|
557
542
|
print_final_result(True, "Successfully upgraded to version {}".format(new_version))
|
558
543
|
else:
|
559
|
-
|
560
|
-
print("Version verification failed")
|
544
|
+
print_status("Upgrade failed. Current version remains: {}".format(new_version), "ERROR")
|
561
545
|
print_final_result(False, "Upgrade verification failed")
|
562
546
|
else:
|
563
|
-
print("Status: FAILED")
|
564
|
-
print("Update process failed")
|
565
547
|
print_final_result(False, "Upgrade process failed")
|
566
548
|
else:
|
567
|
-
|
568
|
-
print("MediCafe is already up to date.")
|
549
|
+
print_status("You already have the latest version installed.", "SUCCESS")
|
569
550
|
print_final_result(True, "Already running latest version")
|
570
551
|
|
571
552
|
if __name__ == "__main__":
|
@@ -38,50 +38,43 @@ def setup_entry_point_paths():
|
|
38
38
|
if workspace_str not in sys.path:
|
39
39
|
sys.path.insert(0, workspace_str)
|
40
40
|
|
41
|
-
#
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
sys.path.insert(0, medibot_dir)
|
47
|
-
if medilink_dir not in sys.path:
|
48
|
-
sys.path.insert(0, medilink_dir)
|
41
|
+
# Ensure we do NOT add package directories directly; only project root should be on sys.path
|
42
|
+
# Clean any existing direct package paths that could break package imports (e.g., 'MediLink' is not a package)
|
43
|
+
for pkg_dir in (os.path.join(workspace_root, 'MediBot'), os.path.join(workspace_root, 'MediLink')):
|
44
|
+
while pkg_dir in sys.path:
|
45
|
+
sys.path.remove(pkg_dir)
|
49
46
|
|
50
47
|
def run_medibot(config_file=None):
|
51
48
|
"""Run MediBot application"""
|
52
49
|
try:
|
53
50
|
print("Starting MediBot...")
|
54
|
-
|
55
|
-
#
|
51
|
+
|
52
|
+
# Resolve workspace root and MediBot.py path
|
53
|
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
54
|
+
workspace_root = os.path.dirname(current_dir)
|
55
|
+
medibot_path = os.path.join(workspace_root, 'MediBot', 'MediBot.py')
|
56
|
+
|
57
|
+
if not os.path.exists(medibot_path):
|
58
|
+
print("Error: MediBot.py not found at {}".format(medibot_path))
|
59
|
+
return 1
|
60
|
+
|
61
|
+
# Build subprocess arguments
|
62
|
+
args = [sys.executable, medibot_path]
|
56
63
|
if config_file:
|
57
|
-
|
64
|
+
args.append(config_file)
|
65
|
+
|
66
|
+
# Ensure subprocess can import project packages
|
67
|
+
env = os.environ.copy()
|
68
|
+
python_path = workspace_root
|
69
|
+
if 'PYTHONPATH' in env:
|
70
|
+
env['PYTHONPATH'] = python_path + os.pathsep + env['PYTHONPATH']
|
58
71
|
else:
|
59
|
-
|
60
|
-
|
61
|
-
#
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
if hasattr(MediBot, 'main'):
|
66
|
-
return MediBot.main()
|
67
|
-
else:
|
68
|
-
# Otherwise, just import it (it will run its own code)
|
69
|
-
return 0
|
70
|
-
except ImportError:
|
71
|
-
# Fallback: try to run the file directly
|
72
|
-
import subprocess
|
73
|
-
medibot_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'MediBot', 'MediBot.py')
|
74
|
-
if os.path.exists(medibot_path):
|
75
|
-
# Use subprocess.call for Python 3.4.4 compatibility
|
76
|
-
result = subprocess.call([sys.executable, medibot_path] + sys.argv[1:],
|
77
|
-
cwd=os.path.dirname(medibot_path))
|
78
|
-
return result
|
79
|
-
else:
|
80
|
-
raise ImportError("MediBot.py not found at {}".format(medibot_path))
|
81
|
-
|
82
|
-
except ImportError as e:
|
83
|
-
print("Error: Unable to import MediBot: {}".format(e))
|
84
|
-
return 1
|
72
|
+
env['PYTHONPATH'] = python_path
|
73
|
+
|
74
|
+
# Run MediBot as a script so its __main__ block executes
|
75
|
+
result = subprocess.call(args, cwd=os.path.dirname(medibot_path), env=env)
|
76
|
+
return result
|
77
|
+
|
85
78
|
except Exception as e:
|
86
79
|
print("Error running MediBot: {}".format(e))
|
87
80
|
return 1
|
@@ -10,16 +10,20 @@ import os, sys
|
|
10
10
|
# Ensure proper path setup for imports
|
11
11
|
# Get the project root directory (parent of MediCafe directory)
|
12
12
|
project_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
13
|
-
medilink_dir = os.path.join(project_dir, 'MediLink')
|
14
|
-
medibot_dir = os.path.join(project_dir, 'MediBot')
|
15
13
|
|
16
|
-
#
|
14
|
+
# Only add project root to sys.path; do NOT add package directories directly
|
17
15
|
if project_dir not in sys.path:
|
18
16
|
sys.path.insert(0, project_dir)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
|
18
|
+
# Remove any direct package paths that may have been injected elsewhere
|
19
|
+
_pkg_dirs = [os.path.join(project_dir, 'MediLink'), os.path.join(project_dir, 'MediBot')]
|
20
|
+
for _p in list(sys.path):
|
21
|
+
if _p in _pkg_dirs:
|
22
|
+
try:
|
23
|
+
while _p in sys.path:
|
24
|
+
sys.path.remove(_p)
|
25
|
+
except Exception:
|
26
|
+
pass
|
23
27
|
|
24
28
|
# Common constants and configurations
|
25
29
|
DEFAULT_CONFIG_PATH = os.path.join(project_dir, 'json', 'config.json')
|
@@ -62,7 +66,7 @@ def setup_module_paths(file_path):
|
|
62
66
|
project_dir = os.path.abspath(os.path.join(os.path.dirname(file_path), ".."))
|
63
67
|
current_dir = os.path.abspath(os.path.dirname(file_path))
|
64
68
|
|
65
|
-
# Add
|
69
|
+
# Add only project root and current module dir; avoid adding package dirs explicitly
|
66
70
|
if project_dir not in sys.path:
|
67
71
|
sys.path.insert(0, project_dir)
|
68
72
|
if current_dir not in sys.path:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|