def main(_):
    user_input = ""
    try:
        settings = True if wf.args[0][0] == '>' else False
    except:
        settings = False

    if wf.update_available:
        Drive.add_update()

    try:
        user_input = wf.args[0][1::].strip() if settings else wf.args[0]
    except:
        user_input = wf.args[0]

    if settings:
        Drive.show_settings(user_input)
    elif len(user_input):
        # try:
        Drive.show_items(user_input)
        # except: figure out speciic error, could be internet, login
        # Drive.show_options('login')
    elif len(user_input) == 0:
        Drive.show_options()
        Drive.refresh_list()

    return 0
Example #2
0
def main(_):
    user_input = ""
    try:
        settings = True if wf.args[0][0] == '>' else False
    except:
        settings = False

    if wf.update_available:
        Drive.add_update()

    try:
        user_input = wf.args[0][1::].strip() if settings else wf.args[0]
    except:
        user_input = wf.args[0]

    if settings:
        Drive.show_settings(user_input)
    elif len(user_input):
        # try:
        Drive.show_items(user_input)
        # except: figure out speciic error, could be internet, login
            # Drive.show_options('login')
    elif len(user_input) == 0:
        Drive.show_options()
        Drive.refresh_list()


    return 0
Example #3
0
 def do_GET(s):
     logging.info('GET request received')
     try:
         code = urlparse.urlparse(s.path)[4].split('=')[1]
         user_credentials = Drive.exchange_tokens(code)
         subprocess.call(['python', './drive_refresh.py'])
         sys.stdout.write('Account Saved')
         logging.info('Account Saved')
         # s.wfile.write('Your code has been saved in Alfred')
     except:
         s.wfile.write('Error with setting code')
 def do_GET(s):
     logging.info('GET request received')
     try:
         code = urlparse.urlparse(s.path)[4].split('=')[1]
         user_credentials = Drive.exchange_tokens(code)
         subprocess.call(['python','./drive_refresh.py'])
         sys.stdout.write('Account Saved')
         logging.info('Account Saved')
         # s.wfile.write('Your code has been saved in Alfred')
     except:
         s.wfile.write('Error with setting code')
def main():
    try:
        # test if internet is working
        urllib2.urlopen('http://google.com', timeout=1)
        results = Drive.get_links()
        wf.cache_data('drive_api_results', results)
        wf.cache_data('drive_error', None) #No error if able to make requests
    except (requests.ConnectionError, PasswordNotFound, urllib2.URLError), e:
        error = type(e).__name__
        print error
        if error == 'URLError':
            error = 'ConnectionError'
        wf.cache_data('drive_error', error)
Example #6
0
def main():
    try:
        # test if internet is working
        urllib2.urlopen('http://google.com', timeout=1)
        results = Drive.get_links()
        wf.cache_data('drive_api_results', results)
        wf.cache_data('drive_error', None)  #No error if able to make requests
    except (requests.ConnectionError, PasswordNotFound, urllib2.URLError), e:
        error = type(e).__name__
        print error
        if error == 'URLError':
            error = 'ConnectionError'
        wf.cache_data('drive_error', error)
Example #7
0
def main(wf):
    url = wf.args[0]
    if url == 'logout':
        Drive.revoke_tokens()
        return sys.stdout.write('logged out')
    elif url == 'login':
        return Drive.open_auth_page()
    elif url == 'clear':
        Drive.clear_cache()
        return sys.stdout.write('cache cleared')
    elif url.startswith('set'):
        length = int(url[3:])
        Drive.set_cache_length(length)
        return sys.stdout.write('cache set to %s seconds' % str(length))

    subprocess.call(['open', url])
def main(wf):
    url = wf.args[0]
    if url == 'logout':
        Drive.revoke_tokens()
        return sys.stdout.write('logged out')
    elif url == 'login':
        return Drive.open_auth_page()
    elif url == 'clear':
        Drive.clear_cache()
        return sys.stdout.write('cache cleared')
    elif url.startswith('set'):
        length = int(url[3:])
        Drive.set_cache_length(length)
        return sys.stdout.write('cache set to %s seconds' % str(length))

    subprocess.call(['open', url])
Example #9
0
def main(wf):
    url = wf.args[0]
    if url == 'logout':
        Drive.revoke_tokens()
        return sys.stdout.write('logged out')
    elif url == 'login':
        return Drive.open_auth_page()
    elif url == 'clear':
        Drive.clear_cache()
        return sys.stdout.write('cache cleared')
    elif url == 'create_doc':
        url = Drive.create_file('DOC')
    elif url == 'create_sheet':
        url = Drive.create_file('SHEET')
    elif url == 'create_slide':
        url = Drive.create_file('SLIDE')
    elif url == 'create_form':
        url = Drive.create_file('FORM')
    elif url.startswith('set'):
        length = int(url[3:])
        Drive.set_cache_length(length)
        return sys.stdout.write('cache set to %s seconds' % str(length))

    subprocess.call(['open', url])