
Converting Python Scripts to meet PEP-8 (and bugs)
-
- Councilor of Technical Direction
- Posts: 2180
- Joined: Fri Nov 16, 2007 9:45 pm
- MOULa KI#: 23335
- Location: South Georgia
- Contact:
Re: Converting Python Scripts to meet PEP-8
It's none of the above. The problem is that Cyan's tech artists added some SDL strings with trailing whitespace ("nb01ReaderBoardVis ")
I fixed this bug a few days ago by adding code to squelch any whitespace in SDL strings.


Re: Converting Python Scripts to meet PEP-8
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.
-
- Councilor of Technical Direction
- Posts: 2180
- Joined: Fri Nov 16, 2007 9:45 pm
- MOULa KI#: 23335
- Location: South Georgia
- Contact:
Re: Converting Python Scripts to meet PEP-8
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.

Re: Converting Python Scripts to meet PEP-8
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:
It appears that all the pubs are affected, Greeters, Writers, etc..
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'
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.
Re: Converting Python Scripts to meet PEP-8
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?
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?
- tachzusamm
- Posts: 575
- Joined: Thu May 29, 2008 2:03 am
- MOULa KI#: 0
- Location: Germany
Re: Converting Python Scripts to meet PEP-8
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. :/
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.
Re: Converting Python Scripts to meet PEP-8
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")
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.
- tachzusamm
- Posts: 575
- Joined: Thu May 29, 2008 2:03 am
- MOULa KI#: 0
- Location: Germany
Re: Converting Python Scripts to meet PEP-8
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?
So, are you sure you used the correct variable everywhere?
Re: Converting Python Scripts to meet PEP-8
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.
- tachzusamm
- Posts: 575
- Joined: Thu May 29, 2008 2:03 am
- MOULa KI#: 0
- Location: Germany
Re: Converting Python Scripts to meet PEP-8
I knowjohnsojc wrote:LOL, It's not my code...

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).