예제 #1
0
 def __init__(self, binding_type):
     """
     :param binding_type: the key for the binding, used in item binding strings.
         Also called the service.pid.
     """
     self.log = oh.getLogger(type(self).__name__)
     self._binding_configs = defaultdict(list) # context -> [bindings]
     self._binding_type = binding_type
     self._registrations = []
     self._registrations.append(bundle_context.registerService(
         EventHandler, self, hashtable((EventConstants.EVENT_TOPIC, ["openhab/*"]))))
     self._registrations.append(bundle_context.registerService(
         ManagedService, self, hashtable((Constants.SERVICE_PID, "org.openhab." + binding_type))))
     self._registrations.append(
         bundle_context.registerService(BindingConfigReader, self, hashtable()))
     self._polling_job_key = None
예제 #2
0
 def __init__(self, binding_type):
     """
     :param binding_type: the key for the binding, used in item binding strings.
         Also called the service.pid.
     """
     self.log = oh.getLogger(type(self).__name__)
     self._binding_configs = defaultdict(list)  # context -> [bindings]
     self._binding_type = binding_type
     self._registrations = []
     self._registrations.append(
         bundle_context.registerService(
             EventHandler, self,
             hashtable((EventConstants.EVENT_TOPIC, ["openhab/*"]))))
     self._registrations.append(
         bundle_context.registerService(
             ManagedService, self,
             hashtable(
                 (Constants.SERVICE_PID, "org.openhab." + binding_type))))
     self._registrations.append(
         bundle_context.registerService(BindingConfigReader, self,
                                        hashtable()))
     self._polling_job_key = None
예제 #3
0
파일: quartz.py 프로젝트: Tknika/openhab
"""
Quartz scheduler utilities for manipulating scheduled jobs.
"""
import types

from openhab.globals import oh
from org.openhab.core.jsr223.internal.actions import Timer
from org.quartz.impl.matchers import GroupMatcher

log = oh.getLogger(__name__)

def visit_jobs(scheduler, visitor, group_filter=None, job_filter=None):
    # Transform group filter
    if isinstance(group_filter, types.StringTypes):
        filter_name = group_filter
        group_filter = lambda name: name == filter_name
    elif hasattr(group_filter, "__iter__"):
        group_filter = lambda name: name in group_filter
    # Visit
    if hasattr(visitor, "visit_scheduler"):
        visitor.visit_scheduler(scheduler)
    for group_name in Timer.scheduler.getJobGroupNames():
        if group_filter is None or group_filter(group_name):
            if hasattr(visitor, "visit_group"):
                visitor.visit_group(scheduler, group_name)
            for jobkey in Timer.scheduler.getJobKeys(GroupMatcher.groupEquals(group_name)):
                if job_filter is None or job_filter(jobkey):
                    if hasattr(visitor, "visit_jobkey"):
                        visitor.visit_jobkey(scheduler, group_name, jobkey)
                    if hasattr(visitor, "visit_trigger"):
                        for trigger in Timer.scheduler.getTriggersOfJob(jobkey):
예제 #4
0
"""
Quartz scheduler utilities for manipulating scheduled jobs.
"""
import types

from openhab.globals import oh
from org.openhab.core.jsr223.internal.actions import Timer
from org.quartz.impl.matchers import GroupMatcher

log = oh.getLogger(__name__)


def visit_jobs(scheduler, visitor, group_filter=None, job_filter=None):
    # Transform group filter
    if isinstance(group_filter, types.StringTypes):
        filter_name = group_filter
        group_filter = lambda name: name == filter_name
    elif hasattr(group_filter, "__iter__"):
        group_filter = lambda name: name in group_filter
    # Visit
    if hasattr(visitor, "visit_scheduler"):
        visitor.visit_scheduler(scheduler)
    for group_name in Timer.scheduler.getJobGroupNames():
        if group_filter is None or group_filter(group_name):
            if hasattr(visitor, "visit_group"):
                visitor.visit_group(scheduler, group_name)
            for jobkey in Timer.scheduler.getJobKeys(
                    GroupMatcher.groupEquals(group_name)):
                if job_filter is None or job_filter(jobkey):
                    if hasattr(visitor, "visit_jobkey"):
                        visitor.visit_jobkey(scheduler, group_name, jobkey)