Пример #1
0
    def get(self, path):
        path = path.replace("{{{cns}}}","").replace("{{{ns}}}","")

        try:
            uri = self.get_argument('uri')
        except:
            if path.endswith(".css"):
                self.absolute_path = os.path.join(HTML_DIR, 'resources', path)
                with open(self.absolute_path, 'r') as fd:
                    self.set_header('Content-type', 'text/css')
                    self.write(fd.read().replace("{{{cns}}}","_sdk").replace("{{{ns}}}",""))
                    return

            return self.shared_resource(path)

        try:
            root = get_plugin_info(uri)['gui']['resourcesDirectory']
        except:
            raise web.HTTPError(404)

        try:
            super(EffectResource, self).initialize(root)
            return super(EffectResource, self).get(path)
        except web.HTTPError as e:
            if e.status_code != 404:
                raise e
            self.shared_resource(path)
        except IOError:
            raise web.HTTPError(404)
Пример #2
0
    def get(self, path):
        path = path.replace("{{{cns}}}","").replace("{{{ns}}}","")

        try:
            uri = self.get_argument('uri')
        except:
            if path.endswith(".css"):
                self.absolute_path = os.path.join(HTML_DIR, 'resources', path)
                with open(self.absolute_path, 'r') as fd:
                    self.set_header('Content-type', 'text/css')
                    self.write(fd.read().replace("{{{cns}}}","_sdk").replace("{{{ns}}}",""))
                    return

            return self.shared_resource(path)

        try:
            data = get_plugin_info(uri)
        except:
            raise web.HTTPError(404)

        try:
            root = data['gui']['resourcesDirectory']
        except:
            raise web.HTTPError(404)

        try:
            super(EffectResource, self).initialize(root)
            return super(EffectResource, self).get(path)
        except web.HTTPError as e:
            if e.status_code != 404:
                raise e
            self.shared_resource(path)
        except IOError:
            raise web.HTTPError(404)
Пример #3
0
    def get(self):
        self.uri    = self.get_argument('uri')
        self.width  = self.get_argument('width')
        self.height = self.get_argument('height')

        try:
            self.data = get_plugin_info(self.uri)
        except:
            self.data = None
            raise web.HTTPError(404)

        self.make_screenshot()
Пример #4
0
    def get(self):
        self.uri    = self.get_argument('uri')
        self.width  = self.get_argument('width')
        self.height = self.get_argument('height')

        try:
            self.data = get_plugin_info(self.uri)
        except:
            self.data = None
            raise web.HTTPError(404)

        self.make_screenshot()
Пример #5
0
    def get(self):
        uri = self.get_argument('uri')

        try:
            data = get_plugin_info(uri)
        except:
            print("get failed")
            raise web.HTTPError(404)

        self.set_header('Content-type', 'application/json')
        self.write(json.dumps({
            'ok': True,
            'data': data
        }))
Пример #6
0
    def get(self):
        uri = self.get_argument('uri')

        # workaround to support fragment in URLs
        # https://github.com/ariya/phantomjs/issues/12667
        # https://github.com/moddevices/mod-sdk/issues/1
        uri = uri.replace('%23', '#')

        try:
            data = get_plugin_info(uri)
        except:
            print("get failed")
            raise web.HTTPError(404)

        self.write({'ok': True, 'data': data})
Пример #7
0
    def initialize(self):
        # return custom type directly. The browser will do the parsing
        self.custom_type = None

        uri = self.get_argument('uri')

        try:
            self.modgui = get_plugin_info(uri)['gui']
        except:
            raise web.HTTPError(404)

        try:
            root = self.modgui['resourcesDirectory']
        except:
            raise web.HTTPError(404)

        return TimelessStaticFileHandler.initialize(self, root)
Пример #8
0
    def initialize(self):
        # return custom type directly. The browser will do the parsing
        self.custom_type = None

        uri = self.get_argument('uri')

        try:
            self.modgui = get_plugin_info(uri)['gui']
        except:
            raise web.HTTPError(404)

        try:
            root = self.modgui['resourcesDirectory']
        except:
            raise web.HTTPError(404)

        return TimelessStaticFileHandler.initialize(self, root)
Пример #9
0
    def get(self):
        uri = self.get_argument('uri')

        # workaround to support fragment in URLs
        # https://github.com/ariya/phantomjs/issues/12667
        # https://github.com/moddevices/mod-sdk/issues/1
        uri = uri.replace('%23', '#')

        try:
            data = get_plugin_info(uri)
        except:
            print("get failed")
            raise web.HTTPError(404)

        self.write({
            'ok'  : True,
            'data': data
        })
Пример #10
0
    def initialize(self):
        uri = self.get_argument('uri')

        try:
            data = get_plugin_info(uri)
        except:
            raise web.HTTPError(404)

        try:
            self.modgui = data['gui']
        except:
            raise web.HTTPError(404)

        try:
            root = self.modgui['resourcesDirectory']
        except:
            raise web.HTTPError(404)

        return TimelessStaticFileHandler.initialize(self, root)
Пример #11
0
    def get(self):
        uri = self.get_argument('uri')

        try:
            data = get_plugin_info(uri)
        except:
            raise web.HTTPError(404)

        try:
            path = data['gui']['javascript']
        except:
            raise web.HTTPError(404)

        if not os.path.exists(path):
            raise web.HTTPError(404)

        with open(path, 'rb') as fd:
            self.set_header('Content-type', 'text/plain')
            self.write(fd.read())
Пример #12
0
    def initialize(self):
        uri = self.get_argument('uri')

        try:
            data = get_plugin_info(uri)
        except:
            raise web.HTTPError(404)

        try:
            self.modgui = data['gui']
        except:
            raise web.HTTPError(404)

        try:
            root = self.modgui['resourcesDirectory']
        except:
            raise web.HTTPError(404)

        return TimelessStaticFileHandler.initialize(self, root)
Пример #13
0
    def get(self, image):
        uri = self.get_argument('uri')

        try:
            data = get_plugin_info(uri)
        except:
            raise web.HTTPError(404)

        try:
            path = data['gui'][image]
        except:
            path = None

        if path is None or not os.path.exists(path):
            try:
                path = DEFAULT_ICON_IMAGE[image]
            except:
                raise web.HTTPError(404)

        with open(path, 'rb') as fd:
            self.set_header('Content-type', 'image/png')
            self.write(fd.read())
Пример #14
0
 def get_bundle_plugins(bundle):
     return [get_plugin_info(p['uri']) for p in get_bundle_plugins2(bundle)]
Пример #15
0
    def post(self):
        if not LV2_DIR:
            self.write(False)
            return

        uri = self.get_argument('uri')
        ttlText = self.get_argument('ttlText')
        filesToCopy = [os.path.join(HTML_DIR, "resources", fil) for fil in json.loads(self.get_argument('filesToCopy'))]
        iconTemplateData = self.get_argument('iconTemplateData')
        iconTemplateFile = self.get_argument('iconTemplateFile')
        stylesheetFile   = self.get_argument('stylesheetFile')

        for fil in filesToCopy:
            if not os.path.exists(fil):
                print("missing file:", fil)
                raise web.HTTPError(404)

        try:
            data = get_plugin_info(uri)
        except:
            print("ERROR in webserver.py: get_plugin_info for '%s' failed" % uri)
            self.write(False)
            return

        bundledir, resrcsdir, appendMode = self.get_bundle_location(data)

        bundledir = os.path.abspath(bundledir)
        resrcsdir = os.path.abspath(resrcsdir)
        lv2dir    = os.path.abspath(os.path.join(bundledir, os.path.pardir))

        if not os.path.exists(lv2dir):
             os.mkdir(lv2dir)
        if not os.path.exists(bundledir):
             os.mkdir(bundledir)
        if not os.path.exists(resrcsdir):
             os.mkdir(resrcsdir)

        if data['gui']['usingSeeAlso'] or appendMode:
            ttlFile = "modgui.ttl"
        else:
            ttlFile = "manifest.ttl"

        if appendMode:
            with open(os.path.join(bundledir, "manifest.ttl"), 'a') as fd:
                fd.write("<%s> rdfs:seeAlso <modgui.ttl> .\n" % (data['uri'],))

        with open(os.path.join(bundledir, ttlFile), 'w') as fd:
            fd.write(ttlText)

        with open(os.path.join(resrcsdir, iconTemplateFile), 'w') as fd:
            fd.write(iconTemplateData)

        with open(os.path.join(resrcsdir, stylesheetFile), 'w') as fd:
            stylesheetData = ""

            for fil in filesToCopy:
                if not fil.endswith(".css"):
                    continue
                with open(fil, 'r') as fild:
                    stylesheetData += fild.read()

            fd.write(stylesheetData)

        for fil in filesToCopy:
            if fil.endswith(".css"):
                continue

            localfile = fil.replace(HTML_DIR,"",1).replace("resources/","",1)
            if localfile[0] == "/":
                localfile = localfile[1:]
            localfile = os.path.join(resrcsdir, localfile)

            localdir  = os.path.dirname(localfile)
            localdir2 = os.path.dirname(localdir)

            if not os.path.exists(localdir2):
                os.mkdir(localdir2)
            if not os.path.exists(localdir):
                os.mkdir(localdir)

            with open(fil, 'rb') as fild:
                with open(localfile, 'wb') as locald:
                    locald.write(fild.read())

        lv2_cleanup()
        lv2_init()

        self.write(True)
Пример #16
0
    def post(self):
        if not LV2_DIR:
            self.write(False)
            return

        uri = self.get_argument('uri')
        ttlText = self.get_argument('ttlText')
        filesToCopy = [os.path.join(HTML_DIR, "resources", fil) for fil in json.loads(self.get_argument('filesToCopy'))]
        iconTemplateData = self.get_argument('iconTemplateData')
        iconTemplateFile = self.get_argument('iconTemplateFile')
        stylesheetFile   = self.get_argument('stylesheetFile')

        for fil in filesToCopy:
            if not os.path.exists(fil):
                print("missing file:", fil)
                raise web.HTTPError(404)

        try:
            data = get_plugin_info(uri)
        except:
            print("ERROR in webserver.py: get_plugin_info for '%s' failed" % uri)
            self.write(False)
            return

        bundledir, resrcsdir, appendMode = self.get_bundle_location(data)

        bundledir = os.path.abspath(bundledir)
        resrcsdir = os.path.abspath(resrcsdir)
        lv2dir    = os.path.abspath(os.path.join(bundledir, os.path.pardir))

        if not os.path.exists(lv2dir):
             os.mkdir(lv2dir)
        if not os.path.exists(bundledir):
             os.mkdir(bundledir)
        if not os.path.exists(resrcsdir):
             os.mkdir(resrcsdir)

        if data['gui']['usingSeeAlso'] or appendMode:
            ttlFile = "modgui.ttl"
        else:
            ttlFile = "manifest.ttl"

        if appendMode:
            with open(os.path.join(bundledir, "manifest.ttl"), 'a') as fd:
                fd.write("<%s> rdfs:seeAlso <modgui.ttl> .\n" % (data['uri'],))

        with open(os.path.join(bundledir, ttlFile), 'w') as fd:
            fd.write(ttlText)

        with open(os.path.join(resrcsdir, iconTemplateFile), 'w') as fd:
            fd.write(iconTemplateData)

        with open(os.path.join(resrcsdir, stylesheetFile), 'w') as fd:
            stylesheetData = ""

            for fil in filesToCopy:
                if not fil.endswith(".css"):
                    continue
                with open(fil, 'r') as fild:
                    stylesheetData += fild.read()

            fd.write(stylesheetData)

        for fil in filesToCopy:
            if fil.endswith(".css"):
                continue

            localfile = fil.replace(HTML_DIR,"",1).replace("resources/","",1)
            if localfile[0] == "/":
                localfile = localfile[1:]
            localfile = os.path.join(resrcsdir, localfile)

            localdir  = os.path.dirname(localfile)
            localdir2 = os.path.dirname(localdir)

            if not os.path.exists(localdir2):
                os.mkdir(localdir2)
            if not os.path.exists(localdir):
                os.mkdir(localdir)

            with open(fil, 'rb') as fild:
                with open(localfile, 'wb') as locald:
                    locald.write(fild.read())

        lv2_cleanup()
        lv2_init()

        self.write(True)
Пример #17
0
    def post(self):
        if not LV2_DIR:
            self.set_header('Content-type', 'application/json')
            self.write(json.dumps(False))
            return

        uri = self.get_argument('uri')
        ttlText = self.get_argument('ttlText')
        filesToCopy = [os.path.join(HTML_DIR, "resources", fil) for fil in json.loads(self.get_argument('filesToCopy'))]
        iconTemplateData = self.get_argument('iconTemplateData')
        iconTemplateFile = self.get_argument('iconTemplateFile')
        stylesheetFile   = self.get_argument('stylesheetFile')

        for fil in filesToCopy:
            if not os.path.exists(fil):
                print("missing file:", fil)
                raise web.HTTPError(404)

        try:
            data = get_plugin_info(uri)
        except:
            print("ERROR in webserver.py: get_plugin_info for '%s' failed" % uri)
            self.set_header('Content-type', 'application/json')
            self.write(json.dumps(False))
            return

        if 'modificableInPlace' in data['gui'] and data['gui']['modificableInPlace']:
            resrcsdir = data['gui']['resourcesDirectory']
            bundledir = os.path.join(resrcsdir, os.path.pardir)

        else:
            bundlname = symbolify(data['name'])
            bundledir = "%s/%s.modgui" % (LV2_DIR, bundlname)

            # if bundle already exists, generate a new random bundle name
            if os.path.exists(bundledir):
                while True:
                    bundledir = "%s/%s-%i.modgui" % (LV2_DIR, bundlname, random.randint(1,99999))
                    if os.path.exists(bundledir):
                        continue
                    break

            resrcsdir = os.path.join(bundledir, "modgui")

        bundledir = os.path.abspath(bundledir)
        resrcsdir = os.path.abspath(resrcsdir)
        lv2dir    = os.path.abspath(os.path.join(bundledir, os.path.pardir))

        if not os.path.exists(lv2dir):
             os.mkdir(lv2dir)
        if not os.path.exists(bundledir):
             os.mkdir(bundledir)
        if not os.path.exists(resrcsdir):
             os.mkdir(resrcsdir)

        if 'usingSeeAlso' in data['gui'].keys() and data['gui']['usingSeeAlso']:
            ttlFile = "modgui.ttl"
        else:
            ttlFile = "manifest.ttl"

        with open(os.path.join(bundledir, ttlFile), 'w') as fd:
            fd.write(ttlText)

        with open(os.path.join(resrcsdir, iconTemplateFile), 'w') as fd:
            fd.write(iconTemplateData)

        with open(os.path.join(resrcsdir, stylesheetFile), 'w') as fd:
            stylesheetData = ""

            for fil in filesToCopy:
                if not fil.endswith(".css"):
                    continue
                with open(fil, 'r') as fild:
                    stylesheetData += fild.read()

            fd.write(stylesheetData)

        for fil in filesToCopy:
            if fil.endswith(".css"):
                continue

            localfile = fil.replace(HTML_DIR,"",1).replace("resources/","",1)
            if localfile[0] == "/":
                localfile = localfile[1:]
            localfile = os.path.join(resrcsdir, localfile)

            localdir  = os.path.dirname(localfile)
            localdir2 = os.path.dirname(localdir)

            if not os.path.exists(localdir2):
                os.mkdir(localdir2)
            if not os.path.exists(localdir):
                os.mkdir(localdir)

            with open(fil, 'rb') as fild:
                with open(localfile, 'wb') as locald:
                    locald.write(fild.read())

        lv2_cleanup()
        lv2_init()

        self.set_header('Content-type', 'application/json')
        self.write(json.dumps(True))
Пример #18
0
 def get_bundle_plugins(bundle):
     return [get_plugin_info(p['uri']) for p in get_bundle_plugins2(bundle)]