Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix das query #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions python/das_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ def do_das_query(query):
Execute das_client for the specified query, and return parsed JSON output
"""

args = ['dasgoclient', '-json', '-format', 'json', '--query', query]
result = subprocess.check_output(args)
args = ['dasgoclient', '--format', 'json', '--query', query]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to dasgoclient -h,

  -format string
        Compatibility option with python das_client, use json to get das_client behavior

so I would default to -json - but the output is not identical: -json gives just the ["data"] part of the -format json. The code that uses it is easy to adjust (actually it gets simpler), but the check in https://github.com/cp3-llbb/SAMADhi/pull/31/files#diff-e068c93f5ddd6d675874177f3be1ef45L58 , should become a simple if len(summary_results) > 1 then, I think.


try:
result = subprocess.check_output(args)
except subprocess.CalledProcessError as exc:
result = exc.output
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safer to print a message that the query failed and exit, rather than work with the output of a failed query


return json.loads(result)

Expand Down Expand Up @@ -46,7 +50,7 @@ def query_das(dataset):
"""

summary_query = "summary dataset=%s" % dataset
metadata_query = "dataset=%s" % dataset
metadata_query = "dataset dataset=%s" % dataset
release_query = "release dataset=%s" % dataset
config_query = "config dataset=%s system=dbs3" % dataset

Expand Down