Example #1
0
 def _try_login(self):
   try:
     self.session = actions.do_logins(self.settings)
     self.update_button['state'] = tk.NORMAL
   except:
     self.update_button['state'] = tk.DISABLED
     self.message.set("Error logging in. Double-check your config!")
def main():
    args = arg_parser.parse_args()

    if args.gui:
        root = tk.Tk()
        root.wm_title("Inara Updater")
        settings = utils.get_settings()
        app = gui.UpdateWindow(root, settings)
        root.minsize(250, 150)
        root.mainloop()

    else:
        settings = utils.get_settings()
        if settings is None:
            util.update_settings(_settings_prompt_cli, settings)
        inara_session = actions.do_logins(settings)
        actions.update_inara(inara_session)
        print("Inara updated!")
Example #3
0
  def _update_inara(self, second_try=False):
    self.message.set("Updating, please wait...")
    self.parent.update()
    try:
      data = actions.update_inara(self.session)
    except:
      if second_try:
        self.message.set("Error updating! Double-check your config,\nor try again later.")
        return
      else:
        # We don't use self._try_login() here because we don't want to disable the update button in this case.
        self.session = actions.do_logins(self.settings)
        self._update_inara(True)

    self.ship_id = data['ship_id']
    ship_name = 'Unknown'
    if self.settings.has_option('ships', str(self.ship_id)):
      ship_name = self.settings.get('ships', str(self.ship_id))
    self.info.update_info(data, ship_name)
    self.message.set("Update successful!\n(Last update: %s)" %
                     datetime.now().isoformat(' ')[:16])
    self.ship_button['state'] = tk.NORMAL # Once we have a current ship ID, we can use the ship button.