fix bug when there is no existing chromedriver exe

This commit is contained in:
Yehuda Davis 2023-08-25 11:18:03 -04:00 committed by GitHub
parent cea80717c5
commit 6fa2220cc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -133,12 +133,13 @@ class Patcher(object):
if self.user_multi_procs: if self.user_multi_procs:
with Lock(): with Lock():
files = list(p.rglob("*chromedriver*")) files = list(p.rglob("*chromedriver*"))
most_recent = max(files, key=lambda f: f.stat().st_mtime) if files:
files.remove(most_recent) most_recent = max(files, key=lambda f: f.stat().st_mtime)
list(map(lambda f: f.unlink(), files)) files.remove(most_recent)
if self.is_binary_patched(most_recent): list(map(lambda f: f.unlink(), files))
self.executable_path = str(most_recent) if self.is_binary_patched(most_recent):
return True self.executable_path = str(most_recent)
return True
if executable_path: if executable_path:
self.executable_path = executable_path self.executable_path = executable_path