Skip to content

Commit 841fea0

Browse files
committed
Fix packaging (everything should work again now?)
1 parent 2523466 commit 841fea0

File tree

8 files changed

+95
-12
lines changed

8 files changed

+95
-12
lines changed

_hp/hp/tools/crawler/android_intent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import numpy as np
66

77

8-
from desktop_selenium import CustomErrorTimeout, CustomTimeout
9-
from utils import get_tests, get_or_create_browser, TIMEOUT
8+
from hp.tools.crawler.desktop_selenium import CustomErrorTimeout, CustomTimeout
9+
from hp.tools.crawler.utils import get_tests, get_or_create_browser, TIMEOUT
1010
from multiprocessing import Pool
1111
import psycopg
1212
import uuid
@@ -17,7 +17,7 @@
1717
proj_config = json.load(open("config.json"))
1818
except OSError:
1919
try:
20-
proj_config = json.load(open("_hp/tools/config.json"))
20+
proj_config = json.load(open("_hp/hp/tools/config.json"))
2121
except OSError:
2222
proj_config = json.load(open("../config.json"))
2323

_hp/hp/tools/crawler/create_page_runner_repeats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
from utils import create_test_page_runner, generate_short_uuid
2+
from hp.tools.crawler.utils import create_test_page_runner, generate_short_uuid
33
import argparse
44

55
if __name__ == '__main__':

_hp/hp/tools/crawler/demo_receiver.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
import json
44

55
# Setup the config
6-
7-
proj_config = json.load(open("_hp/hp/tools/config.json"))
6+
try:
7+
proj_config = json.load(open("config.json"))
8+
except OSError:
9+
try:
10+
proj_config = json.load(open("_hp/hp/tools/config.json"))
11+
except OSError:
12+
proj_config = json.load(open("../config.json"))
813

914
DB_URL = proj_config['DB_URL'].replace("postgresql+psycopg2://", "postgresql://")
1015

_hp/hp/tools/crawler/desktop_selenium.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,9 @@ def unraisable_hook(unraisable):
294294
# Initial experiments showed almost no differences between Linux and macOS versions of brave, chrome, firefox
295295
config = [
296296
# Released 2024-01-22 (17.3 (19617.2.4.11.8))
297-
("safari", "17.3.1", None, None, get_or_create_browser("safari", "17.3.1", "macOS 14.3.1", "real", "selenium", "")),
298-
297+
# ("safari", "17.3.1", None, None, get_or_create_browser("safari", "17.3.1", "macOS 14.3.1", "real", "selenium", "")),
298+
("safari", "17.5", None, None, get_or_create_browser("safari", "17.5", "macOS 14.5", "real", "selenium", "")),
299+
299300
# Brave without updates on MacOS
300301
# Download .dmg from https://github.com/brave/brave-browser/releases and install
301302
# E.g., https://github.com/brave/brave-browser/releases/tag/v1.60.118, rename the file, run with --disable-brave-updage
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>Test Page Runner: open one Test URL at a time from a list of Test URLs.</title>
6+
</head>
7+
8+
<body>
9+
<script>
10+
// Insert URLs and timeout dynamically
11+
let urls = $$$URLS$$$;
12+
let timeout = $$$TIMEOUT$$$;
13+
let counter = 0;
14+
let openWindow;
15+
let timeoutId;
16+
let urlParams = new URLSearchParams(decodeURIComponent(window.location.search));
17+
let browser_id = urlParams.get('browser_id') || 1;
18+
let run_id = urlParams.get('run_id') || "unknown";
19+
20+
function closeCurrentWindow() {
21+
if (openWindow) {
22+
openWindow.close();
23+
}
24+
}
25+
26+
function openNextWindow() {
27+
closeCurrentWindow();
28+
29+
if (counter < urls.length) {
30+
// interpreted as: top=min,left=min,width=min,height=min
31+
let url = urls[counter];
32+
url = url.replace(/browser_id=\d+/, `browser_id=${browser_id}`);
33+
url_timeout = Math.max(parseInt(url.match(/timeout=(\d+)/)[1], 10) * 1000 + 2000, timeout);
34+
openWindow = window.open(url, "_blank", "top=0,left=0,width=100,height=100");
35+
counter++;
36+
// Open the next test after the TIMEOUT
37+
timeoutId = setTimeout(function () {
38+
openNextWindow();
39+
}, url_timeout);
40+
41+
} else {
42+
console.log("Finished!");
43+
// Append a "finished" div which we can await for in Selenium/Playwright based tests
44+
d = document.createElement("div");
45+
d.id = "finished";
46+
document.body.style.backgroundColor = "green";
47+
document.body.appendChild(d);
48+
49+
// Try to stop the page runner
50+
fetch(`${location.origin}/_hp/server/notify_runner_clients.py?run_id=${run_id}`);
51+
52+
}
53+
}
54+
55+
function handleMessage(event) {
56+
// If the test is finished, clear the timeout and directly start the next test
57+
if (event.data === 'finished') {
58+
clearTimeout(timeoutId);
59+
openNextWindow();
60+
}
61+
}
62+
window.addEventListener('message', handleMessage);
63+
64+
// Open the first window
65+
openNextWindow();
66+
67+
68+
</script>
69+
</body>
70+
71+
</html>

_hp/hp/tools/create_repeat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import argparse
22
import json
33
import re
4-
from analysis.utils import get_data, Config
4+
from hp.tools.analysis.utils import get_data, Config
55

66
# Create a json with all tests to redo (either timed out or completely missing in one or more of the 5 runs)
77
# Idea: group by test and count how many outcomes for each browser were observed

_hp/hp/tools/create_responses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from models import Response, Session
1+
from hp.tools.models import Response, Session
22

3-
from crawler.utils import get_or_create
3+
from hp.tools.crawler.utils import get_or_create
44
import json
55

66
# Common area

_hp/hp/tools/models.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010

1111

1212
# Setup the config
13-
proj_config = json.load(open("_hp/hp/tools/config.json"))
13+
try:
14+
proj_config = json.load(open("config.json"))
15+
except OSError:
16+
try:
17+
proj_config = json.load(open("_hp/hp/tools/config.json"))
18+
except OSError:
19+
proj_config = json.load(open("../config.json"))
1420

1521
DB_URL = proj_config['DB_URL']
1622

0 commit comments

Comments
 (0)