pycoze 0.1.187__py3-none-any.whl → 0.1.189__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- pycoze/automation/__init__.py +0 -0
- pycoze/automation/browser/__init__.py +0 -0
- pycoze/automation/browser/edge_driver_manager.py +77 -0
- {pycoze-0.1.187.dist-info → pycoze-0.1.189.dist-info}/METADATA +1 -1
- {pycoze-0.1.187.dist-info → pycoze-0.1.189.dist-info}/RECORD +8 -5
- {pycoze-0.1.187.dist-info → pycoze-0.1.189.dist-info}/LICENSE +0 -0
- {pycoze-0.1.187.dist-info → pycoze-0.1.189.dist-info}/WHEEL +0 -0
- {pycoze-0.1.187.dist-info → pycoze-0.1.189.dist-info}/top_level.txt +0 -0
File without changes
|
File without changes
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import os
|
2
|
+
import requests
|
3
|
+
from selenium.webdriver.edge.service import Service
|
4
|
+
from webdriver_manager.microsoft import EdgeChromiumDriverManager
|
5
|
+
from selenium import webdriver
|
6
|
+
|
7
|
+
|
8
|
+
# Function to check network availability
|
9
|
+
def is_network_available():
|
10
|
+
try:
|
11
|
+
# Attempt to access the download URL for Edge Chromium driver to check network connection
|
12
|
+
response = requests.get("https://msedgedriver.azureedge.net/", timeout=5)
|
13
|
+
return response.status_code == 200
|
14
|
+
except requests.ConnectionError:
|
15
|
+
return False
|
16
|
+
|
17
|
+
|
18
|
+
# Function to get the default download path for Edge Chromium driver
|
19
|
+
def get_default_driver_path():
|
20
|
+
manager = EdgeChromiumDriverManager()
|
21
|
+
return manager.install()
|
22
|
+
|
23
|
+
|
24
|
+
# Function to get the driver version from cache
|
25
|
+
def get_cached_driver_version(manager):
|
26
|
+
cache_dir = manager._cache_manager._root_dir # Get the root path of the cache directory
|
27
|
+
os_type = manager._os_system_manager.get_os_type() # Get the OS type
|
28
|
+
driver_name = manager.driver.get_name()
|
29
|
+
|
30
|
+
# List all versions in the cache directory
|
31
|
+
versions_dir = os.path.join(cache_dir, "drivers", driver_name, os_type)
|
32
|
+
if os.path.exists(versions_dir):
|
33
|
+
versions = os.listdir(versions_dir)
|
34
|
+
if versions:
|
35
|
+
# Return the latest version found in the cache
|
36
|
+
return max(versions)
|
37
|
+
return None
|
38
|
+
|
39
|
+
|
40
|
+
# Function to check if the driver has already been downloaded
|
41
|
+
def get_driver_path():
|
42
|
+
network_available = is_network_available()
|
43
|
+
print("Network status:", "Available" if network_available else "Unavailable")
|
44
|
+
manager = EdgeChromiumDriverManager()
|
45
|
+
if network_available:
|
46
|
+
return get_default_driver_path()
|
47
|
+
else:
|
48
|
+
# If no network, check the cache directory
|
49
|
+
driver_version = get_cached_driver_version(manager)
|
50
|
+
if driver_version:
|
51
|
+
driver_name = manager.driver.get_name()
|
52
|
+
os_type = manager._os_system_manager.get_os_type()
|
53
|
+
cache_dir = manager._cache_manager._root_dir
|
54
|
+
|
55
|
+
# Determine the correct driver filename based on the OS
|
56
|
+
if os.name == 'nt': # Windows
|
57
|
+
driver_filename = "msedgedriver.exe"
|
58
|
+
else: # macOS and Linux
|
59
|
+
driver_filename = "msedgedriver"
|
60
|
+
|
61
|
+
# Construct the driver path
|
62
|
+
driver_path = os.path.join(cache_dir, "drivers", driver_name, os_type, driver_version, driver_filename)
|
63
|
+
# Check if the driver path exists
|
64
|
+
if os.path.exists(driver_path):
|
65
|
+
return driver_path
|
66
|
+
raise Exception("Network unavailable and no downloaded driver found")
|
67
|
+
|
68
|
+
|
69
|
+
# Function to get the Edge driver service
|
70
|
+
def get_edge_driver_service():
|
71
|
+
driver_path = get_driver_path()
|
72
|
+
print("driver_path", driver_path)
|
73
|
+
# Check if the driver path exists
|
74
|
+
if os.path.exists(driver_path):
|
75
|
+
return Service(driver_path)
|
76
|
+
else:
|
77
|
+
raise Exception("Network unavailable and no downloaded driver found")
|
@@ -1,6 +1,9 @@
|
|
1
1
|
pycoze/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
pycoze/ai/__init__.py,sha256=odM2lgYSnApxw4AzLV_5AyaxL5_MLfydOSB1VmLGFyA,75
|
3
3
|
pycoze/ai/vram_reserve.py,sha256=jtNsXamhwquyL9_qknZVu-8vQWaPfUdmvjLbDZaZ4vU,4262
|
4
|
+
pycoze/automation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
pycoze/automation/browser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
pycoze/automation/browser/edge_driver_manager.py,sha256=tJEGXab1XTk2LPjhpQ6NfAbRCdrsuyCDexMvYxZPUEM,3022
|
4
7
|
pycoze/bot/__init__.py,sha256=6HHMxDQVOyZM9dtSjQm9tjGnhj4h7CixD0JOvEwTi48,41
|
5
8
|
pycoze/bot/agent_chat.py,sha256=KshLVuXSnkWsp1J9xKKhoIMvAfQXg5ZyzSkPZdwcRkM,2785
|
6
9
|
pycoze/bot/bot.py,sha256=CCnBmxtmpmz7aLR_MIIiOuKR9IACo5P4uSkQXb5d0KU,3061
|
@@ -24,8 +27,8 @@ pycoze/utils/__init__.py,sha256=Gi5EnrWZGMD2JRejgV4c_VLCXyvA2wwBFI_niDF5MUE,110
|
|
24
27
|
pycoze/utils/arg.py,sha256=GtfGbMTMdaK75Fwh6MpUe1pCA5X6Ep4LFG7a72YrzjI,525
|
25
28
|
pycoze/utils/env.py,sha256=W04lhvTHhAAC6EldP6kk2xrctqtu8K6kl1vDLZDNeh8,561
|
26
29
|
pycoze/utils/text_or_file.py,sha256=gpxZVWt2DW6YiEg_MnMuwg36VNf3TX383QD_1oZNB0Y,551
|
27
|
-
pycoze-0.1.
|
28
|
-
pycoze-0.1.
|
29
|
-
pycoze-0.1.
|
30
|
-
pycoze-0.1.
|
31
|
-
pycoze-0.1.
|
30
|
+
pycoze-0.1.189.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
31
|
+
pycoze-0.1.189.dist-info/METADATA,sha256=yGD8p-JPeousEHUQZv7VQEr9ReGC51lMUgNsnK9Ny7k,726
|
32
|
+
pycoze-0.1.189.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
|
33
|
+
pycoze-0.1.189.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
34
|
+
pycoze-0.1.189.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|