Ejemplo n.º 1
0
    def get(self):
        # Banks have only bundle and title of each pedalboard, which is the necessary information for the HMI.
        # But for the GUI we need to know information about the used pedalboards

        # First we get all pedalboard info
        pedalboards_data = dict((os.path.abspath(pb['bundle']), pb)
                                for pb in get_all_pedalboards())

        # List the broken pedalboards, we do not want to show those
        broken_pedalboards = []

        for bundlepath, pedalboard in pedalboards_data.items():
            if pedalboard['broken']:
                broken_pedalboards.append(bundlepath)

        # Get the banks using our broken pedalboards filter
        banks = list_banks(broken_pedalboards)

        # Put the full pedalboard info into banks
        for bank in banks:
            bank_pedalboards = []
            for pb in bank['pedalboards']:
                bundle = os.path.abspath(pb['bundle'])
                try:
                    pbdata = pedalboards_data[bundle]
                except KeyError:
                    continue
                bank_pedalboards.append(pbdata)
            bank['pedalboards'] = bank_pedalboards

        # All set
        self.write(banks)
Ejemplo n.º 2
0
    def post(self):
        bundles = json.loads(self.request.body.decode("utf-8",
                                                      errors="ignore"))
        error = ""
        removed = []

        print("asked to remove these:", bundles)

        for bundlepath in bundles:
            if os.path.exists(bundlepath) and os.path.isdir(bundlepath):
                resp, data = yield gen.Task(SESSION.host.remove_bundle,
                                            bundlepath, True)

                if resp:
                    removed += data
                    shutil.rmtree(bundlepath)
                else:
                    error = data
                    break
            else:
                print("bundlepath is non-existent:", bundlepath)

        if error:
            resp = {
                'ok': False,
                'error': error,
                'removed': removed,
            }
        elif len(removed) == 0:
            resp = {
                'ok': False,
                'error': "No plugins found",
                'removed': [],
            }
        else:
            resp = {
                'ok': True,
                'removed': removed,
            }

        if len(removed) > 0:
            # Re-save banks, as pedalboards might contain the removed plugins
            broken = get_broken_pedalboards()
            if len(broken) > 0:
                list_banks(broken)

        self.write(resp)
Ejemplo n.º 3
0
    def get(self):
        banks = list_banks()

        # Banks have only URI and title of each pedalboard, which are the necessary information for the HMI.
        # But the GUI needs the whole pedalboard metadata
        pedalboards_dict = get_pedalboards(True)
        pedalboards_keys = pedalboards_dict.keys()

        for bank in banks:
            pedalboards = []

            for pedalboard in bank['pedalboards']:
                if pedalboard['uri'] in pedalboards_keys:
                    pedalboards.append(format_pedalboard(pedalboards_dict[pedalboard['uri']]))

            bank['pedalboards'] = pedalboards

        self.set_header('Content-Type', 'application/json')
        self.write(json.dumps(banks))
Ejemplo n.º 4
0
    def get(self):
        banks = list_banks()

        # Banks have only URI and title of each pedalboard, which are the necessary information for the HMI.
        # But the GUI needs the whole pedalboard metadata
        pedalboards_dict = get_pedalboards(True)
        pedalboards_keys = pedalboards_dict.keys()

        for bank in banks:
            pedalboards = []

            for pedalboard in bank['pedalboards']:
                if pedalboard['uri'] in pedalboards_keys:
                    pedalboards.append(
                        format_pedalboard(pedalboards_dict[pedalboard['uri']]))

            bank['pedalboards'] = pedalboards

        self.set_header('Content-Type', 'application/json')
        self.write(json.dumps(banks))
Ejemplo n.º 5
0
def install_bundles_in_tmp_dir(callback):
    error     = ""
    removed   = []
    installed = []
    pluginsWereRemoved = False

    for bundle in os.listdir(DOWNLOAD_TMP_DIR):
        tmppath    = os.path.join(DOWNLOAD_TMP_DIR, bundle)
        bundlepath = os.path.join(LV2_PLUGIN_DIR, bundle)

        if os.path.exists(bundlepath):
            resp, data = yield gen.Task(SESSION.host.remove_bundle, bundlepath, True)

            # When removing bundles we can ignore the ones that are not loaded
            # It can happen if a previous install failed abruptly
            if not resp and data == "Bundle not loaded":
                resp = True
                data = []

            if resp:
                removed += data
                shutil.rmtree(bundlepath)
            else:
                error = data
                break

        shutil.move(tmppath, bundlepath)
        resp, data = yield gen.Task(SESSION.host.add_bundle, bundlepath)

        if resp:
            installed += data
        else:
            error = data
            # remove bundle that produces errors
            shutil.rmtree(bundlepath)
            break

    for uri in removed:
        if uri not in installed:
            pluginsWereRemoved = True
            try:
                gState.favorites.remove(uri)
            except ValueError:
                pass

    if pluginsWereRemoved:
        # Re-save favorites list
        with open(FAVORITES_JSON_FILE, 'w') as fh:
            json.dump(gState.favorites, fh)

        # Re-save banks
        broken = get_broken_pedalboards()
        if len(broken) > 0:
            list_banks(broken)

    if error or len(installed) == 0:
        # Delete old temp files
        for bundle in os.listdir(DOWNLOAD_TMP_DIR):
            shutil.rmtree(os.path.join(DOWNLOAD_TMP_DIR, bundle))

        resp = {
            'ok'       : False,
            'error'    : error or "No plugins found in bundle",
            'removed'  : removed,
            'installed': [],
        }
    else:
        resp = {
            'ok'       : True,
            'removed'  : removed,
            'installed': installed,
        }

    callback(resp)
Ejemplo n.º 6
0
 def hmi_list_banks(self, callback):
     logging.info("hmi list banks")
     self.banks = list_banks()
     banks = " ".join('"%s" %d' % (bank['title'], i) for i,bank in enumerate(self.banks))
     callback(True, banks)
Ejemplo n.º 7
0
 def hmi_list_banks(self, callback):
     logging.info("hmi list banks")
     self.banks = list_banks()
     banks = " ".join('"%s" %d' % (bank['title'], i)
                      for i, bank in enumerate(self.banks))
     callback(True, banks)