예제 #1
0
def _get_update_status():
    url = gmCfgDB.get4workplace(
        option='horstspace.update.url',
        workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace,
        default='https://www.gnumed.de/downloads/gnumed-versions.txt')
    consider_latest_branch = gmCfgDB.get4workplace(
        option='horstspace.update.consider_latest_branch',
        workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace,
        default=True)
    _cfg = gmCfgINI.gmCfgData()
    update_found, msg = gmNetworkTools.check_for_update(
        url=url,
        current_branch=_cfg.get(option='client_branch'),
        current_version=_cfg.get(option='client_version'),
        consider_latest_branch=consider_latest_branch)
    return update_found, msg
예제 #2
0
    def edit_old(workplace=None):

        available_plugins = gmPlugin.get_installed_plugins(plugin_dir='gui')
        if workplace is None:
            dlg = wx.TextEntryDialog(
                parent,
                _('Enter a descriptive name for the new workplace:'),
                caption=_('Configuring GNUmed workplaces ...'),
                value='',
                style=wx.OK | wx.CENTRE)
            dlg.ShowModal()
            workplace = dlg.GetValue().strip()
            if workplace == '':
                gmGuiHelpers.gm_show_error(
                    _('Cannot save a new workplace without a name.'),
                    _('Configuring GNUmed workplaces ...'))
                return False
            curr_plugins = []
            choices = available_plugins
        else:
            curr_plugins = gmTools.coalesce(
                gmCfgDB.get4workplace(
                    option='horstspace.notebook.plugin_load_order',
                    workplace=workplace), [])
            choices = curr_plugins[:]
            for p in available_plugins:
                if p not in choices:
                    choices.append(p)

        sels = range(len(curr_plugins))
        new_plugins = gmListWidgets.get_choices_from_list(
            parent=parent,
            msg=_('\n'
                  'Select the plugin(s) to be loaded the next time\n'
                  'the client is restarted under the workplace:\n'
                  '\n'
                  ' [%s]'
                  '\n') % workplace,
            caption=_('Configuring GNUmed workplaces ...'),
            choices=choices,
            selections=sels,
            columns=[_('Plugins')],
            single_selection=False)

        if new_plugins == curr_plugins:
            return True

        if new_plugins is None:
            return True

        gmCfgDB.set(option='horstspace.notebook.plugin_load_order',
                    value=new_plugins,
                    workplace=workplace)

        return True
예제 #3
0
    def edit(workplace=None):
        if workplace is None:
            dlg = wx.TextEntryDialog(
                parent,
                _('Enter a descriptive name for the new workplace:'),
                caption=_('Configuring GNUmed workplaces ...'),
                value='',
                style=wx.OK | wx.CENTRE)
            dlg.ShowModal()
            workplace = dlg.GetValue().strip()
            if workplace == '':
                gmGuiHelpers.gm_show_error(
                    _('Cannot save a new workplace without a name.'),
                    _('Configuring GNUmed workplaces ...'))
                return False
            curr_plugins = []
        else:
            curr_plugins = gmTools.coalesce(
                gmCfgDB.get4workplace(
                    option='horstspace.notebook.plugin_load_order',
                    workplace=workplace), [])

        msg = _(
            'Pick the plugin(s) to be loaded the next time the client is restarted under the workplace:\n'
            '\n'
            '    [%s]\n') % workplace

        picker = gmListWidgets.cItemPickerDlg(
            parent, -1, title=_('Configuring workplace plugins ...'), msg=msg)
        picker.set_columns(['Available plugins'], ['Active plugins'])
        available_plugins = gmPlugin.get_installed_plugins(plugin_dir='gui')
        picker.set_choices(available_plugins)
        picker.set_picks(picks=curr_plugins[:])
        btn_pressed = picker.ShowModal()
        if btn_pressed != wx.ID_OK:
            picker.DestroyLater()
            return False

        new_plugins = picker.get_picks()
        picker.DestroyLater()
        if new_plugins == curr_plugins:
            return True

        if new_plugins is None:
            return True

        gmCfgDB.set(option='horstspace.notebook.plugin_load_order',
                    value=new_plugins,
                    workplace=workplace)

        return True
예제 #4
0
    def clone(workplace=None):
        if workplace is None:
            return False

        new_name = wx.GetTextFromUser(
            message=_('Enter a name for the new workplace !'),
            caption=_('Cloning workplace'),
            default_value='%s-2' % workplace,
            parent=parent).strip()
        if new_name == '':
            return False

        opt = 'horstspace.notebook.plugin_load_order'
        plugins = gmCfgDB.get4workplace(option=opt, workplace=workplace)
        gmCfgDB.set(option=opt, value=plugins, workplace=new_name)
        # FIXME: clone cfg, too
        return True
예제 #5
0
def GetPluginLoadList(option, plugin_dir='', defaults=None, workplace=None):
    """Get a list of plugins to load.

	1) from database if option is not None
	2) from list of defaults
	3) if 2 is None, from source directory (then stored in database)

	FIXME: NOT from files in directories (important for py2exe)
	"""
    if workplace == 'System Fallback':
        return ['gmProviderInboxPlugin', 'gmDataMiningPlugin']

    if workplace is None:
        workplace = gmPraxis.gmCurrentPraxisBranch().active_workplace

    p_list = None

    if option is not None:
        p_list = gmCfgDB.get4workplace(option=option,
                                       workplace=workplace,
                                       default=defaults)

    if p_list is not None:
        return p_list

    if defaults is None:
        p_list = get_installed_plugins(plugin_dir=plugin_dir)
        if (len(p_list) == 0):
            _log.error('cannot find plugins by scanning plugin directory ?!?')
            return defaults
    else:
        p_list = defaults
    # store for current user/current workplace
    gmCfgDB.set(option=option, value=p_list, workplace=workplace)
    _log.debug("plugin load list stored: %s" % str(p_list))
    return p_list
예제 #6
0
def load_data_packs_list():
    dpl_url = gmCfgDB.get4workplace(
        option=dpl_url_option,
        workplace=gmPraxis.gmCurrentPraxisBranch().active_workplace,
        default=default_dpl_url)

    items = []
    data = []

    dpl_fname = gmNetworkTools.download_data_packs_list(dpl_url)
    if dpl_fname is None:
        return (items, data)
    try:
        _cfg.add_file_source(source='data-packs', file=dpl_fname)
    except (UnicodeDecodeError):
        _log.exception("cannot read data pack list from [%s]", dpl_fname)
        return (items, data)

    packs = _cfg.get('data packs',
                     'data packs',
                     source_order=[('data-packs', 'return')])
    if packs is None:
        _log.info('no data packs listed in data packs list file')
        _cfg.remove_source('data-packs')
        return (items, data)

    for pack in packs:
        _log.debug('reading pack [%s] metadata', pack)
        pack_group = 'pack %s' % pack
        name = _cfg.get(pack_group,
                        'name',
                        source_order=[('data-packs', 'return')])
        pack_url = _cfg.get(pack_group,
                            'URL',
                            source_order=[('data-packs', 'return')])
        md5_url = pack_url + '.md5'
        db_min = _cfg.get(pack_group,
                          'minimum database version',
                          source_order=[('data-packs', 'return')])
        converted, db_min = gmTools.input2int(
            db_min,
            # here we introduced data packs:
            #16,
            0,
            # no use looking at data packs requiring a database > the current database:
            _cfg.get(option='database_version'))
        if not converted:
            _log.error('cannot convert minimum database version [%s]', db_min)
            continue

        db_max = _cfg.get(pack_group,
                          'maximum database version',
                          source_order=[('data-packs', 'return')])
        if db_max is None:
            db_max = sys.maxsize
        converted, db_max = gmTools.input2int(
            db_max,
            db_min  # max version must be at least db_min
        )
        if not converted:
            _log.error('cannot convert maximum database version [%s]', db_max)
            continue

        if _cfg.get(option='database_version') < db_min:
            _log.error(
                'ignoring data pack: current database version (%s) < minimum required database version (%s)',
                _cfg.get(option='database_version'), db_min)
            continue

        if _cfg.get(option='database_version') > db_max:
            _log.error(
                'ignoring data pack: current database version (%s) > maximum allowable database version (%s)',
                _cfg.get(option='database_version'), db_max)
            continue

        items.append([name, 'v%s' % db_min, 'v%s' % db_max, pack_url])
        data.append({
            'name': name,
            'pack_url': pack_url,
            'md5_url': md5_url,
            'db_min': db_min,
            'db_max': db_max
        })

    _cfg.remove_source('data-packs')
    return (items, data)