コード例 #1
0
    def __init__(self, irc):
        self.__parent = super(DebianDevelChanges, self)
        self.__parent.__init__(irc)
        self.irc = irc
        self.topic_lock = threading.Lock()

        fr = FifoReader()
        fifo_loc = '/var/run/debian-devel-changes/fifo'
        fr.start(self._email_callback, fifo_loc)

        self.queued_topics = {}
        self.last_n_messages = []

        # Schedule datasource updates
        for klass, interval, name in get_datasources():
            try:
                schedule.removePeriodicEvent(name)
            except KeyError:
                pass

            def wrapper(klass=klass):
                klass().update()
                self._topic_callback()

            schedule.addPeriodicEvent(wrapper, interval, name, now=False)
            schedule.addEvent(wrapper, time.time() + 1)
コード例 #2
0
 def die(self):
     FifoReader().stop()
     for _, _, name in get_datasources():
         try:
             schedule.removePeriodicEvent(name)
         except KeyError:
             # A newly added event may not exist, ignore exception.
             pass
コード例 #3
0
    def die(self):
        self.dbus_service.stop()
        if self.mainloop is not None:
            self.mainloop.quit()

        for source in self.data_sources:
            try:
                schedule.removePeriodicEvent(source.NAME)
            except KeyError:
                pass
コード例 #4
0
ファイル: plugin.py プロジェクト: HyperEye/supybot-svn
 def remove(self, irc, msg, args, name):
     """<name>
     
     Removes the notifier called <name>
     """
     if not(name in self.notifiers):
         irc.reply( "There is no notifier named '" + name + "'")
         return
     
     schedule.removePeriodicEvent(name)
     irc.reply( "Removed '" + name + "'")
     del self.notifiers[name]
コード例 #5
0
    def die(self):
        FifoReader().stop()
        for _, _, name in get_datasources():
            try:
                schedule.removePeriodicEvent(name)
            except KeyError:
                # A newly added event may not exist, ignore exception.
                pass

        for source in self.data_sources:
            try:
                schedule.removePeriodicEvent(source.NAME)
            except KeyError:
                pass
コード例 #6
0
    def __init__(self, irc):
        super(DebianDevelChanges, self).__init__(irc)
        self.irc = irc
        self.topic_lock = threading.Lock()

        fr = FifoReader()
        fifo_loc = '/var/run/debian-devel-changes-bot/fifo'
        fr.start(self._email_callback, fifo_loc)

        self.requests_session = requests.Session()
        self.requests_session.verify = True

        self.queued_topics = {}
        self.last_n_messages = []

        self.stable_rc_bugs = StableRCBugs(self.requests_session)
        self.testing_rc_bugs = TestingRCBugs(self.requests_session)
        self.new_queue = NewQueue(self.requests_session)
        self.data_sources = (self.stable_rc_bugs, self.testing_rc_bugs,
                             self.new_queue)

        # Schedule datasource updates
        for klass, interval, name in get_datasources():
            try:
                schedule.removePeriodicEvent(name)
            except KeyError:
                pass

            def wrapper(klass=klass):
                klass().update()
                self._topic_callback()

            schedule.addPeriodicEvent(wrapper, interval, name, now=False)
            schedule.addEvent(wrapper, time.time() + 1)

        def wrapper(source):
            def implementation():
                source.update()
                self._topic_callback()
            return implementation

        for source in self.data_sources:
            schedule.addPeriodicEvent(wrapper(source), source.INTERVAL,
                                      source.NAME, now=False)
            schedule.addEvent(wrapper(source), time.time() + 1)
コード例 #7
0
ファイル: plugin.py プロジェクト: Zhorken/zzz-dywypi
    def __init__(self, irc):
        self.__parent = super(NetHack, self)
        self.__parent.__init__(irc)

        self.xlog = open(os.path.join(CONFIG_PLAYGROUND, 'xlogfile'))
        self.livelog = open(os.path.join(CONFIG_PLAYGROUND, 'livelog'))
        self.xlog.seek(0, os.SEEK_END)
        self.livelog.seek(0, os.SEEK_END)

        # Remove the event first, in case this is a reload.  This will fail if
        # this is the first load, so throw it in a try
        try:
            schedule.removePeriodicEvent('nethack-log-ping')
        except:
            pass

        def callback():
            self._checkLogs(irc)
        schedule.addPeriodicEvent(callback, 10, name='nethack-log-ping')
コード例 #8
0
    def die(self):
        log.info('Stopping D-Bus service')
        self.dbus_service.stop()
        if self.mainloop is not None:
            log.info('Stopping Glib main loop')
            self.mainloop.quit()
            self.mainloop_thread.join(timeout=1.0)
            if self.mainloop_thread.is_alive():
                log.warn('Glib main loop thread is still alive.')

            self.mainloop = None
            self.mainloop_thread = None

        for source in self.data_sources:
            try:
                schedule.removePeriodicEvent(source.NAME)
            except KeyError:
                pass

        super().die()
コード例 #9
0
    def die(self):
        log.info('Stopping D-Bus service')
        self.dbus_service.stop()
        if self.mainloop is not None:
            log.info('Stopping Glib main loop')
            self.mainloop.quit()
            self.mainloop_thread.join(timeout=1.0)
            if self.mainloop_thread.is_alive():
                log.warn('Glib main loop thread is still alive.')

            self.mainloop = None
            self.mainloop_thread = None

        for source in self.data_sources:
            try:
                schedule.removePeriodicEvent(source.NAME)
            except KeyError:
                pass

        super().die()
コード例 #10
0
ファイル: plugin.py プロジェクト: HyperEye/supybot-svn
 def die(self):
     #remove all the notifiers
     for key in self.notifiers.keys():
         try:
             schedule.removePeriodicEvent( self.notifiers[key].name )
         except KeyError:
             #this happens if the key is not there
             pass
             
     #pickle the notifiers to file
     #use notifierConfig-instaces for that
     try:
         filepath = conf.supybot.directories.data.dirize('Subversion.db')
         notifierConfigs = []
         for name, notifier in self.notifiers.items():
             notifierConfigs.append( NotifierConfig(notifier) )
         cPickle.dump( notifierConfigs, open( filepath, "wb" ) )
     except cPickle.PicklingError as error:
         print("More: Error when pickling to file...")
         print(error)
         
     #kill the rest of the plugin
     self.__parent.die()    
コード例 #11
0
ファイル: plugin.py プロジェクト: Znuff/erica
    def __init__(self, irc):
        self.__parent = super(Quake, self)
        self.__parent.__init__(irc)

        self.players = set()

        def poll_event():
            """Poll Q3 server for player information."""
            server = self._query_server()
            if server:
                players_new = set([player.name for player in server.players])
                players_connected = players_new - self.players
                if players_connected:
                    announce = u'%s: %s connected' % (
                        server.vars['sv_hostname'], self._natural_join(map(self._sub_color, players_connected)))
                    self._announce(announce)
                players_disconnected = self.players - players_new
                if players_disconnected:
                    announce = u'%s: %s disconnected' % (
                        server.vars['sv_hostname'], self._natural_join(map(self._sub_color, players_disconnected)))
                    self._announce(announce)
                self.players = players_new.copy()
            else:
                self.players = set()

        # remove any old events
        if 'Quake.pollStatus' in schedule.schedule.events:
            schedule.removePeriodicEvent('Quake.pollStatus')

        # register event
        if self.registryValue('enablePolling'):
            schedule.addPeriodicEvent(
                poll_event,
                self.registryValue('pollingInterval'),
                name='Quake.pollStatus'
            )
コード例 #12
0
ファイル: plugin.py プロジェクト: jasonn85/Racebot
 def die(self):
     schedule.removePeriodicEvent(self.SCHEDULER_TASK_NAME)
     self.__parent.die()
コード例 #13
0
ファイル: plugin.py プロジェクト: buckket/supybot-rfk
 def die(self):
     # remove any old events
     if 'RfK.pollStatus' in schedule.schedule.events:
         schedule.removePeriodicEvent('RfK.pollStatus')
     self.__parent.die()
コード例 #14
0
 def stopPoll(self):
   log.info('stopping poll')
   schedule.removePeriodicEvent('utPoll:' + str(self))
   self.polling = False
   self.conn.close()
コード例 #15
0
ファイル: plugin.py プロジェクト: tanglu-org/glubot
    def __init__(self, irc):
        self.__parent = super(Dak, self)
        self.__parent.__init__(irc)
        self.irc = irc
        self.fname = "dinstallcheck"
        self.dinstallhour = [1, 7, 13, 19]
        self.dinstallmin = self.registryValue('dinstallminute')
        self.webwmlhour = [3, 7, 11, 15, 19, 23]
        self.webwmlmin = self.registryValue('webwmlminute')
        self.britneyhour = [10, 22]
        self.britneymin = self.registryValue('britneyminute')
        self.warntime=10
        self.dinstallduration=4
        self.channel = self.registryValue('channel')
        self.locks = {}

        def checktime():
            log.debug("DAK: Regular dinstall time check")

            now = datetime.datetime.now()
            # figure out time (in minutes) to next and from last dinstall
            nextdinstall = None
            lastdinstall = None
            for h in self.dinstallhour:
                ndt = now.replace(hour=h, minute=self.dinstallmin)
                ldt = ndt
                if ndt < now:
                    ndt += datetime.timedelta(1)
                if ldt > now:
                    ldt -= datetime.timedelta(1)
                ndt = int((ndt-now).seconds/60)
                ldt = int((now-ldt).seconds/60)
                if nextdinstall == None or ndt < nextdinstall:
                    nextdinstall = ndt
                if lastdinstall == None or ldt < lastdinstall:
                    lastdinstall = ldt

            if lastdinstall <= self.dinstallduration:
                msgMaker = ircmsgs.privmsg
                log.debug("DAK: In Dinstall timeframe")
                # No longer time to warn only, now is time to act, if we haven't already
                if self.registryValue('dinstall') == True:
                    log.debug("DAK: Already done once, dinstall flag is %s" %(self.registryValue('dinstall')))
                    return
                log.debug("DAK: Not yet done, dinstall flag %s" % (self.registryValue('dinstall')))
                conf.supybot.plugins.Dak.get('dinstall').setValue(True)
                conf.supybot.plugins.Dak.get('warned').setValue(True)
                if self.locks.has_key("ALL"):
                    irc.queueMsg(msgMaker(self.channel, "While it is DINSTALL time, there is an ALL lock. Assuming nothing happens."))
                    irc.queueMsg(msgMaker(self.channel, "%s: Hope that is correct, Mr. \"Lets_lock_ALL_and_block_everyone.\"" % (self.locks['ALL']) ))
                    return
                irc.queueMsg(msgMaker(self.channel, "It is DINSTALL time"))
                if len(self.locks) >= 1:
                    for key in [lock for lock in self.locks if lock != 'NEW']:
                        irc.queueMsg(msgMaker(self.channel, "%s: DINSTALL time, stop working, unlocking %s" % (self.locks[key], key)))
                    map(lambda lock: self.locks.pop(lock), [lock for lock in self.locks if lock != 'NEW'])
                return
            elif nextdinstall <= self.warntime:
                # Not dinstall as far as we know, but we want to warn people if they have locks, dinstall is soon.
                # We only want to warn once about locks people have, or we would do it every 30 seconds, which wouldnt be nice.
                # Also, with warnframe larger than dinstallframe, this might warn in case the bot somehow misses dinstallframe.
                # Like if it comes up late, or so. Or?
                msgMaker = ircmsgs.privmsg
                log.debug("DAK: In Dinstall Warnframe")
                if self.registryValue('warned') == True:
                    log.debug("DAK: We already warned once, warn flag %s" % (self.registryValue('warned')))
                    return
                log.debug("DAK: Not yet warned about upcoming Dinstall run, flag is %s." % (self.registryValue('warned')))

                if len(self.locks) >= 1:
                    conf.supybot.plugins.Dak.get('warned').setValue(True)
                    for key in [lock for lock in self.locks if lock != 'NEW']:
                        log.debug("DAK: Warning %s, has %s locked." % (self.locks[key], key))
                        irc.queueMsg(msgMaker(self.channel, "%s: DINSTALL soon, hurry up" % (self.locks[key]) ))
                        if key == "ALL":
                            irc.queueMsg(msgMaker(self.channel, "%s: ALL locked. If you want to keep that, remember turning off cron" % (self.locks[key]) ))
            else: # if hour in self.dinstallhour
                # We are far outside a dinstall start
                log.debug("DAK: no dinstall close, lastdinstall: %d, nextdinstall: %d" % (lastdinstall, nextdinstall))
                conf.supybot.plugins.Dak.get('dinstall').setValue(False)
                conf.supybot.plugins.Dak.get('warned').setValue(False)

        # end def checktime
        log.info("DAK: Setting periodic scheduler for checktime")
        try:
            schedule.removePeriodicEvent(self.fname)
        except KeyError:
            pass
        schedule.addPeriodicEvent(checktime, 30, self.fname, now=False)
        schedule.addEvent(checktime, time.time()+1)
        log.info("DAK: Plugin loaded")
コード例 #16
0
ファイル: plugin.py プロジェクト: tanglu-org/glubot
 def die(self):
     try:
         log.info("DAK: We should die, removing periodic scheduler")
         schedule.removePeriodicEvent(self.fname)
     except KeyError:
         pass
コード例 #17
0
ファイル: plugin.py プロジェクト: jasonn85/Racebot
 def die(self):
     schedule.removePeriodicEvent(self.SCHEDULER_TASK_NAME)
     self.__parent.die()
コード例 #18
0
ファイル: plugin.py プロジェクト: unit193/ubuntuunreg
 def die(self):
     schedule.removePeriodicEvent(self.event)