def process_request(cls, params_dict): probes_file = params_dict[ParameterFactory.file("Probes file.")][0] json_response = { FILENAME: probes_file.filename, ERROR: "", } http_status_code = 200 file_uuid = str(uuid4()) path = os.path.join(PROBES_UPLOAD_FOLDER, file_uuid) existing_filenames = cls._DB_CONNECTOR.distinct( PROBES_COLLECTION, FILENAME) if os.path.exists(path) or probes_file.filename in existing_filenames: http_status_code = 403 elif validate_fasta(probes_file) == False: http_status_code = 415 else: try: probes_file.save(path) probes_file.close() json_response[URL] = "http://%s/probes/%s" % (HOSTNAME, file_uuid) json_response[FILEPATH] = path json_response[UUID] = file_uuid json_response[DATESTAMP] = datetime.today().strftime( TIME_FORMAT) json_response[TYPE] = "probes" if "." in probes_file.filename: json_response[FORMAT] = probes_file.filename.split(".")[-1] else: json_response[FORMAT] = "Unknown" cls._DB_CONNECTOR.insert(PROBES_COLLECTION, [json_response]) del json_response[ID] except: json_response[ERROR] = str(sys.exc_info()[1]) http_status_code = 500 return make_response(jsonify(json_response), http_status_code)
def process_request(cls, params_dict): probes_file = params_dict[ParameterFactory.file("Probes file.")][0] json_response = { FILENAME: probes_file.filename, ERROR: "", } http_status_code = 200 file_uuid = str(uuid4()) path = os.path.join(PROBES_UPLOAD_FOLDER, file_uuid) existing_filenames = cls._DB_CONNECTOR.distinct(PROBES_COLLECTION, FILENAME) if os.path.exists(path) or probes_file.filename in existing_filenames: http_status_code = 403 elif validate_fasta(probes_file) == False: http_status_code = 415 else: try: probes_file.save(path) probes_file.close() json_response[URL] = "http://%s/probes/%s" % (HOSTNAME, file_uuid) json_response[FILEPATH] = path json_response[UUID] = file_uuid json_response[DATESTAMP] = datetime.today().strftime(TIME_FORMAT) json_response[TYPE] = "probes" if "." in probes_file.filename: json_response[FORMAT] = probes_file.filename.split(".")[-1] else: json_response[FORMAT] = "Unknown" cls._DB_CONNECTOR.insert(PROBES_COLLECTION, [json_response]) del json_response[ID] except: json_response[ERROR] = str(sys.exc_info()[1]) http_status_code = 500 return make_response(jsonify(json_response), http_status_code)
def parameters(cls): parameters = [ParameterFactory.file("Probes file.")] return parameters
def parameters(cls): parameters = [ ParameterFactory.file("Probes file.") ] return parameters
def parameters(cls): parameters = [ ParameterFactory.file("Targets FASTA file.") ] return parameters