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 johnsojc » Wed Jul 17, 2013 3:56 pm

Here are some of the values I get when the code runs (going to Watcher's Pub):

sdlName = <PlasmaTypes.ptAttribString instance at 0x18AE95A8>
sdlName.value = boolTreeDayLights
ageSDL = PtGetAgeSDL() (= <Plasma.ptSDL object at 0x1346F7D0>)

so ageSDL[sdlName.value][0] would look like
<Plasma.ptSDL object at 0x1346F7D0>[boolTreeDayLights][0]

I do not understand what this is trying to do.

Going to any of the player Guild Pubs. (Writers, greeters, etc.) I get a tuple index out of range error from xAgeSDLBoolShowHide.py

According to the code, ageSDL[sdlName.value][0] should return a bool value but appears to fail for some reason. Even the debug statements I put in the file to get what this code returns causes a traceback.

If ageSDL[sdlName.value][0] (v2) or ageSDL[stringVarName.value][0] (v1) returns TRUE, then a TRUE responder is run otherwise a FALSE responder.

I also used a different client (the CWE Build) and still got the error.
Last edited by johnsojc on Wed Jul 17, 2013 4:30 pm, edited 1 time 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 4:27 pm

johnsojc wrote:sdlName = <PlasmaTypes.ptAttribString instance at 0x18AE95A8>
sdlName.value = boolTreeDayLights
ageSDL = PtGetAgeSDL() (= <Plasma.ptSDL object at 0x1346F7D0>)
[..]
I do not understand what this is trying to do.

Okay, some explanations:
<PlasmaTypes.ptAttribString instance at 0x18AE95A8>
sdlName is in fact not a variable or a string directly, but sort of pointer to a struct (if we think C), containing the information.
"at 0x18AE95A8" says where it can be found in memory,
"PlasmaTypes.ptAttribString" tells which type it is (sort of string).

sdlName.value is a dereferenced access to this structure, giving the value (the string)

johnsojc wrote:so ageSDL[sdlName.value][0] would look like
<Plasma.ptSDL object at 0x1346F7D0>[boolTreeDayLights][0]

Hmm, better forget this. You can't access it this way, or translate it this way.
The Python interpreter just prints out something like "<Plasma.ptSDL object at 0x1346F7D0>" to show it's not directly an SDL value, but sort of reference to an SDL structure/object. Similar to what I said above.

Just working with "sdlName.value" to access it is fine and all we need to know.

Accessing the SDL value using
ageSDL[boolTreeDayLights][0]
gives you the real (current) value; that's the reason for the [0] at the end.

(I don't know what is contained in index [1] - if it even exists in the vault. Maybe it keeps the default values, which we define in the .SDL files - but don't count on that. I'm just guessing.)

Forgive me if I was trying to tell you what you already knew. Maybe I misunderstood what you did not understand. *g*

You do know how you can have a look into the SDL definitions directly? Or how to have a look into the vault to see which are available?


Edit:
johnsojc wrote:According to the code, ageSDL[sdlName.value][0] should return a bool value but appears to fail for some reason. Even the debug statements I put in the file to get what this code returns causes a traceback.

It can fail if there is really no such SDL variable to access. If that's the case, it is not a bug in the Python code, but in the SDL setup itself.
By the way, did you check if your real SDL setup has still leading trailing spaces in their names?
(Not sure if an SDL database can hold whitespaces at all though. In my understanding, Adam's fix did only remove them from the max wiring interface / value passing from the Age file.)
Last edited by tachzusamm on Wed Jul 17, 2013 4:50 pm, edited 1 time 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 4:35 pm

Ummm if you mean VaultShop, I just downloaded it today but haven't tried to use it.

I had Adam's patch that removed any whitespace but I will look again to make sure it is applied at the right place in the code.
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 4:40 pm

Unfortunately I only know how to do this with URU CC and PlasmaShop, I better keep quiet to not confuse you by giving false information how to do it in a MOUL environment.
Basically, yes, you should definitely have a look directly at those SDL variables in the server - to make sure they are really there, correctly written and accessible.

Maybe wait for Hoikas to step in, he knows better how to track it down.
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Converting Python Scripts to meet PEP-8

Postby Tsar Hoikas » Wed Jul 17, 2013 4:51 pm

The problem is that the 3ds Max files specify variables that do not actually exist. I guess I forgot to add a try except for non whitespace failures. Oops

Like you guys, I tired to make this a code problem for several weeks. Then I realized the data was just wrong.

Sent from my HTC6435LVW using Tapatalk 4 Beta
Image
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 2180
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia

Re: Converting Python Scripts to meet PEP-8

Postby tachzusamm » Wed Jul 17, 2013 5:00 pm

Tsar Hoikas wrote:The problem is that the 3ds Max files specify variables that do not actually exist.

A-ha. That's it.

Tsar Hoikas wrote:I guess I forgot to add a try except for non whitespace failures. Oops

Part of. You did sometimes (in _Setup in xAgeSDLBoolShowHide for example), but sometimes not.
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 5:07 pm

I never would have made such a big issue of this but I was using error tracebacks to check my PEP-8 modified files. Errors from other sources kind of make it difficult to determine if I made a mistake or one already existed.

Let me know if you come up with a solution. I have updated about 30 of the scripts to PEP-8... only a couple of hundred or so more to do :roll:
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 6:30 pm

As long as I'm cleaning up files, is anyone interested in my doing a proper cleanup of the default SDL files?

If so, I need to know exactly how to format each line, tabs here spaces there, etc. I really don't mind doing the donkey work and I do have the time. (reminds me of my old job... ;) )
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8

Postby Deledrius » Wed Jul 17, 2013 7:07 pm

johnsojc wrote:As long as I'm cleaning up files, is anyone interested in my doing a proper cleanup of the default SDL files?

If so, I need to know exactly how to format each line, tabs here spaces there, etc. I really don't mind doing the donkey work and I do have the time. (reminds me of my old job... ;) )


I did some cleanup for the SDL files used on Gehn (and got rid of the legacy versions, too, since those are irrelevant on a fresh server), but nothing really sweeping.

I don't think there's any preferred formatting for them, so feel free to devise something consistent and readable. Around here people tend to prefer spaces over tabs (specifically for alignment), but otherwise do what looks good.
User avatar
Deledrius
Gehn Shard Admin
 
Posts: 1377
Joined: Mon Oct 01, 2007 1:21 pm

Re: Converting Python Scripts to meet PEP-8

Postby Tsar Hoikas » Wed Jul 17, 2013 7:10 pm

johnsojc wrote:Let me know if you come up with a solution. I have updated about 30 of the scripts to PEP-8... only a couple of hundred or so more to do :roll:


I'll look into it tomorrow. I like to squash as many of these errors as well (we tee stdout and save a server log for Gehn, and I inspect it regularly).

In the meantime, do you think your could open a pull request against some of the work you've completed? It helps to break down really big changes like these into more manageable chunks.
Image
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 2180
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia

PreviousNext

Return to Plasma Development

Who is online

Users browsing this forum: No registered users and 0 guests

cron