comparison util/subtools.py @ 2:8ff4b84d709f draft

planemo upload for repository https://github.com/Yating-L/jbrowsehub-to-apollo.git commit 324276a31f1d9e410c37d4514ad9432ba6051e35-dirty
author yating-l
date Wed, 25 Oct 2017 12:41:34 -0400
parents 2ae1e96a8380
children
comparison
equal deleted inserted replaced
1:2ae1e96a8380 2:8ff4b84d709f
61 else: 61 else:
62 logging.debug("\tOutput in file {0}".format(stdout.name)) 62 logging.debug("\tOutput in file {0}".format(stdout.name))
63 # If we detect an error from the subprocess, then we raise an exception 63 # If we detect an error from the subprocess, then we raise an exception
64 # TODO: Manage if we raise an exception for everything, or use CRITICAL etc... but not stop process 64 # TODO: Manage if we raise an exception for everything, or use CRITICAL etc... but not stop process
65 # TODO: The responsability of returning a sys.exit() should not be there, but up in the app. 65 # TODO: The responsability of returning a sys.exit() should not be there, but up in the app.
66 #if p.returncode:
67 if p.returncode: 66 if p.returncode:
68 if stderr == subprocess.PIPE: 67 if stderr == subprocess.PIPE:
69 raise PopenError(cmd, error, p.returncode) 68 raise PopenError(cmd, error, p.returncode)
70 else: 69 else:
71 # TODO: To Handle properly with a design behind, if we received a option as a file for the error 70 # TODO: To Handle properly with a design behind, if we received a option as a file for the error
141 for d in all_users: 140 for d in all_users:
142 if d['username'] == user_email: 141 if d['username'] == user_email:
143 return d['userId'] 142 return d['userId']
144 logging.error("Cannot find user %s", user_email) 143 logging.error("Cannot find user %s", user_email)
145 144
146 def verify_user_login(username, password): 145 def verify_user_login(username, password, apollo_host):
147 user_info = {'username': username, 'password': password} 146 user_info = {'username': username, 'password': password}
148 array_call = ['curl', 147 array_call = ['curl',
149 '-b', 'cookies.txt', 148 '-b', 'cookies.txt',
150 '-c', 'cookies.txt', 149 '-c', 'cookies.txt',
151 '-H', 'Content-Type:application/json', 150 '-H', 'Content-Type:application/json',
152 '-d', json.dumps(user_info), 151 '-d', json.dumps(user_info),
153 'http://localhost:8080/apollo/Login?operation=login' 152 apollo_host + '/Login?operation=login'
154 ] 153 ]
155 p = _handleExceptionAndCheckCall(array_call) 154 p = _handleExceptionAndCheckCall(array_call)
156 msg = json.loads(p) 155 msg = json.loads(p)
157 if 'error' in msg: 156 if 'error' in msg:
158 logging.error("The Authentication for user %s failed. Get error message %s", username, msg['error']) 157 logging.error("The Authentication for user %s failed. Get error message %s", username, msg['error'])