* YALI thread's don't like pisi's signal handling. Signal handling is

now optional from pisi.api.init()

* Also a missed "import comar" fix and some code cleanups.
This commit is contained in:
Faik Uygur
2006-11-03 09:20:45 +00:00
parent 843b0bafef
commit 86fe0edc1e
3 changed files with 20 additions and 14 deletions
+5 -1
View File
@@ -52,7 +52,8 @@ class Error(pisi.Error):
def init(database = True, write = True,
options = None, ui = None, comar = True,
stdout = None, stderr = None,
comar_sockname = None):
comar_sockname = None,
signal_handling = True):
"""Initialize PiSi subsystem"""
# UI comes first
@@ -88,6 +89,9 @@ def init(database = True, write = True,
import pisi.config
ctx.config = pisi.config.Config(options)
if signal_handling:
ctx.sig = pisi.signalhandler.SignalHandler()
# TODO: this is definitely not dynamic beyond this point!
ctx.comar = comar and not ctx.config.get_option('ignore_comar')
# This is for YALI, used in comariface.py:make_com()
+10 -8
View File
@@ -12,6 +12,7 @@
import os
import time
import select
import gettext
__trans = gettext.translation('pisi', fallback=True)
@@ -20,18 +21,15 @@ _ = __trans.ugettext
import pisi
import pisi.context as ctx
class Error(pisi.Error):
pass
try:
import comar
except ImportError:
raise Error(_("comar package is not fully installed"))
def make_com():
try:
import comar
# FIXME: maybe we should reload if it is already imported
except ImportError:
raise Error(_("comar package is not fully installed"))
sockname = "/var/run/comar.socket"
# This is used by YALI
if ctx.comar_sockname:
@@ -50,7 +48,7 @@ def make_com():
def wait_comar():
# FIXME: this function is redundant, use make_com in wait_for_result
import socket, time
import socket
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
timeout = 5
sockname = "/var/run/comar.socket"
@@ -70,6 +68,10 @@ def wait_for_result(com, package_name=None):
while 1:
try:
reply = com.read_cmd()
except select.error:
if ctx.keyboard_interrupt_pending():
return
raise
except comar.LinkClosed:
# Comar postInstall does a "service comar restart" which cuts
# our precious communication link, so we waitsss
+5 -5
View File
@@ -18,7 +18,7 @@ import pisi.constants
import pisi.signalhandler
const = pisi.constants.Constants()
sig = pisi.signalhandler.SignalHandler()
sig = None
config = None
@@ -80,13 +80,13 @@ def txn_proc(proc, txn = None):
return proc(txn)
def disable_keyboard_interrupts():
sig.disable_signal(signal.SIGINT)
sig and sig.disable_signal(signal.SIGINT)
def enable_keyboard_interrupts():
sig.enable_signal(signal.SIGINT)
sig and sig.enable_signal(signal.SIGINT)
def keyboard_interrupt_disabled():
return sig.signal_disabled(signal.SIGINT)
return sig and sig.signal_disabled(signal.SIGINT)
def keyboard_interrupt_pending():
return sig.signal_pending(signal.SIGINT)
return sig and sig.signal_pending(signal.SIGINT)