import fetchimg
import apicache
import os.path
+import traceback
+import time
#conic is used for connection handling
import conic
"""
+ about_name = 'mEveMon'
+ about_text = ('Mobile character monitor for EVE Online')
+ about_authors = ['Ryan Campbell <campbellr@gmail.com>',
+ 'Danny Campbell <danny.campbell@gmail.com>']
+
+ about_website = 'http://mevemon.garage.maemo.org'
+ app_version = '0.4'
+
+
GCONF_DIR = "/apps/maemo/mevemon"
def __init__(self):
self.gconf = gnome.gconf.client_get_default()
#NOTE: remove this after a few releases
self.update_settings()
- self.connect()
+ self.connect_to_network()
self.cached_api = eveapi.EVEAPIConnection( cacheHandler = \
apicache.cache_handler(debug=False))
self.gui = gui.mEveMonUI(self)
try:
auth = self.cached_api.auth(userID=uid, apiKey=api_key)
- except:
+ except:
+ traceback.print_exc()
return None
return auth
sheet = self.get_auth(uid).character(char_id).CharacterSheet()
except:
# TODO: we should really have a logger that logs this error somewhere
+ traceback.print_exc()
return None
return sheet
chars = self.cached_api.eve.CharacterName(ids=char_id).characters
name = chars[0].characterName
except:
+ traceback.print_exc()
return None
return name
char_id = chars[0].characterID
char_name = chars[0].name
except:
+ traceback.print_exc()
return None
return char_id
api_char_list = auth.account.Characters()
char_list = [char.name for char in api_char_list.characters]
except:
+ traceback.print_exc()
return None
return char_list
try:
tree = self.cached_api.eve.SkillTree()
except:
+ traceback.print_exc()
return None
return tree
"""
Returns an object from eveapi containing information about the
current skill in training
-
"""
try:
skill = self.get_auth(uid).character(char_id).SkillInTraining()
except:
+ traceback.print_exc()
return None
return skill
def connection_cb(self, connection, event, mgc):
+ """
+ I'm not sure why we need this, but connection.connect() won't work
+ without it, even empty.
+ """
pass
- def connect(self):
+ def connect_to_network(self):
+ """
+ This will connect to the default network if avaliable, or pop up the
+ connection dialog to select a connection.
+ Running this when we start the program ensures we are connected to a
+ network.
+ """
connection = conic.Connection()
#why 0xAA55?
connection.connect("connection-event", self.connection_cb, 0xAA55)
assert(connection.request_connection(conic.CONNECT_FLAG_NONE))
+ def get_sp(self, uid, char_id):
+ """
+ Adds up the SP for all known skills, then calculates the SP gained
+ from an in-training skill.
+ """
+ actual_sp = 0
+
+ sheet = self.get_char_sheet(uid, char_id)
+ for skill in sheet.skills:
+ actual_sp += skill.skillpoints
+
+ live_sp = actual_sp + self.get_training_sp(uid, char_id)
+
+ return live_sp
+
+ def get_spps(self, uid, char_id):
+ """
+ Calculate and returns the skill points per hour for the given character.
+ """
+ skill = self.get_skill_in_training(uid, char_id)
+
+ if not skill.skillInTraining:
+ return (0, 0)
+
+ total_sp = skill.trainingDestinationSP - skill.trainingStartSP
+ total_time = skill.trainingEndTime - skill.trainingStartTime
+
+ spps = float(total_sp) / total_time
+
+ return (spps, skill.trainingStartTime)
+
+ def get_training_sp(self, uid, char_id):
+ """
+ returns the additional SP that the in-training skill has acquired
+ """
+ spps_tuple = self.get_spps(uid, char_id)
+
+ if not spps_tuple:
+ return 0
+ spps, start_time = spps_tuple
+ eve_time = time.time() #evetime is utc, right?
+ time_diff = eve_time - start_time
+
+ return (spps * time_diff)
+
+
if __name__ == "__main__":
app = mEveMon()
app.run()