Skip to content

Commit 1ac8b64

Browse files
authored
Get demo.py running on MacOS (#1105)
* Get demo.py running on MacOS * Revert --force mamba option
1 parent a03fc7c commit 1ac8b64

File tree

3 files changed

+43
-47
lines changed

3 files changed

+43
-47
lines changed

environment.yaml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@ dependencies:
99
- dill=0.3.8
1010
- easyprocess=1.1
1111
- gcsfs=2024.6.1
12-
- geckodriver=0.34.0
12+
- geckodriver=0.35.0
1313
- ipython=8.26.0
1414
- isort=5.13.2
1515
- leveldb=1.23
1616
- multiprocess=0.70.16
17-
- mypy=1.10.1
18-
- nodejs=22.4.0
17+
- mypy=1.11.1
18+
- nodejs=22.5.1
1919
- pandas=2.2.2
2020
- pillow=10.4.0
21-
- pip=24.0
21+
- pip=24.2
2222
- plyvel=1.5.1
23-
- pre-commit=3.7.1
23+
- pre-commit=3.8.0
2424
- psutil=6.0.0
25-
- pyarrow=16.1.0
26-
- pytest-asyncio=0.23.7
25+
- pyarrow=17.0.0
26+
- pytest-asyncio=0.23.8
2727
- pytest-cov=5.0.0
28-
- pytest=8.2.2
29-
- python=3.11.9
30-
- pyvirtualdisplay=3.0
28+
- pytest=8.3.2
29+
- python=3.12.5
30+
- pyvirtualdisplay=2.2
3131
- recommonmark=0.7.1
32-
- redis-py=5.0.7
32+
- redis-py=5.0.9
3333
- s3fs=2024.6.1
34-
- selenium=4.22.0
35-
- sentry-sdk=2.9.0
34+
- selenium=4.23.1
35+
- sentry-sdk=2.12.0
3636
- sphinx-markdown-tables=0.0.17
37-
- sphinx=7.3.7
37+
- sphinx=8.0.2
3838
- tabulate=0.9.0
3939
- tblib=3.0.0
4040
- wget=1.21.4
@@ -43,7 +43,7 @@ dependencies:
4343
- domain-utils==0.7.1
4444
- jsonschema==4.23.0
4545
- tranco==0.8.1
46-
- types-pyyaml==6.0.12.20240311
47-
- types-redis==4.6.0.20240425
46+
- types-pyyaml==6.0.12.20240808
47+
- types-redis==4.6.0.20240806
4848
- types-tabulate==0.9.0.20240106
4949
name: openwpm

openwpm/utilities/platform_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def get_firefox_binary_path():
5151
root_dir = os.path.dirname(__file__) + "/../.."
5252
if platform == "darwin":
5353
firefox_binary_path = os.path.abspath(
54-
root_dir + "/Nightly.app/Contents/MacOS/firefox-bin"
54+
root_dir + "/Nightly.app/Contents/MacOS/firefox"
5555
)
5656
else:
5757
firefox_binary_path = os.path.abspath(root_dir + "/firefox-bin/firefox-bin")

openwpm/utilities/storage_watchdog.py

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
import math
33
import os
4-
import subprocess
54
import time
65
from pathlib import Path
76
from threading import Thread
@@ -31,32 +30,26 @@ def total_folder_size(startup: bool = False, root_dir: str = "/tmp") -> str:
3130

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

47-
for file in os.listdir(root_dir):
48-
path = os.path.join(root_dir, file)
49-
try:
50-
running_total += int(
51-
subprocess.check_output(
52-
["du", "-s", "-b", path], stderr=subprocess.DEVNULL
53-
)
54-
.split()[0]
55-
.decode("utf-8")
56-
)
57-
except:
58-
pass
59-
47+
for dirpath, dirnames, filenames in os.walk(root_dir):
48+
for file in filenames:
49+
path = os.path.join(dirpath, file)
50+
# skip if it is symbolic link
51+
if not os.path.islink(path):
52+
running_total += os.path.getsize(path)
6053
return f"Readable files in {root_dir} folder take up {convert_size(running_total)} of storage on disk at start time..."
6154

6255

@@ -99,11 +92,14 @@ def profile_size_exceeds_max_size(
9992

10093
readable_max_dir_size = convert_size(max_dir_size)
10194

102-
dir_size = int(
103-
subprocess.check_output(["du", "-s", "-b", profile_path])
104-
.split()[0]
105-
.decode("utf-8")
106-
)
95+
dir_size = 0
96+
for dirpath, dirnames, filenames in os.walk(profile_path):
97+
for file in filenames:
98+
path = os.path.join(dirpath, file)
99+
# skip if it is symbolic link
100+
if not os.path.islink(path):
101+
dir_size += os.path.getsize(path)
102+
107103
readable_dir_size = convert_size(dir_size)
108104

109105
if dir_size < max_dir_size:

0 commit comments

Comments
 (0)