def post(self, tracking_id): logger.debug("requeue import tracking") self.check_token() values = self.post_values() self.require_arguments(values, ['state']) state = values['state'] try: tracking_id = utils.decrypt_value(tracking_id) tracking = db.get_import_tracking(tracking_id) print(tracking) tracking['state'] = state for k in ['id', 'create_time', 'update_time']: del tracking[k] tracking[ 'log'] = f"requeue import tracker {tracking_id} and changed state to {state}" tracking_id = db.add_import_tracking(tracking) tracking_id = utils.encrypt_value(tracking_id) submit_mq_job(tracking_id, "import") self.send_response_200() except Exception as e: logger.error(f"Request import tracking error {e}") import stacktrace self.send_response_404()
def post(self, state_id): logger.debug(f"POST VALUES: {self.request.body}") nels_id = int(self.get_body_argument("nelsId", default=None)) location = self.get_body_argument("selectedFiles", default=None) state = states.get(state_id) if state is None: self.send_response_404() logger.debug(f"State info for import: {state}") try: user = state['user'] tracking_id = self._register_import(user, nels_id, location) tracking_id = utils.encrypt_value(tracking_id) submit_mq_job(tracking_id, "import") self.redirect(galaxy_url) except Exception as e: logger.error(f"Error during import registation: {e}") logger.debug(f"State info for import: {state}") logger.debug(f"nels_id: {nels_id}") logger.debug(f"location: {location}") self.send_response_400()
def _usegalaxy_export(self): user = self.get_user() current_history_id = user['current_history_id'] if not isinstance(current_history_id, int): current_history_id = utils.encrypt_value(str(current_history_id)) return user['email'], current_history_id
def post(self, instance, state_id): # logger.debug(f"POST VALUES: {self.request.body}") nels_id = int(self.get_body_argument("nelsId", default=None)) location = self.get_body_argument("selectedFiles", default=None) if instance == instance_id: logger.debug("Direct access to state") state = states.get(state_id) else: logger.debug("Callback access to state") state = instances[instance]['api'].get_state(state_id) if state is None: self.send_response_404() logger.debug(f"State info for export: {state}") try: instance_name = instances[instance]['name'] user = state['user'] history_id = state['history_id'] tracking_id = self._register_export(instance_name, user, history_id, nels_id, location) tracking_id = utils.encrypt_value(tracking_id) submit_mq_job(tracking_id, "export") logger.info(f"Redirecting to {instances[instance]['url']}") self.redirect(instances[instance]['url']) except Exception as e: logger.error(f"Error during export registation: {e}") logger.debug(f"State info for export: {state}") logger.debug(f"nels_id: {nels_id}") logger.debug(f"location: {location}") self.send_response_400()
def get(self): logger.debug("request history export") user = self.get_user() logger.debug("user") logger.debug(user) if user is None or user == []: return self.send_response_401() data = { 'user': user['email'], 'history_id': utils.encrypt_value(user['current_history_id']) } uuid = states.set(data) redirect_url = f"{nels_url}/welcome.xhtml" redirect_url += f"?appCallbackUrl={master_url}/export/" + instance_id + "/" + uuid + "/" if DEV: print(redirect_url) return self.redirect(redirect_url)
def get(self, value): logger.debug("encrypt value") self.check_token() encrypted = utils.encrypt_value(value) return self.send_response(data={'value': encrypted})
def test_encrypt_int(): utils.init('Secret_key') e = utils.encrypt_value(42) assert e == 'bc729496af0697be'
def test_encrypt_str(): utils.init('Secret_key') e = utils.encrypt_value('42') assert e == 'bc729496af0697be'