Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions install/helioviewer/hvpull/net/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@ def get_servers(cls):
"hv_rhessi": "HVRHESSIDataServer",
"punch": "PUNCHDataServer",
"local": "LocalDataServer",
"hv": "HvDataServer",
}

@classmethod
Expand Down
60 changes: 60 additions & 0 deletions install/helioviewer/hvpull/servers/hv.py
Original file line number Diff line number Diff line change
@@ -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
7 changes: 5 additions & 2 deletions settings/Config.Example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/movies/reQueueMovieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/regression/SentryIssue1Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
]);

Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/request/MockPhpStream.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

class MockPhpStream {

Expand All @@ -20,7 +20,7 @@ function __construct(){
}

protected function buffer_filename(){
return sys_get_temp_dir().'\php_input_temp.txt';
return sys_get_temp_dir().'/php_input_temp.txt';
}

function stream_open($path, $mode, $options, &$opened_path)
Expand Down
Loading