summaryrefslogtreecommitdiff
path: root/configshell
Commit message (Collapse)AuthorAgeFilesLines
* Package as both 'configshell' and 'configshell_fb'Andy Grover2014-12-022-5/+9
| | | | | | | | | | | We have changed the API from Datera configshell, so we should be using a different package name to eliminate confusion. Still package under configshell pkg name, but issue a warning to switch. Change code in shell.py to use relative imports instead of package name. Signed-off-by: Andy Grover <agrover@redhat.com>
* Don't reuse "parameter" local variableAndy Grover2014-11-191-3/+3
| | | | | | | | Later on in the function, we assume "parameter" is still the dict that was passed in. Reported-by: Fabian Deutsch <fdeutsch@redhat.com> Signed-off-by: Andy Grover <agrover@redhat.com>
* Fix exception on sortingAndy Grover2014-09-221-1/+1
| | | | | | | | | | | | | | | A node named "foo4" will match the regexp in sorting_keys and will sort by ("foo", 4). A node named "foo" will not match and will sort by ("foo", None). This is incorrect because None is not orderable with integers. In the second case, having the second element in the tuple be 0 does the right thing. Fixes #14 Reported-by: Arthur Lutz Signed-off-by: Andy Grover <agrover@redhat.com>
* Fix ui_command_get() when no parameter is providedChristophe Vu-Brugier2014-07-011-4/+4
| | | | | | | | | | | | | | | | The "get attribute" command displays an error message after the list of attributes. For instance, in the TPG context, the following error is displayed: No parameter 't' in group 'attribute' This happens because the 'parameter' argument in ui_command_get() is overwritten in the loop that iterates over the list of parameters to display their value. This patch fixes the issue by renaming the variable in the loop so that the value of the original 'parameter' variable is preserved. Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
* Don't use elif when previous conditional returnsAndy Grover2014-03-141-1/+2
| | | | | | | | | | To follow-on Christophe's previous fix, now that the previous conditional returns, it's a little easier to follow (IMHO) if the next conditional is an 'if' instead of an 'elif'. Also, add an empty line. Signed-off-by: Andy Grover <agrover@redhat.com>
* Fix exception raised when 'help' is invokedChristophe Vu-Brugier2014-03-141-1/+1
| | | | Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
* Another dumb thing to fix.Andy Grover2014-03-031-1/+1
| | | | | | Arrg. Can't reference self in a default parameter. Signed-off-by: Andy Grover <agrover@redhat.com>
* Remove unneeded sys importAndy Grover2014-03-031-1/+0
| | | | | | | An earlier version of the commit used it, but its use was removed in the final commit. Whups. Signed-off-by: Andy Grover <agrover@redhat.com>
* Make error-level log messages go to stderrAndy Grover2014-03-032-8/+19
| | | | | | | | | | Extend con.display() with an error boolean optional parameter. If true, output goes to stderr. Is this in log._log() to send messages >= 'error' to stderr. This is based on work by Tregaron Bayly and Jason Earl at Bluehost, thanks. Signed-off-by: Andy Grover <agrover@redhat.com>
* Let exceptions through to callers of run_interactiveAndy Grover2014-03-032-193/+182
| | | | | | | | | | | | | Change logic in run_interactive() to not recursively call itself, and to let exceptions through to callers. Raising ExecutionError instead of printing a message but not raising an exception is now allowed. This lets us reorganize a few functions for less nested logic. Change log.error()s to exceptions. Signed-off-by: Andy Grover <agrover@redhat.com>
* Re-enable hack for tab-completion with nothing under the cursorAndy Grover2014-01-061-2/+8
| | | | | | | | | | | | | | | | | | A very nice behavior is having <tab><tab> bring up options for the next expected commandline token when nothing is underneath the cursor. There was a workaround to get this working with the simpleparse parser, and we need a different workaround for it to work with pyparsing. This keeps the same technique of adding a bogus input and seeing what the parser would categorize it as, and then setting current_token based on that. We also ensure current_token is defined. Without this, the call to _dispatch_completion fails with a NameError but somebody catches the error so things just silently don't work, without the debug msg in _dispatch_completion for unknown current_token ever printing. Signed-off-by: Andy Grover <agrover@redhat.com>
* Fix an integer division on Python 3Christophe Vu-Brugier2013-10-181-1/+1
| | | | | | | | | | | | | | | | | With Python 2, '/' returns the floor of the mathematical result of division if the arguments are ints. With Python 3, the operator returns a reasonable approximation of the mathematical result of the division. This commit uses '//', which is the floor division operator in both Python 2 and Python 3, so that the result can be safely used to index an array. For more details, see PEP 238 "changing the division operator" http://www.python.org/dev/peps/pep-0238 Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
* Remove unused parameters in _complete_token_{command,path}()Christophe Vu-Brugier2013-10-121-20/+5
| | | | Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
* Remove the readline completion hook fallback used with Python < 2.6Christophe Vu-Brugier2013-10-121-37/+3
| | | | Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
* Comply with PEP 3310 "Catching Exceptions in Python 3000"Christophe Vu-Brugier2013-10-082-10/+10
| | | | | | Generated with `2to3 -f except`. Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
* Replace simpleparse with pyparsingChristophe Vu-Brugier2013-09-121-46/+46
| | | | | | | | | | | | Configshell uses simpleparse to parse the command line. Unfortunately, simpleparse does not seem to be maintained anymore: the last release was three years ago. Moreover, simpleparse is not widely used (on Debian, only configshell depends on it). On the other hand, pyparsing is actively maintained, widely used and ready for Python 3. So let's use it. Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
* Put package information in setup.py instead of importing configshell's initChristophe Vu-Brugier2013-08-281-6/+0
| | | | | | Also update the package name, version, URL and maintainer. Signed-off-by: Andy Grover <agrover@redhat.com>
* Merge branch 'upstream' into devAndy Grover2013-07-236-66/+66
|\ | | | | | | | | Conflicts: README
| * configshell: Change copyright to Apache License 2.01.2upstreamNicholas Bellinger2013-07-046-66/+66
| | | | | | | | | | | | | | | | | | This patch converts configshell code copyright from AGPL to the permissive Apache License 2.0. It also update copyright owner to Datera, Inc. Signed-off-by: Nicholas Bellinger <nab@risingtidesystems.com>
* | Make sure help ends with carriage returnAndy Grover2013-06-041-0/+1
| | | | | | | | Signed-off-by: Andy Grover <agrover@redhat.com>
* | Merge remote branch 'gh/master' into devv1.1.fb7Andy Grover2013-02-251-1/+1
|\ \
| * | Lambda not neededAndy Grover2013-01-041-1/+1
| | | | | | | | | | | | | | | | | | sorting_keys is already a function. Signed-off-by: Andy Grover <agrover@redhat.com>
* | | Avoid exception when arrowing down past end of listAndy Grover2013-01-151-1/+4
|/ / | | | | | | | | | | | | I have a feeling that urwid has a more elegant way to handle scrolling behavior, but it wasn't very obvious, so this works. Signed-off-by: Andy Grover <agrover@redhat.com>
* | Fix debug log date format to YYYY-MM-DDv1.1.fb6Andy Grover2012-12-191-1/+1
| | | | | | | | Signed-off-by: Andy Grover <agrover@redhat.com>
* | Improve commentAndy Grover2012-12-031-1/+2
| | | | | | | | Signed-off-by: Andy Grover <agrover@redhat.com>
* | Fix sort againAndy Grover2012-12-031-4/+6
| | | | | | | | | | | | | | We actually want to sort by non-ending-numeric part first, and *then* sort by ending number. Signed-off-by: Andy Grover <agrover@redhat.com>
* | Sort first by ending number, if presentAndy Grover2012-12-031-2/+7
| | | | | | | | | | | | | | Sort (lun1, lun2, lun10) as (lun1, lun2, lun10) instead of (lun1, lun10, lun2). Signed-off-by: Andy Grover <agrover@redhat.com>
* | Make log warning color yellowv1.1.fb5Andy Grover2012-07-111-1/+1
| | | | | | | | | | | | | | It seems to be brownish, but whatever, it's better than blue, which is also used for debug level. Signed-off-by: Andy Grover <agrover@redhat.com>
* | Only return dict keys from list_config_groupsAndy Grover2012-02-061-1/+1
| | | | | | | | | | | | That's all anyone is looking at. Signed-off-by: Andy Grover <agrover@redhat.com>
* | Remove unused list_group_params argumentsAndy Grover2012-02-061-13/+5
| | | | | | | | | | | | "param" and "type" are never used, so they can be removed. Signed-off-by: Andy Grover <agrover@redhat.com>
* | remove epydoc importv1.1.fb4Andy Grover2012-01-101-1/+0
| | | | | | | | | | | | | | I put the epydoc import in a try block, but forgot to remove the original import. Signed-off-by: Andy Grover <agrover@redhat.com>
* | Do not print color escape codes if stdout is not a ttyv1.1.fb3Andy Grover2011-12-141-1/+1
| | | | | | | | Signed-off-by: Andy Grover <agrover@redhat.com>
* | Don't use readline unless isattyAndy Grover2011-12-141-3/+10
| | | | | | | | | | | | | | Importing readline emits escape sequences to stdout. We want to avoid this when output is not to a tty. Signed-off-by: Andy Grover <agrover@redhat.com>
* | Allow mixed-case values for true/falsev1.1.fb2Andy Grover2011-12-131-2/+2
| | | | | | | | Signed-off-by: Andy Grover <agrover@redhat.com>
* | Fix get_command_syntax bugAndy Grover2011-12-051-2/+1
| | | | | | | | | | | | | | It was returning the same value for multiple default params (since index was not being incremented). Signed-off-by: Andy Grover <agrover@redhat.com>
* | Fix helptext - shell may not be interactiveAndy Grover2011-12-051-2/+2
| | | | | | | | | | | | | | If invoked with run_cmdline instead of run_interactive, the shell may not be interactive, in which case the helptext would be misleading. Signed-off-by: Andy Grover <agrover@redhat.com>
* | Do not require epydoc at runtimeAndy Grover2011-12-051-0/+14
|/ | | | | | | | It's a little excessive to require the entire epydoc package so that configshell can output italic/bold help text. If it's present, use it, but otherwise just print plaintext. Signed-off-by: Andy Grover <agrover@redhat.com>
* Fixed console get_width()Jerome Martin2011-11-011-13/+17
| | | | | | * Default max width is now 132 cols. * Now also works with non-terminal device, problem was reported by "Pál Gergely" <nightw@niif.hu>
* Made warnings blue by default.Jerome Martin2011-07-201-1/+1
|
* Removed unused import (sys) in log.py.Jerome Martin2011-07-201-1/+0
|
* Improved handling of command_execution result.Jerome Martin2011-07-181-2/+7
| | | | | | | * Replaces 'is' by '==' for string test. * Explicitely looks for a ConfigNode to change current node. * Added debugging output. * Raise an exception on unexpected result.
* Main help text update, a few comments fixes.Jerome Martin2011-07-181-14/+25
|
* Refactored ConfigShell usage and add/del child.Jerome Martin2011-07-182-267/+265
| | | | | | | | | | | | | | | | | | * Moved ConfigNode add_child to child's __init__ . Better semantics matching actual usage. . Allows to skip many checks in add_child. . Knowing parent at __init__ time will allow to access some of its attributes during __init__, useful for actual usage. . Removed _set_name, _set_parent and corresponding setter properties. . Added ConfigNode.remove_child(). * Moved shell property to ConfigNode. . Root node attaches itself to a shell during __init__. . Each node can use con, log and prefs through the shell property. * Linebreaks cleanup: removed unneccessary backslashes. * Catching setting signal handler failure in thread. * Changed a list concat (l1+l2) to use l1.extend(l2).
* Refactored command parameter check.Jerome Martin2011-06-111-14/+88
| | | | | | | | | | * Error messages are now more descriptive regrading wrong parameters errors. * Used to catch TypeError exception after the fact, without distinguishing between actually wrong user-supplied parameters from improper function calls from within our code. Also, was based on greping substrigns in the TypeError message, which is fragile and hackish. * Does not catch TypeError anymore, instead added an assert_params() method that check the user parameters agains the command method before calling it.
* Now allows '%' in grammar for vars.Jerome Martin2011-06-101-2/+2
|
* Added methods to use configuration groups.Jerome Martin2011-06-081-126/+178
| | | | | | | * Direct access is fragile and causes issues when changing the data structure for parameters. Wrapped it in helper methods get_group_param(), list_group_params(), list_config_groups() and define_config_group_param().
* Fixed ui_type_* to type name regressionsJerome Martin2011-06-081-11/+11
| | | | | | * Fixed set param value auto completion * Fixed get/set group usage of param types * Some variable naming cleanup for consistency
* Got rid of direct ui_type_* methods.Jerome Martin2011-06-081-22/+34
| | | | * Use type names instead.
* Fixed child name display for add_child error.Jerome Martin2011-06-081-1/+1
|
* Added writable flag to config groups items.Jerome Martin2011-06-041-37/+55
| | | | | | * Only use writable ones for set operations. * Changed a few messages accrodingly. * Display the params [ro] status in 'get GROUP'.