From ca6eb20c5aead1e03896d3c3467c9f1c10e92a09 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Tue, 4 Oct 2005 22:22:24 +0000 Subject: [PATCH] Various little fixes. Organization: Straylight/Edgeware From: mdw --- tripe-keys.in | 2 +- tripe-keys.master | 2 +- tripemon.in | 251 ++++++++++++++++++++++++---------------------- 3 files changed, 133 insertions(+), 122 deletions(-) diff --git a/tripe-keys.in b/tripe-keys.in index 97378671..a3e5b141 100644 --- a/tripe-keys.in +++ b/tripe-keys.in @@ -328,7 +328,7 @@ def cmd_generate(args): run('key -kkeyring merge repos/param') run('key -kkeyring add -a${kx} -pparam -e${kx-expire} -t%s tripe-${kx}' % tag) - run('key -kkeyring extract -f-secret %s' % keyring_pub) + run('key -kkeyring extract -f-secret %s %s' % (keyring_pub, tag)) def cmd_clean(args): rmtree('repos') diff --git a/tripe-keys.master b/tripe-keys.master index de5e7219..2b59cf9f 100644 --- a/tripe-keys.master +++ b/tripe-keys.master @@ -35,7 +35,7 @@ # How recently an archive must have been signed to be valid. # sig-fresh = always -# When the signing key expires. We're not good at rolling these over. +# When the signing key expires. # sig-expire = forever ### Master key integrity diff --git a/tripemon.in b/tripemon.in index 7ab68882..462967c8 100644 --- a/tripemon.in +++ b/tripemon.in @@ -534,6 +534,70 @@ class MyDialog (G.Dialog, MyWindowMixin, HookClient): def respond(me, hunoz, rid, *hukairz): if rid >= 0: me.rmap[rid]() +def makeactiongroup(name, acts): + """Creates an ActionGroup called NAME. ACTS is a list of tuples + containing: + ACT: an action name + LABEL: the label string for the action + ACCEL: accelerator string, or None + FUNC: thunk to call when the action is invoked""" + actgroup = G.ActionGroup(name) + for act, label, accel, func in acts: + a = G.Action(act, label, None, None) + if func: a.connect('activate', invoker(func)) + actgroup.add_action_with_accel(a, accel) + return actgroup + +class GridPacker (G.Table): + """Like a Table, but with more state: makes filling in the widgets + easier.""" + def __init__(me): + G.Table.__init__(me) + me.row = 0 + me.col = 0 + me.rows = 1 + me.cols = 1 + me.set_border_width(4) + me.set_col_spacings(4) + me.set_row_spacings(4) + def pack(me, w, width = 1, newlinep = False, + xopt = G.EXPAND | G.FILL | G.SHRINK, yopt = 0, + xpad = 0, ypad = 0): + """Packs a new widget. W is the widget to add. XOPY, YOPT, XPAD and + YPAD are as for Table. WIDTH is how many cells to take up horizontally. + NEWLINEP is whether to start a new line for this widget. Returns W.""" + if newlinep: + me.row += 1 + me.col = 0 + bot = me.row + 1 + right = me.col + width + if bot > me.rows or right > me.cols: + if bot > me.rows: me.rows = bot + if right > me.cols: me.cols = right + me.resize(me.rows, me.cols) + me.attach(w, me.col, me.col + width, me.row, me.row + 1, + xopt, yopt, xpad, ypad) + me.col += width + return w + def labelled(me, lab, w, newlinep = False, **kw): + """Packs a labelled widget. Other arguments are as for pack. Returns + W.""" + label = G.Label(lab) + label.set_alignment(1.0, 0) + me.pack(label, newlinep = newlinep, xopt = G.FILL) + me.pack(w, **kw) + return w + def info(me, label, text = None, len = 18, **kw): + """Packs an information widget with a label. LABEL is the label; TEXT is + the initial text; LEN is the estimated length in characters. Returns the + entry widget.""" + e = G.Entry() + if text is not None: e.set_text(text) + e.set_width_chars(len) + e.set_editable(False) + me.labelled(label, e, **kw) + return e + class WindowSlot (HookClient): """A place to store a window. If the window is destroyed, remember this; when we come to open the window, raise it if it already exists; otherwise @@ -640,6 +704,60 @@ def moanbox(msg): d.run() d.destroy() +def unimplemented(*hunoz): + """Indicator of laziness.""" + moanbox("I've not written that bit yet.") + +class ServInfo (MyWindow): + def __init__(me, monitor): + MyWindow.__init__(me) + me.set_title('TrIPE server info') + me.mon = monitor + me.table = GridPacker() + me.add(me.table) + me.e = {} + def add(label, tag, text = None, **kw): + me.e[tag] = me.table.info(label, text, **kw) + add('Implementation', 'implementation') + add('Version', 'version', newlinep = True) + me.update() + me.hook(me.mon.connecthook, me.update) + me.show_all() + def update(me): + info = parseinfo(me.mon.simplecmd('SERVINFO')) + for i in me.e: + me.e[i].set_text(info[i]) + +class TraceOptions (MyDialog): + """Tracing options window.""" + def __init__(me, monitor): + MyDialog.__init__(me, title = 'Tracing options', + buttons = [(G.STOCK_CLOSE, me.destroy), + (G.STOCK_OK, me.ok)]) + me.mon = monitor + me.opts = [] + for o in me.mon.simplecmd('TRACE'): + char = o[0] + onp = o[1] + text = o[3].upper() + o[4:] + if char.isupper(): continue + ticky = G.CheckButton(text) + ticky.set_active(onp != ' ') + me.vbox.pack_start(ticky) + me.opts.append((char, ticky)) + me.show_all() + def ok(me): + on = [] + off = [] + for char, ticky in me.opts: + if ticky.get_active(): + on.append(char) + else: + off.append(char) + setting = ''.join(on) + '-' + ''.join(off) + me.mon.simplecmd('TRACE %s' % setting) + me.destroy() + #----- Logging windows ------------------------------------------------------ class LogModel (G.ListStore): @@ -691,100 +809,7 @@ class LogViewer (MyWindow): me.add(scr) me.show_all() -def makeactiongroup(name, acts): - """Creates an ActionGroup called NAME. ACTS is a list of tuples - containing: - ACT: an action name - LABEL: the label string for the action - ACCEL: accelerator string, or None - FUNC: thunk to call when the action is invoked""" - actgroup = G.ActionGroup(name) - for act, label, accel, func in acts: - a = G.Action(act, label, None, None) - if func: a.connect('activate', invoker(func)) - actgroup.add_action_with_accel(a, accel) - return actgroup - -class TraceOptions (MyDialog): - """Tracing options window.""" - def __init__(me, monitor): - MyDialog.__init__(me, title = 'Tracing options', - buttons = [(G.STOCK_CLOSE, me.destroy), - (G.STOCK_OK, me.ok)]) - me.mon = monitor - me.opts = [] - for o in me.mon.simplecmd('TRACE'): - char = o[0] - onp = o[1] - text = o[3].upper() + o[4:] - if char.isupper(): continue - ticky = G.CheckButton(text) - ticky.set_active(onp != ' ') - me.vbox.pack_start(ticky) - me.opts.append((char, ticky)) - me.show_all() - def ok(me): - on = [] - off = [] - for char, ticky in me.opts: - if ticky.get_active(): - on.append(char) - else: - off.append(char) - setting = ''.join(on) + '-' + ''.join(off) - me.mon.simplecmd('TRACE %s' % setting) - me.destroy() - -def unimplemented(*hunoz): - """Indicator of laziness.""" - moanbox("I've not written that bit yet.") - -class GridPacker (G.Table): - """Like a Table, but with more state: makes filling in the widgets - easier.""" - def __init__(me): - G.Table.__init__(me) - me.row = 0 - me.col = 0 - me.rows = 1 - me.cols = 1 - me.set_border_width(4) - me.set_col_spacings(4) - me.set_row_spacings(4) - def pack(me, w, width = 1, newlinep = False, - xopt = G.EXPAND | G.FILL | G.SHRINK, yopt = 0, - xpad = 0, ypad = 0): - """Packs a new widget. W is the widget to add. XOPY, YOPT, XPAD and - YPAD are as for Table. WIDTH is how many cells to take up horizontally. - NEWLINEP is whether to start a new line for this widget. Returns W.""" - if newlinep: - me.row += 1 - me.col = 0 - bot = me.row + 1 - right = me.col + width - if bot > me.rows or right > me.cols: - if bot > me.rows: me.rows = bot - if right > me.cols: me.cols = right - me.resize(me.rows, me.cols) - me.attach(w, me.col, me.col + width, me.row, me.row + 1, - xopt, yopt, xpad, ypad) - me.col += width - return w - def labelled(me, lab, w, newlinep = False, **kw): - """Packs a labelled widget. Other arguments are as for pack. Returns - W.""" - label = G.Label(lab) - label.set_alignment(1.0, 0) - me.pack(label, newlinep = newlinep, xopt = G.FILL) - me.pack(w, **kw) - return w - def info(me, label, text = None, len = 18, **kw): - e = G.Entry() - if text is not None: e.set_text(text) - e.set_width_chars(len) - e.set_editable(False) - me.labelled(label, e, **kw) - return e +#----- Peer window ---------------------------------------------------------- def xlate_time(t): """Translate a time in tripe's stats format to something a human might @@ -886,6 +911,8 @@ class PeerWindow (MyWindow): s += '; %.2f ms (last %.1f ms)' % (ping.ttot/ping.ngood, ping.tlast); me.e[ping.cmd].set_text(s) +#----- Add peer ------------------------------------------------------------- + class AddPeerCommand (SimpleBackgroundCommand): def __init__(me, conn, dlg, name, addr, port, keepalive = None, tunnel = None): @@ -968,25 +995,7 @@ class AddPeerDialog (MyDialog): GDK.beep() return -class ServInfo (MyWindow): - def __init__(me, monitor): - MyWindow.__init__(me) - me.set_title('TrIPE server info') - me.mon = monitor - me.table = GridPacker() - me.add(me.table) - me.e = {} - def add(label, tag, text = None, **kw): - me.e[tag] = me.table.info(label, text, **kw) - add('Implementation', 'implementation') - add('Version', 'version', newlinep = True) - me.update() - me.hook(me.mon.connecthook, me.update) - me.show_all() - def update(me): - info = parseinfo(me.mon.simplecmd('SERVINFO')) - for i in me.e: - me.e[i].set_text(info[i]) +#----- The server monitor --------------------------------------------------- class PingCommand (SimpleBackgroundCommand): def __init__(me, conn, cmd, peer, func): @@ -1026,17 +1035,17 @@ class MonitorWindow (MyWindow): me.add(vbox) me.ui = G.UIManager() + def cmd(c): me.mon.simplecmd(c) actgroup = makeactiongroup('monitor', [('file-menu', '_File', None, None), ('connect', '_Connect', 'C', me.mon.connect), ('disconnect', '_Disconnect', 'D', me.mon.disconnect), ('quit', '_Quit', 'Q', me.close), ('server-menu', '_Server', None, None), - ('daemon', 'Run in _background', None, - lambda: me.mon.simplecmd('DAEMON')), - ('server-version', 'Server version', None, me.servinfo.open), - ('server-quit', 'Terminate server', None, - lambda: me.mon.simplecmd('QUIT')), + ('daemon', 'Run in _background', None, cmd('DAEMON')), + ('server-version', 'Server version', 'V', me.servinfo.open), + ('reload-keys', 'Reload keys', 'R', cmd('RELOAD')), + ('server-quit', 'Terminate server', None, cmd('QUIT')), ('logs-menu', '_Logs', None, None), ('show-warnings', 'Show _warnings', 'W', me.warnview.open), ('show-trace', 'Show _trace', 'T', me.traceview.open), @@ -1053,12 +1062,13 @@ class MonitorWindow (MyWindow): - + + - + @@ -1294,3 +1304,4 @@ Options supported: if __name__ == '__main__': main() +#----- That's all, folks ---------------------------------------------------- -- [mdw]