Пример #1
0
def register(name, display_name, category, mimetype_regexp, session):
    try:
        probe = Probe.get_by_name(name, session)
        log.info(
            "probe %s already registred "
            "updating parameters: "
            "[display_name:%s cat:%s regexp:%s]", name, display_name, category,
            mimetype_regexp)
        probe.display_name = display_name
        probe.category = category
        probe.mimetype_regexp = mimetype_regexp
        probe.online = True
        probe.update(['category', 'mimetype_regexp', 'online'], session)
    except IrmaDatabaseResultNotFound:
        log.info(
            "register probe %s"
            " with parameters: "
            "[display_name:%s cat:%s regexp:%s]", name, display_name, category,
            mimetype_regexp)
        probe = Probe(name=name,
                      display_name=display_name,
                      category=category,
                      mimetype_regexp=mimetype_regexp,
                      online=True)
        probe.save(session)
        return
Пример #2
0
def register(name, display_name, category, mimetype_regexp, session):
    try:
        probe = Probe.get_by_name(name, session)
        log.info(
            "probe %s already registred "
            "updating parameters: "
            "[display_name:%s cat:%s regexp:%s]", name, display_name, category,
            mimetype_regexp)
        session.query(Probe)\
            .filter_by(id=probe.id)\
            .update({'category': category, 'mimetype_regexp': mimetype_regexp,
                     'online': True, 'display_name': display_name})
    except IrmaDatabaseResultNotFound:
        log.info(
            "register probe %s"
            " with parameters: "
            "[display_name:%s cat:%s regexp:%s]", name, display_name, category,
            mimetype_regexp)
        probe = Probe(name=name,
                      display_name=display_name,
                      category=category,
                      mimetype_regexp=mimetype_regexp,
                      online=True)
        session.add(probe)
        return
Пример #3
0
 def test001___init__(self):
     probe = Probe(self.name, self.display_name, self.category,
                   self.mimetype_regexp, self.online)
     self.assertEqual(probe.name, self.name)
     self.assertEqual(probe.display_name, self.display_name)
     self.assertEqual(probe.category, self.category)
     self.assertEqual(probe.mimetype_regexp, self.mimetype_regexp)
     self.assertEqual(probe.online, self.online)