@@ -39,15 +39,13 @@ class Patcher(object):
3939 data_path = os .path .abspath (os .path .expanduser (downloads_folder ))
4040
4141 def __init__ (self , executable_path = None , force = False , version_main = 0 ):
42- """
43- Args:
44- executable_path: None = automatic
45- A full file path to the chromedriver executable
46- force: False
47- Terminate processes which are holding lock
48- version_main: 0 = auto
49- Specify main chrome version (rounded, ex: 82)
50- """
42+ """Args:
43+ executable_path: None = automatic
44+ A full file path to the chromedriver executable
45+ force: False
46+ Terminate processes which are holding lock
47+ version_main: 0 = auto
48+ Specify main chrome version (rounded, ex: 82) """
5149 self .force = force
5250 self .executable_path = None
5351 prefix = "undetected"
@@ -89,17 +87,17 @@ def auto(self, executable_path=None, force=False, version_main=None):
8987 self .force = force
9088 try :
9189 os .unlink (self .executable_path )
92- except PermissionError : # noqa
90+ except PermissionError :
9391 if self .force :
9492 self .force_kill_instances (self .executable_path )
9593 not_force = not self .force
9694 return self .auto (force = not_force )
9795 try :
9896 if self .is_binary_patched ():
9997 return True # Running AND patched
100- except PermissionError : # noqa
98+ except PermissionError :
10199 pass
102- except FileNotFoundError : # noqa
100+ except FileNotFoundError :
103101 pass
104102 release = self .fetch_release_number ()
105103 self .version_main = release .split ("." )[0 ]
@@ -122,10 +120,8 @@ def fetch_release_number(self):
122120 return urlopen (self .url_repo + path ).read ().decode ()
123121
124122 def fetch_package (self ):
125- """
126- Downloads chromedriver from source.
127- :return: path to downloaded file
128- """
123+ """Downloads chromedriver from source.
124+ :return: path to downloaded file """
129125 from urllib .request import urlretrieve
130126
131127 u = "%s/%s/%s" % (
@@ -135,13 +131,11 @@ def fetch_package(self):
135131 return urlretrieve (u )[0 ]
136132
137133 def unzip_package (self , fp ):
138- """
139- :return: path to unpacked executable
140- """
134+ """ :return: path to unpacked executable """
141135 logger .debug ("unzipping %s" % fp )
142136 try :
143137 os .unlink (self .zip_path )
144- except (FileNotFoundError , OSError ): # noqa
138+ except (FileNotFoundError , OSError ):
145139 pass
146140 os .makedirs (self .zip_path , mode = 0o755 , exist_ok = True )
147141 with zipfile .ZipFile (fp , mode = "r" ) as zf :
@@ -163,10 +157,9 @@ def unzip_package(self, fp):
163157
164158 @staticmethod
165159 def force_kill_instances (exe_name ):
166- """
160+ """ Terminate instances of UC.
167161 :param: executable name to kill, may be a path as well
168- :return: True on success else False
169- """
162+ :return: True on success else False """
170163 exe_name = os .path .basename (exe_name )
171164 if IS_POSIX :
172165 r = os .system ("kill -f -9 $(pidof %s)" % exe_name )
@@ -288,8 +281,8 @@ def __del__(self):
288281 % self .executable_path
289282 )
290283 break
291- except (OSError , RuntimeError , PermissionError ): # noqa
284+ except (OSError , RuntimeError , PermissionError ):
292285 time .sleep (0.1 )
293286 continue
294- except FileNotFoundError : # noqa
287+ except FileNotFoundError :
295288 break
0 commit comments