Run::
- $ hooke --save-config -c ''
+ $ ./bin/hk.py --save-config -c ''
+
+or::
+
+ $ ./bin/hk.py -c 'save_config --output .hooke.cfg'
To write a well commented example config file to :file:`.hooke.cfg`.
run will *not be saved* when Hooke exits. To save the changes,
either run the `save config` command before closing Hooke, or start
Hooke with the ``--save-config`` option.
-
-.. todo:: Implement `save config` command.
def __init__(self):
super(ConfigPlugin, self).__init__(name='config')
self._commands = [GetCommand(self), SetCommand(self),
- PrintCommand(self)]
+ PrintCommand(self), SaveCommand(self),]
# Define common or complicated arguments
outqueue.put(ReloadUserInterfaceConfig(hooke.config))
class PrintCommand (Command):
- """Get the current value of all configuration options.
+ """Get the current configuration file text.
"""
def __init__(self, plugin):
super(PrintCommand, self).__init__(
out = StringIO()
hooke.config.write(out)
outqueue.put(out.getvalue())
+
+
+class SaveCommand (Command):
+ """Save the current configuration options.
+ """
+ def __init__(self, plugin):
+ super(SaveCommand, self).__init__(
+ name='save config',
+ arguments=[
+ Argument(name='output', type='file',
+ help="""
+File name for the output configuration. Defaults to overwriting the
+most local loaded config file.
+""".strip()),
+ ],
+ help=self.__doc__, plugin=plugin)
+
+ def _run(self, hooke, inqueue, outqueue, params):
+ f = None
+ try:
+ if params['output'] != None:
+ f = open(params['output'], 'w')
+ hooke.config.write(fp=f)
+ finally:
+ if f != None:
+ f.close()
*Taking notes*
->>> h = r.run_lines(h, ['''set_note "Hi there.\\nI'm a note"'''])
-Success
-<BLANKLINE>
->>> h = r.run_lines(h, ['note_filter_playlist --output_playlist filtered'])
->>> h = r.run_lines(h, ['get_playlist'])
->>> h = r.run_lines(h, ['jump_to_playlist -- -1'])
->>> h = r.run_lines(h, ['get_playlist'])
->>> h = r.run_lines(h, ['get_curve'])
->>> h = r.run_lines(h, ['curve_index'])
->>> h = r.run_lines(h, ['jump_to_curve -- -1'])
->>> h = r.run_lines(h, ['get_curve'])
->>> h = r.run_lines(h, ['curve_index'])
->>> h = r.run_lines(h, ['get_note'])
->>> h = r.run_lines(h, ['set_note ""'])
->>> h = r.run_lines(h, ['get_note'])
+See :file:`note.py`.
*Exporting curves*
->>> os.path.exists('mycurve.dat')
->>> h = r.run_lines(h, ['export_bock --output mycurve.dat'])
+>>> export_already_exists = os.path.exists('mycurve.dat')
+>>> export_already_exists
+False
+>>> h = r.run_lines(h, ['export_block --output mycurve.dat'])
+Success
+<BLANKLINE>
>>> os.path.isfile('mycurve.dat')
+True
+>>> if export_already_exists == False:
+... os.remove('mycurve.dat')
*Measuring distances and forces*
->>> h = r.run_lines(h, ['delta 300 500'])
+>>> h = r.run_lines(h, ['delta 300 500']) # doctest: +ELLIPSIS
+[('z piezo (m)', -4.913...e-08), ('deflection (m)', -2.834...e-08)]
+Success
+<BLANKLINE>
*Worm like chain and freely jointed chain fitting*
*Configuring Hooke*
>>> h = r.run_lines(h, ['set_config conditions temperature 300.0'])
+Success
+<BLANKLINE>
>>> h = r.run_lines(h, ['get_config conditions temperature'])
+300.0
+Success
+<BLANKLINE>
>>> h = r.run_lines(h, ['set_config conditions temperature 295.3'])
+Success
+<BLANKLINE>
>>> h = r.run_lines(h, ['get_config conditions temperature'])
->>> h = r.run_lines(h, ['print_config'])
+295.3
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['print_config']) # doctest: +ELLIPSIS
+# Default environmental conditions in case they are not specified in
+# the force curve data. Configuration options in this section are
+# available to every plugin.
+[conditions]
+# Temperature in Kelvin
+temperature = 295.3
+<BLANKLINE>
+...
>>> h = r.run_lines(h, ['save_config'])
+Success
+<BLANKLINE>
"""