Example #1
0
 def pic_verify(self):
     succ, msg = validate_pic(self.pic)
     if succ is False:
         alarm(ALARM_LEVEL.CRITICAL, ALM_POSTER_IMAGE_GONE,
               "picture of url{url} cannot be loaded, err({err_msg})\n"
               "\nlocation: \n{location}".\
               format(url=self.pic, err_msg=msg,
                      location=settings.show_exam_stack()))
         return False
     return True
Example #2
0
 def pic_verify(self):
     succ, msg = validate_pic(self.pic)
     if succ is False:
         alarm(ALARM_LEVEL.CRITICAL, ALM_POSTER_IMAGE_GONE,
               "picture of url{url} cannot be loaded, err({err_msg})\n"
               "\nlocation: \n{location}".\
               format(url=self.pic, err_msg=msg,
                      location=settings.show_exam_stack()))
         return False
     return True
Example #3
0
    def self_verify_basic(self):
        om_output("Basic verify the Facet %s" % self._short())
        settings.exam_stack_push(self)
        if not self.pic_verify():
            settings.exam_stack_pop()
            return False
        api = api_module.api_mapping[self.typecode]
        if self.typecode not in api_module.module_mapping:
            om_err_output(
                "Facet::self_verify_basic() no api module defined for "
                "typecode %s" % self.typecode)
            settings.exam_stack_pop()
            return False
        # get class type related to the typecode
        cl = api_module.module_mapping[self.typecode]
        m = cl(self.id)
        if not m.valid():
            om_err_output("apimodule is not valid for typecode %s" %
                          self.typecode)
            settings.exam_stack_pop()
            return False
        if not m.verify_basic():
            for ecode, emsgs in m.last_err.items():
                om_err_output("fail to basic verify %s" % (self._short()))
                alarm_msg = ""
                for m in emsgs:
                    om_err_output("meet error %s, %s" % (ecode, m))
                    alarm_msg += m + "\n"
                alm = None
                # check every error code for the api module, and send related
                # alarm according to the severity level
                alarm_msg += "\nlocation:\n%s" % settings.show_exam_stack()
                if ecode == ErrCode.RESOURCE_CANT_ACCESS:
                    alarm(ALARM_LEVEL.CRITICAL, ALM_NETWORK_ISSUE, alarm_msg)
                elif ecode == ErrCode.RESOURCE_OFFLINE:
                    alarm(ALARM_LEVEL.CRITICAL, ALM_MEDIA_OFFLINE, alarm_msg)
                elif ecode == ErrCode.DATA_INVALID:
                    alarm(ALARM_LEVEL.HIGH, ALM_MEDIA_DATA_INVALID, alarm_msg)
                elif ecode == ErrCode.BAD_LIST_VIEW_MEDIA or \
                         ecode == ErrCode.BAD_LIST_VIEW_IMAGE:
                    alarm(ALARM_LEVEL.HIGH, ALM_CATEGORY_HAS_BAD_MEDIAS,
                          alarm_msg)
                else:
                    alarm(ALARM_LEVEL.NORMAL, ALM_BASIC, alarm_msg)

            settings.exam_stack_pop()
            return False
        settings.exam_stack_pop()
        return True
Example #4
0
 def self_verify_basic(self):
     om_output("Basic verify the Facet %s"%self._short())
     settings.exam_stack_push(self)
     if not self.pic_verify():
         settings.exam_stack_pop()
         return False
     api = api_module.api_mapping[self.typecode]
     if self.typecode not in api_module.module_mapping:
         om_err_output("Facet::self_verify_basic() no api module defined for "
                       "typecode %s"%self.typecode)
         settings.exam_stack_pop()
         #return False
         # currently the not support api module need not return fail
         return True
     # get class type related to the typecode
     cl = api_module.module_mapping[self.typecode]
     m = cl(self.id)
     if not m.valid():
         om_err_output("apimodule is not valid for typecode %s"%self.typecode)
         settings.exam_stack_pop()
         return False
     if not m.verify_basic():
         for ecode, emsgs in m.last_err.items():
             om_err_output("fail to basic verify %s"%(self._short()))
             alarm_msg = ""
             for m in emsgs:
                 om_err_output("meet error %s, %s"%(ecode, m))
                 alarm_msg += m + "\n"
             alm = None
             # check every error code for the api module, and send related
             # alarm according to the severity level
             alarm_msg += "\nlocation:\n%s"%settings.show_exam_stack()
             if ecode == ErrCode.RESOURCE_CANT_ACCESS:
                 alarm(ALARM_LEVEL.CRITICAL, ALM_NETWORK_ISSUE, alarm_msg)
             elif ecode == ErrCode.RESOURCE_OFFLINE:
                 alarm(ALARM_LEVEL.CRITICAL, ALM_MEDIA_OFFLINE, alarm_msg)
             elif ecode == ErrCode.DATA_INVALID:
                 alarm(ALARM_LEVEL.HIGH, ALM_MEDIA_DATA_INVALID, alarm_msg)
             elif ecode == ErrCode.BAD_LIST_VIEW_MEDIA or \
                      ecode == ErrCode.BAD_LIST_VIEW_IMAGE:
                 alarm(ALARM_LEVEL.HIGH, ALM_CATEGORY_HAS_BAD_MEDIAS, alarm_msg)
             else:
                 alarm(ALARM_LEVEL.NORMAL, ALM_BASIC, alarm_msg)
                 
         settings.exam_stack_pop()
         return False
     settings.exam_stack_pop()
     return True
Example #5
0
def warn(string):
    ''' warn does not require program exit, so just record the
    recent warn mesage '''
    settings.last_warn_stack_msg = settings.show_exam_stack()
    settings.last_warn_msg = string
    log("WARN: " + string)
Example #6
0
def warn(string):
    ''' warn does not require program exit, so just record the
    recent warn mesage '''
    settings.last_warn_stack_msg = settings.show_exam_stack()
    settings.last_warn_msg = string
    log("WARN: " + string)