Skip to content

Commit

Permalink
Get demo.py running on MacOS (#1105)
Browse files Browse the repository at this point in the history
* Get demo.py running on MacOS

* Revert --force mamba option
  • Loading branch information
englehardt authored Aug 20, 2024
1 parent a03fc7c commit 1ac8b64
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 47 deletions.
32 changes: 16 additions & 16 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ dependencies:
- dill=0.3.8
- easyprocess=1.1
- gcsfs=2024.6.1
- geckodriver=0.34.0
- geckodriver=0.35.0
- ipython=8.26.0
- isort=5.13.2
- leveldb=1.23
- multiprocess=0.70.16
- mypy=1.10.1
- nodejs=22.4.0
- mypy=1.11.1
- nodejs=22.5.1
- pandas=2.2.2
- pillow=10.4.0
- pip=24.0
- pip=24.2
- plyvel=1.5.1
- pre-commit=3.7.1
- pre-commit=3.8.0
- psutil=6.0.0
- pyarrow=16.1.0
- pytest-asyncio=0.23.7
- pyarrow=17.0.0
- pytest-asyncio=0.23.8
- pytest-cov=5.0.0
- pytest=8.2.2
- python=3.11.9
- pyvirtualdisplay=3.0
- pytest=8.3.2
- python=3.12.5
- pyvirtualdisplay=2.2
- recommonmark=0.7.1
- redis-py=5.0.7
- redis-py=5.0.9
- s3fs=2024.6.1
- selenium=4.22.0
- sentry-sdk=2.9.0
- selenium=4.23.1
- sentry-sdk=2.12.0
- sphinx-markdown-tables=0.0.17
- sphinx=7.3.7
- sphinx=8.0.2
- tabulate=0.9.0
- tblib=3.0.0
- wget=1.21.4
Expand All @@ -43,7 +43,7 @@ dependencies:
- domain-utils==0.7.1
- jsonschema==4.23.0
- tranco==0.8.1
- types-pyyaml==6.0.12.20240311
- types-redis==4.6.0.20240425
- types-pyyaml==6.0.12.20240808
- types-redis==4.6.0.20240806
- types-tabulate==0.9.0.20240106
name: openwpm
2 changes: 1 addition & 1 deletion openwpm/utilities/platform_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_firefox_binary_path():
root_dir = os.path.dirname(__file__) + "/../.."
if platform == "darwin":
firefox_binary_path = os.path.abspath(
root_dir + "/Nightly.app/Contents/MacOS/firefox-bin"
root_dir + "/Nightly.app/Contents/MacOS/firefox"
)
else:
firefox_binary_path = os.path.abspath(root_dir + "/firefox-bin/firefox-bin")
Expand Down
56 changes: 26 additions & 30 deletions openwpm/utilities/storage_watchdog.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import math
import os
import subprocess
import time
from pathlib import Path
from threading import Thread
Expand Down Expand Up @@ -31,32 +30,26 @@ def total_folder_size(startup: bool = False, root_dir: str = "/tmp") -> str:

running_total: int = 0
if not startup:
for file in os.listdir(root_dir):
if "firefox" in file or ".xpi" in file or "owpm" in file or "Temp" in file:
path = os.path.join(root_dir, file)
try:
running_total += int(
subprocess.check_output(["du", "-s", "-b", path])
.split()[0]
.decode("utf-8")
)
except:
pass
for dirpath, dirnames, filenames in os.walk(root_dir):
for file in filenames:
if (
"firefox" in file
or ".xpi" in file
or "owpm" in file
or "Temp" in file
):
path = os.path.join(dirpath, file)
# skip if it is symbolic link
if not os.path.islink(path):
running_total += os.path.getsize(path)
return f"Currently using: {convert_size(running_total)} of storage on disk..."

for file in os.listdir(root_dir):
path = os.path.join(root_dir, file)
try:
running_total += int(
subprocess.check_output(
["du", "-s", "-b", path], stderr=subprocess.DEVNULL
)
.split()[0]
.decode("utf-8")
)
except:
pass

for dirpath, dirnames, filenames in os.walk(root_dir):
for file in filenames:
path = os.path.join(dirpath, file)
# skip if it is symbolic link
if not os.path.islink(path):
running_total += os.path.getsize(path)
return f"Readable files in {root_dir} folder take up {convert_size(running_total)} of storage on disk at start time..."


Expand Down Expand Up @@ -99,11 +92,14 @@ def profile_size_exceeds_max_size(

readable_max_dir_size = convert_size(max_dir_size)

dir_size = int(
subprocess.check_output(["du", "-s", "-b", profile_path])
.split()[0]
.decode("utf-8")
)
dir_size = 0
for dirpath, dirnames, filenames in os.walk(profile_path):
for file in filenames:
path = os.path.join(dirpath, file)
# skip if it is symbolic link
if not os.path.islink(path):
dir_size += os.path.getsize(path)

readable_dir_size = convert_size(dir_size)

if dir_size < max_dir_size:
Expand Down

0 comments on commit 1ac8b64

Please sign in to comment.