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 » Fri Jul 26, 2013 6:46 am

Well moss does something like this:
Code: Select all
update textnote set value = E'<cover src=\"xSharperJournalCover*1#0.hsm....(lots of text and formatting)...where title = 'Sharper' and creatorid='0';

I've thought to myself that the E'... might be the encoding for English but this is probably not the best way to change it unless you are trying to maintain compatibility with MOUL I really have not looked very deeply far into how this actually works.

It appears the concept is to have a global node textnote with dependent nodes containing the data to display.

EDIT: (slap me upside the head for speculating too much)

moss sets it up by creating GlobalIndex nodes and adding the following nodes to handle dynamic entities:
    Text note - Laxman "Welcome to the cavern
    DeviceInboxFolder - CommunityImager
    Generic Folder - Journals
    Text Note - Sharper journal
    Image node - GZImage
    Generic Folder - MemorialImager
    Text note - MemorialImager
I'm not familiar enough with dirtsand to know if something like this can be set up.
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8

Postby johnsojc » Fri Jul 26, 2013 11:36 am

Testing in Ahnonay:
Post deleted. Somehow my files got corrupted and all the testing I did was using bad code. I will rerun my tests now that everything appears to be working again.

EDIT: It appears I broke ahnyPressurePlates.py somehow. I finally managed to complete Ahnonay.

I have started over for the third time in cleaning up the scripts. The more I do, the more I learn so I end up revisiting the scripts time after time. LOL, I though all I was going to do was just clean up the code style but I spend so much time troubleshooting odd bits of code that I keep getting slowed down and distracted from my original goal. But hey, It all needs to be done. I just have to slow down and smell the code.
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8

Postby johnsojc » Sat Jul 27, 2013 12:22 pm

Testing in Ahnonay:
OK, everthing seems to be working. I have about 4 more Ahnonay scripts to process but so far, so good. The only issue I've found (which may not be an issue) is that if you launch into flymode, the pressure plate you were standing on remains activated as if you were still there, I have found no way to get it to stop indicating short of leaving the Age and returning.

I did find what may be a problem in Relto. If you invite someone to your Relto and they use the bookshelf before you do, the bookshelf will not work for you. One instance, the guest activated the shelf, selected a book, put it back and stepped away. When the owner tried to use the shelf, psnlBookshelf.py threw a tuple index error. The 2nd scenario was the guest used a book first and linked away. Then the owner could not activate the shelf but no traceback error.
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8

Postby Tsar Hoikas » Sat Jul 27, 2013 5:47 pm

johnsojc wrote:I just have to slow down and smell the code.


Oh dear. You may want to visit some olfactory doctor/clinic afterward ;)

I kept getting bitten in the butt by that pressure plate flying bug as well. It's something to investigate in the avatar controller code.
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 Acorn » Sun Jul 28, 2013 4:01 am

johnsojc wrote:Testing in Ahnonay:
OK, everthing seems to be working. I have about 4 more Ahnonay scripts to process but so far, so good. The only issue I've found (which may not be an issue) is that if you launch into flymode, the pressure plate you were standing on remains activated as if you were still there, I have found no way to get it to stop indicating short of leaving the Age and returning.


Tsar Hoikas wrote:
I kept getting bitten in the butt by that pressure plate flying bug as well. It's something to investigate in the avatar controller code.


It's great news that you've verified that Adam's fixes have worked, johnsojc. I was worried by your earlier (deleted) post. So in Gehn17 it'll be possible to complete the age - so long as you don't use fly mode, of course. ;)

Not my area of expertise but: might the Ahnonay pressure plate bug relate to a bug I've previously reported in the Teledahn slave caves where (some/one) of the pressure plates revert(s) to act as though there are no rocks or bones (or fish baskets) on them/it?
Image
Acorn
 
Posts: 724
Joined: Sun Feb 26, 2012 9:56 am

Re: Converting Python Scripts to meet PEP-8

Postby johnsojc » Sun Jul 28, 2013 6:09 am

Acorn wrote:Not my area of expertise but: might the Ahnonay pressure plate bug relate to a bug I've previously reported in the Teledahn slave caves where (some/one) of the pressure plates revert(s) to act as though there are no rocks or bones (or fish baskets) on them/it?

I can't say that I know anything about Teledahn since I have not gotten to the script to reformat it. I've use flymode in Teledahn a lot to go through the Age quickly and never had a problem with the pressure plates in the prison.

On another issue I have been having:
Part of what keeps slowing me down are the changes my style scanner keeps insisting I make which means test... test... test!.
PEP-8 keeps yelling at me about comparing types (if type(bc) != type(None)) and telling me to use isinstance() instead. I find this less than desirable and thought maybe I could use the following instead:
    for defined types (int, str, list, dict) - instead of if isinstance(x, str) use if type(x) is str
    for special case of None - instead of if isinstance(x, type(None)) use if x is None

Does anyone know of any reason these simplified statements would cause a problem?
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8

Postby johnsojc » Mon Jul 29, 2013 12:34 pm

I've finally gotten caught up to where I was before and did a commit to my GitHub account, pep8 branch.

This commit includes;
    All the previous work I did plus a few more files.
    Bug fixes to xAgeSDLBoolRespond.py and xAgeSDLBoolShowHide.py.
    Reformatted highly dense code in xAvatarCustomization.py to be readable (it made my eyes hurt to try to read this).
    Restored long lines. (Some are near or over 200 chars so let me know if you want me to wrap any)
    Tried to implement suggestions from Adam for coding changes. (Let me know if I missed anything... which is likely)
    Replaced print with PtDebugPrint()
    Changed code which has been removed in Python3.
    Deleted commented-out code snippets

Let me know if you want me to issue a PR or will just strip these out manually.

I tested these files as well as I could in game but there are parts of the code I'm sure that have not been touched yet as I have not made it all the way through the game with my test avvies.
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8

Postby johnsojc » Tue Jul 30, 2013 10:56 am

While testing the modified scripts for Er'cana, dirtsand threw a string of SQL function syntax errors when the client tried to update the pellet and lake point scores. I hoped someone could tell me whether the problem is a missing node or two that I need to INSERT into the tables or if there might be another problem.

If it's just a missing node or two, does anyone have the SQL statements to insert them? (It would be nice to put in all the missing public nodes I mentioned in an earlier post above).

EDIT: It appears the scores table was created but there are no rows at all in the DB. I'm thinking at this point that there is a logic error in ErcanaCitySilo.py that fails to create the players score record (ki points or lake points). If the msg is to update (which is what happens when you drop a pellet) then the script bombs out. If it is a list score msg, then it tries to create the row if it doesn't exist. I haven't found what causes a list rather than an update. (help!)

EDIT2: And I found the problem and fixed it. I now have KI points accumulating and displaying in the Neighborhood imager.
I read the error coming from dirtsand about a compilation error in create score function. I couldn't see anything wrong with the code but when I opened it up in pgAdmin, I noticed that a couple of words were colorized so I went looking for reserved words in Postgresql. Although name and type are supposed to not be reserved, they were the source of the problem in the following dirtsand function:

from functions.sql Show Spoiler

The 3rd line is where the compile blows up as a syntax error.
type ALIAS FOR $2;

The fix is to change: Show Spoiler


This is apllicable to PostgreSQL 8.4
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Converting Python Scripts to meet PEP-8

Postby Tsar Hoikas » Tue Jul 30, 2013 4:35 pm

I had just looked up the CREATE statements and was preparing to post them here, but it looks like you've found the problem yourself. AFAIK, you're the only one using Postgres 8.x. I do all my local development on debian testing, which is using postgres 9.1. The Gehn deployment is on the same version as well.

And yes, we do need to add the Sharper journal to the dbinit scripts. I can look into that when I get around to reinstalling VirtualBox. I had been holding off on doing that until I installed Hyper-V for WOA emulation, but I guess DS needs more immediate attention than testing my Win 8 app on WOA.
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 johnsojc » Tue Jul 30, 2013 5:13 pm

No rush. I'm still slowly working my way through the scripts and it's the testing for bonehead typos that keeps slowing me down. I'm up to Gira scripts now.

I am contemplating saving the KI code for the weekend. 440K of code to clean up should take a few days. I suspect all the mucking about in that code will take some monumental disentangling.

The previous time I made an abortive attempt to use 9.1 caused me so many problems (of my own making, no doubt) that I started with 8.4 this time. I will probably update eventually.

I would have thought if this problem with dirtsand was already known, an updated db/functions.SQL would have been pushed to the repository by now.
johnsojc
 
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

PreviousNext

Return to Plasma Development

Who is online

Users browsing this forum: No registered users and 0 guests

cron