# HG changeset patch # User fabio # Date 1517523210 18000 # Node ID e780b47013dfaf3db9d19fc461a6da159dee7c08 # Parent b5f070767ed4414f2756ce943c432975b20fbbfd Uploaded 20180201 diff -r b5f070767ed4 -r e780b47013df ._.shed.yml Binary file ._.shed.yml has changed diff -r b5f070767ed4 -r e780b47013df ._example.tsv Binary file ._example.tsv has changed diff -r b5f070767ed4 -r e780b47013df ._query.py Binary file ._query.py has changed diff -r b5f070767ed4 -r e780b47013df ._query.xml Binary file ._query.xml has changed diff -r b5f070767ed4 -r e780b47013df query.py --- a/query.py Thu Feb 01 16:23:26 2018 -0500 +++ b/query.py Thu Feb 01 17:13:30 2018 -0500 @@ -18,9 +18,12 @@ __version__ = "1.0.0"; VALID_CHARS = '.-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ' +# in the case of collections, exitcodes equal to 0 and 1 are not considered errors +ERR_EXIT_CODE = 2; +OK_EXIT_CODE = 0; -# in the case of collections, exitcodes equal to 0 and 1 are not considered errors -def raiseException( exitcode, message, errorfilepath ): +def raiseException( exitcode, message, output_dir_path, errorfilename ): + errorfilepath = os.path.join(output_dir_path, errorfilename+"_txt"); with open(errorfilepath, 'w') as out: out.write(message); sys.exit(exitcode); @@ -66,7 +69,7 @@ task_processed = True; break; elif json_status_content['state'] in ['FAILURE', 'REVOKED']: - return raiseException( 1, "Task ID: "+str(task_id)+"\nTask status: "+str(json_status_content['state']), str(options.errorfile) ); + return raiseException( ERR_EXIT_CODE, "Task ID: "+str(task_id)+"\nTask status: "+str(json_status_content['state']), output_dir_path, str(options.errorfile) ); else: time.sleep(QUERY_DELAY); # in seconds @@ -81,9 +84,9 @@ accessions_list = accessions_list + accession_number + "\n"; with open(output_file_path, 'w') as out: out.write(accessions_list.strip()); - return sys.exit(0); + return sys.exit(OK_EXIT_CODE); else: - return raiseException( 1, "Unable to query the remote server. Please try again in a while.", str(options.errorfile) ); + return raiseException( ERR_EXIT_CODE, "Unable to query the remote server. Please try again in a while.", output_dir_path, str(options.errorfile) ); def query( options, args ): output_dir_path = options.outputdir; @@ -110,13 +113,13 @@ seq_id = ''.join(e for e in seq_id if e in VALID_CHARS) seq_text = line_split[1]; if seq_id in multiple_data: - return raiseException( 1, "Error: the id '"+seq_id+"' is duplicated", str(options.errorfile) ); + return raiseException( ERR_EXIT_CODE, "Error: the id '"+seq_id+"' is duplicated", output_dir_path, str(options.errorfile) ); multiple_data[seq_id] = seq_text; if len(multiple_data) > 0: return query_request( options, args, multiple_data ); #return echo( options, args ); else: - return raiseException( 1, "An error has occurred. Please be sure that your input files are valid.", str(options.errorfile) ); + return raiseException( ERR_EXIT_CODE, "An error has occurred. Please be sure that your input files are valid.", output_dir_path, str(options.errorfile) ); else: # try with the sequence in --sequence text_content = options.sequences; @@ -136,16 +139,16 @@ seq_id = ''.join(e for e in seq_id if e in VALID_CHARS) seq_text = line_split[1]; if seq_id in multiple_data: - return raiseException( 1, "Error: the id '"+seq_id+"' is duplicated", str(options.errorfile) ); + return raiseException( ERR_EXIT_CODE, "Error: the id '"+seq_id+"' is duplicated", output_dir_path, str(options.errorfile) ); multiple_data[seq_id] = seq_text; if len(multiple_data) > 0: return query_request( options, args, multiple_data ); #return echo( options, args ); else: - return raiseException( 1, "An error has occurred. Please be sure that your input files are valid.", str(options.errorfile) ); + return raiseException( ERR_EXIT_CODE, "An error has occurred. Please be sure that your input files are valid.", output_dir_path, str(options.errorfile) ); else: - return raiseException( 1, "You have to insert at least one row formatted as a tab delimited (ID, SEQUENCE) couple", str(options.errorfile) ); - return 1; + return raiseException( ERR_EXIT_CODE, "You have to insert at least one row formatted as a tab delimited (ID, SEQUENCE) couple", output_dir_path, str(options.errorfile) ); + return ERR_EXIT_CODE; def __main__(): # Parse the command line options diff -r b5f070767ed4 -r e780b47013df query.xml --- a/query.xml Thu Feb 01 16:23:26 2018 -0500 +++ b/query.xml Thu Feb 01 17:13:30 2018 -0500 @@ -1,5 +1,5 @@ - + the AllSome Sequence Bloom Tree python @@ -25,6 +25,7 @@ #end if --outputdir 'collection_content' + --errorfile 'Error Log File' ]]>