* 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:
+5
-1
@@ -52,7 +52,8 @@ class Error(pisi.Error):
|
|||||||
def init(database = True, write = True,
|
def init(database = True, write = True,
|
||||||
options = None, ui = None, comar = True,
|
options = None, ui = None, comar = True,
|
||||||
stdout = None, stderr = None,
|
stdout = None, stderr = None,
|
||||||
comar_sockname = None):
|
comar_sockname = None,
|
||||||
|
signal_handling = True):
|
||||||
"""Initialize PiSi subsystem"""
|
"""Initialize PiSi subsystem"""
|
||||||
|
|
||||||
# UI comes first
|
# UI comes first
|
||||||
@@ -88,6 +89,9 @@ def init(database = True, write = True,
|
|||||||
import pisi.config
|
import pisi.config
|
||||||
ctx.config = pisi.config.Config(options)
|
ctx.config = pisi.config.Config(options)
|
||||||
|
|
||||||
|
if signal_handling:
|
||||||
|
ctx.sig = pisi.signalhandler.SignalHandler()
|
||||||
|
|
||||||
# TODO: this is definitely not dynamic beyond this point!
|
# TODO: this is definitely not dynamic beyond this point!
|
||||||
ctx.comar = comar and not ctx.config.get_option('ignore_comar')
|
ctx.comar = comar and not ctx.config.get_option('ignore_comar')
|
||||||
# This is for YALI, used in comariface.py:make_com()
|
# This is for YALI, used in comariface.py:make_com()
|
||||||
|
|||||||
+10
-8
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import select
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
__trans = gettext.translation('pisi', fallback=True)
|
__trans = gettext.translation('pisi', fallback=True)
|
||||||
@@ -20,18 +21,15 @@ _ = __trans.ugettext
|
|||||||
import pisi
|
import pisi
|
||||||
import pisi.context as ctx
|
import pisi.context as ctx
|
||||||
|
|
||||||
|
|
||||||
class Error(pisi.Error):
|
class Error(pisi.Error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
import comar
|
||||||
|
except ImportError:
|
||||||
|
raise Error(_("comar package is not fully installed"))
|
||||||
|
|
||||||
def make_com():
|
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"
|
sockname = "/var/run/comar.socket"
|
||||||
# This is used by YALI
|
# This is used by YALI
|
||||||
if ctx.comar_sockname:
|
if ctx.comar_sockname:
|
||||||
@@ -50,7 +48,7 @@ def make_com():
|
|||||||
|
|
||||||
def wait_comar():
|
def wait_comar():
|
||||||
# FIXME: this function is redundant, use make_com in wait_for_result
|
# 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)
|
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
timeout = 5
|
timeout = 5
|
||||||
sockname = "/var/run/comar.socket"
|
sockname = "/var/run/comar.socket"
|
||||||
@@ -70,6 +68,10 @@ def wait_for_result(com, package_name=None):
|
|||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
reply = com.read_cmd()
|
reply = com.read_cmd()
|
||||||
|
except select.error:
|
||||||
|
if ctx.keyboard_interrupt_pending():
|
||||||
|
return
|
||||||
|
raise
|
||||||
except comar.LinkClosed:
|
except comar.LinkClosed:
|
||||||
# Comar postInstall does a "service comar restart" which cuts
|
# Comar postInstall does a "service comar restart" which cuts
|
||||||
# our precious communication link, so we waitsss
|
# our precious communication link, so we waitsss
|
||||||
|
|||||||
+5
-5
@@ -18,7 +18,7 @@ import pisi.constants
|
|||||||
import pisi.signalhandler
|
import pisi.signalhandler
|
||||||
|
|
||||||
const = pisi.constants.Constants()
|
const = pisi.constants.Constants()
|
||||||
sig = pisi.signalhandler.SignalHandler()
|
sig = None
|
||||||
|
|
||||||
config = None
|
config = None
|
||||||
|
|
||||||
@@ -80,13 +80,13 @@ def txn_proc(proc, txn = None):
|
|||||||
return proc(txn)
|
return proc(txn)
|
||||||
|
|
||||||
def disable_keyboard_interrupts():
|
def disable_keyboard_interrupts():
|
||||||
sig.disable_signal(signal.SIGINT)
|
sig and sig.disable_signal(signal.SIGINT)
|
||||||
|
|
||||||
def enable_keyboard_interrupts():
|
def enable_keyboard_interrupts():
|
||||||
sig.enable_signal(signal.SIGINT)
|
sig and sig.enable_signal(signal.SIGINT)
|
||||||
|
|
||||||
def keyboard_interrupt_disabled():
|
def keyboard_interrupt_disabled():
|
||||||
return sig.signal_disabled(signal.SIGINT)
|
return sig and sig.signal_disabled(signal.SIGINT)
|
||||||
|
|
||||||
def keyboard_interrupt_pending():
|
def keyboard_interrupt_pending():
|
||||||
return sig.signal_pending(signal.SIGINT)
|
return sig and sig.signal_pending(signal.SIGINT)
|
||||||
|
|||||||
Reference in New Issue
Block a user