Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python script pulling data from XML file for Eve-Online data
#1
I'm in Ubuntu using Conky. I also play EVE-Online [and if you do, "No, I do not want to join your corp"]. I have this set of Python scripts that pull data from XML files that get my character status and other info. The problem is that the whole thing doesn't work; Nothing is outputted to my Conky. Seeing as I am unfamiliar with Python, I thought I'd ask you guys for some support.

I know that I'm getting the info OK because I can open the XML files and see perfectly clear that it contains a bunch of stuff about my character.

So let me just give you an example of what I'm dealing with; The following script gets my character name from the XML file:
Code:
#!/usr/bin/python
from xml.dom.minidom import parse
from xml import xpath
import os

doc = parse("/home/me/eve/character.xml")

print doc.getElementsByTagName("name")[0].childNodes[0].nodeValue,

And the following is a portion of the XML file:
Code:
<eveapi version="2">
  <currentTime>2009-11-10 00:53:09</currentTime>
  <result>
    <characterID>57371xxxx</characterID>
    <name>[My Name]</name>
    <race>Gallente</race>
    <bloodLine>Gallente</bloodLine>
    <gender>Male</gender>
. . . .etc, etc, etc. . . .

So the "print" command in that python script doesn't work; Why not?
Okay, further development: I tried running the Python script by itself in a terminal [works OK with my Gmail python script I use in Conky], but the following is the output:

Code:
xxx@xxx:~$ python /home/me/eve/eve-name.py
Traceback (most recent call last):
  File "/home/me/eve/eve-name.py", line 3, in <module>
    from xml import xpath
  File "/usr/lib/python2.6/dist-packages/_xmlplus/xpath/__init__.py", line 105, in <module>
    import Context
  File "/usr/lib/python2.6/dist-packages/_xmlplus/xpath/Context.py", line 15, in <module>
    import CoreFunctions
  File "/usr/lib/python2.6/dist-packages/_xmlplus/xpath/CoreFunctions.py", line 20, in <module>
    from xml.xpath import Util, Conversions
  File "/usr/lib/python2.6/dist-packages/_xmlplus/xpath/Conversions.py", line 22, in <module>
    from xml.utils import boolean
ImportError: cannot import name boolean

Can anybody interpret those compile errors? This is from running that script that I first posted above.
Reply
#2
Well, you guys were basically no help. Haha, no worries, though. I spent all night reading, plus trial-and-error [Note: I knew nothing about Python going into it], and eventually developed this little script:
Code:
#!/usr/bin/env python
import xml.etree.ElementTree as ET
tree = ET.parse("/home/me/eve/character.xml")

def traverse(node):
    for c in node.getchildren():
    if c.tag == "name": print c.text
        traverse(c)

root = tree.getroot()
traverse(root)

And modified the search tag for each script I was using.
So, another project down. Plus, check out my screenshot:
[Image: evescriptshot.jpg]

Sweet, right? Eh, probably not if you're not into Eve [most of you aren't]. And from here, there's actually a lot more I could do with it, such as listing my specific skills or skills I'm training on. I've discovered that XML is pretty freaking awesome!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Help Dεlluzion 3 1,749 09-30-2019, 12:59 AM
Last Post: samsmith001
  Fetch data from a web page hami1981 1 1,200 09-05-2014, 01:45 PM
Last Post: hami1981
  How to display variable serial data on Tkinter window. srinivas.rambha 0 933 06-17-2013, 05:54 AM
Last Post: srinivas.rambha
  Python to parse text file and get the count of items magicjack89 0 644 06-28-2012, 10:01 AM
Last Post: magicjack89
  How to Run a Python Script..? Need Help aloneak 4 1,532 05-03-2012, 06:55 AM
Last Post: Rhynorater

Forum Jump:


Users browsing this thread: 1 Guest(s)