Beispiel #1
0
    def pedalboard(self):
        context = self.index()
        bundlepath = self.get_argument('bundlepath')

        try:
            pedalboard = get_pedalboard_info(bundlepath)
        except:
            print("ERROR in webserver.py: get_pedalboard_info failed")
            context['pedalboard'] = ""
            return context

        data = {
            "instances": [],
            "connections": pedalboard['connections'],
            "hardware": pedalboard['hardware'],
        }

        for plugin in pedalboard['plugins']:
            data["instances"].append({
                "uri": plugin['uri'],
                "x": plugin['x'],
                "y": plugin['y'],
                "bypassed": not plugin['enabled'],
            })

        context['pedalboard'] = b64encode(json.dumps(data).encode("utf-8"))
        return context
Beispiel #2
0
    def pedalboard(self):
        context = self.index()
        bundlepath = self.get_argument('bundlepath')

        try:
            pedalboard = get_pedalboard_info(bundlepath)
        except:
            print("ERROR in webserver.py: get_pedalboard_info failed")
            context['pedalboard'] = ""
            return context

        data = {
            "instances": [],
            "connections": pedalboard['connections'],
            "hardware": pedalboard['hardware'],
        }

        for plugin in pedalboard['plugins']:
            data["instances"].append({
                "uri": plugin['uri'],
                "x": plugin['x'],
                "y": plugin['y'],
                "bypassed": not plugin['enabled'],
            })

        context['pedalboard'] = b64encode(json.dumps(data).encode("utf-8"))
        return context
Beispiel #3
0
def generate_screenshot(bundlepath, max_width, max_height, callback):
    if not os.path.exists(PHANTOM_BINARY):
        return callback()
    #try: # TESTING let us receive exceptions for now
    pedalboard = get_pedalboard_info(bundlepath)
    #except:
        #return callback()

    path = '%s/screenshot.png' % bundlepath
    port = DEVICE_WEBSERVER_PORT

    proc = subprocess.Popen([ PHANTOM_BINARY,
                              SCREENSHOT_JS,
                              'http://localhost:%d/pedalboard.html?bundlepath=%s' % (port, bundlepath),
                              path,
                              str(pedalboard['size']['width']),
                              str(pedalboard['size']['height']),
                             ],
                            stdout=subprocess.PIPE)

    def handle_image():
        img = Image.open(path)
        resize_image(img, max_width, max_height)
        callback(img)

    loop = ioloop.IOLoop.instance()

    def proc_callback(fileno, event):
        if proc.poll() is None:
            return
        loop.remove_handler(fileno)
        handle_image()

    loop.add_handler(proc.stdout.fileno(), proc_callback, 16)
Beispiel #4
0
    def pedalboard(self):
        context = self.index()
        bundlepath = self.get_argument('bundlepath')

        #try: # TESTING let us receive exceptions for now
        pedalboard = get_pedalboard_info(bundlepath)
        #except:
            #return None

        data = b'{ "_id": "0", "instances": ['

        first = True
        for plugin in pedalboard['plugins']:
            if first:
                first = False
            else:
                data += b','

            msg = '{ "url": "%s", "bypassed": false, "x": %i, "y": %i, "values": {} }' % (plugin['uri'], plugin['x'], plugin['y'])
            print(msg)
            data += bytes(msg, "utf-8")

        data += b'], "connections": ['

        first = True
        for connection in pedalboard['connections']:
            if first:
                first = False
            else:
                data += b','

            msg = '{ "source": "%s", "target": "%s" }' % (connection['source'], connection['target'])
            print(msg)
            data += bytes(msg, "utf-8")

        data += b'] } '

        context['pedalboard'] = b64encode(data)
        return context
Beispiel #5
0
def generate_screenshot(bundlepath, max_width, max_height, callback):
    if not os.path.exists(PHANTOM_BINARY):
        return callback()
    #try: # TESTING let us receive exceptions for now
    pedalboard = get_pedalboard_info(bundlepath)
    #except:
    #return callback()

    path = '%s/screenshot.png' % bundlepath
    port = DEVICE_WEBSERVER_PORT

    proc = subprocess.Popen([
        PHANTOM_BINARY,
        SCREENSHOT_JS,
        'http://localhost:%d/pedalboard.html?bundlepath=%s' %
        (port, bundlepath),
        path,
        str(pedalboard['size']['width']),
        str(pedalboard['size']['height']),
    ],
                            stdout=subprocess.PIPE)

    def handle_image():
        img = Image.open(path)
        resize_image(img, max_width, max_height)
        callback(img)

    loop = ioloop.IOLoop.instance()

    def proc_callback(fileno, event):
        if proc.poll() is None:
            return
        loop.remove_handler(fileno)
        handle_image()

    loop.add_handler(proc.stdout.fileno(), proc_callback, 16)