@@ -97,26 +97,12 @@ def log_d(message):
9797 print (message )
9898
9999
100- def make_writable (file_path ):
101- # Set permissions to: "If you can read it, you can write it."
102- mode = os .stat (file_path ).st_mode
103- mode |= (mode & 0o444 ) >> 1 # copy R bits to W
104- os .chmod (file_path , mode )
105-
106-
107- def make_executable (file_path ):
108- # Set permissions to: "If you can read it, you can execute it."
109- mode = os .stat (file_path ).st_mode
110- mode |= (mode & 0o444 ) >> 2 # copy R bits to X
111- os .chmod (file_path , mode )
112-
113-
114100def make_driver_executable_if_not (driver_path ):
115101 # Verify driver has executable permissions. If not, add them.
116102 permissions = oct (os .stat (driver_path )[0 ])[- 3 :]
117103 if "4" in permissions or "6" in permissions :
118104 # We want at least a '5' or '7' to make sure it's executable
119- make_executable (driver_path )
105+ shared_utils . make_executable (driver_path )
120106
121107
122108def extend_driver (driver ):
@@ -566,6 +552,10 @@ def uc_open_with_cdp_mode(driver, url=None):
566552 for tab in driver .cdp_base .tabs [- 1 ::- 1 ]:
567553 if "chrome-extension://" not in str (tab ):
568554 with gui_lock :
555+ with suppress (Exception ):
556+ shared_utils .make_writable (
557+ constants .MultiBrowser .PYAUTOGUILOCK
558+ )
569559 loop .run_until_complete (tab .activate ())
570560 break
571561
@@ -580,11 +570,17 @@ def uc_open_with_cdp_mode(driver, url=None):
580570 if page_tab :
581571 loop .run_until_complete (page_tab .aopen ())
582572 with gui_lock :
573+ with suppress (Exception ):
574+ shared_utils .make_writable (
575+ constants .MultiBrowser .PYAUTOGUILOCK
576+ )
583577 loop .run_until_complete (page_tab .activate ())
584578
585579 loop .run_until_complete (driver .cdp_base .update_targets ())
586580 page = loop .run_until_complete (driver .cdp_base .get (url ))
587581 with gui_lock :
582+ with suppress (Exception ):
583+ shared_utils .make_writable (constants .MultiBrowser .PYAUTOGUILOCK )
588584 loop .run_until_complete (page .activate ())
589585 loop .run_until_complete (page .wait ())
590586 if not safe_url :
@@ -883,17 +879,12 @@ def install_pyautogui_if_missing(driver):
883879 with pip_find_lock :
884880 pass
885881 except Exception :
886- # Need write permissions
887- with suppress (Exception ):
888- make_writable (constants .PipInstall .FINDLOCK )
889- try :
890- with pip_find_lock :
891- pass
892- except Exception :
893- # Since missing permissions, skip the locks
894- __install_pyautogui_if_missing ()
895- return
882+ # Since missing permissions, skip the locks
883+ __install_pyautogui_if_missing ()
884+ return
896885 with pip_find_lock : # Prevent issues with multiple processes
886+ with suppress (Exception ):
887+ shared_utils .make_writable (constants .PipInstall .FINDLOCK )
897888 __install_pyautogui_if_missing ()
898889
899890
@@ -1789,6 +1780,8 @@ def _add_chrome_proxy_extension(
17891780 if zip_it :
17901781 proxy_zip_lock = fasteners .InterProcessLock (PROXY_ZIP_LOCK )
17911782 with proxy_zip_lock :
1783+ with suppress (Exception ):
1784+ shared_utils .make_writable (PROXY_ZIP_LOCK )
17921785 if multi_proxy :
17931786 _set_proxy_filenames ()
17941787 if not os .path .exists (proxy_helper .PROXY_ZIP_PATH ):
@@ -1800,6 +1793,8 @@ def _add_chrome_proxy_extension(
18001793 else :
18011794 proxy_dir_lock = fasteners .InterProcessLock (PROXY_DIR_LOCK )
18021795 with proxy_dir_lock :
1796+ with suppress (Exception ):
1797+ shared_utils .make_writable (PROXY_DIR_LOCK )
18031798 if multi_proxy :
18041799 _set_proxy_filenames ()
18051800 if not os .path .exists (proxy_helper .PROXY_DIR_PATH ):
@@ -1825,6 +1820,8 @@ def is_using_uc(undetectable, browser_name):
18251820def _unzip_to_new_folder (zip_file , folder ):
18261821 proxy_dir_lock = fasteners .InterProcessLock (PROXY_DIR_LOCK )
18271822 with proxy_dir_lock :
1823+ with suppress (Exception ):
1824+ shared_utils .make_writable (PROXY_DIR_LOCK )
18281825 if not os .path .exists (folder ):
18291826 import zipfile
18301827 zip_ref = zipfile .ZipFile (zip_file , "r" )
@@ -2934,6 +2931,8 @@ def get_remote_driver(
29342931 constants .PipInstall .FINDLOCK
29352932 )
29362933 with pip_find_lock : # Prevent issues with multiple processes
2934+ with suppress (Exception ):
2935+ shared_utils .make_writable (constants .PipInstall .FINDLOCK )
29372936 try :
29382937 from seleniumwire import webdriver
29392938 import blinker
@@ -3371,6 +3370,8 @@ def get_local_driver(
33713370 constants .PipInstall .FINDLOCK
33723371 )
33733372 with pip_find_lock : # Prevent issues with multiple processes
3373+ with suppress (Exception ):
3374+ shared_utils .make_writable (constants .PipInstall .FINDLOCK )
33743375 try :
33753376 from seleniumwire import webdriver
33763377 import blinker
@@ -3434,6 +3435,10 @@ def get_local_driver(
34343435 constants .MultiBrowser .DRIVER_FIXING_LOCK
34353436 )
34363437 with geckodriver_fixing_lock :
3438+ with suppress (Exception ):
3439+ shared_utils .make_writable (
3440+ constants .MultiBrowser .DRIVER_FIXING_LOCK
3441+ )
34373442 if not geckodriver_on_path ():
34383443 sys_args = sys .argv # Save a copy of sys args
34393444 log_d (
@@ -3736,6 +3741,10 @@ def get_local_driver(
37363741 constants .MultiBrowser .DRIVER_FIXING_LOCK
37373742 )
37383743 with edgedriver_fixing_lock :
3744+ with suppress (Exception ):
3745+ shared_utils .make_writable (
3746+ constants .MultiBrowser .DRIVER_FIXING_LOCK
3747+ )
37393748 msg = "Microsoft Edge Driver not found."
37403749 if edgedriver_upgrade_needed :
37413750 msg = "Microsoft Edge Driver update needed."
@@ -4119,6 +4128,10 @@ def get_local_driver(
41194128 constants .MultiBrowser .DRIVER_FIXING_LOCK
41204129 )
41214130 with edgedriver_fixing_lock :
4131+ with suppress (Exception ):
4132+ shared_utils .make_writable (
4133+ constants .MultiBrowser .DRIVER_FIXING_LOCK
4134+ )
41224135 with suppress (Exception ):
41234136 if not _was_driver_repaired ():
41244137 _repair_edgedriver (edge_version )
@@ -4501,6 +4514,10 @@ def get_local_driver(
45014514 constants .MultiBrowser .DRIVER_FIXING_LOCK
45024515 )
45034516 with chromedriver_fixing_lock :
4517+ with suppress (Exception ):
4518+ shared_utils .make_writable (
4519+ constants .MultiBrowser .DRIVER_FIXING_LOCK
4520+ )
45044521 msg = "chromedriver update needed. Getting it now:"
45054522 if not path_chromedriver :
45064523 msg = "chromedriver not found. Getting it now:"
@@ -4592,6 +4609,10 @@ def get_local_driver(
45924609 constants .MultiBrowser .DRIVER_FIXING_LOCK
45934610 )
45944611 with uc_lock : # Avoid multithreaded issues
4612+ with suppress (Exception ):
4613+ shared_utils .make_writable (
4614+ constants .MultiBrowser .DRIVER_FIXING_LOCK
4615+ )
45954616 if make_uc_driver_from_chromedriver :
45964617 if os .path .exists (LOCAL_CHROMEDRIVER ):
45974618 with suppress (Exception ):
@@ -4851,6 +4872,10 @@ def get_local_driver(
48514872 if not os .path .exists (cf_lock_path ):
48524873 # Avoid multithreaded issues
48534874 with cf_lock :
4875+ with suppress (Exception ):
4876+ shared_utils .make_writable (
4877+ cf_lock_path
4878+ )
48544879 # Install Python Certificates (MAC)
48554880 os .system (
48564881 r"bash /Applications/Python*/"
@@ -4994,6 +5019,10 @@ def get_local_driver(
49945019 constants .MultiBrowser .DRIVER_FIXING_LOCK
49955020 )
49965021 with chromedriver_fixing_lock :
5022+ with suppress (Exception ):
5023+ shared_utils .make_writable (
5024+ constants .MultiBrowser .DRIVER_FIXING_LOCK
5025+ )
49975026 if not _was_driver_repaired ():
49985027 _repair_chromedriver (
49995028 chrome_options , headless_options , mcv
@@ -5192,7 +5221,10 @@ def get_local_driver(
51925221 chromedr_fixing_lock = fasteners .InterProcessLock (
51935222 constants .MultiBrowser .DRIVER_FIXING_LOCK
51945223 )
5224+ D_F_L = constants .MultiBrowser .DRIVER_FIXING_LOCK
51955225 with chromedr_fixing_lock :
5226+ with suppress (Exception ):
5227+ shared_utils .make_writable (D_F_L )
51965228 if not _was_driver_repaired ():
51975229 with suppress (Exception ):
51985230 _repair_chromedriver (
0 commit comments