# HG changeset patch
# User yating-l
# Date 1511802378 18000
# Node ID 6f262a92e8dccf4a399296d4ca2a9b996b82f2ef
# Parent 8ff4b84d709f9029ff12543340c4d3b558232dd5
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 91b46f7c891c2466bc5b6a063411cdae75964515-dirty
diff -r 8ff4b84d709f -r 6f262a92e8dc apollo/ApolloInstance.py
--- a/apollo/ApolloInstance.py Wed Oct 25 12:41:34 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-#!/usr/bin/env python
-import os
-import json
-import shutil
-import tempfile
-import logging
-import random
-import string
-from util import subtools
-from mako.lookup import TemplateLookup
-
-
-class ApolloInstance(object):
- def __init__(self, apollo_host, apollo_admin, tool_directory):
- self.apollo_host = apollo_host
- self.tool_directory = tool_directory
- self.logger = logging.getLogger(__name__)
- self.apollo_admin = apollo_admin
- self.apolloTemplate = self._getApolloTemplate()
- self._arrow_init()
-
-
- def _arrow_init(self):
- subtools.verify_user_login(self.apollo_admin.user_email, self.apollo_admin.password, self.apollo_host)
- arrow_config = tempfile.NamedTemporaryFile(bufsize=0)
- with open(arrow_config.name, 'w') as conf:
- htmlMakoRendered = self.apolloTemplate.render(
- apollo_host = self.apollo_host,
- admin_user = self.apollo_admin.user_email,
- admin_pw = self.apollo_admin.password
- )
- conf.write(htmlMakoRendered)
-
- home_dir = os.path.expanduser('~')
- arrow_config_dir = os.path.join(home_dir, '.apollo-arrow.yml')
- shutil.copyfile(arrow_config.name, arrow_config_dir)
- self.logger.debug("Initated arrow: apollo-arrow.yml= %s", arrow_config_dir)
-
- #TODO: Encode admin password
- '''
- def _generatePassword(self, length=8):
- chars = string.digits + string.letters
- pw = ''.join([random.choice(chars) for _ in range(length)])
- return pw
- '''
-
- def _getApolloTemplate(self):
- mylookup = TemplateLookup(directories=[os.path.join(self.tool_directory, 'templates')],
- output_encoding='utf-8', encoding_errors='replace')
- apolloTemplate = mylookup.get_template("apollo-arrow.yml")
- return apolloTemplate
-
- def createApolloUser(self, apollo_user, admin=None):
- p = subtools.arrow_create_user(apollo_user.user_email, apollo_user.firstname, apollo_user.lastname, apollo_user.password, admin)
- user_info = json.loads(p)
- user_id = user_info.get('userId')
- if not user_id:
- self.logger.debug("Cannot create new user: %s; The user may already exist", apollo_user.user_email)
- subtools.verify_user_login(apollo_user.user_email, apollo_user.password, self.apollo_host)
- user_id = subtools.arrow_get_users(apollo_user.user_email)
- self.logger.debug("Got user_id for new or existing user: user_id = %s", str(user_id))
- return user_id
-
- def grantPermission(self, user_id, organism_id, **user_permissions):
- subtools.arrow_update_organism_permissions(user_id, organism_id, **user_permissions)
- self.logger.debug("Grant user %s permissions to organism %s, permissions = %s", str(user_id), str(organism_id), ','.join(user_permissions))
-
- def addOrganism(self, organism_name, organism_dir):
- p = subtools.arrow_add_organism(organism_name, organism_dir)
- if not p:
- self.logger.error("The user is not authorized to add organism")
- exit(-1)
- organism = json.loads(p)
- organism_id = organism['id']
- self.logger.debug("Added new organism to Apollo instance, %s", p)
- return organism_id
-
- def loadHubToApollo(self, apollo_user, organism_name, organism_dir, admin_user=False, **user_permissions):
- #user_id = self.createApolloUser(apollo_user, admin_user)
- organism_id = self.addOrganism(organism_name, organism_dir)
- #self.grantPermission(user_id, organism_id, **user_permissions)
- self.logger.debug("Successfully load the hub to Apollo")
\ No newline at end of file
diff -r 8ff4b84d709f -r 6f262a92e8dc apollo/ApolloInstance.pyc
Binary file apollo/ApolloInstance.pyc has changed
diff -r 8ff4b84d709f -r 6f262a92e8dc apollo/ApolloUser.py
--- a/apollo/ApolloUser.py Wed Oct 25 12:41:34 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-#!/usr/bin/python
-
-import os
-
-class ApolloUser(object):
- def __init__(self, user_email, password, firstname=None, lastname=None):
- self.user_email = user_email
- self.firstname = firstname
- self.lastname = lastname
- self.password = password
diff -r 8ff4b84d709f -r 6f262a92e8dc apollo/ApolloUser.pyc
Binary file apollo/ApolloUser.pyc has changed
diff -r 8ff4b84d709f -r 6f262a92e8dc apollo/__init__.py
diff -r 8ff4b84d709f -r 6f262a92e8dc apollo/__init__.pyc
Binary file apollo/__init__.pyc has changed
diff -r 8ff4b84d709f -r 6f262a92e8dc jbrowsehubToApollo.py
--- a/jbrowsehubToApollo.py Wed Oct 25 12:41:34 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-#!/usr/bin/env python
-import os
-import sys
-import argparse
-import json
-import logging
-import socket
-from apollo.ApolloInstance import ApolloInstance
-from util.Reader import Reader
-from util.Logger import Logger
-
-
-def main(argv):
- parser = argparse.ArgumentParser(description='Upload a hub to display on Apollo.')
- parser.add_argument('-j', '--data_json', help='JSON file containing the metadata of the inputs')
- parser.add_argument('-o', '--output', help='HTML output')
-
- #parser.add_argument('-e', '--extra_file_path', help='Extra file path for generated jbrowse hub')
- #parser.add_argument('-d', '--jbrowsehub', help='Name of the HTML summarizing the content of the JBrowse Hub Archive')
-
- # Get the args passed in parameter
- args = parser.parse_args()
- json_inputs_data = args.data_json
- outputFile = args.output
- #outputFile = args.jbrowsehub
-
-
- ##Parse JSON file with Reader
- reader = Reader(json_inputs_data)
-
- # Begin init variables
- extra_files_path = reader.getExtFilesPath()
- #user_email = reader.getUserEmail()
- species_name = reader.getSpeciesName()
- #apollo_host = reader.getApolloHost()
- apollo_port = reader.getPortNum()
- apollo_host = "http://localhost:"+ apollo_port + "/apollo"
- #apollo_host = "http://localhost:8080/apollo"
- #apollo_user = reader.getApolloUser()
- apollo_admin_user = reader.getAdminUser()
- toolDirectory = reader.getToolDir()
- #jbrowse_hub = reader.getJBrowseHubDir()
- debug_mode = reader.getDebugMode()
-
- #### Logging management ####
- # If we are in Debug mode, also print in stdout the debug dump
- log = Logger(tool_directory=toolDirectory, debug=debug_mode, extra_files_path=extra_files_path)
- log.setup_logging()
-
- logging.info("#### JBrowseArchiveCreator: Start to upload JBrowse Hub to Apollo instance: %s #### ", apollo_host)
- logging.debug('JSON parameters: %s\n\n', json.dumps(reader.args))
-
- # Set up apollo
- apollo = ApolloInstance(apollo_host, apollo_admin_user, toolDirectory)
- jbrowse_hub_dir = _getHubDir(extra_files_path)
- apollo.loadHubToApollo(apollo_admin_user, species_name, jbrowse_hub_dir, admin=True)
- outHtml(outputFile, apollo_host, species_name)
-
- logging.info('#### JBrowseArchiveCreator: Congratulation! JBrowse Hub is uploaded! ####\n')
-
-def _getHubDir(extra_files_path):
- for root, dirs, files in os.walk(extra_files_path):
- for name in files:
- if name == "trackList.json":
- logging.debug("JBrowse hub directory: %s", root)
- return root
- logging.error("Cannot find jbrowsehub")
- exit(-1)
-
-def outHtml(outputFile, host_name, species_name):
- with open(outputFile, 'w') as htmlfile:
- htmlstr = 'The new Organism "%s" is created on Apollo:
' % species_name
- jbrowse_hub = '
View JBrowse Hub on Apollo' % host_name
- htmlstr += jbrowse_hub
- htmlfile.write(htmlstr)
-
-if __name__ == "__main__":
- main(sys.argv)
\ No newline at end of file
diff -r 8ff4b84d709f -r 6f262a92e8dc jbrowsehubToApollo.xml
--- a/jbrowsehubToApollo.xml Wed Oct 25 12:41:34 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-
-
- This Galaxy tool is used to prepare your files to be ready for displaying on JBrowse with Apollo plugin
-
-
-
- apollo_api
-
-
-
-
-
-
-
-
-import json
-import sys
-
-file_path = sys.argv[1]
-#set global data_parameter_dict = {}
-#silent $data_parameter_dict.update({"species_name": str($species_name)})
-#set apollo_admin = {"user_email": str($admin_username), "password": str($admin_password)}
-#silent $data_parameter_dict.update({"apollo_admin": $apollo_admin})
-##silent $data_parameter_dict.update({"user_email": str($__user_email__)})
-#silent $data_parameter_dict.update({"tool_directory": str($__tool_directory__)})
-#silent $data_parameter_dict.update({"extra_files_path": str($jbrowse_hub.extra_files_path)})
-#silent $data_parameter_dict.update({"port": str($advanced_options.port)})
-#silent $data_parameter_dict.update({"debug_mode": str($advanced_options.debug_mode)})
-with open(file_path, 'w') as f:
- json.dump($data_parameter_dict, f)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Use this option if you are a G-OnRamp developer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- This Galaxy tool will load a jbrowse hub to Apollo instance for visualization and interactive annotation.
-
-
-
-
\ No newline at end of file
diff -r 8ff4b84d709f -r 6f262a92e8dc logging.json
--- a/logging.json Wed Oct 25 12:41:34 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-{
- "version": 1,
- "disable_existing_loggers": false,
- "formatters": {
- "simple": {
- "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
- }
- },
-
- "handlers": {
- "console": {
- "class": "logging.StreamHandler",
- "level": "INFO",
- "formatter": "simple",
- "stream": "ext://sys.stdout"
- },
-
- "console_stderr": {
- "class": "logging.StreamHandler",
- "level": "ERROR",
- "formatter": "simple",
- "stream": "ext://sys.stderr"
- }
- },
-
- "loggers": {
- "Reader": {
- "level": "INFO",
- "handlers": ["console"],
- "propagate": "yes"
- }
- },
-
- "root": {
- "level": "DEBUG",
- "handlers": ["console", "console_stderr"]
- }
-}
\ No newline at end of file
diff -r 8ff4b84d709f -r 6f262a92e8dc templates/__init__.py
diff -r 8ff4b84d709f -r 6f262a92e8dc templates/apollo-arrow.yml
--- a/templates/apollo-arrow.yml Wed Oct 25 12:41:34 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-## Apollo's Arrow: Global Configuration File.
-# Each stanza should contian a single galaxy server to control.
-#
-# You can set the key __default to the name of a default instance
-__default: local
-
-local:
- url: ${apollo_host}
- username: ${admin_user}
- password: ${admin_pw}
diff -r 8ff4b84d709f -r 6f262a92e8dc todo.md
--- a/todo.md Wed Oct 25 12:41:34 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-# JBrowseHubToApollo's TODO
-
-- [ ] Correct new Apollo user's email address. Galaxy santitizes '@' to '__at__'
-- [ ] Check password for admin login
-
-### DONE
-
-
-- [x] upload jbrowsehub to Apollo instance
diff -r 8ff4b84d709f -r 6f262a92e8dc tool_dependencies.xml
--- a/tool_dependencies.xml Wed Oct 25 12:41:34 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-
-
-
-
-
-
- https://github.com/galaxy-genome-annotation/python-apollo/archive/3.0.3.tar.gz
- $INSTALL_DIR/apollo
-
- export PYTHONPATH=$PYTHONPATH:$INSTALL_DIR/apollo &&
- python setup.py install --install-lib $INSTALL_DIR/apollo
-
-
- $INSTALL_DIR/apollo
- $INSTALL_DIR/apollo
-
-
-
-
-
-
-
-
diff -r 8ff4b84d709f -r 6f262a92e8dc util/Logger.py
--- a/util/Logger.py Wed Oct 25 12:41:34 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-import os
-import sys
-import json
-import logging
-import logging.config
-
-#from util.Filters import TraceBackFormatter
-
-class Logger(object):
- def __init__(self, tool_directory, debug="False", extra_files_path=None):
- self.tool_directory = tool_directory
- self.default_level = logging.INFO
- self.debug = debug
- self.extra_files_path = extra_files_path
-
- def setup_logging(self):
- """Setup logging configuration
- reference: https://fangpenlin.com/posts/2012/08/26/good-logging-practice-in-python/
- """
- config_path = os.path.join(self.tool_directory, 'logging.json')
- default_level=logging.INFO
- if self.debug.lower() == "true":
- default_level=logging.DEBUG
- if os.path.exists(config_path):
- with open(config_path, 'rt') as f:
- config = json.load(f)
- config["handlers"]["console"]["level"] = default_level
- if self.extra_files_path:
- for i in config["handlers"]:
- if "filename" in config["handlers"][i]:
- config["handlers"][i]["filename"] = os.path.join(self.extra_files_path, config["handlers"][i]["filename"])
- logging.config.dictConfig(config)
- else:
- logging.warn("Extra files path is not set. The log files will exist at current working directory instead of final output folder")
- else:
- logging.basicConfig(level=default_level)
- logging.warn("Cannot find logging configuration file!\n")
-
diff -r 8ff4b84d709f -r 6f262a92e8dc util/Reader.py
--- a/util/Reader.py Wed Oct 25 12:41:34 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-import json
-import re
-import logging
-import codecs
-import socket
-from apollo.ApolloUser import ApolloUser
-from util import santitizer
-
-class Reader(object):
-
- def __init__(self, input_json_file):
- self.inputFile = input_json_file
- self.args = self.loadJson()
-
-
- def loadJson(self):
- try:
- data_file = codecs.open(self.inputFile, 'r', 'utf-8')
- return json.load(data_file)
- except IOError:
- print "Cannot find JSON file\n"
- exit(1)
-
- def getJBrowseHubDir(self):
- try:
- return self.args["jbrowse_hub"]
- except KeyError:
- print ("jbrowse_hub is not defined in the input file!")
- exit(1)
-
- def getToolDir(self):
- try:
- return self.args["tool_directory"]
- except KeyError:
- print ("tool_directory is not defined in the input file!")
- exit(1)
-
- def getExtFilesPath(self):
- try:
- return self.args["extra_files_path"]
- except KeyError:
- print ("extra_files_path is not defined in the input file!")
- exit(1)
-
- def getUserEmail(self):
- try:
- return self.args["user_email"]
- except KeyError:
- print ("user_email is not defined in the input file!")
- exit(1)
-
- def getDebugMode(self):
- try:
- return self.args["debug_mode"]
- except KeyError:
- print ("debug_mode is not defined in the input file!")
- exit(1)
-
- def getPortNum(self):
- try:
- return self.args["port"]
- except KeyError:
- print ("port is not defined in the input file!")
- exit(1)
-
- def getApolloHost(self):
- #apollo_host = self.args.get("apollo_host")
- hostname = socket.gethostname()
- ip = socket.gethostbyname(hostname)
- protocol = socket.getprotobyname(hostname)
- apollo_host = str(protocol) + str(ip)
- return apollo_host
-
-
- def getSpeciesName(self):
- species_name = santitizer.sanitize_name_input(self.args["species_name"])
- return species_name
-
- def getAdminUser(self):
- admin_info = self.args.get("apollo_admin")
- user_email = admin_info['user_email']
- password = admin_info['password']
- apollo_admin = ApolloUser(user_email, password)
- return apollo_admin
-
- def getApolloUser(self):
- user_info = self.args.get("apollo_user")
- if not user_info:
- firstname = "demo"
- lastname = "user"
- password = "gonramp"
- user_email = self.getUserEmail()
- else:
- firstname = user_info['firstname']
- lastname = user_info['lastname']
- user_email = user_info['user_email']
- password = user_info['password']
- apollo_user = ApolloUser(user_email, firstname, lastname, password)
- return apollo_user
-
-
\ No newline at end of file
diff -r 8ff4b84d709f -r 6f262a92e8dc util/Reader.pyc
Binary file util/Reader.pyc has changed
diff -r 8ff4b84d709f -r 6f262a92e8dc util/__init__.py
diff -r 8ff4b84d709f -r 6f262a92e8dc util/__init__.pyc
Binary file util/__init__.pyc has changed
diff -r 8ff4b84d709f -r 6f262a92e8dc util/santitizer.py
--- a/util/santitizer.py Wed Oct 25 12:41:34 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf8 -*-
-
-"""
-This class handles the subprocess calls of the different tools used
-in HubArchiveCreator
-"""
-
-import logging
-import os
-import subprocess
-import sys
-import string
-import tempfile
-
-
-def prefixTrackName(filename):
- """
- santitize trackName. Because track name must begin with a letter and
- contain only the following chars: [a-zA-Z0-9_].
- See the "track" Common settings at:
- https://genome.ucsc.edu/goldenpath/help/trackDb/trackDbHub.html#bigPsl_-_Pairwise_Alignments
- skip the santitization for cytoBandIdeo track
- """
- if filename == 'cytoBandIdeo':
- return filename
- valid_chars = "_%s%s" % (string.ascii_letters, string.digits)
- sanitize_name = ''.join([c if c in valid_chars else '_' for c in filename])
- sanitize_name = "gonramp_" + sanitize_name
- return sanitize_name
-
-def sanitize_name_input(string_to_sanitize):
- """
- Sanitize the string passed in parameter by replacing '/' and ' ' by '_'
-
- :param string_to_sanitize:
- :return :
-
- :Example:
-
- >>> sanitize_name_input('this/is an//example')
- this_is_an__example
- """
- return string_to_sanitize \
- .replace("/", "_") \
- .replace(" ", "_")
-
-def sanitize_name_inputs(inputs_data):
- """
- Sanitize value of the keys "name" of the dictionary passed in parameter.
-
- Because sometimes output from Galaxy, or even just file name, from user inputs, have spaces.
- Also, it can contain '/' character and could break the use of os.path function.
-
- :param inputs_data: dict[string, dict[string, string]]
- """
- for key in inputs_data:
- inputs_data[key]["name"] = sanitize_name_input(inputs_data[key]["name"])
-
-def sanitize_group_name(group_name):
- return group_name.lower().replace(' ', '_')
-
-def sanitize_name(input_name):
- """
- Galaxy will name all the files and dirs as *.dat,
- the function can replace '.' to '_' for the dirs
- """
- validChars = "_-%s%s" % (string.ascii_letters, string.digits)
- sanitized_name = ''.join([c if c in validChars else '_' for c in input_name])
- return "gonramp_" + sanitized_name
diff -r 8ff4b84d709f -r 6f262a92e8dc util/santitizer.pyc
Binary file util/santitizer.pyc has changed
diff -r 8ff4b84d709f -r 6f262a92e8dc util/subtools.py
--- a/util/subtools.py Wed Oct 25 12:41:34 2017 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,160 +0,0 @@
-#!/usr/bin/env python
-
-"""
-This file include common used functions for converting file format to gff3
-"""
-from collections import OrderedDict
-import json
-import subprocess
-import os
-import sys
-import tempfile
-import string
-import logging
-
-class PopenError(Exception):
- def __init__(self, cmd, error, return_code):
- self.cmd = cmd
- self.error = error
- self.return_code = return_code
-
- def __str__(self):
- message = "The subprocess {0} has returned the error: {1}.".format(
- self.cmd, self.return_code)
- message = ','.join(
- (message, "Its error message is: {0}".format(self.error)))
- return repr(message)
-
-
-def _handleExceptionAndCheckCall(array_call, **kwargs):
- """
- This class handle exceptions and call the tool.
- It maps the signature of subprocess.check_call:
- See https://docs.python.org/2/library/subprocess.html#subprocess.check_call
- """
- stdout = kwargs.get('stdout', subprocess.PIPE)
- stderr = kwargs.get('stderr', subprocess.PIPE)
- shell = kwargs.get('shell', False)
- stdin = kwargs.get('stdin', None)
-
- cmd = array_call[0]
-
- output = None
- error = None
-
- # TODO: Check the value of array_call and <=[0]
- logging.debug("Calling {0}:".format(cmd))
- logging.debug("%s", array_call)
- logging.debug("---------")
-
- # TODO: Use universal_newlines option from Popen?
- try:
- p = subprocess.Popen(array_call, stdout=stdout,
- stderr=stderr, shell=shell, stdin=stdin)
-
- # TODO: Change this because of possible memory issues => https://docs.python.org/2/library/subprocess.html#subprocess.Popen.communicate
-
- output, error = p.communicate()
-
- if stdout == subprocess.PIPE:
- logging.debug("\t{0}".format(output))
- else:
- logging.debug("\tOutput in file {0}".format(stdout.name))
- # If we detect an error from the subprocess, then we raise an exception
- # TODO: Manage if we raise an exception for everything, or use CRITICAL etc... but not stop process
- # TODO: The responsability of returning a sys.exit() should not be there, but up in the app.
- if p.returncode:
- if stderr == subprocess.PIPE:
- raise PopenError(cmd, error, p.returncode)
- else:
- # TODO: To Handle properly with a design behind, if we received a option as a file for the error
- raise Exception("Error when calling {0}. Error as been logged in your file {1}. Error code: {2}".format(cmd, stderr.name, p.returncode))
-
- except OSError as e:
- message = "The subprocess {0} has encountered an OSError: {1}".format(
- cmd, e.strerror)
- if e.filename:
- message = '\n'.join(
- (message, ", against this file: {0}".format(e.filename)))
- logging.error(message)
- sys.exit(-1)
- except PopenError as p:
- message = "The subprocess {0} has returned the error: {1}.".format(
- p.cmd, p.return_code)
- message = '\n'.join(
- (message, "Its error message is: {0}".format(p.error)))
-
- logging.exception(message)
-
- sys.exit(p.return_code)
- except Exception as e:
- message = "The subprocess {0} has encountered an unknown error: {1}".format(
- cmd, e)
- logging.exception(message)
-
- sys.exit(-1)
- return output
-
-def arrow_add_organism(organism_name, organism_dir, public=False):
- array_call = ['arrow', 'organisms', 'add_organism', organism_name, organism_dir]
- if public:
- array_call.append('--public')
- p = _handleExceptionAndCheckCall(array_call)
- #p = subprocess.check_output(array_call)
- return p
-
-def arrow_create_user(user_email, firstname, lastname, password, admin=False):
- """ Create a new user of Apollo, the default user_role is "user" """
- array_call = ['arrow', 'users', 'create_user', user_email, firstname, lastname, password]
- if admin:
- array_call += ['--role', 'admin']
- logging.debug("%s", array_call)
- print array_call
- p = subprocess.check_output(array_call)
- print ("p = %s", p)
- return p
-
-def arrow_update_organism_permissions(user_id, organism, **user_permissions):
- array_call = ['arrow', 'users', 'update_organism_permissions', str(user_id), str(organism)]
- admin = user_permissions.get("admin", False)
- write = user_permissions.get("write", False)
- read = user_permissions.get("read", False)
- export = user_permissions.get("export", False)
- if admin:
- array_call.append('--administrate')
- if write:
- array_call.append('--write')
- if read:
- array_call.append('--read')
- if export:
- array_call.append('--export')
- p = subprocess.check_output(array_call)
- return p
-
-def arrow_get_users(user_email):
- array_call = ['arrow', 'users', 'get_users']
- logging.debug("%s", array_call)
- print array_call
- p = subprocess.check_output(array_call)
- all_users = json.loads(p)
- for d in all_users:
- if d['username'] == user_email:
- return d['userId']
- logging.error("Cannot find user %s", user_email)
-
-def verify_user_login(username, password, apollo_host):
- user_info = {'username': username, 'password': password}
- array_call = ['curl',
- '-b', 'cookies.txt',
- '-c', 'cookies.txt',
- '-H', 'Content-Type:application/json',
- '-d', json.dumps(user_info),
- apollo_host + '/Login?operation=login'
- ]
- p = _handleExceptionAndCheckCall(array_call)
- msg = json.loads(p)
- if 'error' in msg:
- logging.error("The Authentication for user %s failed. Get error message %s", username, msg['error'])
- exit(-1)
-
-
diff -r 8ff4b84d709f -r 6f262a92e8dc util/subtools.pyc
Binary file util/subtools.pyc has changed