Balloon Collaboration
September 21, 2019, 01:47:13 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: DaddyB, Larry and Dan are your administrators...Private message for any problems or issues with the Forum//barntekadmin
 
   Home   Help Search gallery Calendar Login Register  
Pages: [1]
  Print  
Author Topic: XML on Python  (Read 3084 times)
Larry
Administrator
Hero Member
*****
Posts: 1167



View Profile
« on: December 31, 2012, 04:40:14 PM »

Ok, Danny got me interested in programming XML on the python.  I have done a couple of tests and here are the results.  Danny and I play this stupid game called Eve Online and they have "API Functions" that will let you look at information about your character via xml files.  These are the files I am playing with.  I created a key that will only allow access to my account status for the purposes of this code.

EveAPI2.py


If you download this file, it will come down as a .txt...  Just rename it from a .txt to a .py

In order to run this, I had to install the urllib2 and the lxml libraries:
  sudo apt-get install python-urllib2
  sudo apt-get install python-lxml
Once these installed, I was able to start programming with them.

This is a fairly simple sample.  I may try getting fancier and try to get deeper into it.  I know this doesn't seem to have any benifit to out balloon project, yet, but maybe something will come of it in the future.  If nothing else, it is giving me keyboard time with python...
« Last Edit: January 01, 2013, 06:35:32 PM by Larry » Logged
Dan
Administrator
Full Member
*****
Posts: 175



View Profile
« Reply #1 on: January 01, 2013, 05:54:42 PM »

Just a suggestion, for the purposes of this bulletin board, when you post a new test (or otherwise) Python script, give it a .py.txt extension...that way it will be easily downloadable and you can just delete the .txt to make it executable...


Done... and done.  Thanks for the tip. LB
« Last Edit: January 01, 2013, 10:07:06 PM by Larry » Logged
Larry
Administrator
Hero Member
*****
Posts: 1167



View Profile
« Reply #2 on: January 01, 2013, 05:55:06 PM »

Ok, this is the code I am working on now.  It calls up the Characters API and prints a list of all your characters associated with the given key.  It then gives you the oportunity to select which charecter you wish to view.  Once selected, it re-reads the file to get the info for that character.  I know this is a clumsy way to code this, but, for now, I am not sure how to assign the info to an array so I don't have to reread it.  When I tried the I wanted to do it, it said that function would do it.  

I still have an idea how I maight do it, but I am getting burned out right now.  One other thing I need to look into is how to setup labels I can jump to with a Goto statement or the like..

EveAPI2_1.py
« Last Edit: January 01, 2013, 06:48:44 PM by Larry » Logged
Larry
Administrator
Hero Member
*****
Posts: 1167



View Profile
« Reply #3 on: January 01, 2013, 10:02:23 PM »

HeHeHe  I figured out part of my delima...  Here is the latest code.  It loads the Cahacter API info, then presents you with the characters to choose from, then loads up the Accout Status page and generats a report from it and presents it to you.  This is the same thing the last one did, only I am calling the page once and using Lists to store the info for later recall.

EveAPI2_2.py
Logged
Larry
Administrator
Hero Member
*****
Posts: 1167



View Profile
« Reply #4 on: January 01, 2013, 10:49:07 PM »

ok, one last update...  Turns out that Python does not support Labels or Goto statements, so you have to plan your program flow around that.  Sounds like we will probably have to create a lot of funtions, and then have a central loop or something that calls them. 

With this in mind, I created a function to collect the Character info.  I tried doing the same thing for the account Status, but had some issues, so I gave up for now.  I will get back to it soon.

I also added a line at the end of the program that causes it to wait until you hit enter before closing the program.  When running in Windows, the window closes before you can read anything and needed a way to stay open until you were ready.

Also, Windows uses a different command to clear the screen than Linux does, so I added code to detect which OS is running, then select the appropriate command. 

I am trying to keep good comments in the code.  Not only so you can follow it, but so I can too when I come back to it later.


EveAPI2_3.py
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!