Esempio n. 1
0
def main():
	todo = reminders.get_reminders(completed=False)
	print 'TODO List\n========='
	for r in todo:
		print '[ ] ' + r.title
	done = reminders.get_reminders(completed=True)
	print 'DONE\n===='
	for r in done:
		print '[x] ' + r.title
Esempio n. 2
0
def completeReminder():

	_title = sys.argv[1] if len(sys.argv) > 1 else None
	_list = sys.argv[2] if len(sys.argv) > 2 else None

	if _list:
		calendars = reminders.get_all_calendars()
		_list = [x for x in calendars if x.title == _list]
		_list_title = _list[0].title
		todo = reminders.get_reminders(completed=False, calendar=_list[0])
		callback = 'twodo://x-callback-url/showList?name=%s' % quote(_list_title)
	else:
		todo = reminders.get_reminders(completed=False)
		callback = 'twodo://'
	
	if len(todo) == 0:
		return dialogs.hud_alert('You don\'t have any reminder left to do.')
	
	if _title:
		
		this = [x for x in todo if x.title == _title]
		
		if len(this) == 1:
			this = this[0]
		elif len(this) <= 0:
			return dialogs.hud_alert('You don\'t have any reminder matching these terms.')
		else:
			todomap = {x.title: x for x in this}
			this = dialogs.list_dialog('Multiple matches', list(todomap.keys()))
			
			if not this:
				return dialogs.hud_alert('You gotta pick the correct reminder.')
			else:
				this = todomap.get(this)
				
	else:
		todomap = {x.title: x for x in todo}
		this = dialogs.list_dialog('Multiple matches', list(todomap.keys()))
			
		if not this:
			return dialogs.hud_alert('You gotta pick the correct reminder.')
		else:
			this = todomap.get(this)
	
	this.completed = True
	this.save()
	webbrowser.open(callback)
def get_reminders_today():
	import reminders
	import re
	calendar = reminders.get_reminders()
	reminder_1 = re.findall(r'"(.*?)"', str(calendar[0]))
	speech.say("On your reminders list was {}, not sure how important that is, but nevertheless you might want to look into it. I've taken the liberty to send you a text message regarding this. Just a gentle reminder to take care of your stuff today.".format(str(reminder_1[0])), "en-UK") 
	options = {"value1": reminder_1[0]}
	requests.post("https://maker.ifttt.com/trigger/Calendar/with/key/{IFTT Key Goes Here}", options)
Esempio n. 4
0
 def _refresh(self, force=False):
     if self.cached and not force:
         return
     list_reminders = reminders.get_reminders(self.list_calendar)
     for item in list_reminders:
         self.items[item.title] = item
         if self.cached:
             self.cache[item.title] = item.notes
Esempio n. 5
0
	def _refresh(self, force = False):
		if self.cached and not force:
			return
		list_reminders = reminders.get_reminders(self.list_calendar)
		for item in list_reminders:
			self.items[item.title] = item
			if self.cached:
				self.cache[item.title] = item.notes
    def test_get_reminders_error_01(self) -> None:
        """ Test the function that obtains the list of reminders of a user, without a user. """

        # The expected result
        expected_result = []

        # Call the function
        actual_result = reminders.get_reminders(self.session, None)

        # Verify the result
        self.assertEqual(expected_result, actual_result)
    def test_get_reminders_ok(self) -> None:
        """ Test the function that obtains the list of reminders of a user, with success. """

        # Prepare the mocks
        reminder_1 = models.Reminder(10, 1, 1)
        reminder_1.id = 1

        reminder_2 = models.Reminder(50, 2, 1)
        reminder_2.id = 2

        db_calls_mock.get_reminders_user.return_value = [reminder_1, reminder_2]

        response_reminder: response_models.Reminder = unittest.mock.MagicMock()
        response_reminder.anticipation_minutes = 10

        show_session = models.ShowSession(None, None, datetime.datetime(2020, 1, 1), 5, 10)
        channel = models.Channel(None, 'Channel Name')

        show_data = models.ShowData('_Show_Name_', 'Show Name')
        show_data.is_movie = True

        complete_session = (show_session, channel, show_data)

        show_session_2 = models.ShowSession(None, None, datetime.datetime(2020, 2, 2), 15, 20)
        channel_2 = models.Channel(None, 'Channel Name 2')

        show_data_2 = models.ShowData('_Show_Name_2_', 'Show Name 2')
        show_data_2.is_movie = False

        complete_session_2 = (show_session_2, channel_2, show_data_2)

        db_calls_mock.get_show_session_complete.side_effect = [complete_session, complete_session_2]

        # Call the function
        actual_result = reminders.get_reminders(self.session, 1)

        # Verify the result
        self.assertEqual(2, len(actual_result))

        self.assertEqual(1, actual_result[0].id)
        self.assertEqual('Show Name', actual_result[0].title)
        self.assertEqual(datetime.datetime(2020, 1, 1), actual_result[0].date_time)
        self.assertEqual(10, actual_result[0].anticipation_minutes)

        self.assertEqual(2, actual_result[1].id)
        self.assertEqual('Show Name 2', actual_result[1].title)
        self.assertEqual(datetime.datetime(2020, 2, 2), actual_result[1].date_time)
        self.assertEqual(50, actual_result[1].anticipation_minutes)

        # Verify the calls to the mocks
        db_calls_mock.get_reminders_user.assert_called_with(self.session, 1)
        db_calls_mock.get_show_session_complete.assert_has_calls(
            [unittest.mock.call(self.session, 1), unittest.mock.call(self.session, 2)])
Esempio n. 8
0
    def get(self):
        """Get the list of reminders of the user."""

        with session_scope() as session:
            # Get the user id from the token
            token = flask.request.headers.environ['HTTP_AUTHORIZATION'][7:]
            user_id = authentication.get_token_field(token.encode(), 'user')

            reminder_list = reminders.get_reminders(session, user_id)

            return flask.make_response(
                flask.jsonify(
                    {'reminder_list': auxiliary.list_to_json(reminder_list)}),
                200)
Esempio n. 9
0
def todo_list():
    todo = reminders.get_reminders(completed=False)

    l = list()
    for r in todo:
        if r.notes is None:
            continue
            
        if r.notes.lower() != 'mkr':
            continue

        l.append(r.title)

    return l
    def test_get_reminders_error_02(self) -> None:
        """ Test the function that obtains the list of reminders of a user, without reminders. """

        # The expected result
        expected_result = []

        # Prepare the mocks
        db_calls_mock.get_reminders_user.return_value = []

        # Call the function
        actual_result = reminders.get_reminders(self.session, 1)

        # Verify the result
        self.assertEqual(expected_result, actual_result)

        # Verify the calls to the mocks
        db_calls_mock.get_reminders_user.assert_called_with(self.session, 1)
Esempio n. 11
0
    def delete(self, args):
        """Delete a reminder."""

        reminder_id = args['reminder_id']

        with session_scope() as session:
            # Get the user id from the token
            token = flask.request.headers.environ['HTTP_AUTHORIZATION'][7:]
            user_id = authentication.get_token_field(token.encode(), 'user')

            if db_calls.delete_reminder(session, reminder_id, user_id):
                return flask.make_response(
                    flask.jsonify({
                        'reminder_list':
                        auxiliary.list_to_json(
                            reminders.get_reminders(session, user_id))
                    }), 200)
            else:
                return flask.make_response('', 404)
Esempio n. 12
0
def update_reminders(book_list):
    db = get_reminder_list()
    checked_titles = [
        reminder.title
        for reminder in reminders.get_reminders(db, completed=True)
    ]
    reminders.delete_calendar(db)
    db = create_reminder_list()
    title_list = (book['title'] for book in book_list.values())
    lookup = {
        book_list[barcode]['title']: barcode
        for barcode in book_list.keys()
    }
    for title in sorted(title_list):
        r = reminders.Reminder(db)
        r.title = title
        if title in checked_titles:
            r.completed = True
        r.save()
        book_list[lookup[title]]['reminder'] = r
Esempio n. 13
0
def start_scanning():
    global main_view, all_books
    global scraper
    db = scraper.get_reminder_list()
    for r in reminders.get_reminders(db):
        code = r.notes[:r.notes.index(' ')]
        all_books[code] = r
    delegate = MetadataDelegate.new()
    main_view = ui.View(frame=(0, 0, 400, 400))
    main_view.name = 'Kirjaskanneri'
    session = AVCaptureSession.alloc().init()
    device = AVCaptureDevice.defaultDeviceWithMediaType_('vide')
    _input = AVCaptureDeviceInput.deviceInputWithDevice_error_(device, None)
    if _input:
        session.addInput_(_input)
    else:
        print('Failed to create input')
        return
    output = AVCaptureMetadataOutput.alloc().init()
    queue = ObjCInstance(dispatch_get_current_queue())
    output.setMetadataObjectsDelegate_queue_(delegate, queue)
    session.addOutput_(output)
    output.setMetadataObjectTypes_(output.availableMetadataObjectTypes())
    prev_layer = AVCaptureVideoPreviewLayer.layerWithSession_(session)
    prev_layer.frame = ObjCInstance(main_view).bounds()
    prev_layer.setVideoGravity_('AVLayerVideoGravityResizeAspectFill')
    ObjCInstance(main_view).layer().addSublayer_(prev_layer)
    label = ui.Label(frame=(0, 0, 400, 30), flex='W', name='label')
    label.background_color = (0, 0, 0, 0.5)
    label.text_color = 'white'
    label.text = 'Nothing scanned yet'
    label.alignment = ui.ALIGN_CENTER
    main_view.add_subview(label)
    session.startRunning()
    main_view.present('sheet')
    main_view.wait_modal()
    session.stopRunning()
    delegate.release()
    session.release()
    output.release()
Esempio n. 14
0
    def post(self, args):
        """Register a reminder."""

        show_session_id = args['show_session_id']
        anticipation_minutes = args['anticipation_minutes']

        with session_scope() as session:
            # Get the user id from the token
            token = flask.request.headers.environ['HTTP_AUTHORIZATION'][7:]
            user_id = authentication.get_token_field(token.encode(), 'user')

            if reminders.register_reminder(session, show_session_id,
                                           anticipation_minutes,
                                           user_id) is not None:
                return flask.make_response(
                    flask.jsonify({
                        'reminder_list':
                        auxiliary.list_to_json(
                            reminders.get_reminders(session, user_id))
                    }), 201)
            else:
                return flask.make_response('Invalid reminder', 400)
Esempio n. 15
0
	def refresh_cache(self):
		delta = { "added": set(), "deleted": set(), "changed": set() }
		has_delta = False
		list_reminders = reminders.get_reminders(self.list_calendar)
		self.items = {}
		new_cache = {}
		for item in list_reminders:
			self.items[item.title] = item
			new_cache[item.title] = item.notes
			if not item.title in self.cache:
				has_delta = True
				delta['added'].add(item.title)
			else:
				if item.notes <> self.cache[item.title]:
					has_delta = True
					delta['changed'].add(item.title)
				del self.cache[item.title]
		if len(self.cache) > 0:
			has_delta = True
			for key in self.cache:
				delta['deleted'].add(key)
		self.cache = new_cache
		return delta if has_delta else None	
Esempio n. 16
0
 def refresh_cache(self):
     delta = {"added": set(), "deleted": set(), "changed": set()}
     has_delta = False
     list_reminders = reminders.get_reminders(self.list_calendar)
     self.items = {}
     new_cache = {}
     for item in list_reminders:
         self.items[item.title] = item
         new_cache[item.title] = item.notes
         if not item.title in self.cache:
             has_delta = True
             delta['added'].add(item.title)
         else:
             if item.notes != self.cache[item.title]:
                 has_delta = True
                 delta['changed'].add(item.title)
             del self.cache[item.title]
     if len(self.cache) > 0:
         has_delta = True
         for key in self.cache:
             delta['deleted'].add(key)
     self.cache = new_cache
     return delta if has_delta else None
Esempio n. 17
0
def hub_page(user_id):
    """Main user hub. Contains user information like their gardens, quick weather, and reminders"""
    try:
        if (session[LOGGED_IN_USER] == user_id):

            try:
                which_user = User.query.get_or_404(user_id)
                weather = get_weather(WEATHER_API_KEY_REMOVE_ME, g.user.location, False)
                reminders = get_reminders(which_user)
                garden = which_user.garden

                data_list = [weather.json(), reminders, garden]

                return render_template('hub.html', data=data_list)
            except:
                message = 'Please add a plant to your account to start'
                return render_template('hub.html', error=message)
        else:
            flash ('Not authorized for that', 'danger')
            return redirect('/')
    except:
        flash ('Not authorized for that', 'danger')
        return redirect('/')
Esempio n. 18
0
import reminders
import datetime
from collections import Counter

# get uncomplete reminders
todo = reminders.get_reminders(completed=False)

# get reminders w dates
todo = [item for item in todo if item.due_date]

# get reminders due before today
todo = [item for item in todo if item.due_date < datetime.datetime.now()]

# make due date today
for r in todo:
    r.due_date = datetime.datetime.now()
    r.alarms[0].date = r.due_date
    r.save()
Esempio n. 19
0
def get_reminder_items(completed=False):
    return [{'title': r.title, 'reminder': r}
            for r in reminders.get_reminders(completed=completed)]
Esempio n. 20
0
def get_reminder_items(completed=False):
    return [{'title': r.title, 'reminder': r}
                for r in reminders.get_reminders(completed=completed)]
Esempio n. 21
0
	
	store = ReminderStore(namespace, cache = True)
	
	store['to be deleted'] = 'sample'
	store['to be changed'] = 'sample'
	
	# Simulate changes to the Reminders synced from another device
	
	# Add
	a = reminders.Reminder(store.list_calendar)
	a.title = 'has been added'
	a.notes = 'sample'
	a.save()
	
	# Change
	list_reminders = reminders.get_reminders(store.list_calendar)
	for item in list_reminders:
		if item.title == 'to be changed':
			item.notes = 'new value'
			item.save()
	
	# Delete
	reminders.delete_reminder(store.items['to be deleted'])
	
	diff = store.refresh_cache()
	
	print
	print 'DIFF: ' + str(diff)
	
	del store['to be changed']
	del store['has been added']
Esempio n. 22
0
    store = ReminderStore(namespace, cache=True)

    store['to be deleted'] = 'sample'
    store['to be changed'] = 'sample'

    # Simulate changes to the Reminders synced from another device

    # Add
    a = reminders.Reminder(store.list_calendar)
    a.title = 'has been added'
    a.notes = 'sample'
    a.save()

    # Change
    list_reminders = reminders.get_reminders(store.list_calendar)
    for item in list_reminders:
        if item.title == 'to be changed':
            item.notes = 'new value'
            item.save()

    # Delete
    reminders.delete_reminder(store.items['to be deleted'])

    diff = store.refresh_cache()

    print()
    print('DIFF: ' + str(diff))

    del store['to be changed']
    del store['has been added']
Esempio n. 23
0
# https://forum.omz-software.com/topic/3972/taskpaper-and-reminders-recurring-tasks

import reminders
todo = reminders.get_reminders(completed=False)
print('TODO List')
print('=========')
for r in todo:
	#print('[ ] ' + r.title)
	print('[ ] {} {}'.format(r.title, r.due_date))
done = reminders.get_reminders(completed=True)
print('DONE')
print('====')
for r in done:
	#print('[x] ' + r.title)
	print('[x] {} {}'.format(r.title, r.due_date))