EmilyDirsh / hotwire-shell

Automatically exported from code.google.com/p/hotwire-shell
Other
0 stars 0 forks source link

pipeline starting with '#' does not get added to history #205

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. enter "#ls"
2. press return

What is the expected output? What do you see instead?

I expect to get blank output and have the command in history.

Instead nothing happens and the text remains in the command text box.  If I
run with --debug, I get

17:28:05 [140391002527456] hotwire.Command DEBUG parsing '#ls'
17:28:05 [140391002527456] hotwire.ui.Shell ERROR Exception in callback
Traceback (most recent call last):
  File "/home/mish/dev/hotwire/hotwire/logutil.py", line 28, in _exec_cb
    return func(*args, **kwargs)
  File "/home/mish/dev/hotwire/hotwire_ui/shell.py", line 968, in
__on_input_keypress
    self.__execute()
  File "/home/mish/dev/hotwire/hotwire_ui/shell.py", line 808, in __execute
    self.__do_parse(partial=False, resolve=True)
  File "/home/mish/dev/hotwire/hotwire_ui/shell.py", line 1118, in __do_parse
    resolve=resolve)
  File "/home/mish/dev/hotwire/hotwire/command.py", line 1182, in parse
    return Pipeline.parse(text, context=self.__context, resolver=(resolve
and self.__resolver or None), **kwargs)
  File "/home/mish/dev/hotwire/hotwire/command.py", line 1004, in parse
    tokens = list(Pipeline.tokenize(text, context,
accept_partial=accept_partial))
  File "/home/mish/dev/hotwire/hotwire/command.py", line 750, in tokenize
    (token, quoted) = parser.get_token_info()
  File "/home/mish/dev/hotwire/hotwire/externals/shlex.py", line 106, in
get_token_info
    (raw, quoted) = self.read_token_info()
  File "/home/mish/dev/hotwire/hotwire/externals/shlex.py", line 169, in
read_token_info
    self.instream.readline()
AttributeError: 'CountingStream' object has no attribute 'readline'

Not sure what the intent is here - readline is only used for comments.  But
I guess the easiest way to fix this is to add readline to the
CountingStream class (in hotwire/command.py)

The workflow I want this for is when entering a long complex command.  I
may have constructed a lot of it, and then realise I need to check a
detail.  So I put a # in front of it and press return, adding it to
history.  Then I can enter the commands to check the required detail.  Then
I can press up a couple of times to get my partial command back, add the
detail, remove the # and execute the command.

Original issue reported on code.google.com by dmi...@gmail.com on 14 Jul 2008 at 8:19

GoogleCodeExporter commented 9 years ago
OK, tried adding readline() to CountingStream (see attached patch).  Now I just 
get
told that it is an empty pipeline (see debug trace below).

What I want is for this to be added to the history and to be given a blank text 
box
to type my next command in.

It seems a PipelineParseException is caught in hotwire_ui/shell.py in
Hotwire.__do_parse() (line 1118) and it simply returns false and exits.

Two possible ways around it - where the exception is caught (line 1119) there 
could
be a little bit of logic to say if the exception is EmptyPipeline then check if 
there
is some non-whitespace, and if there is add it to the history and clear the 
input
before returning.  Maybe EmptyPipelineException could inherit from
PipelineParseException for this purpose.

Alternatively there could be some way to communicate to the __execute() method 
that
calls __do_parse() that there is some history, and it could communicate that to 
the
execute_pipeline() method which does the adding to history and clearing input 
anyway.

I think the first method would probably be cleaner, but will defer to Colin as 
to
what would fit in best to his code, though I might try coding the first method 
at
some point.

21:21:46 [140684159440608] hotwire.Command DEBUG parsing '#ls'
21:21:46 [140684159440608] hotwire.Command DEBUG tokenize: None
21:21:46 [140684159440608] hotwire.ui.Shell DEBUG parse failed, current
syntax=<hotwire.command.HotwirePipeLanguage object at 0x10909d0>
Traceback (most recent call last):
  File "/home/mish/dev/hw/comment/hotwire_ui/shell.py", line 1118, in __do_parse
    resolve=resolve)
  File "/home/mish/dev/hw/comment/hotwire/command.py", line 1189, in parse
    return Pipeline.parse(text, context=self.__context, resolver=(resolve and
self.__resolver or None), **kwargs)
  File "/home/mish/dev/hw/comment/hotwire/command.py", line 1012, in parse
    return Pipeline.create(context, resolver, accept_partial=accept_partial, *tokens)
  File "/home/mish/dev/hw/comment/hotwire/command.py", line 991, in create
    raise PipelineParseException(_("Empty pipeline"))
PipelineParseException: Empty pipeline

Original comment by dmi...@gmail.com on 14 Jul 2008 at 8:40

Attachments: