Skip to content

Commit

Permalink
Reformatted with black as per CONTRIBUTING.md.
Browse files Browse the repository at this point in the history
  • Loading branch information
ndanner-wesleyancs committed Jul 3, 2024
1 parent 2e09752 commit bc0d6ae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
36 changes: 19 additions & 17 deletions openwpm/browser_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,26 @@ def launch_browser_manager(self) -> bool:
# use `tmpdir`, it just makes it available.
if self.browser_params.tmpdir is not None:
self.logger.debug(
"BROWSER %i: leftover temp directory %s? Deleting it." %
(self.browser_params.browser_id, self.browser_params.tmpdir)
"BROWSER %i: leftover temp directory %s? Deleting it."
% (self.browser_params.browser_id, self.browser_params.tmpdir)
)
try:
shutil.rmtree(self.browser_params.tmpdir)
except Exception as e:
self.logger.debug(
"BROWSER %i: error deleting %s: %s." %
(self.browser_params.browser_id,
"BROWSER %i: error deleting %s: %s."
% (
self.browser_params.browser_id,
self.browser_params.tmpdir,
str(e))
str(e),
)
)
self.browser_params.tmpdir = Path(tempfile.mkdtemp(
prefix="openwpm_",
dir=os.getenv('TMPDIR', default='/tmp')
))
self.browser_params.tmpdir = Path(
tempfile.mkdtemp(prefix="openwpm_", dir=os.getenv("TMPDIR", default="/tmp"))
)
self.logger.debug(
"BROWSER %i: Using temp dir %s" %
(self.browser_params.browser_id, self.browser_params.tmpdir)
"BROWSER %i: Using temp dir %s"
% (self.browser_params.browser_id, self.browser_params.tmpdir)
)

self.logger.info("BROWSER %i: Launching browser..." % self.browser_id)
Expand Down Expand Up @@ -369,18 +370,19 @@ def close_browser_manager(self, force: bool = False) -> None:
# Delete the temporary directory used by geckodriver.
try:
self.logger.debug(
"BROWSER %i: deleting temp dir %s" %
(self.browser_params.browser_id,
self.browser_params.tmpdir)
"BROWSER %i: deleting temp dir %s"
% (self.browser_params.browser_id, self.browser_params.tmpdir)
)
shutil.rmtree(self.browser_params.tmpdir)
self.browser_params.tmpdir = None
except Exception as e:
self.logger.warn(
"BROWSER %i: failed to delete temp dir %s: %s" %
(self.browser_params.browser_id,
"BROWSER %i: failed to delete temp dir %s: %s"
% (
self.browser_params.browser_id,
self.browser_params.tmpdir,
str(e))
str(e),
)
)

def execute_command_sequence(
Expand Down
4 changes: 2 additions & 2 deletions openwpm/deploy_browsers/deploy_firefox.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def deploy_firefox(
# copy of `os.environ` because I'm a little nervous about modifying the
# OpenWPM process' environment.
env = os.environ.copy()
env['TMPDIR'] = str(browser_params.tmpdir)
env["TMPDIR"] = str(browser_params.tmpdir)

fo.binary_location = firefox_binary_path
geckodriver_path = subprocess.check_output(
Expand All @@ -158,7 +158,7 @@ def deploy_firefox(
service=Service(
executable_path=geckodriver_path,
log_output=open(webdriver_interceptor.fifo, "w"),
env=env
env=env,
),
)

Expand Down

0 comments on commit bc0d6ae

Please sign in to comment.