def get_worksheets_info(): """Gets information related to the Excel worksheets. This information contains the names of the worksheets in a workbook, the names of the columns in the first worksheet, and column indices that contain HED tags in the first worksheet. Parameters ---------- Returns ------- string A serialized JSON string containing information related to the Excel worksheets. """ worksheets_info = {} try: worksheets_info = utils.find_worksheets_info(request) if error_constants.ERROR_KEY in worksheets_info: return handle_http_error( error_constants.INTERNAL_SERVER_ERROR, worksheets_info[error_constants.ERROR_KEY]) except: worksheets_info[error_constants.ERROR_KEY] = traceback.format_exc() return json.dumps(worksheets_info)
def download_file_in_upload_directory(filename): """Downloads the specified other from the upload other. Parameters ---------- filename: string The name of the other to download from the upload other. Returns ------- File The contents of a other in the upload directory to send to the client. """ download_response = utils.generate_download_file_response(filename) if isinstance(download_response, str): handle_http_error(error_constants.NOT_FOUND_ERROR, download_response) return download_response
def get_validation_results(): """Validate the spreadsheet in the form after submission and return an attachment other containing the output. Parameters ---------- Returns ------- string A serialized JSON string containing information related to the worksheet columns. If the validation fails then a 500 error message is returned. """ validation_status = utils.report_spreadsheet_validation_status(request) if error_constants.ERROR_KEY in validation_status: return handle_http_error(error_constants.INTERNAL_SERVER_ERROR, validation_status[error_constants.ERROR_KEY]) return json.dumps(validation_status)
def delete_file_in_upload_directory(filename): """Deletes the specified other from the upload other. Parameters ---------- filename: string The name of the other to delete from the upload other. Returns ------- """ if hed.util.file_util.delete_file_if_it_exist( os.path.join(app_config['UPLOAD_FOLDER'], filename)): return Response(status=error_constants.NO_CONTENT_SUCCESS) else: return handle_http_error(error_constants.NOT_FOUND_ERROR, error_constants.FILE_DOES_NOT_EXIST)
def get_hed_version_in_file(): """Gets information related to the spreadsheet columns. This information contains the names of the spreadsheet columns and column indices that contain HED tags. Parameters ---------- Returns ------- string A serialized JSON string containing information related to the spreadsheet columns. """ hed_info = utils.find_hed_version_in_file(request) if error_constants.ERROR_KEY in hed_info: return handle_http_error(error_constants.INTERNAL_SERVER_ERROR, hed_info[error_constants.ERROR_KEY]) return json.dumps(hed_info)
def get_EEG_events_validation_results(): """Validate the hed strings associated with EEG events after submission from HEDTools EEGLAB plugin and return json string containing the output. Parameters ---------- Returns ------- string A serialized JSON string containing information related to the EEG events' hed-strings. If the validation fails then a 500 error message is returned. """ validation_status = utils.report_eeg_events_validation_status(request) if error_constants.ERROR_KEY in validation_status: return handle_http_error(error_constants.INTERNAL_SERVER_ERROR, validation_status[error_constants.ERROR_KEY]) return json.dumps(validation_status)