def set_auth(self):
+ """
+ set self.auth to None if there was a problem. somehow later on we'll
+ have to pass the error to the UI, but for now I just want the program
+ to not be broken. --danny
+ """
uid = self.get_uid()
api_key = self.get_api_key()
self.cached_api = eveapi.EVEAPIConnection( cacheHandler = \
apicache.cache_handler( debug = False ) )
-
try:
self.auth = self.cached_api.auth( userID = uid, apiKey = api_key )
except eveapi.Error, e:
- # if we can't, return the error message/pic --danny
- return None
- except Exception, e:
- # unknown exception, dunno if this needs to be here if I just
- # ignore it... probably a bad idea, but it was in the
- # apitest.py example... --danny
+ # we need to deal with this, so raise --danny
raise
+ except ValueError, e:
+ self.auth = None
+ #raise
def get_auth(self):
return self.auth
def get_char_sheet(self, charID):
+ if not self.auth: return None
try:
sheet = self.auth.character(charID).CharacterSheet()
except eveapi.Error, e:
return char_id
def get_account_balance(self, charID):
+ if not self.auth: return None
try:
wallet = self.auth.char.AccountBalance(CharacterID=charID)
isk = wallet.accounts[0].balance # do we always want the first one??
return isk
- # really quick hack to get character list. doesn't handle errors well, and
- # if it can't get the gconf settings it just returns the placeholders, when
- # in reality it should tell the UI or something. basically half finished,
- # just uploading to show ry... FIXME --danny
def get_characters( self ):
+ """
+ returns a list containing a single character with an error message for a
+ name, if there's a problem. FIXME --danny
+ """
ui_char_list = []
- # error message --danny
placeholder_chars = [("Please check your API settings.", "imgs/error.jpg")]
-
+ if not self.auth: return placeholder_chars
try:
api_char_list = self.auth.account.Characters()
- # append each char we get to the list we'll return to the UI --danny
+ # append each char we get to the list we'll return to the
+ # UI --danny
for character in api_char_list.characters:
- ui_char_list.append( ( character.name,
- fetchimg.portrait_filename( character.characterID, 64 ) ) )
- # if not entered into gconf, error message --danny
+ ui_char_list.append( ( character.name, fetchimg.portrait_filename( character.characterID, 64 ) ) )
except eveapi.Error, e:
- return placeholder_chars
+ # again, we need to handle this... --danny
+ raise
return ui_char_list
gtk.set_application_name("mEveMon")
- # create the main window, changing from StackableWindow() --danny
+ # create the main window
win = hildon.Window()
win.connect("destroy", self.controller.quit)
# Create menu
menu = self.create_menu(win)
- # Attach menu to the window, changed from set_app_menu() --danny
+ # Attach menu to the window
win.set_menu(menu)
# will probably need to refer to http://maemo.org/community/maemo-developers/gtktreeview_issue/ for sample code again when we make these clickable --danny
def create_char_model(self):
lstore = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING)
-
#get icon and name and put in a liststore
-
self.fill_char_model(lstore)
-
return lstore
def fill_char_model(self, lstore):
uidLabel.set_justify(gtk.JUSTIFY_LEFT)
vbox.add(uidLabel)
- # had to remove placeholder stuff --danny
uidEntry = gtk.Entry()
uidEntry.set_text(self.controller.get_uid())
uidEntry.set_property('is_focus', False)
apiLabel.set_justify(gtk.JUSTIFY_LEFT)
vbox.add(apiLabel)
- # had to remove placeholder stuff --danny
apiEntry = gtk.Entry()
apiEntry.set_text(self.controller.get_api_key())
apiEntry.set_property('is_focus', False)
self.update_model(self.char_model)
def create_menu(self, window):
-
- # changed from hildon.AppMenu --danny
menu = gtk.Menu()
-
for command in self.menu_items:
- # Create menu entries, changed from hildon.GtkButton() --danny
button = gtk.MenuItem( command )
-
if command == "About":
button.connect("activate", self.about_clicked)
elif command == "Settings":
button.connect("activate", self.refresh_clicked, window)
else:
assert False, command
-
# Add entry to the view menu
menu.append(button)
-
menu.show_all()
-
return menu
if __name__ == "__main__":