Beispiel #1
0
    def __init__(self, args=[]):
        Core.__init__(self)
        self._init_parser(NonExitingArgumentParser)

        if args:
            try:
                print json.dumps(self.do(args), indent=4)
            except ArgParseException:
                pass
        else:
            self.main_loop()
Beispiel #2
0
import os
import web
import json

from chunker.core import Core
from chunker.args import WebArgumentParser, ArgParseException
from chunker.util import get_config_path


core = Core()
core._init_parser(WebArgumentParser)
core.start()


class api:
    def GET(self, cmd):
        try:
            args = core.parser.parse_args(cmd, web.input())
            data = args.func(args)
            return json.dumps(data, indent=4)
        except Exception as e:
            return json.dumps({"status": "error", "message": str(e)})


class index:
    def GET(self):
        return file("static/index.html").read()


class download:
    def GET(self, uuid, name):