[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r23814: {arm} Basic editing functionality for configuration values. (in arm/trunk: . src src/interface)
Author: atagar
Date: 2010-11-17 03:32:30 +0000 (Wed, 17 Nov 2010)
New Revision: 23814
Modified:
arm/trunk/armrc.sample
arm/trunk/src/interface/configStatePanel.py
arm/trunk/src/interface/controller.py
arm/trunk/src/settings.cfg
Log:
Basic editing functionality for configuration values.
Modified: arm/trunk/armrc.sample
===================================================================
--- arm/trunk/armrc.sample 2010-11-16 22:42:03 UTC (rev 23813)
+++ arm/trunk/armrc.sample 2010-11-17 03:32:30 UTC (rev 23814)
@@ -82,7 +82,7 @@
features.config.order 0, 6, 7
features.config.selectionDetails.height 6
features.config.state.colWidth.option 25
-features.config.state.colWidth.value 15
+features.config.state.colWidth.value 10
features.config.file.showScrollbars true
features.config.file.maxLinesPerEntry 8
features.config.showPrivateOptions false
Modified: arm/trunk/src/interface/configStatePanel.py
===================================================================
--- arm/trunk/src/interface/configStatePanel.py 2010-11-16 22:42:03 UTC (rev 23813)
+++ arm/trunk/src/interface/configStatePanel.py 2010-11-17 03:32:30 UTC (rev 23814)
@@ -12,7 +12,7 @@
"features.config.showPrivateOptions": False,
"features.config.showVirtualOptions": False,
"features.config.state.colWidth.option": 25,
- "features.config.state.colWidth.value": 15}
+ "features.config.state.colWidth.value": 10}
TOR_STATE, ARM_STATE = range(1, 3) # state to be presented
@@ -161,6 +161,13 @@
for key in armConf.getKeys():
self.confContents.append(ConfigEntry("", key, ", ".join(armConf.getValue(key, [], True)), "", "", True))
+ def getSelection(self):
+ """
+ Provides the currently selected entry.
+ """
+
+ return self.scroller.getCursorSelection(self.confContents)
+
def setSortOrder(self, ordering = None):
"""
Sets the configuration attributes we're sorting by and resorts the
Modified: arm/trunk/src/interface/controller.py
===================================================================
--- arm/trunk/src/interface/controller.py 2010-11-16 22:42:03 UTC (rev 23813)
+++ arm/trunk/src/interface/controller.py 2010-11-17 03:32:30 UTC (rev 23814)
@@ -1547,6 +1547,71 @@
panels["torrc"].setSortOrder(resultEnums)
panels["torrc"].redraw(True)
+ elif page == 2 and key in (curses.KEY_ENTER, 10, ord(' ')):
+ # let the user edit the configuration value, unchanged if left blank
+ panel.CURSES_LOCK.acquire()
+ try:
+ setPauseState(panels, isPaused, page, True)
+
+ # provides prompt
+ selection = panels["torrc"].getSelection()
+ configOption = selection.get(configStatePanel.FIELD_OPTION)
+ titleMsg = "%s Value: " % configOption
+ panels["control"].setMsg(titleMsg)
+ panels["control"].redraw(True)
+
+ # makes cursor and typing visible
+ try: curses.curs_set(1)
+ except curses.error: pass
+ curses.echo()
+
+ # gets user input (this blocks monitor updates)
+ # TODO: can I prepopulate a value?
+ newConfigValue = panels["control"].win.getstr(0, len(titleMsg))
+
+ # reverts visability settings
+ try: curses.curs_set(0)
+ except curses.error: pass
+ curses.noecho()
+ curses.halfdelay(REFRESH_RATE * 10) # evidenlty previous tweaks reset this...
+
+ # it would be nice to quit on esc, but looks like this might not be possible...
+ if newConfigValue != "":
+ conn = torTools.getConn()
+
+ try:
+ conn.getTorCtl().set_option(configOption, newConfigValue)
+
+ # resets the isDefault flag
+ setOptions = set()
+ configTextQuery = conn.getInfo("config-text", "").strip().split("\n")
+ for entry in configTextQuery: setOptions.add(entry[:entry.find(" ")])
+
+ selection.fields[configStatePanel.FIELD_IS_DEFAULT] = not configOption in setOptions
+
+ # flushing cached values (needed until we can detect SETCONF calls)
+ for fetchType in ("str", "list", "map"):
+ entry = (configOption, fetchType)
+
+ if entry in conn._cachedConf:
+ del conn._cachedConf[entry]
+
+ panels["torrc"].redraw(True)
+ except Exception, exc:
+ excStr = str(exc)
+
+ if excStr.startswith("513 Unacceptable option value: "):
+ # common validation error prefix
+ excStr = excStr[31:]
+
+ panels["control"].setMsg("Invalid value: %s" % excStr, curses.A_STANDOUT)
+ panels["control"].redraw(True)
+ time.sleep(2)
+
+ panels["control"].setMsg(CTL_PAUSED if isPaused else CTL_HELP)
+ setPauseState(panels, isPaused, page)
+ finally:
+ panel.CURSES_LOCK.release()
elif page == 0:
panels["log"].handleKey(key)
elif page == 1:
Modified: arm/trunk/src/settings.cfg
===================================================================
--- arm/trunk/src/settings.cfg 2010-11-16 22:42:03 UTC (rev 23813)
+++ arm/trunk/src/settings.cfg 2010-11-17 03:32:30 UTC (rev 23814)
@@ -33,6 +33,8 @@
# registered
# [WARN] I have no descriptor for the router named "Amunet8" in my declared
# family; I'll use the nickname as is, but this may confuse clients.
+# [WARN] Controller gave us config lines that didn't validate: Value
+# 'BandwidthRate ' is malformed or out of bounds.
# [WARN] Problem bootstrapping. Stuck at 80%: Connecting to the Tor network.
# (Network is unreachable; NOROUTE; count 47; recommendation warn)
# [WARN] 4 unknown, 1 missing key, 3 good, 0 bad, 1 no signature, 4 required
@@ -59,6 +61,7 @@
msg.NOTICE Attempt by
msg.WARN You specified a server
msg.WARN I have no descriptor for the router named
+msg.WARN Controller gave us config lines that didn't validate
msg.WARN Problem bootstrapping. Stuck at
msg.WARN *missing key,
msg.ARM_DEBUG refresh rate: