Esempio n. 1
0
def auto_sync_toggled(auto_button, time_button):
    active = auto_button.get_active()
    if active:
        (hours, minutes) = time_button.get_time()
        event = alarm.Event()
        event.appid = "erminig"
        event.title = "Synchronization with erminig"
        #event.flags |= alarm.EVENT_RUN_DELAYED
        action = event.add_actions(1)[0]
        action.flags |= alarm.ACTION_WHEN_TRIGGERED | alarm.ACTION_WHEN_DELAYED | alarm.ACTION_TYPE_EXEC
        action.command = os.path.abspath(sys.argv[0]) + " -a -d"
        recur = event.add_recurrences(1)[0]
        # let's see what this does...
        recur.mask_min = 1 << minutes
        recur.mask_hour = 1 << hours
        # initialize alarm time to somewhere in the future
        event.alarm_time = time.time() + 5
        # lt = time.localtime(time.time() + 5)
        # tz = time.tzname[lt.tm_isdst]
        # event.alarm_time = time.mktime(recur.next(lt, tz))
        event.recurrences_left = -1
        sync_id = alarm.add_event(event)
        auto_sync_update_syncid(sync_id)
        auto_sync_update_synctime(hours, minutes)
    else:
        alarm.delete_event(int(auto_sync_get_syncid()))
        dblayer.run("DELETE FROM Prefs where name='auto_sync_id'")
        dblayer.commit()
Esempio n. 2
0
def auto_sync_toggled(auto_button, time_button):
	active = auto_button.get_active()
	if active:
		(hours, minutes) = time_button.get_time()
		event = alarm.Event()
		event.appid = "erminig"
		event.title = "Synchronization with erminig"
		#event.flags |= alarm.EVENT_RUN_DELAYED
		action = event.add_actions(1)[0]
		action.flags |= alarm.ACTION_WHEN_TRIGGERED | alarm.ACTION_WHEN_DELAYED | alarm.ACTION_TYPE_EXEC
		action.command = os.path.abspath(sys.argv[0]) + " -a -d"
		recur = event.add_recurrences(1)[0]
		# let's see what this does...
		recur.mask_min = 1 << minutes
		recur.mask_hour = 1 << hours
		# initialize alarm time to somewhere in the future
		event.alarm_time = time.time() + 5
		# lt = time.localtime(time.time() + 5)
		# tz = time.tzname[lt.tm_isdst]
		# event.alarm_time = time.mktime(recur.next(lt, tz))
		event.recurrences_left = -1
		sync_id=alarm.add_event(event)
		auto_sync_update_syncid(sync_id)
		auto_sync_update_synctime(hours, minutes)
	else:
		alarm.delete_event(int(auto_sync_get_syncid()))
		dblayer.run("DELETE FROM Prefs where name='auto_sync_id'")
		dblayer.commit()
Esempio n. 3
0
    def testCreateDelete(self):
        '''General lifecycle of an Event: Add, Retrieve, Update, Delete'''
        event = alarm.Event()
        appid = 'aaaa'
        event.appid = appid
        action = event.add_actions(1)[0]
        action.flags |= alarm.ACTION_WHEN_TRIGGERED | alarm.ACTION_TYPE_SNOOZE

        cookie = alarm.add_event(event)

        # Compare with 'cookie', as event.cookie is still 0 after adding
        event2 = alarm.get_event(cookie)
        self.assertEqual(cookie, event2.cookie)
        self.assertEqual(appid, event2.appid)

        event2.alarm_time = time() + 3
        alarm.update_event(event2)

        alarm.delete_event(cookie)
        self.assertRaises(IndexError, alarm.get_event, cookie)
Esempio n. 4
0
	def _clear_alarm(self):
		if self._alarmCookie == self._INVALID_COOKIE:
			return
		alarm.delete_event(self._alarmCookie)
		self._alarmCookie = self._INVALID_COOKIE
Esempio n. 5
0
 def tearDown(self):
     try:
         alarm.delete_event(self.cookie)
         del self.cookie
     except:
         pass
Esempio n. 6
0
def main():
    alarm.delete_event(int(sys.argv[1]))

    print "Deleted event %s" % sys.argv[1]