Sep 19, 2010

Play python interface compatibility

it looks like the new version of GreenScript is quite welcome in the community.

Tom is obviously one of them who love this plugin. He report a bug very promptly. After installed v1.1, as long as he try to invoke any play command like play eclipsify or play greenscript:cp .... it will end up with the following error:
=====
C:\code\phase3>play eclipsify
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.0.3.2, http://www.playframework.org
~
Traceback (most recent call last):
File "C:\play-1.0.3.2\play", line 1459, in
execfile(commands)
File "C:\play-1.0.3.2\modules\greenscript-1.1\commands.py", line 4,
in
from play.utils import *
ImportError: No module named play.utils
====


This is my fault. I didn't expect the play command interface has been changed since play-1.1. Here is the solution:

try:
# play_command is defined in Play-1.0 only
play_command
except NameError:
play_command = None
if play_command is None:
# ~~~~~~~~~~~~~~~~~~~~~ running on v1.1
# go v1.1 logic
else:
# ~~~~~~~~~~~~~~~~~~~~~ running on v1.0
# go v1.0 logic

No comments:

About Me

My photo