Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
args = parse_args()
web_protocol, fqdn, ftp_protocol, port, api_key = \
args.protocol, args.fqdn, args.ftp_protocol, args.port, args.api_key
if args.http_auth_username:
GalaxyInstance.make_delete_request = inject_auth(make_delete_request, args.http_auth_username, args.http_auth_password)
GalaxyInstance.make_post_request = inject_auth(make_post_request, args.http_auth_username, args.http_auth_password)
GalaxyInstance.make_put_request = inject_auth(make_put_request, args.http_auth_username, args.http_auth_password)
GalaxyInstance.make_get_request = inject_auth(GalaxyInstance.make_get_request, args.http_auth_username, args.http_auth_password)
url = web_protocol + "://" + fqdn
new_api_key, user_email, password = create_user(url, api_key)
tmpfile = NamedTemporaryFile()
tmpfile.write("1\n2\n3\n")
if ftp_protocol == "ftp":
ftp_upload_file(fqdn, user_email, password, port, tmpfile.name)
else:
sftp_upload_file(fqdn, user_email, password, port, tmpfile.name)
if not successfull_upload(url, new_api_key, tmpfile.name):
sys.exit("{ftp_protocol} upload to galaxy server {fqdn} failed.".format(ftp_protocol = ftp_protocol, fqdn = fqdn))
def _gi(args):
gi = galaxy.GalaxyInstance(args.host, key=args.api_key)
name = "wftest-user-%d" % random.randint(0, 1000000)
user = gi.users.create_local_user(name, "%s@galaxytesting.dev" % name, "pass123")
user_id = user["id"]
api_key = gi.users.create_user_apikey(user_id)
user_gi = galaxy.GalaxyInstance(args.host, api_key)
return user_gi
Usage: python3 create_user_get_api_key.py
"""
from __future__ import print_function
import sys
import bioblend.galaxy
if len(sys.argv) != 6:
print("Usage: python3 create_user_get_api_key.py ")
sys.exit(1)
galaxy_url = sys.argv[1]
galaxy_api_key = sys.argv[2]
# Initiating Galaxy connection
gi = bioblend.galaxy.GalaxyInstance(galaxy_url, galaxy_api_key)
# Create a new user and get a new API key for her
new_user = gi.users.create_local_user(sys.argv[3], sys.argv[4], sys.argv[5])
new_api_key = gi.users.create_user_apikey(new_user['id'])
print(new_api_key)
def generateWorkflowReport(request, settings):
# Get the invocation and workflow data
invocation = request.json.get("invocation")
workflow = request.json.get("workflow")
# Open a new connection with bioblend
galaxy_key = request.values.get("key")
gi = GalaxyInstance(settings.GALAXY_SERVER, galaxy_key)
workflow_steps = {}
for step in workflow.get("steps"):
workflow_steps[step.get("uuid")] = step
for step in invocation.get("steps"):
workflow_step = workflow_steps[step.get("workflow_step_uuid")]
workflow_step["state"] = step.get("state")
workflow_step["job_id"] = step.get("job_id")
workflow_step["job"] = gi.jobs.show_job(step.get("job_id"))
# GENERATE THE HTML
html_code = ""
to_close_tags = []
html_code += addTag("h2", "Workflow details", "font-size: 30px; color:red")
def get_instance(self):
return bioblend.galaxy.GalaxyInstance(url=self.url, key=self.api_key)
def __init__(self, api_key):
self.gi = galaxy.GalaxyInstance(url='http://127.0.0.1:80/galaxy/', key=api_key)
self.datasets_cache = {}
self.histories_cache = {'time':None, 'contents':None}
def galaxy_instance(url=None, api_key=None):
"""
Get an instance of the `GalaxyInstance` object. If the arguments are not
provided, load the default values using `load_input_file` method.
"""
if not (url and api_key):
tl = load_input_file()
url = tl['galaxy_instance']
api_key = tl['api_key']
return GalaxyInstance(url, api_key)
def galaxy_instance(url=None, api_key=None):
"""
Get an instance of the `GalaxyInstance` object. If the arguments are not
provided, load the default values using `load_input_file` method.
"""
if not (url and api_key):
tl = load_input_file()
url = tl['galaxy_instance']
api_key = tl['api_key']
return GalaxyInstance(url, api_key)