~thecashewtrader/scripts

afcf0cda73c0d423d9276b028370d67641d6b3d6 — thecashewtrader 5 months ago 8294e18 main
add mkankideck.py
2 files changed, 24 insertions(+), 0 deletions(-)

A mkankideck/mkankideck.py
M symlinks/symlinks.sh
A mkankideck/mkankideck.py => mkankideck/mkankideck.py +23 -0
@@ 0,0 1,23 @@
#!/usr/bin/env python

import json
import urllib.request
import sys

def request(action, **params):
    return {'action': action, 'params': params, 'version': 6}

def invoke(action, **params):
    requestJson = json.dumps(request(action, **params)).encode('utf-8')
    response = json.load(urllib.request.urlopen(urllib.request.Request('http://127.0.0.1:8765', requestJson)))
    if len(response) != 2:
        raise Exception('response has an unexpected number of fields')
    if 'error' not in response:
        raise Exception('response is missing required error field')
    if 'result' not in response:
        raise Exception('response is missing required result field')
    if response['error'] is not None:
        raise Exception(response['error'])
    return response['result']

invoke('createDeck', deck=sys.argv[1])

M symlinks/symlinks.sh => symlinks/symlinks.sh +1 -0
@@ 34,3 34,4 @@ ln -s ~/.scripts/cscat/cscat.sh ~/.local/bin/cscat
ln -s ~/.scripts/digitise_clipboard/digitise_clipboard.sh ~/.local/bin/digitise_clipboard
ln -s ~/.scripts/ytdlp_clip/ytdlp_clip.sh ~/.local/bin/ytdlp_clip
ln -s ~/.scripts/get_firefox_tabs/get_firefox_tabs.py ~/.local/bin/get_firefox_tabs
ln -s ~/.scripts/mkankideck/mkankideck.py ~/.local/bin/mkankideck