def refresh_cache():
    wf = Workflow()
    # Start the OAuth flow to retrieve credentials
    flow = flow_from_clientsecrets(
        config.CLIENT_SECRET_FILE, scope=config.OAUTH_SCOPE)
    http = httplib2.Http()

    try:
        credentials = OAuth2Credentials.from_json(
            wf.get_password('gmail_credentials'))
        if credentials is None or credentials.invalid:
            credentials = run(flow, PseudoStorage(), http=http)
            wf.save_password('gmail_credentials', credentials.to_json())
            wf.logger.debug('Credentials securely updated')

        # Authorize the httplib2.Http object with our credentials
        http = credentials.authorize(http)
        # Build the Gmail service from discovery
        gmail_service = build('gmail', 'v1', http=http)

        wf.cache_data('gmail_list', get_list(wf, http, gmail_service))

    except PasswordNotFound:
        wf.logger.debug('Credentials not found')
        credentials = run(flow, PseudoStorage(), http=http)
        wf.save_password('gmail_credentials', credentials.to_json())
        wf.logger.debug('New Credentials securely saved')
Example #2
0
#!/usr/bin/python
# encoding: utf-8

import sys
from workflow import Workflow, web
from collections import Counter
from workflow.background import run_in_background, is_running

wf = Workflow()
arg = wf.args[0]
if len(arg) > 0:
    token = arg
    wf.save_password('GitHub-gist-alfred-token', token)
    wf.send_feedback()
Example #3
0
#!/usr/bin/python
# encoding: utf-8

import sys
from workflow import Workflow, web
from collections import Counter
from workflow.background import run_in_background, is_running


wf = Workflow()



arg = wf.args[0]
#arg = wf.args[0]


if arg.startswith("Username:"******":")[1]
    wf.store_data("Username", username)
    arg = "Saved " + arg
elif arg.startswith("Token:"):
    token = arg.split(":")[1]
    wf.save_password('Token',token)

wf.send_feedback()


Example #4
0
#!/usr/bin/python
# encoding: utf-8

import sys
from workflow import Workflow, web
from collections import Counter
from workflow.background import run_in_background, is_running


wf = Workflow()
arg = wf.args[0]
if len(arg) > 0:
    token = arg
    wf.save_password('GitHub-gist-alfred-token', token)
    wf.send_feedback()
Example #5
0
    ## Save the parsed arguments in the wf object for later access
    wf.pargs = parser.parse_args(wf.args)

    #Check if the user wants to initiate settings saving
    if wf.pargs.reset:
        wf.delete_password(u'yt_password')
        wf.reset()
        sys.exit()

    if wf.pargs.set:
        params = split_query_to_params(wf.pargs.set)
        if len(params) == 3:
            # if we have 3 params, means the user already chose a setting and filled it
            log.error('User wants to save something!! %s' % wf.pargs)
            if params[0] == 'yt_password':
                wf.save_password(u'yt_password', params[1])
            else:
                wf.store_data(params[0], params[1])
            print "Saved %s sucesfully!" % yt_title(params[0])
            sys.exit()
        if params[1] == '':
            wf.add_item('Please enter your YouTrack %s' % yt_title(params[0]),subtitle=u'Cannot be empty!', icon=ICON_SETTINGS)
        else:
            wf.add_item('Set your YouTrack %s to \'%s\'' % (yt_title(params[0]),params[1]),
                        subtitle=u'Hit enter to set.',
                        icon=ICON_SETTINGS,
                        arg=wf.pargs.set + SEPARATOR,
                        valid=True)
        wf.send_feedback()

    settings = {}
Example #6
0
import sys
from workflow import Workflow, ICON_WEB, web
from lib import get_token
from enums import ANALOGUE_API_TOKEN, ANALOGUE_USERNAME

wf = Workflow()
result, username = get_token(str(sys.argv[1]), str(sys.argv[2]))
wf.save_password(ANALOGUE_API_TOKEN, result)
wf.save_password(ANALOGUE_USERNAME, username)