(self, event)
| 349 | return self.charChoice.GetClientData(selection) if selection not in (None, -1) else None |
| 350 | |
| 351 | def exportFitting(self, event): |
| 352 | sPort = Port.getInstance() |
| 353 | fitID = self.mainFrame.getActiveFit() |
| 354 | |
| 355 | self.statusbar.SetStatusText("", 0) |
| 356 | |
| 357 | if fitID is None: |
| 358 | self.statusbar.SetStatusText(_t("Please select an active fitting in the main window"), 1) |
| 359 | return |
| 360 | |
| 361 | self.statusbar.SetStatusText(_t("Sending request and awaiting response"), 1) |
| 362 | sEsi = Esi.getInstance() |
| 363 | |
| 364 | sFit = Fit.getInstance() |
| 365 | exportCharges = self.exportChargesCb.GetValue() |
| 366 | exportImplants = self.exportImplantsCb.GetValue() |
| 367 | exportBoosters = self.exportBoostersCb.GetValue() |
| 368 | try: |
| 369 | data = sPort.exportESI(sFit.getFit(fitID), exportCharges, exportImplants, exportBoosters) |
| 370 | except ESIExportException as e: |
| 371 | msg = str(e) |
| 372 | if not msg: |
| 373 | msg = _t("Failed to generate export data") |
| 374 | pyfalog.warning(msg) |
| 375 | self.statusbar.SetStatusText(msg, 1) |
| 376 | return |
| 377 | activeChar = self.getActiveCharacter() |
| 378 | if activeChar is None: |
| 379 | msg = _t("Need at least one ESI character to export") |
| 380 | pyfalog.warning(msg) |
| 381 | self.statusbar.SetStatusText(msg, 1) |
| 382 | return |
| 383 | |
| 384 | try: |
| 385 | res = sEsi.postFitting(activeChar, data) |
| 386 | res.raise_for_status() |
| 387 | self.statusbar.SetStatusText("", 0) |
| 388 | self.statusbar.SetStatusText(res.reason, 1) |
| 389 | except requests.exceptions.ConnectionError: |
| 390 | msg = _t("Connection error, please check your internet connection") |
| 391 | pyfalog.error(msg) |
| 392 | self.statusbar.SetStatusText(_t("ERROR"), 0) |
| 393 | self.statusbar.SetStatusText(msg, 1) |
| 394 | except APIException as ex: |
| 395 | pyfalog.error(ex) |
| 396 | self.statusbar.SetStatusText(_t("ERROR"), 0) |
| 397 | self.statusbar.SetStatusText("HTTP {} - {}".format(ex.status_code, ex.response["error"]), 1) |
| 398 | try: |
| 399 | ESIExceptionHandler(ex) |
| 400 | except: |
| 401 | # don't need to do anything - we should already get the error in ex.response |
| 402 | pass |
| 403 | except Exception as ex: |
| 404 | self.statusbar.SetStatusText(_t("ERROR"), 0) |
| 405 | self.statusbar.SetStatusText("Unknown error", 1) |
| 406 | pyfalog.error(ex) |
| 407 | |
| 408 |
nothing calls this directly
no test coverage detected