Topic
7 replies Latest Post - ‏2012-03-05T19:21:30Z by gcompest
gcompest
gcompest
6 Posts
ACCEPTED ANSWER

Pinned topic pycleartool and escape sequences?

‏2012-02-27T22:22:45Z |
Hello,

I'm using the Python Cleartool module http://pypi.python.org/pypi/pycleartool/2007.01 to develop some Clearcase scripts.

When I run the following command:

result = cleartool.cmd("lscheckout -cview -recurse")

The captured output that comes back contains escape sequences, meant to bold the filename on an ANSI terminal.

If I run this from within Perl, I don't get the escape sequences.

Is there an easy way to supress the escape sequences, so I don't have to strip them from the output?

Thanks,

Greg
Updated on 2012-03-05T19:21:30Z at 2012-03-05T19:21:30Z by gcompest
  • SystemAdmin
    SystemAdmin
    47293 Posts
    ACCEPTED ANSWER

    Re: pycleartool and escape sequences?

    ‏2012-02-28T09:53:49Z  in response to gcompest
    Greg wrote:
    > Is there an easy way to supress the escape sequences,
    > so I don't have to strip them from the output?
    Use directly ClearCase::Argv from Perl, and strip there.
    Especially the ipc mode.

    Marc
    • gcompest
      gcompest
      6 Posts
      ACCEPTED ANSWER

      Re: pycleartool and escape sequences?

      ‏2012-02-29T00:08:10Z  in response to SystemAdmin
      I could just as easily strip the escape sequences from within Python. I was more interested in knowing if there's a way of controlling this on the Clearcase side, rather than compensating for it in the wrapping script.

      Is Perl preferred to Python in the Clearcase community?
      • SystemAdmin
        SystemAdmin
        47293 Posts
        ACCEPTED ANSWER

        Re: pycleartool and escape sequences?

        ‏2012-02-29T08:20:57Z  in response to gcompest
        Greg wrote:
        > I could just as easily strip the escape sequences from within Python.

        I mentioned it because you wrote that you were 'running this from within Perl'.

        > I was more interested in knowing if there's a way of controlling this on
        > the Clearcase side, rather than compensating for it in the wrapping script.

        These are not generated by cleartool!?
        I can only guess they are added by the Python script.

        > Is Perl preferred to Python in the Clearcase community?

        It used to be. Perl is/was used in the ClearCase distribution, in various places.
        That's why there is a Perl as part of the distribution.

        Now:
        • I keep claiming that this ClearCase Perl should not be used by users for various reasons
        • It strongly looks like the trend is to move to Java, Eclipse, etc. away from command line scripting.

        This said, I have myself invested into the Perl ClearCase::Argv / ClearCase::SyncTree / ClearCase::Wrapper infrastructure, developed and proposed by David Boyce, and I know nothing nearly equivalent.
        In fact, I see there the only real future of ClearCase, hoping that IBM might understand it before it's too late.
        http:// Well... it is maybe already too late. The only glimpse of hope comes from the weakness of the (Open Source--there is no other) competition

        Marc
        • SystemAdmin
          SystemAdmin
          47293 Posts
          ACCEPTED ANSWER

          Re: pycleartool and escape sequences?

          ‏2012-02-29T08:23:23Z  in response to SystemAdmin
          Argh! I keep using square brackets forgetting that this *&^%$£ forum software interprets them as links... Two unfortunate occurrences (pairs thereof) in my previous message.

          Marc
        • keolw
          keolw
          303 Posts
          ACCEPTED ANSWER

          Re: pycleartool and escape sequences?

          ‏2012-02-29T08:53:03Z  in response to SystemAdmin
          > These are not generated by cleartool!?

          Actually, I think it's "always" been so...although I can't remember when I saw it last, presumably a function of how I use putty et al nowadays.

          Anyway, supposedly it depends on your TERM and ATRIA_NO_BOLD variables. Having 'atria' in there hints that it's from old times; read up on it in 'ct man env_ccase'. Personally I'd guess it also happens if stdout is detected as a tty, which is sort of common if I understand correctly - after all, you don't want the escape sequences if you put the command output in a pipe...or as here, something you trap.

          So presumably, setting ATRIA_NO_BOLD would work. But I'm also confused that the stdout presented to the cleartool run by the python code thinks it's a tty. I've never seen this happen in a Perl backtick or similar so...I think it's a Python problem that could/should be rectified (not a Python programmer however, so just guessing).

          ken1

          PS. And this forum software is, and has been, for many years a %&¤%&¤ disgrace when it comes to resending posts as mails...
          • gcompest
            gcompest
            6 Posts
            ACCEPTED ANSWER

            Re: pycleartool and escape sequences?

            ‏2012-03-05T19:21:30Z  in response to keolw
            Thanks Ken, this appears to work!

            I think you're right that Python is probably presenting the wrong terminal type to the Clearcase subprocess. I can investigate that separately, but the env variable does what I'm expecting.

            Greg
    • gcompest
      gcompest
      6 Posts
      ACCEPTED ANSWER

      Re: pycleartool and escape sequences?

      ‏2012-02-29T00:08:17Z  in response to SystemAdmin
      I could just as easily strip the escape sequences from within Python. I was more interested in knowing if there's a way of controlling this on the Clearcase side, rather than compensating for it in the wrapping script.

      Is Perl preferred to Python in the Clearcase community?