Exemplo n.º 1
0
def summarise_log():

    print("Summarising the log")
    logging.info("Summarising the daily logs into a weekly log")

    # concatenate all the daily logs for the week
    # create a new note in weekly logs with that content

    evernote_client = EvernoteConnector(token=settings.EVERNOTE_AUTH_TOKEN, sandbox=settings.EVERNOTE_SANDBOX_MODE)

    # The week is Monday 00:00:00 to Sunday 23:59:59
    start_time = get_start_of_week(datetime.now())
    end_time = get_end_of_week(datetime.now())

    try:

        summary_content = evernote_client.get_concatenated_daily_logs(start_time, end_time)

        first_day_of_this_week = datetime.now() - timedelta(days=datetime.now().weekday())
        summary_title = datetime.strftime(first_day_of_this_week,"W/C %Y-%m-%d")

        evernote_client.create_summary_log("Summaries", summary_title, summary_content)

        logging.info("Completed summarising the daily logs into a weekly log")

    except EvernoteConnectorException as e:
        logging.critical("There was an error with the EvernoteConnector: " + e.msg)
        return

    print("Completed summarising the log")
Exemplo n.º 2
0
def process_goals():

    previous_goal_states = get_stored_goal_states(settings.STORED_GOAL_STATES_LOCATION)

    logging.info("Processing goal state-changes")
    evernote_client = EvernoteConnector(token=settings.EVERNOTE_AUTH_TOKEN,sandbox=settings.EVERNOTE_SANDBOX_MODE)
    new_goal_states = evernote_client.process_goal_updates(previous_goal_states)

    save_stored_goal_states(settings.STORED_GOAL_STATES_LOCATION,new_goal_states)
    logging.info("Completed processing goals")
Exemplo n.º 3
0
def process_goals():

    previous_goal_states = get_stored_goal_states(
        settings.STORED_GOAL_STATES_LOCATION)

    logging.info("Processing goal state-changes")
    evernote_client = EvernoteConnector(token=settings.EVERNOTE_AUTH_TOKEN,
                                        sandbox=settings.EVERNOTE_SANDBOX_MODE)
    new_goal_states = evernote_client.process_goal_updates(
        previous_goal_states)

    save_stored_goal_states(settings.STORED_GOAL_STATES_LOCATION,
                            new_goal_states)
    logging.info("Completed processing goals")
Exemplo n.º 4
0
def process_events():

    current_check_time = None

    # Get new events from Evernote
    logging.info("Getting new events from Evernote")
    evernote_client = EvernoteConnector(token=settings.EVERNOTE_AUTH_TOKEN,
                                        sandbox=settings.EVERNOTE_SANDBOX_MODE)
    try:
        current_check_time = datetime.now().strftime("%Y%m%dT%H%M%S")
        last_successful_check_time = get_last_successful_check_time(
            settings.LATEST_CHECK_TIME_LOCATION)

        logging.debug("Last successful check was " +
                      last_successful_check_time)

        events = evernote_client.get_new_events(
            since=last_successful_check_time)
        logging.debug("Evernote connection was successful")

    except EvernoteConnectorException as e:
        logging.critical("There was an error with the EvernoteConnector: " +
                         e.msg)
        return

    logging.info('Found ' + str(len(events)) + ' new events:')

    for event in events:
        logging.debug('StartTime: ' +
                      event.start_time.strftime('%Y-%m-%d %H%M') +
                      ', EndTime: ' +
                      event.end_time.strftime('%Y-%m-%d %H%M') + ", Title: '" +
                      event.title + "'")

    # Add new events to Google Calender

    if len(events) > 0:
        logging.info('Adding new events to Google Calendar')
        google_client = GoogleCalendarConnector(
            credentials_file=settings.GOOGLE_CREDENTIALS_FILE)
        google_client.add_new_events(events)

    save_successful_check_time(settings.LATEST_CHECK_TIME_LOCATION,
                               current_check_time)
    logging.info('Completed processing events, saved check time as ' +
                 current_check_time)
Exemplo n.º 5
0
def process_events():

    current_check_time = None

    # Get new events from Evernote
    logging.info("Getting new events from Evernote")
    evernote_client = EvernoteConnector(token=settings.EVERNOTE_AUTH_TOKEN,sandbox=settings.EVERNOTE_SANDBOX_MODE)
    try:
        current_check_time = datetime.now().strftime("%Y%m%dT%H%M%S")
        last_successful_check_time = get_last_successful_check_time(settings.LATEST_CHECK_TIME_LOCATION)

        logging.debug("Last successful check was " + last_successful_check_time)

        events = evernote_client.get_new_events(since=last_successful_check_time)
        logging.debug("Evernote connection was successful")

    except EvernoteConnectorException as e:
        logging.critical("There was an error with the EvernoteConnector: " + e.msg)
        return

    logging.info('Found ' + str(len(events)) + ' new events:')

    for event in events:
        logging.debug('StartTime: ' + event.start_time.strftime('%Y-%m-%d %H%M') +
                      ', EndTime: ' + event.end_time.strftime('%Y-%m-%d %H%M') +
                      ", Title: '" + event.title + "'")

    # Add new events to Google Calender

    if len(events) > 0:
        logging.info('Adding new events to Google Calendar')
        google_client = GoogleCalendarConnector(credentials_file=settings.GOOGLE_CREDENTIALS_FILE)
        google_client.add_new_events(events)

    save_successful_check_time(settings.LATEST_CHECK_TIME_LOCATION,current_check_time)
    logging.info('Completed processing events, saved check time as ' + current_check_time)
Exemplo n.º 6
0
def summarise_log():

    print("Summarising the log")
    logging.info("Summarising the daily logs into a weekly log")

    # concatenate all the daily logs for the week
    # create a new note in weekly logs with that content

    # The week is Monday 00:00:00 to Sunday 23:59:59
    start_time = get_start_of_week(datetime.now())
    end_time = get_end_of_week(datetime.now())

    try:
        evernote_client = EvernoteConnector(
            token=settings.EVERNOTE_AUTH_TOKEN,
            sandbox=settings.EVERNOTE_SANDBOX_MODE)

        summary_content = evernote_client.get_concatenated_daily_logs(
            start_time, end_time)

        first_day_of_this_week = datetime.now() - timedelta(
            days=datetime.now().weekday())
        summary_title = datetime.strftime(first_day_of_this_week,
                                          "W/C %Y-%m-%d")

        evernote_client.create_summary_log("Summaries", summary_title,
                                           summary_content)

        logging.info("Completed summarising the daily logs into a weekly log")

    except EvernoteConnectorException as e:
        logging.critical("There was an error with the EvernoteConnector: " +
                         e.msg)
        return

    print("Completed summarising the log")
Exemplo n.º 7
0
                      help="If notebook is not present, create it")
    parser.add_option("-d", "--dont-update",
                      action="store_true", dest="dont_update", default=False,
                      help="Don't update contact if already present in Hello")
    (options, args) = parser.parse_args()

    # Set logging level
    logging.getLogger().setLevel(options.logging)

    # Connect to evernote
    # Check for required parameters, if not present, ask for them
    if not options.evernote_username:
        options.evernote_username = raw_input("Your Evernote username: "******"Your Evernote password: "******"Could not connect to Evernote")
        sys.exit(1)


    # Get Hello notes from Evernote
    # Check for required parameter, if not present, ask for it
    if not options.hello_notebook:
        options.hello_notebook = raw_input("Your Hello Notebook name: ")
    notebook = ec.get_notebook_by_name(options.hello_notebook)
    if not notebook:
        if options.create_notebook:
            notebook = ec.create_notebook(options.hello_notebook)
        else:
            # try to connect to business account