• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python zeroinstall._函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中zeroinstall._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了_函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: canonical_iface_uri

def canonical_iface_uri(uri):
	"""If uri is a relative path, convert to an absolute one.
	A "file:///foo" URI is converted to "/foo".
	An "alias:prog" URI expands to the URI in the 0alias script
	Otherwise, return it unmodified.
	@rtype: str
	@raise SafeException: if uri isn't valid
	"""
	if uri.startswith('http://') or uri.startswith('https://'):
		if uri.count("/") < 3:
			raise SafeException(_("Missing / after hostname in URI '%s'") % uri)
		return uri
	elif uri.startswith('file:///'):
		return uri[7:]
	elif uri.startswith('alias:'):
		from zeroinstall import alias, support
		alias_prog = uri[6:]
		if not os.path.isabs(alias_prog):
			full_path = support.find_in_path(alias_prog)
			if not full_path:
				raise alias.NotAnAliasScript("Not found in $PATH: " + alias_prog)
		else:
			full_path = alias_prog
		interface_uri, main = alias.parse_script(full_path)
		return interface_uri
	else:
		iface_uri = os.path.realpath(uri)
		if os.path.isfile(iface_uri):
			return iface_uri
	raise SafeException(_("Bad interface name '%(uri)s'.\n"
			"(doesn't start with 'http:', and "
			"doesn't exist as a local file '%(interface_uri)s' either)") %
			{'uri': uri, 'interface_uri': iface_uri})
开发者ID:pombredanne,项目名称:zero-install,代码行数:33,代码来源:model.py


示例2: populate_model

	def populate_model(self):
		m = self.model
		m.clear()

		for uri in self.app_list.get_apps():
			itr = m.append()
			m[itr][AppListBox.URI] = uri

			try:
				iface = self.iface_cache.get_interface(uri)
				feed = self.iface_cache.get_feed(uri)
				if feed:
					name = feed.get_name()
					summary = feed.summary or _('No information available')
					summary = summary[:1].capitalize() + summary[1:]
				else:
					name = iface.get_name()
					summary = _('No information available')
				# (GTK3 returns an extra boolean at the start)
				icon_width, icon_height = gtk.icon_size_lookup(gtk.ICON_SIZE_DIALOG)[-2:]
				pixbuf = icon.load_icon(self.iface_cache.get_icon_path(iface), icon_width, icon_height)
			except model.InvalidInterface as ex:
				name = uri
				summary = unicode(ex)
				pixbuf = None

			m[itr][AppListBox.NAME] = name
			if pixbuf is None:
				pixbuf = self.window.render_icon(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_DIALOG)
			m[itr][AppListBox.ICON] = pixbuf

			m[itr][AppListBox.MARKUP] = '<b>%s</b>\n<i>%s</i>' % (_pango_escape(name), _pango_escape(summary))
开发者ID:dsqmoore,项目名称:0install,代码行数:32,代码来源:applistbox.py


示例3: import_key

def import_key(stream):
	"""Run C{gpg --import} with this stream as stdin."""
	errors = tempfile.TemporaryFile()

	child = _run_gpg(['--quiet', '--import', '--batch'],
				stdin = stream, stderr = errors)

	status = child.wait()

	errors.seek(0)
	error_messages = errors.read().strip()
	errors.close()

	if error_messages:
		import codecs
		decoder = codecs.lookup('utf-8')
		error_messages = decoder.decode(error_messages, errors = 'replace')[0]

	if status != 0:
		if error_messages:
			raise SafeException(_("Errors from 'gpg --import':\n%s") % error_messages)
		else:
			raise SafeException(_("Non-zero exit code %d from 'gpg --import'") % status)
	elif error_messages:
		warn(_("Warnings from 'gpg --import':\n%s") % error_messages)
开发者ID:dabrahams,项目名称:zeroinstall,代码行数:25,代码来源:gpg.py


示例4: __init__

    def __init__(self, config, requirements):
        """
		@param config: The configuration settings to use
		@type config: L{config.Config}
		@param requirements: Details about the program we want to run
		@type requirements: L{requirements.Requirements}
		@since: 0.53
		"""
        self.watchers = []

        assert config
        self.config = config

        assert requirements
        self.requirements = requirements

        self.target_arch = arch.get_architecture(requirements.os, requirements.cpu)

        from zeroinstall.injector.solver import DefaultSolver

        self.solver = DefaultSolver(self.config)

        logger.debug(_("Supported systems: '%s'"), arch.os_ranks)
        logger.debug(_("Supported processors: '%s'"), arch.machine_ranks)

        if requirements.before or requirements.not_before:
            self.solver.extra_restrictions[config.iface_cache.get_interface(requirements.interface_uri)] = [
                model.VersionRangeRestriction(
                    model.parse_version(requirements.before), model.parse_version(requirements.not_before)
                )
            ]
开发者ID:timdiels,项目名称:0install,代码行数:31,代码来源:driver.py


示例5: update_feed_from_network

	def update_feed_from_network(self, feed_url, new_xml, modified_time, dry_run = False):
		"""Update a cached feed.
		Called by L{update_feed_if_trusted} if we trust this data.
		After a successful update, L{writer} is used to update the feed's
		last_checked time.
		@param feed_url: the feed being updated
		@type feed_url: L{model.Interface}
		@param new_xml: the downloaded replacement feed document
		@type new_xml: str
		@param modified_time: the timestamp of the oldest trusted signature (used as an approximation to the feed's modification time)
		@type modified_time: long
		@type dry_run: bool
		@raises ReplayAttack: if modified_time is older than the currently cached time
		@since: 0.48"""
		logger.debug(_("Updating '%(interface)s' from network; modified at %(time)s") %
			{'interface': feed_url, 'time': _pretty_time(modified_time)})

		self._import_new_feed(feed_url, new_xml, modified_time, dry_run)

		if dry_run: return

		feed = self.get_feed(feed_url)

		from . import writer
		feed.last_checked = int(time.time())
		writer.save_feed(feed)

		logger.info(_("Updated feed cache entry for %(interface)s (modified %(time)s)"),
			{'interface': feed.get_name(), 'time': _pretty_time(modified_time)})
开发者ID:res2k,项目名称:0install,代码行数:29,代码来源:iface_cache.py


示例6: process_binding

def process_binding(e):
	"""Internal"""
	if e.name == 'environment':
		mode = {
			None: EnvironmentBinding.PREPEND,
			'prepend': EnvironmentBinding.PREPEND,
			'append': EnvironmentBinding.APPEND,
			'replace': EnvironmentBinding.REPLACE,
		}[e.getAttribute('mode')]

		binding = EnvironmentBinding(e.getAttribute('name'),
					     insert = e.getAttribute('insert'),
					     default = e.getAttribute('default'),
					     value = e.getAttribute('value'),
					     mode = mode,
					     separator = e.getAttribute('separator'))
		if not binding.name: raise InvalidInterface(_("Missing 'name' in binding"))
		if binding.insert is None and binding.value is None:
			raise InvalidInterface(_("Missing 'insert' or 'value' in binding"))
		if binding.insert is not None and binding.value is not None:
			raise InvalidInterface(_("Binding contains both 'insert' and 'value'"))
		return binding
	elif e.name == 'executable-in-path':
		return ExecutableBinding(e, in_path = True)
	elif e.name == 'executable-in-var':
		return ExecutableBinding(e, in_path = False)
	elif e.name == 'overlay':
		return OverlayBinding(e.getAttribute('src'), e.getAttribute('mount-point'))
	else:
		raise Exception(_("Unknown binding type '%s'") % e.name)
开发者ID:michel-slm,项目名称:0install,代码行数:30,代码来源:model.py


示例7: extract_deb

def extract_deb(stream, destdir, extract = None, start_offset = 0):
	if extract:
		raise SafeException(_('Sorry, but the "extract" attribute is not yet supported for Debs'))

	stream.seek(start_offset)
	# ar can't read from stdin, so make a copy...
	deb_copy_name = os.path.join(destdir, 'archive.deb')
	with open(deb_copy_name, 'wb') as deb_copy:
		shutil.copyfileobj(stream, deb_copy)

	data_tar = None
	p = subprocess.Popen(('ar', 't', 'archive.deb'), stdout=subprocess.PIPE, cwd=destdir, universal_newlines=True)
	o = p.communicate()[0]
	for line in o.split('\n'):
		if line == 'data.tar':
			data_compression = None
		elif line == 'data.tar.gz':
			data_compression = 'gzip'
		elif line == 'data.tar.bz2':
			data_compression = 'bzip2'
		elif line == 'data.tar.lzma':
			data_compression = 'lzma'
		else:
			continue
		data_tar = line
		break
	else:
		raise SafeException(_("File is not a Debian package."))

	_extract(stream, destdir, ('ar', 'x', 'archive.deb', data_tar))
	os.unlink(deb_copy_name)
	data_name = os.path.join(destdir, data_tar)
	with open(data_name, 'rb') as data_stream:
		os.unlink(data_name)
		extract_tar(data_stream, destdir, None, data_compression)
开发者ID:dabrahams,项目名称:0install,代码行数:35,代码来源:unpack.py


示例8: confirm_install

	def confirm_install(self, message):
		yield self._switch_to_main_window(_('Need to confirm installation of distribution packages'))

		from zeroinstall.injector.download import DownloadAborted
		import dialog
		import gtk
		box = gtk.MessageDialog(self.mainwindow.window,
					gtk.DIALOG_DESTROY_WITH_PARENT,
					gtk.MESSAGE_QUESTION, gtk.BUTTONS_CANCEL,
					str(message))
		box.set_position(gtk.WIN_POS_CENTER)

		install = dialog.MixedButton(_('Install'), gtk.STOCK_OK)
		install.set_can_default(True)
		box.add_action_widget(install, gtk.RESPONSE_OK)
		install.show_all()
		box.set_default_response(gtk.RESPONSE_OK)
		box.show()

		response = dialog.DialogResponse(box)
		yield response
		box.destroy()

		if response.response != gtk.RESPONSE_OK:
			raise DownloadAborted()
开发者ID:dsqmoore,项目名称:0install,代码行数:25,代码来源:gui.py


示例9: load_feed

def load_feed(source, local=False):
    """Load a feed from a local file.
	@param source: the name of the file to read
	@type source: str
	@param local: this is a local feed
	@type local: bool
	@return: the new feed
	@rtype: L{ZeroInstallFeed}
	@raise InvalidInterface: if the source's syntax is incorrect
	@since: 0.48
	@see: L{iface_cache.iface_cache}, which uses this to load the feeds"""
    try:
        with open(source, "rb") as stream:
            root = qdom.parse(stream, filter_for_version=True)
    except IOError as ex:
        if ex.errno == errno.ENOENT and local:
            raise MissingLocalFeed(
                _(
                    "Feed not found. Perhaps this is a local feed that no longer exists? You can remove it from the list of feeds in that case."
                )
            )
        raise InvalidInterface(_("Can't read file"), ex)
    except Exception as ex:
        raise InvalidInterface(_("Invalid XML"), ex)

    if local:
        assert os.path.isabs(source), source
        local_path = source
    else:
        local_path = None
    feed = ZeroInstallFeed(root, local_path)
    feed.last_modified = int(os.stat(source).st_mtime)
    return feed
开发者ID:pombredanne,项目名称:0install,代码行数:33,代码来源:reader.py


示例10: fetch_feed

        def fetch_feed():
            yield dl.downloaded
            tasks.check(dl.downloaded)

            pending = PendingFeed(feed_url, stream)

            if use_mirror:
                # If we got the feed from a mirror, get the key from there too
                key_mirror = self.feed_mirror + "/keys/"
            else:
                key_mirror = None

            keys_downloaded = tasks.Task(
                pending.download_keys(self.handler, feed_hint=feed_url, key_mirror=key_mirror),
                _("download keys for %s") % feed_url,
            )
            yield keys_downloaded.finished
            tasks.check(keys_downloaded.finished)

            if not iface_cache.update_feed_if_trusted(pending.url, pending.sigs, pending.new_xml):
                blocker = self.handler.confirm_keys(pending, self.fetch_key_info)
                if blocker:
                    yield blocker
                    tasks.check(blocker)
                if not iface_cache.update_feed_if_trusted(pending.url, pending.sigs, pending.new_xml):
                    raise NoTrustedKeys(_("No signing keys trusted; not importing"))
开发者ID:pombredanne,项目名称:zero-install,代码行数:26,代码来源:fetch.py


示例11: _confirm_unknown_keys

	def _confirm_unknown_keys(self, to_trust, valid_sigs):
		"""Check the key-info server's results for these keys. If we don't know any of them,
		ask for extra confirmation from the user.
		@param to_trust: the signatures the user wants to trust
		@return: True to continue"""

		def is_unknown(sig):
			for note in valid_sigs[sig].info:
				if note.getAttribute("vote") == "good":
					return False
			return True
		unknown = [sig for sig in to_trust if is_unknown(sig)]

		if unknown:
			if len(unknown) == 1:
				msg = _('WARNING: you are confirming a key which was not known to the key server. Are you sure?')
			else:
				msg = _('WARNING: you are confirming keys which were not known to the key server. Are you sure?')

			box = gtk.MessageDialog(self,
						gtk.DIALOG_DESTROY_WITH_PARENT,
						gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL,
						msg)
			box.set_position(gtk.WIN_POS_CENTER)
			response = box.run()
			box.destroy()
			return response == gtk.RESPONSE_OK

		return True
开发者ID:pombredanne,项目名称:zero-install,代码行数:29,代码来源:trust_box.py


示例12: is_stale

	def is_stale(self, feed, freshness_threshold):
		"""Check whether feed needs updating, based on the configured L{freshness}.
		None is considered to be stale.
		If we already tried to update the feed within FAILED_CHECK_DELAY, returns false.
		@return: True if feed should be updated
		@since: 0.53"""
		if feed is None:
			return True
		if os.path.isabs(feed.url):
			return False		# Local feeds are never stale
		if feed.last_modified is None:
			return True		# Don't even have it yet
		now = time.time()
		staleness = now - (feed.last_checked or 0)
		debug(_("Staleness for %(feed)s is %(staleness).2f hours"), {'feed': feed, 'staleness': staleness / 3600.0})

		if freshness_threshold <= 0 or staleness < freshness_threshold:
			return False		# Fresh enough for us

		last_check_attempt = self.get_last_check_attempt(feed.url)
		if last_check_attempt and last_check_attempt > now - FAILED_CHECK_DELAY:
			debug(_("Stale, but tried to check recently (%s) so not rechecking now."), time.ctime(last_check_attempt))
			return False

		return True
开发者ID:gvsurenderreddy,项目名称:zeroinstall,代码行数:25,代码来源:iface_cache.py


示例13: parse_version

def parse_version(version_string):
	"""Convert a version string to an internal representation.
	The parsed format can be compared quickly using the standard Python functions.
	 - Version := DottedList ("-" Mod DottedList?)*
	 - DottedList := (Integer ("." Integer)*)
	@rtype: tuple (opaque)
	@raise SafeException: if the string isn't a valid version
	@since: 0.24 (moved from L{reader}, from where it is still available):"""
	if version_string is None: return None
	parts = _version_re.split(version_string)
	if parts[-1] == '':
		del parts[-1]	# Ends with a modifier
	else:
		parts.append('')
	if not parts:
		raise SafeException(_("Empty version string!"))
	l = len(parts)
	try:
		for x in range(0, l, 2):
			part = parts[x]
			if part:
				parts[x] = list(map(int, parts[x].split('.')))
			else:
				parts[x] = []	# (because ''.split('.') == [''], not [])
		for x in range(1, l, 2):
			parts[x] = _version_mod_to_value[parts[x]]
		return parts
	except ValueError as ex:
		raise SafeException(_("Invalid version format in '%(version_string)s': %(exception)s") % {'version_string': version_string, 'exception': ex})
	except KeyError as ex:
		raise SafeException(_("Invalid version modifier in '%(version_string)s': %(exception)s") % {'version_string': version_string, 'exception': str(ex).strip("u")})
开发者ID:dsqmoore,项目名称:0install,代码行数:31,代码来源:versions.py


示例14: process_depends

def process_depends(item, local_feed_dir):
	"""Internal"""
	# Note: also called from selections
	attrs = item.attrs
	dep_iface = item.getAttribute('interface')
	if not dep_iface:
		raise InvalidInterface(_("Missing 'interface' on <%s>") % item.name)
	if dep_iface.startswith('./'):
		if local_feed_dir:
			dep_iface = os.path.abspath(os.path.join(local_feed_dir, dep_iface))
			# (updates the element too, in case we write it out again)
			attrs['interface'] = dep_iface
		else:
			raise InvalidInterface(_('Relative interface URI "%s" in non-local feed') % dep_iface)
	dependency = InterfaceDependency(dep_iface, element = item)

	for e in item.childNodes:
		if e.uri != XMLNS_IFACE: continue
		if e.name in binding_names:
			dependency.bindings.append(process_binding(e))
		elif e.name == 'version':
			dependency.restrictions.append(
				VersionRangeRestriction(not_before = parse_version(e.getAttribute('not-before')),
						        before = parse_version(e.getAttribute('before'))))
	return dependency
开发者ID:pombredanne,项目名称:zero-install,代码行数:25,代码来源:model.py


示例15: __init__

	def __init__(self):
		user_store = os.path.join(basedir.xdg_cache_home, '0install.net', 'implementations')
		self.stores = [Store(user_store)]

		impl_dirs = basedir.load_first_config('0install.net', 'injector',
							  'implementation-dirs')
		debug(_("Location of 'implementation-dirs' config file being used: '%s'"), impl_dirs)
		if impl_dirs:
			dirs = open(impl_dirs)
		else:
			if os.name == "nt":
				from win32com.shell import shell, shellcon
				localAppData = shell.SHGetFolderPath(0, shellcon.CSIDL_LOCAL_APPDATA, 0, 0)
				commonAppData = shell.SHGetFolderPath(0, shellcon.CSIDL_COMMON_APPDATA, 0, 0)

				userCache = os.path.join(localAppData, "0install.net", "implementations")
				sharedCache = os.path.join(commonAppData, "0install.net", "implementations")
				dirs = [userCache, sharedCache]

			else:
				dirs = ['/var/cache/0install.net/implementations']

		for directory in dirs:
			directory = directory.strip()
			if directory and not directory.startswith('#'):
				debug(_("Added system store '%s'"), directory)
				self.stores.append(Store(directory))
开发者ID:dabrahams,项目名称:zeroinstall,代码行数:27,代码来源:__init__.py


示例16: _parse_manifest

def _parse_manifest(manifest_data):
	"""Parse a manifest file.
	@param manifest_data: the contents of the manifest file
	@type manifest_data: str
	@return: a mapping from paths to information about that path
	@rtype: {str: tuple}"""
	wanted = {}
	dir = ''
	for line in manifest_data.split('\n'):
		if not line: break
		if line[0] == 'D':
			data = line.split(' ', 1)
			if len(data) != 2: raise BadDigest(_("Bad line '%s'") % line)
			path = data[-1]
			if not path.startswith('/'): raise BadDigest(_("Not absolute: '%s'") % line)
			path = path[1:]
			dir = path
		elif line[0] == 'S':
			data = line.split(' ', 3)
			path = os.path.join(dir, data[-1])
			if len(data) != 4: raise BadDigest(_("Bad line '%s'") % line)
		else:
			data = line.split(' ', 4)
			path = os.path.join(dir, data[-1])
			if len(data) != 5: raise BadDigest(_("Bad line '%s'") % line)
		if path in wanted:
			raise BadDigest(_('Duplicate entry "%s"') % line)
		wanted[path] = data[:-1]
	return wanted
开发者ID:dabrahams,项目名称:0install,代码行数:29,代码来源:manifest.py


示例17: discover_existing_apps

def discover_existing_apps():
	"""Search through the configured XDG datadirs looking for .desktop files created by L{add_to_menu}.
	@return: a map from application URIs to .desktop filenames"""
	already_installed = {}
	for d in basedir.load_data_paths('applications'):
		for desktop_file in os.listdir(d):
			if desktop_file.startswith('zeroinstall-') and desktop_file.endswith('.desktop'):
				full = os.path.join(d, desktop_file)
				try:
					with open(full, 'rt') as stream:
						for line in stream:
							line = line.strip()
							if line.startswith('Exec=0launch '):
								bits = line.split(' -- ', 1)
								if ' ' in bits[0]:
									uri = bits[0].split(' ', 1)[1]		# 0launch URI -- %u
								else:
									uri = bits[1].split(' ', 1)[0].strip()	# 0launch -- URI %u
								already_installed[uri] = full
								break
						else:
							logger.info(_("Failed to find Exec line in %s"), full)
				except Exception as ex:
					logger.warn(_("Failed to load .desktop file %(filename)s: %(exceptions"), {'filename': full, 'exception': ex})
	return already_installed
开发者ID:dabrahams,项目名称:0install,代码行数:25,代码来源:xdgutils.py


示例18: _check_xml_stream

def _check_xml_stream(stream):
	xml_comment_start = '<!-- Base64 Signature'

	data_to_check = stream.read()

	last_comment = data_to_check.rfind('\n' + xml_comment_start)
	if last_comment < 0:
		raise SafeException(_("No signature block in XML. Maybe this file isn't signed?"))
	last_comment += 1	# Include new-line in data
	
	data = tempfile.TemporaryFile()
	data.write(data_to_check[:last_comment])
	data.flush()
	os.lseek(data.fileno(), 0, 0)

	errors = tempfile.TemporaryFile()

	sig_lines = data_to_check[last_comment:].split('\n')
	if sig_lines[0].strip() != xml_comment_start:
		raise SafeException(_('Bad signature block: extra data on comment line'))
	while sig_lines and not sig_lines[-1].strip():
		del sig_lines[-1]
	if sig_lines[-1].strip() != '-->':
		raise SafeException(_('Bad signature block: last line is not end-of-comment'))
	sig_data = '\n'.join(sig_lines[1:-1])

	if re.match('^[ A-Za-z0-9+/=\n]+$', sig_data) is None:
		raise SafeException(_("Invalid characters found in base 64 encoded signature"))
	try:
		sig_data = base64.decodestring(sig_data) # (b64decode is Python 2.4)
	except Exception, ex:
		raise SafeException(_("Invalid base 64 encoded signature: %s") % str(ex))
开发者ID:pombredanne,项目名称:zero-install,代码行数:32,代码来源:gpg.py


示例19: unpack_archive

def unpack_archive(url, data, destdir, extract = None, type = None, start_offset = 0):
	"""Unpack stream 'data' into directory 'destdir'. If extract is given, extract just
	that sub-directory from the archive (i.e. destdir/extract will exist afterwards).
	Works out the format from the name."""
	if type is None: type = type_from_url(url)
	if type is None: raise SafeException(_("Unknown extension (and no MIME type given) in '%s'") % url)
	if type == 'application/x-bzip-compressed-tar':
		extract_tar(data, destdir, extract, 'bzip2', start_offset)
	elif type == 'application/x-deb':
		extract_deb(data, destdir, extract, start_offset)
	elif type == 'application/x-rpm':
		extract_rpm(data, destdir, extract, start_offset)
	elif type == 'application/zip':
		extract_zip(data, destdir, extract, start_offset)
	elif type == 'application/x-tar':
		extract_tar(data, destdir, extract, None, start_offset)
	elif type == 'application/x-lzma-compressed-tar':
		extract_tar(data, destdir, extract, 'lzma', start_offset)
	elif type == 'application/x-xz-compressed-tar':
		extract_tar(data, destdir, extract, 'xz', start_offset)
	elif type == 'application/x-compressed-tar':
		extract_tar(data, destdir, extract, 'gzip', start_offset)
	elif type == 'application/vnd.ms-cab-compressed':
		extract_cab(data, destdir, extract, start_offset)
	elif type == 'application/x-apple-diskimage':
		extract_dmg(data, destdir, extract, start_offset)
	elif type == 'application/x-ruby-gem':
		extract_gem(data, destdir, extract, start_offset)
	else:
		raise SafeException(_('Unknown MIME type "%(type)s" for "%(url)s"') % {'type': type, 'url': url})
开发者ID:dabrahams,项目名称:0install,代码行数:30,代码来源:unpack.py


示例20: button_press

		def button_press(tree_view, bev):
			if bev.button not in (1, 3):
				return False
			pos = tree_view.get_path_at_pos(int(bev.x), int(bev.y))
			if not pos:
				return False
			path, col, x, y = pos
			impl = self.model[path][ITEM]

			menu = gtk.Menu()

			stability_menu = gtk.MenuItem(_('Rating'))
			stability_menu.set_submenu(_build_stability_menu(self.policy, impl))
			stability_menu.show()
			menu.append(stability_menu)

			if not impl.id.startswith('package:') and self.policy.get_cached(impl):
				def open():
					os.spawnlp(os.P_WAIT, '0launch',
						'0launch', rox_filer, '-d',
						self.policy.get_implementation_path(impl))
				item = gtk.MenuItem(_('Open cached copy'))
				item.connect('activate', lambda item: open())
				item.show()
				menu.append(item)

			menu.popup(None, None, None, bev.button, bev.time)
开发者ID:gvsurenderreddy,项目名称:zeroinstall,代码行数:27,代码来源:impl_list.py



注:本文中的zeroinstall._函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python arch.get_architecture函数代码示例发布时间:2022-05-26
下一篇:
Python dns.currentTimeMillis函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap