def __init__(self, url, profile): m = re.match(r"(http://)?([a-zA-Z0-9-.]+)?([a-zA-Z0-9-._/?=&%]*)", url) if m is None: raise Exception("Invalid URL: {}".format(url)) self._url = url if isinstance(profile, profiles.base.ProfileBase): self._profile = profile elif isinstance(profile, str): self._profile = profiles.get_profile_by_name(profile)
def execute(self): logging.info("Setting up observer '{}'".format(self._cmd_info["name"])) profile = profiles.get_profile_by_name(self._cmd_info["profile"]) store = self._setup_store(self._cmd_info["store"]) assessor = AdAssessor() for json in self._cmd_info["criteria"]: assessor.add_criterion(AdCriterion.from_json(json)) notification_server = NotificationServer() # Add an empty notification server observer = Observer(url=self._cmd_info["url"], profile=profile, # Setup the actual observer store=store, assessor=assessor, notifications=notification_server, update_interval=self._cmd_info["interval"], name=self._cmd_info["name"]) self._server.add_observer(observer)
def execute(self): logging.info("Setting up observer '{}'".format(self._cmd_info["name"])) profile = profiles.get_profile_by_name(self._cmd_info["profile"]) store = self._setup_store(self._cmd_info["store"]) assessor = AdAssessor() for json in self._cmd_info["criteria"]: assessor.add_criterion(AdCriterion.from_json(json)) notification_server = NotificationServer( ) # Add an empty notification server observer = Observer( url=self._cmd_info["url"], profile=profile, # Setup the actual observer store=store, assessor=assessor, notifications=notification_server, update_interval=self._cmd_info["interval"], name=self._cmd_info["name"]) self._server.add_observer(observer)