Changeset 3381


Ignore:
Timestamp:
08/15/13 10:56:56 (11 years ago)
Author:
sanmai
Message:
  • Fix validation: it was always judged as valid even if invalid.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • monitoring/plugins/mpi/generic_tla_monitoring.py

    r3316 r3381  
    5050    special_plugin_file_name = kwargs['special_plugin_file_name'] # X-
    5151
    52     timestamp                = datetime.datetime.today().isoformat()
     52    timestamp = datetime.datetime.today().isoformat()
     53    valid = False
    5354
    5455    try :
    55         special_validator(data,
    56                           descriptive_string,
    57                           kwargs)
     56        valid = special_validator(data,
     57                                  descriptive_string,
     58                                  kwargs)
    5859    except :
    59         traceback_string  = traceback.format_exc()
     60        traceback_string = traceback.format_exc()
    6061        #pdb.set_trace()
    6162
    62         err_log_file_path = os.path.normpath("/tmp/" + special_plugin_file_name + "_err_well-formedness_check__" + descriptive_string.replace('/' , '%2F') + "__" + timestamp + ".log")
     63        err_log_file_path = os.path.normpath("/tmp/" + special_plugin_file_name + "_err_generic_validator__" + descriptive_string.replace('/' , '%2F') + "__" + timestamp + ".log")
    6364
    6465        with open(name = err_log_file_path,
    6566                  mode = "wt") as debugging_output_file :
    6667            debugging_output_file.write(traceback_string)
    67        
    68         return False
    69     else :
    70         return True
     68        sys.exit(999) # X- exit with some special error status
     69   
     70    return valid
    7171
    7272
     
    9494                                       special_validator)
    9595
    96     return (wellformedness)
     96    return wellformedness
    9797
    9898
     
    110110                                       special_validator)
    111111
    112     return (wellformedness)
     112    return wellformedness
    113113
    114114
     
    120120                          descriptive_string,
    121121                          kwargs) :
     122
    122123        try :           
    123124            data_tree_root_element = xml.etree.ElementTree.XML(text = data)
     
    125126            if data_tree_root_element.tag == kwargs['valid_root_element_tag'] :
    126127                return True
    127 
    128             return False
     128            else :
     129                return False
    129130        except :
    130131            return False
     
    134135                                       kwargs,
    135136                                       special_validator)
    136     return (wellformedness)
     137    return wellformedness
    137138
    138139
     
    234235    else :
    235236        try :
    236             response         = conn.getresponse()
    237 
    238             data             = response.read()
     237            response = conn.getresponse()
     238
     239            data = response.read()
    239240           
    240241            conn.close()
     
    255256            # HTTP status codes 200 and 302
    256257            # X- Resolve redirect in case of HTTP status == 302
    257                 well_formed  = validator(data                   = data,
     258                well_formed = validator(data                    = data,
    258259                                         descriptive_string     = UP_URL,
    259260                                         **validator_arguments) # ['validator_arguments'])
Note: See TracChangeset for help on using the changeset viewer.