Esempio n. 1
0
def delete(arg):
    import urllib,urllib2
    import main

    config = main.config_data()
    try:
        user = config['pinboard_username']
        token = config['pinboard_token']
    except:
        print "Setup not complete\npbauth username:token"
        sys.exit(0)

    deleted_url = main.deleted_url_data()
    history = main.launch_history()
    try:
        url = 'https://api.pinboard.in/v1/posts/delete?format=json&auth_token=%s:%s&url=%s'%(user,token,urllib.quote(arg))
        data = urllib2.urlopen(url).read()
        ret = json.loads(data)
        if ret['result_code']=='done':
            print "%s deleted"%urlparse.urlparse(arg)[1]
            deleted_url.append(arg)
            with open(os.path.join(alfred.work(False),'deleted-url.json'),'w+') as f:
                json.dump(deleted_url,f)

            if arg in history:
                del history[arg]
                with open(os.path.join(alfred.work(False),'launch-history.json'),'w+') as f:
                    json.dump(history,f)
        else:
            print ret['result_code']
    except:
        print "Error"
Esempio n. 2
0
def delete(arg):
    import urllib,urllib2
    import main

    config = main.config_data()
    try:
        user = config['pinboard_username']
        token = config['pinboard_token']
    except:
        print "Setup not complete\npbauth username:token"
        sys.exit(0)

    deleted_url = main.deleted_url_data()
    history = main.launch_history()
    try:
        url = 'https://api.pinboard.in/v1/posts/delete?format=json&auth_token=%s:%s&url=%s'%(user,token,urllib.quote(arg))
        data = urllib2.urlopen(url).read()
        ret = json.loads(data)
        if ret['result_code']=='done':
            print "%s deleted"%urlparse.urlparse(arg)[1]
            deleted_url.append(arg)
            with open(os.path.join(alfred.work(False),'deleted-url.json'),'w+') as f:
                json.dump(deleted_url,f)

            if arg in history:
                del history[arg]
                with open(os.path.join(alfred.work(False),'launch-history.json'),'w+') as f:
                    json.dump(history,f)
        else:
            print ret['result_code']
    except:
        print "Error"
Esempio n. 3
0
def delete_history(arg):
    import main

    history = main.launch_history()
    if arg in history:
        del history[arg]
        with open(os.path.join(alfred.work(False),'launch-history.json'),'w+') as f:
            json.dump(history,f)
Esempio n. 4
0
def delete_history(arg):
    import main

    history = main.launch_history()
    if arg in history:
        del history[arg]
        with open(os.path.join(alfred.work(False),'launch-history.json'),'w+') as f:
            json.dump(history,f)
Esempio n. 5
0
def update_history(arg):
    import main
    history = main.launch_history()
    now = int(time.time())
    if arg in history:
        history[arg][0] += 1
        history[arg][1] = now
    else:
        history[arg] = [1, now]
    with open(os.path.join(alfred.work(False),'launch-history.json'),'w+') as f:
        json.dump(history,f)
Esempio n. 6
0
def update_history(arg):
    import main
    history = main.launch_history()
    now = int(time.time())
    if arg in history:
        history[arg][0] += 1
        history[arg][1] = now
    else:
        history[arg] = [1, now]
    with open(os.path.join(alfred.work(False),'launch-history.json'),'w+') as f:
        json.dump(history,f)