1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 01:22:19 +03:00

241 Commits

Author SHA1 Message Date
Athanasius
f80623e025
CAPI: Convert full Update flow to class passing
* Base the following on common EDMCCAPIReturn: EDMCFailedrequest,
  EDMCCAPIRequest, EDMCCAPIResponse.  This saves repeating a bunch of
  variable types and comments.
* Use the above throughout the 'Update' button flow.
* Still need to address 'Save Raw Data', i.e. AppWindow.save_raw().
2021-08-23 18:29:36 +01:00
Athanasius
c6f93bd3c6
companion: Update "close down" check for using EDMCAPIRequest 2021-08-23 18:29:36 +01:00
Athanasius
dc705b92e5
companion: Convert to EDMCCAPIRequest class, not bare tuple 2021-08-23 18:29:36 +01:00
Athanasius
92e3ce9f4b
CAPI: Notes/dummy classes for using them to encapsulate requests/responses 2021-08-23 18:29:35 +01:00
Athanasius
3f817c0fc0
companion: TODO: store /profile data for use elsewhere 2021-08-23 18:29:35 +01:00
Athanasius
e5d200311e
companion: mypy pass
* Still need to change stats.py to use a cached copy of CAPI data,
  rather than it querying that itself.  That means actually storing that
  cached copy whilst in the capi worker.
2021-08-23 18:29:35 +01:00
Athanasius
62b1f0dd0d
companion: flake8 pass 2021-08-23 18:29:35 +01:00
Athanasius
c1deb9113e
CAPI: 'station' query going via work queue
* Defined inner functions in the worker function to handle the actual
  queries.  This allows for *them* to simply return data or raise
  exceptions to be caught by the main worker function.  *IT* then
  handles returning any error appropriately via the queue to AppWindow.

* Due to the coupling between AppWindow and these queries there are
  several extra parameters passed into the queue worker and then back
  out.  This is largely due to having to split AppWindow.getandsend()
  into two functions: capi_request_data() and capi_handle_response().

  This might get changed to use a class to encapsulate those values,
  rather than the bare tuple currently being used.

* No full flake8 & mypy pass done yet.

* Some companion.py globals renamed so their use is more obvious.
2021-08-23 18:29:34 +01:00
Athanasius
3fe097a955
companion: Start moving CAPI 'station' query into thread worker 2021-08-23 18:29:34 +01:00
Athanasius
305ba157ec
companion: s/URL_SHIPYARD/Session.FRONTIER_CAPI_PATH_SHIPYARD/g 2021-08-23 18:29:34 +01:00
Athanasius
58ea0abd5e
companion: s/URL_MARKET/Session.FRONTIER_CAPI_PATH_MARKET/g 2021-08-23 18:29:34 +01:00
Athanasius
6f9f71d699
companion: s/FRONTIER_PATH/FRONTIER_AUTH_PATH/g
This is so as to keep Frontier *auth* separate from Frontier *CAPI*.
2021-08-23 18:29:34 +01:00
Athanasius
661ffb100b
companion: URL_DECODE -> Auth.FRONTIER_PATH_DECODE 2021-08-23 18:29:33 +01:00
Athanasius
52a6eeb82a
companion: URL_TOKEN -> Auth.FRONTIER_PATH_TOKEN
Also, rename FRONTIER_AUTH_PATH to FRONTIER_PATH_AUTH.
2021-08-23 18:29:33 +01:00
Athanasius
f5bde2dcc6
companion: Rename URL_AUTH to FRONTIER_AUTH_PATH, in class Auth 2021-08-23 18:29:33 +01:00
Athanasius
a823106556
companion: Rename SERVER_AUTH to FRONTIER_AUTH_SERVER
Also moves back to global scope, as it's used in both Auth and Session
classes.
2021-08-23 18:29:33 +01:00
Athanasius
692b014cda
companion: Correct import order of tkinter 2021-08-23 18:29:33 +01:00
Athanasius
23e67dab82
companion: Move global constants into appropriate classes 2021-08-23 18:29:32 +01:00
Athanasius
454c9f3d0c
CAPI: Continuing code moving/cleanup up/testing
1. Sending back a spurious CredentialsError() to check it's now handled,
   but other issues blocking the code from getting there currently.
2. Move the "Update suit data from CAPI" call into the AppWindow
   handler.
3. Move some more of the old query() exception handling into the worker.
4. session.query() no longer returns anything, and neither should
   anything that calls it (like session.station()).  This is going to
   take quite some unwinding and code moving.
2021-08-23 18:29:32 +01:00
Athanasius
018b4563b3
CAPI: return good data from worker & start handling reauth 2021-08-23 18:29:32 +01:00
Athanasius
ce02cfdf2d
CAPI: Remove "test failure propogration" forced error 2021-08-23 18:29:32 +01:00
Athanasius
655c7ea1ca
CAPI: Some progress in using a Queue to signal result/error
Due to main app being Tk we can't just use Python async functionality.

So instead we have a class to hold a message and optional exception.
And instance of that goes into a queue.
The reading of that in the main thread is triggered by sending a Tk
event.

Much more to come.
2021-08-23 18:29:31 +01:00
Athanasius
11916f1387
companion; Dummy CAPI worker enqueue to test code
This properly triggered the logging in the worker thread
2021-08-23 18:29:30 +01:00
Athanasius
9661d770cb
companion: Implement, and use, asking CAPI thread to close down 2021-08-23 18:29:30 +01:00
Athanasius
c5af0a3397
companion: Create CAPI worker thread on startup
Confirmed to also *not* block shutdown currently
2021-08-23 18:29:30 +01:00
Athanasius
d0e1391238
companion: More function reordering, and comment-marking of sections
The file has:

1a. class Session - Frontier Auth
1b. class Session - CAPI queries
1c. class Session - Utility functions (to do with CAPI query data, but
  not directly about *making* those queries.
2. Some non-class utility functions.
2021-08-23 18:29:30 +01:00
Athanasius
c01438f77e
companion: Move start_frontier_auth() above login()
The former will be used by the latter, so this makes more sense when
reading the code.

In general I'm going to ensure there are two sections to this Session
class:

1. Frontier Auth code.
2. CAPI query code.

Yes, ideally I'd split it into two classes.  But that kind of
refactoring isn't for *this* branch.  I just want things straight in my
head for the "make CAPI queries run in a thread" changes.
2021-08-23 18:29:29 +01:00
Athanasius
81b5d015fd
Frontier Auth: Rename start() method to something more obvious 2021-08-23 18:29:29 +01:00
Athanasius
7339cc59ed
companion: Fix class Session docstring
This is *not* only for the Frontier oAuth2 authn, it's also for the
actual CAPI queries.
2021-08-23 18:29:15 +01:00
e6c6f7f155
companion.py: Move check for CAPI pretend down 2021-08-16 15:30:14 +03:00
b30b25216b
companion.py: change raising exception when pretending CAPI down 2021-08-16 15:24:01 +03:00
2e90a1bbe9
Remove raise CAPI pretend down on auth requests, add endpoint for which CAPI pretend down raising 2021-08-16 14:40:46 +03:00
92b131f81a
companion.py: reorder conf_module import for isort 2021-08-13 23:07:18 +03:00
d068dc7620
Merge branch 'develop' into enhancement/1096/CAPI-pretend-down-CL-arg 2021-08-13 23:04:42 +03:00
01bd637730
Add CL arg --capi-pretend-down in order to pretend that CAPI is down 2021-08-13 21:47:47 +03:00
Athanasius
7149f7e792
companion: Change trace_if 'capi-query' to 'capi.query' 2021-08-13 15:20:42 +01:00
Athanasius
df84b8aa64
companion: Change logger.trace to logger.trace_if
This adds only 'capi-query' to --trace-on possibilities.
2021-08-13 15:14:01 +01:00
Athanasius
bb54bc25b4
companion: Clean up some flake8 and mypy gripes 2021-08-07 14:08:16 +01:00
inb
f1ef557dee re #1198 work around +size suffixes in CAPI responses
Co-authored-by: A_D <A-UNDERSCORE-D@users.noreply.github.com>
2021-08-06 20:59:04 +01:00
Athanasius
713b6b753d CAPI: Catch where we're CAPI-docked, but monitor.station is None
Docked at an EDO settlement means CAPI says we are, but we've forgotten
monitor.station because there's not enough Journal information and too
many corner cases to be *sure* of re-using old data.
2021-06-13 20:09:00 +01:00
Athanasius
88b56b6913 CAPI: Add logger.warning() for *why* we raise ServerLagging 2021-06-13 19:43:14 +01:00
Athanasius
83f3f09882 companion: Tweak LANG comment for 'CAPI disagreed with Journal game location'
'Journal location' is ambiguous, potentially referring to where on-disk
the files are.
2021-06-13 14:59:35 +01:00
Athanasius
e736f30358
Merge pull request #1158 from EDCD/enhancement/l10n-add-missing-LANG-comments
Add all missing LANG comments
2021-06-13 13:48:34 +01:00
Athanasius
b09a102d87 companion.py: Final LANG comments added. 2021-06-13 12:51:48 +01:00
Athanasius
f449e85c0b CAPI: 'SKUError' exception was never used - removed
Also LANG comments added.
2021-06-13 12:42:50 +01:00
Athanasius
8a756fee39
Merge pull request #1167 from A-UNDERSCORE-D/fix/890/forget-frontier-auth
Added CL arg to forget all frontier tokens
2021-06-13 12:04:32 +01:00
Athanasius
799b5b7666 CAPI: Change confusing post-login again log message 2021-06-12 19:24:26 +01:00
A_D
284064d6ed
Added CL arg to forget all frontier tokens
This is obviously quite annoying but should provide a magic fix to any
user with weird auth trouble (such as those seen by
EDCD/EDMarketConnector#1166 )

Closes EDCD/EDMarketConnector#890
2021-06-12 16:38:25 +02:00
A_D
09a0b70891
Switched logs to warning 2021-06-07 19:07:24 +02:00
A_D
a79cde641e
Removed unused import 2021-06-07 19:06:30 +02:00