diff --git a/install/helioviewer/hvpull/net/daemon.py b/install/helioviewer/hvpull/net/daemon.py index 0a0e31b87..6fa8e0cf1 100644 --- a/install/helioviewer/hvpull/net/daemon.py +++ b/install/helioviewer/hvpull/net/daemon.py @@ -887,6 +887,7 @@ def get_servers(cls): "hv_rhessi": "HVRHESSIDataServer", "punch": "PUNCHDataServer", "local": "LocalDataServer", + "hv": "HvDataServer", } @classmethod diff --git a/install/helioviewer/hvpull/servers/hv.py b/install/helioviewer/hvpull/servers/hv.py new file mode 100644 index 000000000..04fc9ef71 --- /dev/null +++ b/install/helioviewer/hvpull/servers/hv.py @@ -0,0 +1,60 @@ +import os +import re +import requests +from helioviewer.hvpull.servers import DataServer + +class HvDataServer(DataServer): + def __init__(self): + # Get the HV_DATA_PATH environment variable, defaulting to helioviewer.org if not set + hv_data_path = os.environ.get('HV_DATA_PATH', 'https://helioviewer.org/jp2') + DataServer.__init__(self, hv_data_path, "HV") + + def compute_directories(self, start_date, end_date): + """Computes a list of remote directories expected to contain files""" + dirs = [] + + # Start with date directories + for date in self.get_dates(start_date, end_date): + date_url = os.path.join(self.uri, date) + + # Query the URL to find subdirectories + try: + response = requests.get(date_url) + response.raise_for_status() + + # Extract subdirectory links from HTML + subdirs = self._parse_directory_links(response.content.decode('utf-8')) + + if subdirs: + # Add each subdirectory with date_url as prefix + for subdir in subdirs: + dirs.append(f"{date_url}/{subdir}") + else: + # No subdirectories found, add the date URL itself + dirs.append(date_url) + + except requests.RequestException: + # If we can't query the URL, add it as-is + dirs.append(date_url) + + return dirs + + def _parse_directory_links(self, html): + """Parse HTML content and extract directory links""" + # Match href links + matches = re.findall(r'href="([^"]+)"', html) + + dirs = [] + for match in matches: + # Skip parent directory links, absolute URLs, and paths starting with / + if match in ['/', '../', '..', '/..'] or match.startswith('http') or match.startswith('/'): + continue + + # Only keep directory links (ending with /) + if match.endswith('/'): + # Remove trailing slash for consistency + dir_name = match.rstrip('/') + if dir_name: + dirs.append(dir_name) + + return dirs diff --git a/settings/Config.Example.ini b/settings/Config.Example.ini index 414f0869d..d50a55dce 100644 --- a/settings/Config.Example.ini +++ b/settings/Config.Example.ini @@ -15,8 +15,8 @@ ; contact@helioviewer.org ; [version] -last_update = 2021/11/18 -build_num = 821 +last_update = 2025/12/10 +build_num = 822 [application] app_env = development @@ -43,6 +43,9 @@ jp2_dir = /var/www-api/docroot/jp2 ; The URL that corresponds with the root_dir specified above. This is your API root web_root_url = http://localhost +; The URL that should be used when making requests in tests +local_test_url = http://127.0.0.1:80 + ; The URL that corresponds with the jp2_dir specified above. jp2_root_url = http://localhost/jp2 diff --git a/tests/unit_tests/movies/reQueueMovieTest.php b/tests/unit_tests/movies/reQueueMovieTest.php index d96472d3b..73d1bed70 100644 --- a/tests/unit_tests/movies/reQueueMovieTest.php +++ b/tests/unit_tests/movies/reQueueMovieTest.php @@ -32,7 +32,7 @@ final class reQueueMovieTest extends TestCase */ private function _queueTestMovie() { // Queue the movie - $url = HV_WEB_ROOT_URL . "?action=queueMovie&startTime=2023-12-01T00:00:00Z&endTime=2023-12-01T01:00:00Z&layers=[4,1,100]&imageScale=0.6&events=&eventsLabels=false"; + $url = HV_LOCAL_TEST_URL . "?action=queueMovie&startTime=2023-12-01T00:00:00Z&endTime=2023-12-01T01:00:00Z&layers=[4,1,100]&imageScale=0.6&events=&eventsLabels=false"; $result = file_get_contents($url); $data = json_decode($result); // Confirm the API request was accepted diff --git a/tests/unit_tests/regression/SentryIssue1Test.php b/tests/unit_tests/regression/SentryIssue1Test.php index 00d1980ad..8b763c4ce 100644 --- a/tests/unit_tests/regression/SentryIssue1Test.php +++ b/tests/unit_tests/regression/SentryIssue1Test.php @@ -19,7 +19,7 @@ public function testItShouldDumpProperResponseCodeAndReasonPhraseIfThereIsNoActi $client = new Client(); // Send a GET request to the specified URL - $response = $client->get(HV_WEB_ROOT_URL, [ + $response = $client->get(HV_LOCAL_TEST_URL, [ 'http_errors' => false ]); diff --git a/tests/unit_tests/request/MockPhpStream.php b/tests/unit_tests/request/MockPhpStream.php index 6593e1505..3433fafa4 100644 --- a/tests/unit_tests/request/MockPhpStream.php +++ b/tests/unit_tests/request/MockPhpStream.php @@ -1,4 +1,4 @@ -