Converting Python Scripts to meet PEP-8 (and bugs)

Announcements and discussion regarding any projects related to Cyan Worlds' Plasma Engine including (but not limited to) CyanWorlds.com Engine, Drizzle, OfflineKI, PyPRP, and libHSPlasma.

Re: Converting Python Scripts to meet PEP-8

Postby Tsar Hoikas » Tue Jul 16, 2013 3:43 pm

It's none of the above. The problem is that Cyan's tech artists added some SDL strings with trailing whitespace ("nb01ReaderBoardVis ") :roll: I fixed this bug a few days ago by adding code to squelch any whitespace in SDL strings.
Image
User avatar
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 1932
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia

Re: Converting Python Scripts to meet PEP-8

Postby johnsojc » Tue Jul 16, 2013 5:05 pm

Deleted the <TAB> that was on the end of the line and stripped any trailing white space out of the SDL file. Still getting the error on the same SDL variable.
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8

Postby Tsar Hoikas » Tue Jul 16, 2013 5:08 pm

Sorry, I wasn't very clear above. I mean that the trailing whitespace is in the max file, and therefore the PRP file. This is another case of Cyan artist fail (the SDL files are fine). Here's my fix.
Image
User avatar
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 1932
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia

Re: Converting Python Scripts to meet PEP-8

Postby johnsojc » Tue Jul 16, 2013 5:49 pm

Great! It worked!

I implemented your patches in the files I'm reformatting to PEP-8.

EDIT: Oops! spoke too soon. Going to my Neighborhood and the city works. Going to the watcher's pub still gives this error:
Code: Select all
(07/16 21:20:34) cPythDayNight2 - Traceback (most recent call last):
(07/16 21:20:34)   File ".\python\xAgeSDLBoolRespond.py", line 95, in OnServerInitComplete
(07/16 21:20:34)     self._Setup()
(07/16 21:20:34)   File ".\python\xAgeSDLBoolRespond.py", line 129, in _Setup
(07/16 21:20:34)     self._Execute(ageSDL[sdlName.value][0], initFastFwd.value)
(07/16 21:20:34) KeyError: 'SDL key boolTreeDayLights not found'

It appears that all the pubs are affected, Greeters, Writers, etc..
Code: Select all
(07/16 21:28:39) cPythBallHallDoorVis_0 - Traceback (most recent call last):
(07/16 21:28:39)   File ".\python\xAgeSDLBoolShowHide.py", line 81, in OnServerInitComplete
(07/16 21:28:39)     self._Setup()
(07/16 21:28:39)   File ".\python\xAgeSDLBoolShowHide.py", line 114, in _Setup
(07/16 21:28:39)     self.sdl_value = ageSDL[sdlName.value][0]
(07/16 21:28:39) IndexError: tuple index out of range
(07/16 21:28:39) islmGZBeamBrain.OnServerInitComplete:  ERROR!  Can't find the boolGZBeamVis sdl, doing nothing.
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8

Postby johnsojc » Wed Jul 17, 2013 2:48 pm

No matter what I do, the code ageSDL[sdlName.value][0] triggers a traceback in both xAgeSDLBoolRespond.py and xAgeSDLBoolShowHide.py. I know this code is in the original scripts.. go figger.

On the extraneous spaces in SDL names... I know you said the problem was in the PRP file exported from Max but then I cleaned up the SDL files on my server, wiped the vault and rebuilt it. The original problem that you provided the patch for not longer occurs. Either it's magic or dirtsand sucked in the bad names from the SDL files when the server was initialized. This could only be true if the server actually sucks in the SDL files when started the first time. Am I crazy or does this really happen?
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8

Postby tachzusamm » Wed Jul 17, 2013 3:15 pm

I have no clue about which version of the scripts you are talking, but in a version I have there's no such line containing a string like "ageSDL[sdlName.value][0]" in it; instead, it reads "ageSDL[stringVarName.value][0]".

But could be we have completely different versions of course.
So if that's the case - which would mean the max wiring parameters have already been renamed in the top of the files - just ignore my comment. ;)

EDIT: Yes, forget it. My version was quite old. :/
Last edited by tachzusamm on Wed Jul 17, 2013 3:32 pm, edited 2 times in total.
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Converting Python Scripts to meet PEP-8

Postby johnsojc » Wed Jul 17, 2013 3:29 pm

It lloks like you have version 1. I am working with version 2.

These are equivalent. sdlName in V2 is the same value as stringVarName in V1 which looks something like this... <PlasmaTypes.ptAttribString instance at 0x18AE95A8>. These are equal to the first value in the max file... ptAttribString(1, "Age SDL Var Name")
Last edited by johnsojc on Wed Jul 17, 2013 3:35 pm, edited 2 times in total.
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8

Postby tachzusamm » Wed Jul 17, 2013 3:32 pm

In my opinion, that renaming of parameters is a bit problematic though. In the OnSDLNotify method, there's a parameter called SDLname, which could easily be confused with the max wiring parameter sdlName. Sure, Python does take care of lower/uppercase, but for humans maintaining the code it's confusing.
So, are you sure you used the correct variable everywhere?
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Converting Python Scripts to meet PEP-8

Postby johnsojc » Wed Jul 17, 2013 3:35 pm

LOL, It's not my code... I'm just trying to figure out why it's failing in my test bed. There could be a conflict somewhere else affecting this but I have no idea where to look.
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8

Postby tachzusamm » Wed Jul 17, 2013 3:40 pm

johnsojc wrote:LOL, It's not my code...

I know ;)

Does it still complain about index out of range, or only about missing SDL variables?
If the latter is true, you could check if it's correct, and the SDLs are really not there (if you did not already).
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

PreviousNext

Return to Plasma Development

Who is online

Users browsing this forum: No registered users and 2 guests

cron