Python assistance

31 replies [Last post]
Joined: 11/04/2008

I just upgraded the server to Debian Squeeze, and I guess the Python API for xpath has changed. I've tried using Python 2.5, and I've installed all XML/Python related Debian packages, but I still get:

Traceback (most recent call last):
  File "./draw-tower.py", line 7, in <module>
    from xml import xpath
ImportError: cannot import name xpath

Anyone know how to fix this? Or, if it needs to be rewritten to use a new API, can anyone volunteer for this?

-davidc

Joined: 03/31/2009

Hmm, maybe contact Daft as Brush? He worked with Python when he made Goo editors...

My Gooish profile | Videos on YouTube | My WOG Mods

Joined: 07/08/2011

This is the problem?
*facepalm.jpg*

There's a fix for this, but for which operating system do you need it?

Joined: 09/01/2009

*facepalm.jpg*

*lern2read.jpg*

davidc wrote:
I just upgraded the server to Debian Squeeze

Joined: 07/08/2011

It had completely slipped my mind that Debian Squeeze was an actual OS. :3

Anyway, seems you need Python-XML installed. Here's a search:
http://packages.debian.org/search?keywords=python-xml

Joined: 09/01/2009

No problem. Smile Just keeping you in line here. Tongue

Joined: 11/04/2008

See, python-xml isn't listed as available for Squeeze, I think it's outdated or something.

Joined: 07/08/2011

From further searching I can tell you, yes, it's outdated. There's no version available for Squeeze anywhere. You may have to change your API.

Joined: 08/18/2010

python-lxml

from lxml import etree
instead of
from xml import xpath
And some changes to code needed

I can try to look at the code

or you can install python-xml from oldstable Package: python-xml (0.8.4-10.1+lenny1)
which needs python 2.5

you must add a line for oldstable in /etc/apt/souces.list
copy the one with stable and change to oldstable
(if you do not know this allerady)

which makes the problem to hide until Debian 7.0

Joined: 12/23/2010

OK, just so you guys know I know NOTHING of all this stuff. But I did a bit of Googling and this looks like it could be helpful. This also seems related to the issue.

Sorry I can't help more, hope this does at all.

Joined: 07/08/2011

Sweet! Send those links to David.

Joined: 07/05/2011

Get something here with IronPython 2.7.1:

>>> import xml
>>> from xml import xpath
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import xpath from xml
>>> dir()
['__builtins__', '__doc__', '__name__', 'xml']
>>> dir(xml)
['_MINIMUM_XMLPLUS_VERSION', '__all__', '__builtins__', '__doc__', '__file__', '
__name__', '__package__', '__path__']
>>> dir(xml.__path__)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delsli
ce__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getit
em__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__',
 '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__r
add__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '
__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclas
shook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reve
rse', 'sort']

Maybe you can try __path__?

IronPython can import .NET types directly, I don't know if it works on your device.

>>> import clr
>>> clr.AddReference('System.Xml')
>>> from System.Xml import *
>>> dir()
['ConformanceLevel', 'DtdProcessing', 'EntityHandling', 'Formatting', 'IHasXmlNo
de', 'IXmlLineInfo', 'IXmlNamespaceResolver', 'NameTable', 'NamespaceHandling',
'NewLineHandling', 'ReadState', 'Resolvers', 'Schema', 'Serialization', 'Validat
ionType', 'WhitespaceHandling', 'WriteState', 'XPath', 'XmlAttribute', 'XmlAttri
buteCollection', 'XmlCDataSection', 'XmlCharacterData', 'XmlComment', 'XmlConver
t', 'XmlDateTimeSerializationMode', 'XmlDeclaration', 'XmlDocument', 'XmlDocumen
tFragment', 'XmlDocumentType', 'XmlElement', 'XmlEntity', 'XmlEntityReference',
'XmlException', 'XmlImplementation', 'XmlLinkedNode', 'XmlNameTable', 'XmlNamedN
odeMap', 'XmlNamespaceManager', 'XmlNamespaceScope', 'XmlNode', 'XmlNodeChangedA
ction', 'XmlNodeChangedEventArgs', 'XmlNodeChangedEventHandler', 'XmlNodeList',
'XmlNodeOrder', 'XmlNodeReader', 'XmlNodeType', 'XmlNotation', 'XmlOutputMethod'
, 'XmlParserContext', 'XmlProcessingInstruction', 'XmlQualifiedName', 'XmlReader
', 'XmlReaderSettings', 'XmlResolver', 'XmlSecureResolver', 'XmlSignificantWhite
space', 'XmlSpace', 'XmlText', 'XmlTextReader', 'XmlTextWriter', 'XmlTokenizedTy
pe', 'XmlUrlResolver', 'XmlValidatingReader', 'XmlWhitespace', 'XmlWriter', 'Xml
WriterSettings', 'Xsl', '__builtins__', '__doc__', '__name__', 'clr', 'xml']

By the way, why couldn't I visit this website few hours ago?

Joined: 08/06/2010

Drupal was saying something about the site being disconnected from its database? IDK.

Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.

Joined: 09/01/2009

IDK either. All davidc said on the chat about it was "that was odd". Tongue

Joined: 12/23/2010

It was pretty weird, but it was probably just a minor server failure or the like. In any case I'm glad it's back up Laughing out loud

EDIT: Oh, and I emailed David. Hoping for a reply before too long.

Joined: 12/29/2008

He told me that his MySQL was misbehaving...

Check out my SoundCloud, MomoSoundWaves

Joined: 12/29/2008

So does all this have anything to do with the leaderboards being annoying?

Check out my SoundCloud, MomoSoundWaves

Joined: 04/17/2011

Please don't double post, momo - but instead edit your previous post.

Joined: 12/29/2008

I think this thread has been asleep long enough for me to double post. This is something quite important if you hadn't noticed. And wiki, if something is wrong with me double posting a mod will tell me, thank you very much.

Check out my SoundCloud, MomoSoundWaves

Joined: 09/01/2009

Yes, wiki, you're not a mod, so please don't act like one. Wink 8 days is a reasonable timespan to wait before bumping a thread.

I don't think the MySQL problem has anything to do with the leaderboard issues, as the leaderboard parsing problem is because of XML errors, not SQL errors. I have seen davidc pushing changes to GooTool's svn recently, though, so he might possibly be working on the leaderboard problems as well. No guarantees.

Joined: 12/29/2008

That would be cool. Not that I have anything special to upload!

Check out my SoundCloud, MomoSoundWaves

Joined: 12/23/2010

MOM4Evr wrote:
8 days is a reasonable timespan to wait before bumping a thread.

Actually, I'm pretty sure editing a post bumps it too (on this forum). Although double-posting is still OK after such a long time.

Joined: 11/04/2008

I've been recoding the leaderboards in PHP today. It's mostly done now, just needs some anti-DoS protection, and generation of the main leaderboard images, so it'll be live 'soon'.

In related news, with these changes I just made the 500th commit to goofans' SVN repository! \o/

15:40 <@sargasso> [SVN goofans r489] by david: broaden compatibility of background linear-gradient
16:12 <@sargasso> [SVN goofans r490] by david: convert level data loading from python
16:20 <@sargasso> [SVN goofans r491] by david: cache level data in memcache
17:24 <@sargasso> [SVN goofans r492] by david: decode profiles using new php functions rather than external python script
17:57 <@sargasso> [SVN goofans r493] by david: fix ocd and lost function header
18:12 <@sargasso> [SVN goofans r494] by david: fix ocd achieement detection. fix x/y coordinates of balls. fix min/max dimensions.
18:12 <@sargasso> [r494] fix tower height scaled by 100.
18:12 <@sargasso> [r494] don't convert to xml or generate images on the initial upload.
18:13 <@sargasso> [SVN goofans r495] by david: move gooprofile_load_profile out of gooprofile.upload.inc as it will be used on-demand
19:02 <@sargasso> [SVN goofans r496] by david: generate the profile html on-the-fly from profile.dat
19:13 <@sargasso> [SVN goofans r497] by david: link to autogenerated tower images (not yet done)
20:41 <@sargasso> [SVN goofans r498] by david: tower drawing implemented in php and made on-demand
20:46 <@sargasso> [SVN goofans r499] by david: use a different temp dir for live and dev sites
20:50 <@sargasso> [SVN goofans r500] by david: don't regenerate the tower image if it already exists

-davidc

Joined: 02/20/2011

hey davidc, haven't seen you in a while!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
i am glad the leaderboards are almost up. It has been a long time. thanks for stoping by!

-_-

Joined: 07/08/2011

Haha! Sounds great! That was a big part of the site before.

Joined: 12/29/2008

That looks good!

Check out my SoundCloud, MomoSoundWaves

Joined: 04/17/2011

momo1526 wrote:
I think this thread has been asleep long enough for me to double post. This is something quite important if you hadn't noticed. And wiki, if something is wrong with me double posting a mod will tell me, thank you very much.

Like you dunno why I'm doing this... By the way better would be if you DIDN'T double post - it would make more sence and people would better understand you. You could have wrote like:

momo1526 wrote:
He told me that his MySQL was misbehaving...

So does all this have anything to do with the leaderboards being annoying?

But lets not discuss this... Either from now on I'm not double posting - no matter what reason (It's still the same - words Wink)

Joined: 07/05/2011

GREAT!!!

Joined: 12/29/2008

You used up more space by attempting to correct me.

Check out my SoundCloud, MomoSoundWaves

Joined: 09/01/2009

I just edited momo1526's post above (added a space at the end) to see if it would bump the topic. It didn't. Double-posting is the only way to do so. End of argument.

Joined: 12/23/2010

Well, maybe it doesn't bump the thread, but I'm almost positive that it adds the "1 new message" to the Tracker and forums. Which is kind of like bumping.
In any case, let's say that double-posting is fine for the purpose of thread bumping.

About the leaderboards news... AWESOME! Hope to see them back up soon!