summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
authorNecoro <>2007-11-01 23:55:10 +0000
committerNecoro <>2007-11-01 23:55:10 +0000
commitc1fff1ed4879dcc035cbf77e648074e952c0f925 (patch)
treebb1cc8c0a8075d9010ef03305a042bf312f45be5 /portato
parentb7c30a8494c0cc7f74fcd3810a2c146ae3b1a6e4 (diff)
downloadportato-c1fff1ed4879dcc035cbf77e648074e952c0f925.tar.gz
portato-c1fff1ed4879dcc035cbf77e648074e952c0f925.tar.bz2
portato-c1fff1ed4879dcc035cbf77e648074e952c0f925.zip
r521@Devoty: necoro | 2007-10-31 17:19:09 +0100
r522@Devoty: necoro | 2007-11-02 00:51:00 +0100 No more instanceof calls r523@Devoty: necoro | 2007-11-02 00:51:51 +0100 Fixed bugs; removed unnecessairy dbus calls; make update world being async r524@Devoty: necoro | 2007-11-02 00:52:09 +0100 always use catapult
Diffstat (limited to 'portato')
-rw-r--r--portato/backend/__init__.py10
-rw-r--r--portato/backend/catapult/__init__.py3
-rw-r--r--portato/backend/catapult/package.py15
-rw-r--r--portato/backend/catapult/system.py17
-rw-r--r--portato/backend/flags.py24
-rw-r--r--portato/gui/gui_helper.py4
6 files changed, 47 insertions, 26 deletions
diff --git a/portato/backend/__init__.py b/portato/backend/__init__.py
index 16cebe6..26585c6 100644
--- a/portato/backend/__init__.py
+++ b/portato/backend/__init__.py
@@ -12,6 +12,7 @@
from __future__ import absolute_import
+from ..helper import debug
from ..constants import USE_CATAPULT
from .system_interface import SystemInterface
from .exceptions import BlockedException, PackageNotFoundException, DependencyCalcError, InvalidSystemError
@@ -55,9 +56,13 @@ def load_system ():
global _sys
if SYSTEM == "portage":
+ debug("Setting Portage System")
+ from traceback import print_stack
+ print_stack()
from .portage import PortageSystem
_sys = PortageSystem ()
elif SYSTEM == "catapult":
+ debug("Setting Catapult System")
from .catapult import CatapultSystem
_sys = CatapultSystem()
else:
@@ -65,10 +70,7 @@ def load_system ():
system = SystemWrapper()
-# import package before loading the system as some systems may depend on it being in the namespace
-from .package import Package
-
def is_package(what):
- return isinstance(what, Package)
+ return isinstance(what, _Package)
load_system()
diff --git a/portato/backend/catapult/__init__.py b/portato/backend/catapult/__init__.py
index 47fc042..348b941 100644
--- a/portato/backend/catapult/__init__.py
+++ b/portato/backend/catapult/__init__.py
@@ -12,5 +12,8 @@
from __future__ import absolute_import
+from dbus.mainloop.glib import DBusGMainLoop
+DBusGMainLoop(set_as_default=True)
+
from .system import CatapultSystem
from .package import CatapultPackage
diff --git a/portato/backend/catapult/package.py b/portato/backend/catapult/package.py
index b5f3539..b1dbcfb 100644
--- a/portato/backend/catapult/package.py
+++ b/portato/backend/catapult/package.py
@@ -34,12 +34,6 @@ class CatapultPackage(Package):
suggest = ""
return str(self.proxy.use_expanded(self.get_cpv(), flag, suggest))
- def get_cp (self):
- return str(self.proxy.get_cp(self.get_cpv()))
-
- def get_slot_cp (self):
- return str(self.proxy.get_slot_cp(self.get_cpv()))
-
def get_package_path(self):
return str(self.proxy.get_package_path(self.get_cpv()))
@@ -107,7 +101,12 @@ class CatapultPackage(Package):
return [str(x) for x in self.proxy.get_matched_dep_packages(self.get_cpv(), self.get_new_use_flags())]
def get_dep_packages (self, depvar = ["RDEPEND", "PDEPEND", "DEPEND"], with_criterions = False):
- return [str(x) for x in self.proxy.get_dep_packages(self.get_cpv(), depvar, self.get_new_use_flags(), with_criterions)]
+ pkgs = self.proxy.get_dep_packages(self.get_cpv(), depvar, self.get_new_use_flags())
+
+ if not with_criterions:
+ return [str(x) for x,y in pkgs]
+ else:
+ return [(str(x),str(y)) for x,y in pkgs]
def get_global_settings(self, key):
return str(self.proxy.get_global_settings(self.get_cpv(), key))
@@ -122,7 +121,7 @@ class CatapultPackage(Package):
return " ".join(self.proxy.get_use_flags(self.get_cpv()))
def compare_version(self, other):
- return self.proxy.compare_version(self.get_cpv(), other)
+ return self.proxy.compare_version(self.get_cpv(), other.get_cpv())
def matches (self, criterion):
return self.proxy.matches(self.get_cpv(), criterion)
diff --git a/portato/backend/catapult/system.py b/portato/backend/catapult/system.py
index cfa74ed..c5365c9 100644
--- a/portato/backend/catapult/system.py
+++ b/portato/backend/catapult/system.py
@@ -14,6 +14,7 @@ from __future__ import absolute_import
import re, os
from gettext import lgettext as _
+from threading import Event
import dbus
from .package import CatapultPackage
@@ -124,7 +125,21 @@ class CatapultSystem (SystemInterface):
return self.proxy.reload_settings()
def update_world (self, newuse = False, deep = False):
- return [(CatapultPackage(x), CatapultPackage(y)) for x,y in self.proxy.update_world(newuse, deep, {})]
+
+ ret = []
+ e = Event()
+
+ def wait (list):
+ ret.extend([(CatapultPackage(x), CatapultPackage(y)) for x,y in list])
+ e.set()
+
+ def error (ex):
+ raise ex
+
+ self.proxy.update_world(newuse, deep, {}, reply_handler = wait, error_handler = error)
+ e.wait()
+ return ret
+ # return [(CatapultPackage(x), CatapultPackage(y)) for x,y in self.proxy.update_world(newuse, deep, {})]
def get_updated_packages (self):
return self.geneticize_list(self.proxy.get_updated_packages())
diff --git a/portato/backend/flags.py b/portato/backend/flags.py
index 1e1325e..a623973 100644
--- a/portato/backend/flags.py
+++ b/portato/backend/flags.py
@@ -17,7 +17,7 @@ import os.path
from subprocess import Popen, PIPE # needed for grep
from gettext import lgettext as _
-from . import system, _Package
+from . import system, is_package
from ..helper import debug, error, unique_array
CONFIG = {
@@ -94,7 +94,7 @@ def grep (pkg, path):
@returns: occurences of pkg in the format: "file:line-no:complete_line_found"
@rtype: string"""
- if not isinstance(pkg, _Package):
+ if not is_package(pkg):
pkg = system.new_package(pkg) # assume it is a cpv or a gentoolkit.Package
if os.path.exists(path):
@@ -202,7 +202,7 @@ def set_use_flag (pkg, flag):
global useFlags, newUseFlags
- if not isinstance(pkg, _Package):
+ if not is_package(pkg):
pkg = system.new_package(pkg) # assume cpv or gentoolkit.Package
cpv = pkg.get_cpv()
@@ -266,7 +266,7 @@ def remove_new_use_flags (cpv):
@param cpv: the package for which to remove the flags
@type cpv: string (cpv) or L{backend.Package}-object"""
- if isinstance(cpv, _Package):
+ if is_package(cpv):
cpv = cpv.get_cpv()
try:
@@ -282,7 +282,7 @@ def get_new_use_flags (cpv):
@returns: list of flags
@rtype: string[]"""
- if isinstance(cpv, _Package):
+ if is_package(cpv):
cpv = cpv.get_cpv()
list2return = []
@@ -399,7 +399,7 @@ def set_masked (pkg, masked = True):
global new_masked, newunmasked
- if not isinstance(pkg, _Package):
+ if not is_package(pkg):
pkg = system.new_package(pkg)
cpv = pkg.get_cpv()
@@ -458,7 +458,7 @@ def set_masked (pkg, masked = True):
debug("new_(un)masked: %s",str(link_neq))
def remove_new_masked (cpv):
- if isinstance(cpv, _Package):
+ if is_package(cpv):
cpv = cpv.get_cpv()
try:
@@ -472,7 +472,7 @@ def remove_new_masked (cpv):
pass
def new_masking_status (cpv):
- if isinstance(cpv, _Package):
+ if is_package(cpv):
cpv = cpv.get_cpv()
def get(list):
@@ -500,7 +500,7 @@ def new_masking_status (cpv):
def is_locally_masked (pkg, changes = True):
- if not isinstance(pkg, _Package):
+ if not is_package(pkg):
pkg = system.new_package(pkg) # assume it is a cpv or a gentoolkit.Package
if changes:
@@ -595,7 +595,7 @@ newTesting = {}
arch = ""
def remove_new_testing (cpv):
- if isinstance(cpv, _Package):
+ if is_package(cpv):
cpv = cpv.get_cpv()
try:
@@ -604,7 +604,7 @@ def remove_new_testing (cpv):
pass
def new_testing_status (cpv):
- if isinstance(cpv, _Package):
+ if is_package(cpv):
cpv = cpv.get_cpv()
if cpv in newTesting:
@@ -622,7 +622,7 @@ def set_testing (pkg, enable):
@type enable: boolean"""
global arch, newTesting
- if not isinstance(pkg, _Package):
+ if not is_package(pkg):
pkg = system.new_package(pkg)
arch = pkg.get_global_settings("ARCH")
diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py
index 0090c84..462e749 100644
--- a/portato/gui/gui_helper.py
+++ b/portato/gui/gui_helper.py
@@ -22,6 +22,7 @@ from subprocess import Popen, PIPE, STDOUT
from .. import backend, plugin
from ..backend import flags, system, set_system
from ..helper import debug, info, send_signal_to_group, set_log_level, unique_array
+from ..constants import USE_CATAPULT
from ..waiting_queue import WaitingQueue
# parser
@@ -113,7 +114,8 @@ class Config:
def modify_system_config (self):
"""Sets the system config.
@see: L{backend.set_system()}"""
- set_system(self.get("system"))
+ if not USE_CATAPULT:
+ set_system(self.get("system"))
def modify_external_configs (self):
"""Convenience function setting all external configs."""