Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 46526 Details for
Bug 75159
portageq executed for every line of output, slow
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
daemonised version of portageq
portageqd (text/plain), 6.49 KB, created by
Daniel Lawson
on 2004-12-21 03:17:55 UTC
(
hide
)
Description:
daemonised version of portageq
Filename:
MIME Type:
Creator:
Daniel Lawson
Created:
2004-12-21 03:17:55 UTC
Size:
6.49 KB
patch
obsolete
>#!/usr/bin/python -O ># Copyright 1999-2004 Gentoo Foundation ># Distributed under the terms of the GNU General Public License v2 ># $Header: /var/cvsroot/gentoo-src/portage/bin/portageq,v 1.13 2004/10/04 13:56:50 vapier Exp $ > >import sys >sys.path = ["/usr/lib/portage/pym"]+sys.path > >import portage,types,string >from socket import * > > >#----------------------------------------------------------------------------- ># ># To add functionality to this tool, add a function below. ># ># The format for functions is: ># ># def function(argv): ># """<list of options for this function> ># <description of the function> ># """ ># <code> ># ># "argv" is an array of the command line parameters provided after the command. ># ># Make sure you document the function in the right format. The documentation ># is used to display help on the function. ># ># You do not need to add the function to any lists, this tool is introspective, ># and will automaticly add a command by the same name as the function! ># > > >def has_version(argv): > """<root> <category/package> > Return code 0 if it's available, 1 otherwise. > """ > if (len(argv) < 2): > return "ERROR: insufficient parameters!" > sys.exit(2) > try: > mylist=portage.db[argv[0]]["vartree"].dbapi.match(argv[1]) > if mylist: > return "0"; > else: > return "1"; > except KeyError: > pass > > >def best_version(argv): > """<root> <category/package> > Returns category/package-version (without .ebuild). > """ > if (len(argv) < 2): > return "ERROR: insufficient parameters!" > #sys.exit(2) > try: > mylist=portage.db[argv[0]]["vartree"].dbapi.match(argv[1]) > return portage.best(mylist) > except KeyError: > pass > #sys.exit(1) > > >def mass_best_version(argv): > """<root> [<category/package>]+ > Returns category/package-version (without .ebuild). > """ > if (len(argv) < 2): > return "ERROR: insufficient parameters!" > #sys.exit(2) > try: > retval = "" > for pack in argv[1:]: > mylist=portage.db[argv[0]]["vartree"].dbapi.match(pack) > retval = retval + pack+":"+portage.best(mylist) > return retval > except KeyError: > #sys.exit(1) > pass > > >def best_visible(argv): > """<root> [<category/package>]+ > Returns category/package-version (without .ebuild). > """ > if (len(argv) < 2): > return "ERROR: insufficient parameters!" > sys.exit(2) > try: > mylist=portage.db[argv[0]]["porttree"].dbapi.match(argv[1]) > return portage.best(mylist) > except KeyError: > pass > #sys.exit(1) > > >def mass_best_visible(argv): > """<root> [<category/package>]+ > Returns category/package-version (without .ebuild). > """ > if (len(argv) < 2): > return "ERROR: insufficient parameters!" > sys.exit(2) > try: > retval = "" > for pack in argv[1:]: > mylist=portage.db[argv[0]]["porttree"].dbapi.match(pack) > retval = retval + pack+":"+portage.best(mylist) > return retval > except KeyError: > pass > #sys.exit(1) > > >def all_best_visible(argv): > """<root> > Returns all best_visible packages (without .ebuild). > """ > if (len(argv) < 1): > return "ERROR: insufficient parameters!" > > #print portage.db[argv[0]]["porttree"].dbapi.cp_all() > retval = "" > for pkg in portage.db[argv[0]]["porttree"].dbapi.cp_all(): > mybest=portage.best(portage.db[argv[0]]["porttree"].dbapi.match(pkg)) > if mybest: > retval = retval + mybest > return retval > >def match(argv): > """<root> <category/package> > Returns \n seperated list of category/package-version > """ > if (len(argv) < 2): > return "ERROR: insufficient parameters!" > sys.exit(2) > try: > return string.join(portage.db[argv[0]]["vartree"].dbapi.match(argv[1]),"\n") > except KeyError: > pass > #sys.exit(1) > > >def vdb_path(argv): > """ > Returns the path used for the var(installed) package database for the > set environment/configuration options. > """ > return portage.root+portage.VDB_PATH > >def gentoo_mirrors(argv): > """ > Returns the mirrors set to use in the portage configuration. > """ > return portage.settings["GENTOO_MIRRORS"] > > >def portdir(argv): > """ > Returns the PORTDIR path as defined in the portage configuration. > """ > return portage.settings["PORTDIR"] > > >def config_protect(argv): > """ > Returns the CONFIG_PROTECT paths as defined in the portage configuration. > """ > return portage.settings["CONFIG_PROTECT"] > > >def config_protect_mask(argv): > """ > Returns the CONFIG_PROTECT_MASK paths as defined in the portage configuration. > """ > return portage.settings["CONFIG_PROTECT_MASK"] > > >def portdir_overlay(argv): > """ > Returns the PORTDIR_OVERLAY path as defined in the portage configuration. > """ > return portage.settings["PORTDIR_OVERLAY"] > > >def pkgdir(argv): > """ > Returns the PKGDIR path as defined in the portage configuration. > """ > return portage.settings["PKGDIR"] > > >def distdir(argv): > """ > Returns the DISTDIR path as defined in the portage configuration. > """ > return portage.settings["DISTDIR"] > > >def envvar(argv): > """<variable> > Returns a specific environment variable as exists prior to ebuild.sh. > Similar to: emerge --verbose --info | egrep '^<variable>=' > """ > return portage.settings[argv[0]] > > >#----------------------------------------------------------------------------- ># ># DO NOT CHANGE CODE BEYOND THIS POINT - IT'S NOT NEEDED! ># > >def usage(): > rev="$Revision: 1.13 $" > ver=string.split(rev, ' ')[1] > print ">>> Portage information query tool -- version "+ver > print ">>> Usage: portageq <command> [<option> ...]" > print "" > print "Available commands:" > > # > # Show our commands -- we do this by scanning the functions in this > # file, and formatting each functions documentation. > # > for name in globals().keys(): > # Drop python stuff, modules, and our own support functions. > if (name in ("usage", "__doc__", "__name__", "main", "os", "portage", "sys", "__builtins__", "types", "string")): > continue > > # Drop non-functions > obj = globals()[name] > if (type(obj) != types.FunctionType): > continue > > doc = obj.__doc__ > if (doc == None): > print " "+name > print " MISSING DOCUMENTATION!" > print "" > continue > > lines = string.split(doc, '\n') > print " "+name+" "+string.strip(lines[0]) > for line in lines[1:]: > print " "+string.strip(line) > > >def main(): > host = "localhost" > port = 21567 > buf = 65536 > addr = (host,port) > i = 1 > sock = socket(AF_INET,SOCK_STREAM) > sock.bind(addr) > sock.listen(5) > sock.setsockopt(SOL_SOCKET,SO_REUSEADDR,i) > while 1: > (isock, address) = sock.accept() > data = isock.recv(1024) > datalist = data.split(" ") > cmd = datalist[0] > if not data: > break > else: > try: > function = globals()[cmd] > isock.send(function(datalist[1:])) > isock.close > except: > isock.close > pass > # Close socket > sock.close() >main() > >#-----------------------------------------------------------------------------
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 75159
: 46526 |
46527