<commit_before>#!/usr/bin/python3
import sys
import json
from serverboards_aio import print, settings
import serverboards_aio as serverboards
import curio
import curio.subprocess


def json_loads(str):
    if isinstance(str, bytes):
        str = bytes.decode('utf8')
    return json.loads(str)


@serverboards.rpc_method
async def search(*args, **kwargs):
    terms = list(args) + ["%s:%s" % x for x in kwargs.items() if not x[0].startswith('-')]
    await serverboards.debug("Searching for components with: %s" % terms)

    cmd = ["s10s", "plugin", "search", "--format=json", *terms, "--fields=base,icon,icon64"]
    print(cmd)
    result = await curio.subprocess.check_output(cmd)

    return json_loads(result)


@serverboards.rpc_method
async def install(plugin_id):
    try:
        res = await curio.subprocess.check_output(["s10s", "plugin", "install", "--format=json", plugin_id])
    except curio.subprocess.CalledProcessError as e:
        print(e.output)
        raise

    return json_loads(res)


@serverboards.rpc_method
async def account():
    try:
        res = await curio.subprocess.check_output(["s10s", "plugin", "account", "--format=json"])
    except curio.subprocess.CalledProcessError as e:
        raise Exception(json_loads(e.output)["message"])<commit_msg>Fix marketplace at real installations<commit_after>#!/usr/bin/python3
import sys
import json
from serverboards_aio import print, settings
import serverboards_aio as serverboards
import curio
import curio.subprocess


def json_loads(s):
    if isinstance(s, bytes):
        s = s.decode('utf8')
    return json.loads(s)


@serverboards.rpc_method
async def search(*args, **kwargs):
    terms = list(args) + ["%s:%s" % x for x in kwargs.items() if not x[0].startswith('-')]
    await serverboards.debug("Searching for components with: %s" % terms)

    cmd = ["s10s", "plugin", "search", "--format=json", *terms, "--fields=base,icon,icon64"]
    print(cmd)
    result = await curio.subprocess.check_output(cmd)

    return json_loads(result)


@serverboards.rpc_method
async def install(plugin_id):
    try:
        res = await curio.subprocess.check_output(["s10s", "plugin", "install", "--format=json", plugin_id])
    except curio.subprocess.CalledProcessError as e:
        print(e.output)
        raise

    return json_loads(res)


@serverboards.rpc_method
async def account():
    try:
        res = await curio.subprocess.check_output(["s10s", "plugin", "account", "--format=json"])
    except curio.subprocess.CalledProcessError as e:
        raise Exception(json_loads(e.output)["message"])
{'fraction_non_alphanumeric': 0.1369969040247678, 'fraction_numerical': 0.008513931888544891, 'mean_word_length': 4.078585461689587, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2267203', 'n_tokens_mistral': 843, 'n_tokens_neox': 832, 'n_words': 203}