Ignore:
Timestamp:
06/11/13 09:33:58 (11 years ago)
Author:
jripsl
Message:

Improve "config-card" file handling.
Use explicite function for "repo_io" module initialization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Monitoring/Watch/watch

    r866 r871  
    2929import smon.types 
    3030 
    31 """ 
    32 Code list reminder 
    33  
    34 0000 (la simulation démarre) 
    35 1000 (le job d'une simulation démarre) 
    36 2000 (PushStack) 
    37 3000 (PopStack OK) 
    38 9000 (PopStack NOK) 
    39 9999 (FATAL) 
    40 """ 
    41  
    4231class Mail(): 
    4332 
     
    129118        @classmethod 
    130119        def start(cls): 
    131                 pass 
     120                repo_io.init() # open DB connection 
    132121 
    133122        @classmethod 
    134123        def stop(cls): 
    135                 pass 
     124                repo_io.free() # close DB connection 
    136125 
    137126        @classmethod 
     
    174163 
    175164                                # debug 
    176                                 print " [x] Received %s" % field 
     165                                #print " [x] Received %s" % field 
    177166 
    178167                                splitted_field=field.split(":") 
     
    185174 
    186175                        # debug 
    187                         print " [x] Received %s (encoded)" % l__tmp_dic["body"] 
     176                        #print " [x] Received %s (encoded)" % l__tmp_dic["body"] 
    188177 
    189178                         
     
    194183                        # debug 
    195184                        #print " [x] Received %s" % raw_msg 
    196                         print " [x] Received %s (uudecoded)" % base64_decoded_msg  
    197185                        #print " [x] Received %s (uudecoded)" % base64_decoded_msg  
    198  
    199  
     186                        #print " [x] Received %s (uudecoded)" % base64_decoded_msg  
     187 
     188 
     189                        # message deserialization  
    200190                        message=None 
    201191                        try: 
    202                                 # body deserialization  
    203192                                JSON_msg=json.loads(base64_decoded_msg) 
    204193                                message=smon.types.Message(JSON_msg)      # all JSON object members will be available in smon.types.Message object 
    205194 
    206                                 if "file" in l__tmp_dic: 
    207  
    208                                         # base64 decode file 
    209                                         base64_decoded_file=base64.b64decode(l__tmp_dic["file"]) 
    210  
    211                                         # add into msg 
    212                                         message.file=base64_decoded_file 
    213  
     195 
     196 
     197                        except Exception,e: 
     198                                print "ERR009 - exception occurs (exception=%s,msg=%s)"%(str(e),base64_decoded_msg) 
     199 
     200                                #traceback.print_exc() 
     201                                #raise 
     202 
     203 
     204 
     205                        # manage config-card file which is attached to the "0000" type message (this file is base64 encoded and need to be unencoded) 
     206                        # 
     207                        if "file" in l__tmp_dic: 
     208 
     209                                # base64 decode file 
     210                                base64_decoded_file=base64.b64decode(l__tmp_dic["file"]) 
     211 
     212                                # add as msg attribute 
     213                                message.file=base64_decoded_file 
     214 
     215 
     216 
     217                        # execute actions 
     218                        try: 
    214219                                # message code based action 
    215                                 Actions.execActions(message) 
    216  
     220                                #Actions.execActions(message) 
     221                                pass 
    217222                        except Exception,e: 
    218                                 print "Exception occurs (exception=%s,msg=%s)"%(str(e),base64_decoded_msg) 
    219  
    220                                 #traceback.print_exc() 
     223                                print "ERR019 - exception occurs (exception=%s,msg=%s)"%(str(e),base64_decoded_msg) 
     224 
     225                                traceback.print_exc() 
    221226 
    222227                                raise 
     228 
     229 
    223230 
    224231                self.channel.basic_consume(callback, queue='myqueue', no_ack=True) 
Note: See TracChangeset for help on using the changeset viewer.