X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/chopwood/blobdiff_plain/a2916c0635fec5b45ad742904db9f5769b48f53d..76ee7d4f64bc1f20013f44c8045cd708ef0b9641:/service.py diff --git a/service.py b/service.py index 5153539..26406b5 100644 --- a/service.py +++ b/service.py @@ -31,6 +31,7 @@ import subprocess as SUB from auto import HOME import backend as B +import cgi as CGI import config as CONF; CFG = CONF.CFG import hash as H import util as U @@ -77,8 +78,9 @@ class BasicService (object): A simple base class for services. """ - def __init__(me, friendly, *args, **kw): + def __init__(me, friendly, name = None, *args, **kw): super(BasicService, me).__init__(*args) + me.name = name me.friendly = friendly me.meta = kw @@ -204,7 +206,7 @@ class BasicRemoteService (BasicService): """ ## Run the command and collect its output and status. - with timeout(30, "waiting for remote service %s" % me._describe()): + with U.timeout(30, "waiting for remote service %s" % me._describe()): proc = SUB.Popen(me._mkcmd(cmd), stdin = input is not None and SUB.PIPE or None, stdout = SUB.PIPE, stderr = SUB.PIPE) @@ -289,7 +291,7 @@ class SSHRemoteService (BasicRemoteService): def _mkcmd(me, cmd): """Format a command for SSH. Mainly escaping arguments.""" - return ['ssh', me._remote, ' '.join(map(urlencode, cmd))] + return ['ssh', me._remote, ' '.join(map(CGI.urlencode, cmd))] def setpasswd(me, user, passwd): """Service protocol: set the USER's password to PASSWD.""" @@ -378,5 +380,7 @@ def add_master_service(): 'users', 'user', 'passwd'), CFG.HASH, friendly = 'Password changing service') + for name, svc in SERVICES.iteritems(): + if svc.name is None: svc.name = name ###----- That's all, folks --------------------------------------------------