

def poll(self):
    self._logger.debug('Requesting list of deployments')
    deployments = self._get_deployments()
    if (deployments is None):
        self._logger.info('No deployments found')
        return
    if (len(deployments) is 0):
        self._logger.info('Empty list of deployments')
        return
    last_deployment = deployments[0]
    last_assembled_date = self._to_date(last_deployment['assembled'])
    index_date = self._get_last_date()
    self._logger.debug(('Index date is %s' % index_date))
    if (index_date is None):
        self._logger.info('Initializing index')
        self._set_last_date(last_assembled_date)
        index_date = self._get_last_date()
    if (last_assembled_date > index_date):
        self._logger.info('Found deployments to trigger')
        for deployment in deployments:
            if (self._to_date(deployment['assembled']) > index_date):
                self._logger.info(('Raising trigger for %s' % deployment['id']))
                self._dispatch_trigger_for_payload(deployment)
            else:
                break
        self._set_last_date(last_assembled_date)
    else:
        self._logger.debug(('No new deployments comparing %s' % time.strftime('%Y-%m-%dT%H:%M:%S', last_assembled_date)))
        self._logger.debug(('and %s' % time.strftime('%Y-%m-%dT%H:%M:%S', index_date)))

dataset/ETHPy150Open StackStorm/st2contrib/packs/octopusdeploy/sensors/new_deployment_sensor.py NewDeploymentSensor.poll/original