0

I am trying to create a subversion hook for running PMD rules based on this article: http://yarenty.blogspot.in/2014/02/svn-hooks-to-automatically-check-code.html

I was able to get it working in Windows but having trouble getting it to work in Linux.

if __name__ == "__main__":
    if len(sys.argv) != 3:
        sys.stderr.write("invalid args\n")
        sys.exit(1)

    try:
        sys.exit(main(sys.argv[1], sys.argv[2]))
    except ConfigParser.Error as e:
        sys.stderr.write("Error IN xxxx: %s\n" % e)
        sys.exit(1)

The following error is thrown on commit:

Syntax Error: except configparser.Error as e:

I have very minimal programming experience. Can someone assist on this? BTW, both Windows and Linux are on Python 2.7.

  • 2
    Is that `enter code here` bit in your original file? – Kevin Mar 26 '14 at 19:00
  • 1
    How are you running this on Linux? That's an error message you'd get using Python 2.5 or earlier, not 2.7. – Wooble Mar 26 '14 at 19:01
  • If you delete the `enter code here` part and fix the indentation (have the `except` aligned with `try`) it works. tested on osx – skamsie Mar 26 '14 at 19:02
  • Sorry.. the enter code here bit and the indentation are correct in my script. I've updated the question to reflect it. @Wooble: I am pretty sure that it was python 2.7 that i installed on linux. – user3465643 Mar 27 '14 at 02:47
  • @user3465643: there's a difference between installing it and using it. WHat distro are you using? What's the actual command you're using to run Python? If you run this same command without specifying a script, do you actually see "2.7."? – Wooble Mar 27 '14 at 10:32
  • You were right. There was an older Python 2.4 installation which was being referred to. Once I specified the full path to Python 2.7 when invoking the script it worked fine. Spot on! Thanks for taking the time. – user3465643 Mar 27 '14 at 18:11

0 Answers0