mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-01 15:37:32 +08:00
8cdca0f343
introduced in https://github.com/galaxyproject/galaxy/pull/18003 . In particular, when using requests in the tests to connect to Galaxy or the ToolShed it's not needed to use the modified headers. Also: - Move some imports after conditional imports. - Fix type annotations in `lib/tool_shed/test/base/populators.py` - Fix typo bug in `test/unit/util/test_get_url.py`
29 lines
959 B
Python
29 lines
959 B
Python
import argparse
|
|
import json
|
|
|
|
import requests
|
|
import yaml
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="Upload a directory into a data library")
|
|
parser.add_argument("-u", "--url", dest="url", required=True, help="Galaxy URL")
|
|
parser.add_argument("-a", "--api", dest="api_key", required=True, help="API Key")
|
|
parser.add_argument("target", metavar="FILE", type=str, help="file describing data library to fetch")
|
|
args = parser.parse_args()
|
|
with open(args.target) as f:
|
|
target = yaml.safe_load(f)
|
|
|
|
histories_url = args.url + "/api/histories"
|
|
new_history_response = requests.post(histories_url, data={"key": args.api_key})
|
|
|
|
fetch_url = args.url + "/api/tools/fetch"
|
|
payload = {"key": args.api_key, "targets": json.dumps([target]), "history_id": new_history_response.json()["id"]}
|
|
|
|
response = requests.post(fetch_url, data=payload)
|
|
print(response.content)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|