Skip to content

Commit

Permalink
Fixed bug where files matching desired pattern in NAIF index were not…
Browse files Browse the repository at this point in the history
… being added to list to be downloaded

Included HTML delimiters around pattern for scraping NAIF file listing (to avoid duplicate downloads)

Added debug log messages
  • Loading branch information
jameswilburlewis committed Jan 15, 2025
1 parent 484b130 commit 22eba7e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pyspedas/projects/maven/download_files_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def get_orbit_files():
import re

orbit_files_url = "http://naif.jpl.nasa.gov/pub/naif/MAVEN/kernels/spk/"
pattern = r"maven_orb_rec(\.orb|.{17}\.orb)"
pattern = r">maven_orb_rec(\.orb|.{17}\.orb)<"
logging.debug("get_orbit_files() making request to URL %s", orbit_files_url)
page = urllib.request.urlopen(orbit_files_url)
logging.debug("get_orbit_files() finished request to URL %s", orbit_files_url)
Expand Down Expand Up @@ -155,11 +155,17 @@ def get_orbit_files():
logging.debug("get_orbit_files() finished request to URL %s", orbit_files_url + filename)

if is_fsspec_uri(toolkit_path):
fo = fs.open("/".join([orbit_files_path, filename]), "wb")
ifn = "/".join([orbit_files_path, filename])
logging.debug("reading fsspec file %s",ifn)
fo = fs.open(ifn, "wb")
else:
fo = open(os.path.join(orbit_files_path, filename), "wb")
ifn = os.path.join(orbit_files_path, filename)
logging.debug("reading plain file %s",ifn)
fo = open(ifn, "wb")
with fo as code:
code.write(o_file.read())
content=o_file.read()
logging.debug("writing %d bytes into file %s",len(content), ifn)
code.write(content)

merge_orbit_files()

Expand Down Expand Up @@ -203,6 +209,7 @@ def merge_orbit_files():
x = re.match(pattern, f)
if x is not None:
orb_file = os.path.join(orbit_files_path, f) if not is_fsspec_uri(toolkit_path) else "/".join([orbit_files_path, f])
orb_files.append(orb_file)
if x.group(2) != "":
orb_dates.append(x.group(2))
else:
Expand Down

0 comments on commit 22eba7e

Please sign in to comment.