Menu

program works in a terminal but not in pydev

ndlarsen
2008-03-03
2013-03-15
  • ndlarsen

    ndlarsen - 2008-03-03

    Hello.

    I found a pice of code on the web which for some reason runs as intended in a terminal but not in eclipse with pydev. Here's the code:

    #! /usr/bin/python

    import fcntl, struct, sys, termios

    def get_terminal_dimensions():
        fd_stdout = sys.stdout.fileno()
        r = fcntl.ioctl(fd_stdout, termios.TIOCGWINSZ, struct.pack("HHHH", 0, 0, 0, 0))
        rows, cols, x_pixels, y_pixels = struct.unpack("HHHH", r)
        return cols

    print get_terminal_dimensions()

    When running it through pydev the console output is this:

    Traceback (most recent call last):
      File "/home/x/workspace/pyprogs/src/functions/getTtySize.py", line 6, in <module>
        r = fcntl.ioctl(fd_stdout, termios.TIOCGWINSZ, struct.pack("HHHH", 0, 0, 0, 0))
    IOError: [Errno 22] Invalid argument

    Now, I am not entirely sure if it is caused by misconfiguration in eclipse/pydev, a bug or something else. I'm just wondering if anyone could help me out on this. I'm running Eclipse 3.3.1.1 Build id: M20071023-1652 with Pydev 1.3.13 on Linux 2.6.24.1.
    Thank you.

     
    • Fabio Zadrozny

      Fabio Zadrozny - 2008-03-03

      Hi,

      I'm not really able to reproduce it right now because I'm not currently on linux, but the 'usual' problem related to the Eclipse console is that when you hit 'return', it'll not only give you a '\n' as the line ending, but a '\r\n' -- but that's on windows (I'm not 100% sure on how it behaves on linux).

      If that's not it, please report it as a bug (so that I don't forget to review that).

      Cheers,

      Fabio

       
    • ndlarsen

      ndlarsen - 2008-03-03

      Hi.

      I appreciate your reply. I just realized that this might be caused by plain stupidity on my behalf. I tried out curses and it gives me errors in Eclipse but works just fine in a terminal. Could this be caused by Eclipse's console functionality not being a true terminal/tty at all?

      Regards.

       
      • Fabio Zadrozny

        Fabio Zadrozny - 2008-03-04

        That's very likely... The Eclipse console is not a real terminal (and making it so is not really in the pydev context, but in the Eclipse context).

        I haven't tested it myself, but I've heard that the Wicked Shell plugin may be better in this respect: http://www.wickedshell.net/ (if you do try it, please paste your comments back here, as it could be a solution for those that want to use a 'real' shell within Eclipse).

        Cheers,

        Fabio

         
        • ndlarsen

          ndlarsen - 2008-03-04

          Hi again.

          Thank you very much for pointing me in this direction. I'll post back when I have tried it out properly.
          Regards.

           
    • ndlarsen

      ndlarsen - 2008-03-27

      I have used wickedshell a bit now. So far it seems that it allows executing the script unless it's functionality related the console, such as getting size, columns etc. which makes sense as it's just emulation. At least that's an improvement.