MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / unzip_package

Method unzip_package

seleniumbase/undetected/patcher.py:153–179  ·  view source on GitHub ↗

:return: path to unpacked executable

(self, fp)

Source from the content-addressed store, hash-verified

151 return urlretrieve(u)[0]
152
153 def unzip_package(self, fp):
154 """ :return: path to unpacked executable """
155 logger.debug("Unzipping %s" % fp)
156 try:
157 os.unlink(self.zip_path)
158 except (FileNotFoundError, OSError):
159 pass
160 try:
161 os.makedirs(self.zip_path, mode=0o755, exist_ok=True)
162 except Exception:
163 pass
164 with zipfile.ZipFile(fp, mode="r") as zf:
165 zf.extract(self.exe_name, self.zip_path)
166 try:
167 os.rename(
168 os.path.join(self.zip_path, self.exe_name),
169 self.executable_path,
170 )
171 os.remove(fp)
172 except PermissionError:
173 pass
174 try:
175 os.rmdir(self.zip_path)
176 os.chmod(self.executable_path, 0o755)
177 except PermissionError:
178 pass
179 return self.executable_path
180
181 @staticmethod
182 def force_kill_instances(exe_name):

Callers 1

autoMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected