Mercurial > repos > xuebing > sharplabtool
comparison tools/validation/fix_errors_code.py @ 0:9071e359b9a3
Uploaded
| author | xuebing |
|---|---|
| date | Fri, 09 Mar 2012 19:37:19 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:9071e359b9a3 |
|---|---|
| 1 # runs after the job (and after the default post-filter) | |
| 2 | |
| 3 import pkg_resources | |
| 4 pkg_resources.require( "bx-python" ) | |
| 5 | |
| 6 from galaxy import datatypes, jobs, util | |
| 7 # needed to reference ParseError types, is this bad? | |
| 8 from bx.tabular.io import * | |
| 9 from bx.intervals.io import * | |
| 10 import sys, tempfile, os | |
| 11 | |
| 12 def validate(incoming): | |
| 13 """Validator""" | |
| 14 #raise Exception, 'not quite right' | |
| 15 pass | |
| 16 | |
| 17 def exec_before_job( app, inp_data, out_data, param_dict, tool=None): | |
| 18 """Build a temp file with errors in it""" | |
| 19 errors = [] | |
| 20 for name, data in inp_data.items(): | |
| 21 validation_errors = data.validation_errors | |
| 22 for error in validation_errors: | |
| 23 # build dummy class | |
| 24 try: | |
| 25 temp = eval(error.err_type)() | |
| 26 except: | |
| 27 temp = object() | |
| 28 # stuff attributes | |
| 29 temp.__dict__ = util.string_to_object( error.attributes ) | |
| 30 errors.append(temp) | |
| 31 # There *should* only be 1 input, so we assume there is and continue | |
| 32 # base64 pickel | |
| 33 errors_str = util.object_to_string( errors ) | |
| 34 # write | |
| 35 database_tmp = "./database/tmp" # globaly visible path | |
| 36 error_file = tempfile.NamedTemporaryFile(mode="w", dir=database_tmp, suffix=".b64") | |
| 37 error_file_name = error_file.name | |
| 38 error_file.close() | |
| 39 error_file = open(error_file_name, "w") | |
| 40 error_file.write(errors_str) | |
| 41 error_file.close() | |
| 42 param_dict["errorsfile"] = error_file_name | |
| 43 | |
| 44 | |
| 45 def exec_after_process( app, inp_data, out_data, param_dict, tool=None, stdout=None, stderr=None): | |
| 46 # in a perfect world, changes to param_dict would persist | |
| 47 # for now, unlink from tool | |
| 48 # os.unlink(param_dict["errorsfile"]) | |
| 49 pass |
