Skip to content
Snippets Groups Projects
Commit 2cddc482 authored by Erin (Josh) Rigler's avatar Erin (Josh) Rigler
Browse files

Attempt StringIO after failed BytesIO file read

This is a bandaid to allow the `--input-url` option to be used to
read in single files. It adds zero functionality beyond what already
existed when the `--input-file` option was used.
parent 3fee5483
No related branches found
No related tags found
1 merge request!183Attempt StringIO after failed BytesIO file read
"""Controller class for geomag algorithms""" """Controller class for geomag algorithms"""
import argparse import argparse
from io import BytesIO from io import BytesIO, StringIO
import sys import sys
from typing import List, Optional, Tuple, Union from typing import List, Optional, Tuple, Union
...@@ -506,7 +506,12 @@ def get_input_factory(args): ...@@ -506,7 +506,12 @@ def get_input_factory(args):
input_factory_args["urlInterval"] = args.input_url_interval input_factory_args["urlInterval"] = args.input_url_interval
input_factory_args["urlTemplate"] = args.input_url input_factory_args["urlTemplate"] = args.input_url
else: else:
input_stream = BytesIO(Util.read_url(args.input_url)) try:
input_stream = BytesIO(Util.read_url(args.input_url))
except TypeError as e:
print(str(e), file=sys.stderr)
print("Warning: reading url as BytesIO failed; attempting StringIO", file=sys.stderr)
input_stream = StringIO(Util.read_url(args.input_url))
input_type = args.input input_type = args.input
if input_type == "edge": if input_type == "edge":
input_factory = edge.EdgeFactory( input_factory = edge.EdgeFactory(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment