ncoronado / tracshell

Automatically exported from code.google.com/p/tracshell
1 stars 0 forks source link

Cannot pipe or redirect non-interactive output #43

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I've applied patch 41 to allow non-interactive access to a trac.
Exactly what I wanted!!

I now wish to do some batch processing from scripts, involving
piping and redirection:

What steps will reproduce the problem?
1.  tracshell -s <site> log 300 | sed 's/ ...
2.  tracshell -s <site> log 300 > myFile
3.  X=`tracshell -s <site> log 300`
4.  X=$(tracshell -s <site> log 300)

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

All the above fail because tracshell tries to access
terminal info:

stefan@xxxx:~ > tracshell -s mySite log 300 > myFile
Traceback (most recent call last):
  File "/nfshome/stefan/bin/tracshell", line 8, in <module>
    from tracshell import shell
  File "/usr/lib/python2.6/dist-packages/tracshell/shell.py", line 30, in 
<module>
    TERM_SIZE = get_termsize(sys.stdout)
  File "/usr/lib/python2.6/dist-packages/tracshell/helpers.py", line 6, in 
get_termsize
    st_ioctl = fcntl.ioctl(term, termios.TIOCGWINSZ, '1234')
IOError: [Errno 25] Inappropriate ioctl for device

In non-interactive mode, terminal info functions should not be accessed,
so the tracshell cmd can be piped & redirected like other unix cmds.

What version of the product are you using? On what operating system?

TracShell: 0.100000  + Patch 41
Kubuntu 9.10

Please provide any additional information below.

Original issue reported on code.google.com by stefan.ronsiek@gmail.com on 26 Mar 2010 at 6:48

GoogleCodeExporter commented 8 years ago
I have managed to hack the change I want in shell.py, no doubt there is also a 
proper 
way to implement this. Anyhow, here are the diffs, I also attach the complete 
file.

stefan@xxxx:~/tracshell/tracshell > diff shell.py.orig shell.py
30c30,32
< TERM_SIZE = get_termsize(sys.stdout)
---
> TERM_SIZE = None
> interactive = True
> 
43a46,50
>     if len(args) > 0:
>       interactive = False
>     else:
>       TERM_SIZE = get_termsize(sys.stdout)
>      
153c160
<         if getattr(settings, 'pager', False) and len(output) > TERM_SIZE[0]:
---
>         if interactive and getattr(settings, 'pager', False) and len(output) 
> 
TERM_SIZE[0]:

Original comment by stefan.ronsiek@gmail.com on 29 Mar 2010 at 9:39

Attachments:

GoogleCodeExporter commented 8 years ago
Added. Thanks for the patch. :)

Original comment by j.kennet...@gmail.com on 18 Sep 2010 at 3:16