Exemplo n.º 1
0
    def format(self, single_line=False):
        if single_line:
            return self.format_single_line()

        txt = _('%s document part                 [#%s]\n') % (
            gmTools.bool2str(
                boolean=self._payload[self._idx['reviewed']],
                true_str=_('Reviewed'),
                false_str=_('Unreviewed')), self._payload[self._idx['pk_obj']])

        f_ext = ''
        if self._payload[self._idx['filename']] is not None:
            f_ext = os.path.splitext(
                self._payload[self._idx['filename']])[1].strip('.').strip()
        if f_ext != '':
            f_ext = '.' + f_ext.upper() + ' '
        txt += _(' Part %s: %s %s(%s Bytes)\n') % (
            self._payload[self._idx['seq_idx']],
            gmTools.size2str(self._payload[self._idx['size']]), f_ext,
            self._payload[self._idx['size']])

        if self._payload[self._idx['filename']] is not None:
            path, fname = os.path.split(self._payload[self._idx['filename']])
            if not path.endswith(os.path.sep):
                if path != '':
                    path += os.path.sep
            if path != '':
                path = ' (%s)' % path
            txt += _(' Filename: %s%s\n') % (fname, path)

        if self._payload[self._idx['obj_comment']] is not None:
            txt += '\n%s\n' % self._payload[self._idx['obj_comment']]

        return txt
Exemplo n.º 2
0
    def format(self, single_line=False):
        if single_line:
            return self.format_single_line()

        txt = _("%s document part                 [#%s]\n") % (
            gmTools.bool2str(
                boolean=self._payload[self._idx["reviewed"]], true_str=_("Reviewed"), false_str=_("Unreviewed")
            ),
            self._payload[self._idx["pk_obj"]],
        )

        f_ext = u""
        if self._payload[self._idx["filename"]] is not None:
            f_ext = os.path.splitext(self._payload[self._idx["filename"]])[1].strip(".").strip()
        if f_ext != u"":
            f_ext = u"." + f_ext.upper() + u" "
        txt += _(" Part %s: %s %s(%s Bytes)\n") % (
            self._payload[self._idx["seq_idx"]],
            gmTools.size2str(self._payload[self._idx["size"]]),
            f_ext,
            self._payload[self._idx["size"]],
        )

        if self._payload[self._idx["filename"]] is not None:
            txt += _(" Filename: %s\n") % self._payload[self._idx["filename"]]

        if self._payload[self._idx["obj_comment"]] is not None:
            txt += u"\n%s\n" % self._payload[self._idx["obj_comment"]]

        return txt
Exemplo n.º 3
0
    def refresh(self, *args, **kwargs):
        if self.__channel_owner is None:
            self._LCTRL_items.set_string_items()
            return

        comms = self.__channel_owner.get_comm_channels()
        self._LCTRL_items.set_string_items(items=[[
            gmTools.bool2str(c['is_confidential'], 'X', ''),
            c['l10n_comm_type'], c['url'],
            gmTools.coalesce(c['comment'], '')
        ] for c in comms])
        self._LCTRL_items.set_column_widths()
        self._LCTRL_items.set_data(data=comms)
Exemplo n.º 4
0
	def refresh(self, *args, **kwargs):
		if self.__channel_owner is None:
			self._LCTRL_items.set_string_items()
			return

		comms = self.__channel_owner.get_comm_channels()
		self._LCTRL_items.set_string_items (
			items = [ [
				gmTools.bool2str(c['is_confidential'], u'X', u''),
				c['l10n_comm_type'],
				c['url'],
				gmTools.coalesce(c['comment'], u'')
			] for c in comms ]
		)
		self._LCTRL_items.set_column_widths()
		self._LCTRL_items.set_data(data = comms)
Exemplo n.º 5
0
	def __init__(self, *args, **kwargs):

		episodes = kwargs['episodes']
		del kwargs['episodes']

		gmListWidgets.cGenericListSelectorDlg.__init__(self, *args, **kwargs)

		self.SetTitle(_('Select the episodes you are interested in ...'))
		self._LCTRL_items.set_columns([_('Episode'), _('Status'), _('Health Issue')])
		self._LCTRL_items.set_string_items (
			items = [ 
				[	epi['description'], 
					gmTools.bool2str(epi['episode_open'], _('ongoing'), ''), 
					gmTools.coalesce(epi['health_issue'], '')
				]
				for epi in episodes ]
		)
		self._LCTRL_items.set_column_widths()
		self._LCTRL_items.set_data(data = episodes)
Exemplo n.º 6
0
	def __init__(self, *args, **kwargs):

		episodes = kwargs['episodes']
		del kwargs['episodes']

		gmListWidgets.cGenericListSelectorDlg.__init__(self, *args, **kwargs)

		self.SetTitle(_('Select the episodes you are interested in ...'))
		self._LCTRL_items.set_columns([_('Episode'), _('Status'), _('Health Issue')])
		self._LCTRL_items.set_string_items (
			items = [ 
				[	epi['description'], 
					gmTools.bool2str(epi['episode_open'], _('ongoing'), ''), 
					gmTools.coalesce(epi['health_issue'], '')
				]
				for epi in episodes ]
		)
		self._LCTRL_items.set_column_widths()
		self._LCTRL_items.set_data(data = episodes)
Exemplo n.º 7
0
	def format(self, single_line=False):
		if single_line:
			return self.format_single_line()

		txt = _('%s document part                 [#%s]\n') % (
			gmTools.bool2str (
				boolean = self._payload[self._idx['reviewed']],
				true_str = _('Reviewed'),
				false_str = _('Unreviewed')
			),
			self._payload[self._idx['pk_obj']]
		)

		f_ext = ''
		if self._payload[self._idx['filename']] is not None:
			f_ext = os.path.splitext(self._payload[self._idx['filename']])[1].strip('.').strip()
		if f_ext != '':
			f_ext = '.' + f_ext.upper() + ' '
		txt += _(' Part %s: %s %s(%s Bytes)\n') % (
			self._payload[self._idx['seq_idx']],
			gmTools.size2str(self._payload[self._idx['size']]),
			f_ext,
			self._payload[self._idx['size']]
		)

		if self._payload[self._idx['filename']] is not None:
			path, fname = os.path.split(self._payload[self._idx['filename']])
			if not path.endswith(os.path.sep):
				if path != '':
					path += os.path.sep
			if path != '':
				path = ' (%s)' % path
			txt += _(' Filename: %s%s\n') % (fname, path)

		if self._payload[self._idx['obj_comment']] is not None:
			txt += '\n%s\n' % self._payload[self._idx['obj_comment']]

		return txt
Exemplo n.º 8
0
def check_for_update(url=None,
                     current_branch=None,
                     current_version=None,
                     consider_latest_branch=False):
    """Check for new releases at <url>.

	Returns (bool, text).
	True: new release available
	False: up to date
	None: don't know
	"""
    if current_version == u'GIT HEAD':
        _log.debug('GIT HEAD always up to date')
        return (False, None)

    try:
        remote_file = wget.urlopen(url)
    except (wget.URLError, ValueError, OSError, IOError):
        # IOError: socket.error
        _log.exception("cannot retrieve version file from [%s]", url)
        return (None,
                _('Cannot retrieve version information from:\n\n%s') % url)

    _log.debug('retrieving version information from [%s]', url)

    cfg = gmCfg2.gmCfgData()
    try:
        cfg.add_stream_source(source='gm-versions', stream=remote_file)
    except (UnicodeDecodeError):
        remote_file.close()
        _log.exception("cannot read version file from [%s]", url)
        return (None, _('Cannot read version information from:\n\n%s') % url)

    remote_file.close()

    latest_branch = cfg.get('latest branch',
                            'branch',
                            source_order=[('gm-versions', 'return')])
    latest_release_on_latest_branch = cfg.get('branch %s' % latest_branch,
                                              'latest release',
                                              source_order=[('gm-versions',
                                                             'return')])
    latest_release_on_current_branch = cfg.get('branch %s' % current_branch,
                                               'latest release',
                                               source_order=[('gm-versions',
                                                              'return')])

    cfg.remove_source('gm-versions')

    _log.info('current release: %s', current_version)
    _log.info('current branch: %s', current_branch)
    _log.info('latest release on current branch: %s',
              latest_release_on_current_branch)
    _log.info('latest branch: %s', latest_branch)
    _log.info('latest release on latest branch: %s',
              latest_release_on_latest_branch)

    # anything known ?
    no_release_information_available = (
        ((latest_release_on_current_branch is None) and
         (latest_release_on_latest_branch is None))
        or (not consider_latest_branch and
            (latest_release_on_current_branch is None)))
    if no_release_information_available:
        _log.warning('no release information available')
        msg = _('There is no version information available from:\n\n%s') % url
        return (None, msg)

    # up to date ?
    if consider_latest_branch:
        _log.debug('latest branch taken into account')
        if latest_release_on_latest_branch is None:
            if compare_versions(latest_release_on_current_branch,
                                current_version) in [-1, 0]:
                _log.debug(
                    'up to date: current version >= latest version on current branch and no latest branch available'
                )
                return (False, None)
        else:
            if compare_versions(latest_release_on_latest_branch,
                                current_version) in [-1, 0]:
                _log.debug(
                    'up to date: current version >= latest version on latest branch'
                )
                return (False, None)
    else:
        _log.debug('latest branch not taken into account')
        if compare_versions(latest_release_on_current_branch,
                            current_version) in [-1, 0]:
            _log.debug(
                'up to date: current version >= latest version on current branch'
            )
            return (False, None)

    new_release_on_current_branch_available = (
        (latest_release_on_current_branch is not None) and (compare_versions(
            latest_release_on_current_branch, current_version) == 1))
    _log.info(
        '%snew release on current branch available',
        gmTools.bool2str(new_release_on_current_branch_available, '', 'no '))

    new_release_on_latest_branch_available = ((latest_branch is not None) and (
        (latest_branch > current_branch) or
        ((latest_branch == current_branch) and (compare_versions(
            latest_release_on_latest_branch, current_version) == 1))))
    _log.info(
        '%snew release on latest branch available',
        gmTools.bool2str(new_release_on_latest_branch_available, '', 'no '))

    if not (new_release_on_current_branch_available
            or new_release_on_latest_branch_available):
        _log.debug('up to date: no new releases available')
        return (False, None)

    # not up to date
    msg = _('A new version of GNUmed is available.\n\n')
    msg += _(' Your current version: "%s"\n') % current_version
    if consider_latest_branch:
        if new_release_on_current_branch_available:
            msg += u'\n'
            msg += _(' New version: "%s"') % latest_release_on_current_branch
            msg += u'\n'
            msg += _(' - bug fixes only\n')
            msg += _(' - database fixups may be needed\n')
        if new_release_on_latest_branch_available:
            if current_branch != latest_branch:
                msg += u'\n'
                msg += _(
                    ' New version: "%s"') % latest_release_on_latest_branch
                msg += u'\n'
                msg += _(' - bug fixes and new features\n')
                msg += _(' - database upgrade required\n')
    else:
        msg += u'\n'
        msg += _(' New version: "%s"') % latest_release_on_current_branch
        msg += u'\n'
        msg += _(' - bug fixes only\n')
        msg += _(' - database fixups may be needed\n')

    msg += u'\n\n'
    msg += _('Note, however, that this version may not yet\n'
             'be available *pre-packaged* for your system.')

    msg += u'\n\n'
    msg += _('Details are found on <http://wiki.gnumed.de>.\n')
    msg += u'\n'
    msg += _('Version information loaded from:\n\n %s') % url

    return (True, msg)
Exemplo n.º 9
0
def check_for_update(url=None, current_branch=None, current_version=None, consider_latest_branch=False):
	"""Check for new releases at <url>.

	Returns (bool, text).
	True: new release available
	False: up to date
	None: don't know
	"""
	if current_version == u'GIT HEAD':
		_log.debug('GIT HEAD always up to date')
		return (False, None)

	try:
		remote_file = wget.urlopen(url)
	except (wget.URLError, ValueError, OSError):
		_log.exception("cannot retrieve version file from [%s]", url)
		return (None, _('Cannot retrieve version information from:\n\n%s') % url)

	_log.debug('retrieving version information from [%s]', url)

	cfg = gmCfg2.gmCfgData()
	try:
		cfg.add_stream_source(source = 'gm-versions', stream = remote_file)
	except (UnicodeDecodeError):
		remote_file.close()
		_log.exception("cannot read version file from [%s]", url)
		return (None, _('Cannot read version information from:\n\n%s') % url)

	remote_file.close()

	latest_branch = cfg.get('latest branch', 'branch', source_order = [('gm-versions', 'return')])
	latest_release_on_latest_branch = cfg.get('branch %s' % latest_branch, 'latest release', source_order = [('gm-versions', 'return')])
	latest_release_on_current_branch = cfg.get('branch %s' % current_branch, 'latest release', source_order = [('gm-versions', 'return')])

	cfg.remove_source('gm-versions')

	_log.info('current release: %s', current_version)
	_log.info('current branch: %s', current_branch)
	_log.info('latest release on current branch: %s', latest_release_on_current_branch)
	_log.info('latest branch: %s', latest_branch)
	_log.info('latest release on latest branch: %s', latest_release_on_latest_branch)

	# anything known ?
	no_release_information_available = (
		(
			(latest_release_on_current_branch is None) and
			(latest_release_on_latest_branch is None)
		) or (
			not consider_latest_branch and
			(latest_release_on_current_branch is None)
		)
	)
	if no_release_information_available:
		_log.warning('no release information available')
		msg = _('There is no version information available from:\n\n%s') % url
		return (None, msg)

	# up to date ?
	if consider_latest_branch:
		_log.debug('latest branch taken into account')
		if latest_release_on_latest_branch is None:
			if compare_versions(latest_release_on_current_branch, current_version) in [-1, 0]:
				_log.debug('up to date: current version >= latest version on current branch and no latest branch available')
				return (False, None)
		else:
			if compare_versions(latest_release_on_latest_branch, current_version) in [-1, 0]:
				_log.debug('up to date: current version >= latest version on latest branch')
				return (False, None)
	else:
		_log.debug('latest branch not taken into account')
		if compare_versions(latest_release_on_current_branch, current_version) in [-1, 0]:
			_log.debug('up to date: current version >= latest version on current branch')
			return (False, None)

	new_release_on_current_branch_available = (
		(latest_release_on_current_branch is not None) and
		(compare_versions(latest_release_on_current_branch, current_version) == 1)
	)
	_log.info('%snew release on current branch available', gmTools.bool2str(new_release_on_current_branch_available, '', 'no '))

	new_release_on_latest_branch_available = (
		(latest_branch is not None)
			and
		(
			(latest_branch > current_branch) or (
				(latest_branch == current_branch) and
				(compare_versions(latest_release_on_latest_branch, current_version) == 1)
			)
		)
	)
	_log.info('%snew release on latest branch available', gmTools.bool2str(new_release_on_latest_branch_available, '', 'no '))

	if not (new_release_on_current_branch_available or new_release_on_latest_branch_available):
		_log.debug('up to date: no new releases available')
		return (False, None)

	# not up to date
	msg = _('A new version of GNUmed is available.\n\n')
	msg += _(' Your current version: "%s"\n') % current_version
	if consider_latest_branch:
		if new_release_on_current_branch_available:
			msg += u'\n'
			msg += _(' New version: "%s"') % latest_release_on_current_branch
			msg += u'\n'
			msg += _(' - bug fixes only\n')
			msg += _(' - database fixups may be needed\n')
		if new_release_on_latest_branch_available:
			if current_branch != latest_branch:
				msg += u'\n'
				msg += _(' New version: "%s"') % latest_release_on_latest_branch
				msg += u'\n'
				msg += _(' - bug fixes and new features\n')
				msg += _(' - database upgrade required\n')
	else:
		msg += u'\n'
		msg += _(' New version: "%s"') % latest_release_on_current_branch
		msg += u'\n'
		msg += _(' - bug fixes only\n')
		msg += _(' - database fixups may be needed\n')

	msg += u'\n\n'
	msg += _(
		'Note, however, that this version may not yet\n'
		'be available *pre-packaged* for your system.'
	)

	msg += u'\n\n'
	msg += _('Details are found on <http://wiki.gnumed.de>.\n')
	msg += u'\n'
	msg += _('Version information loaded from:\n\n %s') % url

	return (True, msg)