1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

733 Commits

Author SHA1 Message Date
aussig
3e295db061 Typing of return values from killswitch.check_killswitch() 2022-12-22 17:39:20 +00:00
aussig
9e17c46b25 Implement suggestions from PR #1773. 2022-12-22 16:21:42 +00:00
aussig
cb2a6b6995 Merge branch 'develop' into feature/847/capi-fleetcarrier 2022-12-22 15:32:17 +00:00
Athanasius
292b449cf6
Fix up companion.Session.close() refactor
* When PyCharm made a mess I accidentally undid two renames in
  EDMarketConnector.py...
* ... but one of those actually *does* need to only close the session.  So
  made a new Session.close() that performs only the closing, with
  Session.reinit_session() now utilising that.
2022-12-22 09:15:16 +00:00
aussig
6ebdea1a6c Fleetcarrier CAPI now triggered by certain carrier journal events, and throttled on its own cooldown (15 mins) 2022-12-21 23:00:36 +00:00
aussig
8e5953408e Handling of /fleetcarrier CAPI endpoint and implementation of plugin callback function 2022-12-21 23:00:35 +00:00
aussig
eedf4febdf Initial implementation of CAPI /fleetcarrier endpoint 2022-12-21 23:00:35 +00:00
Athanasius
579c95024b
'develop only for devs': d'oh, re-allow Athan on Windows 2022-12-21 10:45:55 +00:00
Athanasius
8386487dc1
Tweak non-developer-running-develop check
This allows for someone running a custom branch, with working `git branch`,
even if it's an `-alpha0` version.
2022-12-20 17:58:38 +00:00
Athanasius
ba68397b3f
CAPI killswitches: endpoint killswitches & eddn export ones too
* Added `capi.request.<endpoint>` killswitches at appropriate call points.
* Added `eddn.capi_export.<type>` killswitches.  This allows for killing
  just the EDDN export of such CAPI-derived data, without stopping the actual
  queries, as other plugins/functionality might still have harmless use of
  the data.
* PLUGINS.md: Actually describe the contents of `data` passed to plugins, and
  point out it might not always contain market or shipyard data.  This is
  not only because of the new killswitches, but could already have happened
  if the station/port docked at didn't have the services.
* Some misc typing cleanups.
2022-12-16 15:06:01 +00:00
Athanasius
1cc4a9d0af
CAPI killswitches: 'capi.auth' now preventing all CAPI actions. 2022-12-16 14:17:00 +00:00
Athanasius
12ee3deb59
killswitches: Implement --killswitches-file CL arg
* New CL arge `--killswitches-file`.  This needs to reference a file either
  with an absolute path, or relative to the CWD of the process.
* Internally if the argument is provided it is prefixed with `"file:"` in
  order to actually be loaded.  This is because `requests` doesn't have an
  adapter for `file:` URLs.
* Also fixes a visual bug with reporting of active killswitches.  The entire
  SingleKill object was used instead of just its `reason` property.  mypy
  type checks caught this.
2022-12-16 14:02:59 +00:00
Athanasius
ccdc187efa
CAPI: Remove 'safeties' preventing Legacy CAPI queries 2022-12-08 11:58:34 +00:00
Athanasius
75ee57939a
EDMarketConnector: Force type of ship_state
It can be `tk.NORMAL` or `tk.DISABLED`.  Why `True` was ever used I don't
know, possibly relying on undefined behaviour.

However, those 'types' end up as `Literal['normal']` and `Literal['disabled']`
and the only way to declare a Union of those is to be explicit with the
actual strings.  tk.(NORMAL|DISABLED) are not a types.
2022-12-08 11:32:41 +00:00
Athanasius
b6fe115ea7
CAPI: Add support for plugin cmdr_data_legacy()
* Renames `plug.notify_newdata()` to the more precise `notify_capidata()`.
* If CAPI data was from SERVER_LEGACY, then use plugin `cmdr_data_legacy()`
  instead of `cmdr_data()`.
2022-12-08 11:17:52 +00:00
Athanasius
0523e2289a
EDMarketConnector: Improve 'develop only for devs' check
* Move it later, after CLI args processing.  This would allow for a magic
  'override' this, providing a key or similar.
* Correct text 'XAthan' to 'Athan' in 'win32' check.
* If `git_branch != 'develop'` check if `-alpha0` is in the app version.
  Such version strings are never in any pre-release or release.
2022-12-08 10:51:31 +00:00
Athanasius
0d65adb77e
EDMarketConnector: Tweak 'only developers in develop' message 2022-12-07 20:10:41 +00:00
Athanasius
a69b271928
EDMarketConnector: Only developers should be running develop 2022-12-07 19:45:55 +00:00
Athanasius
62e285b52e
themes: Use defined constants for which theme throughout
This has been relying on knowledge of the magic numbers for far too long.

As part of this, remove all the obfuscating "oh, default is 0, and we want
that or any other theme, so treat this like a boolean" nonsense.

Also, stop assuming that "> 1" is a synonym for "transparent theme".  Just
Do The Equality Check.
2022-12-05 15:57:15 +00:00
Athanasius
3358babe00
EDMarketConnector: Move tk 'status' Label to its own section 2022-12-04 14:55:22 +00:00
Athanasius
3cc9aed724
EDMarketConnector: Updated for update.py function renames 2022-12-04 14:35:49 +00:00
Athanasius
b40d3b889f
CAPI: Use CAPI-Live-<endpoint> game_version for market & shipyard 2022-12-01 16:42:05 +00:00
Athanasius
4b31b67042
CAPI: Only perform queries for Live galaxy.
* This is *temporary* pending properly implementing utilising the Legacy
  CAPI host.
* Check in the EDMarketConnector.EDApp.capi_request_data() function *and*
  also in some companion.session functions.  But not absolutely all possible
  entry points because we'll be undoing it when we implement Legacy support.

This *is* sufficient for the current core code entry points.  If any plugin
is invoking its own CAPI requests, well it shouldn't be.
2022-12-01 16:42:04 +00:00
Athanasius
0d35f8874a
config/EDDN: Rename OUT_MKT_EDDN to OUT_EDDN_SEND_STATION_DATA
This flag controls whether commodity, outfitting or shipyard schema messages
are sent.  Thus 'MKT' ('market') is misleading.  Rename it so the intent when
used is clear.
2022-11-22 14:02:15 +00:00
Athanasius
e38d5e1b46
CAPI: Check if lastStarport->id matches Journal MarketID
Ref: <https://github.com/EDCD/EDMarketConnector/issues/1572>
2022-06-04 16:57:18 +01:00
Athanasius
3a78daf66c
Use daemon flag for threads, not setDaemon() 2022-03-18 09:55:03 +00:00
A_D
bff6175ee7
Update to use sys.platform over platform 2022-01-26 18:51:49 +02:00
A_D
7bb060f32c
dont explode if a key doesnt exist when resetting 2022-01-20 16:02:23 +02:00
A_D
cd81f65ed7
Reset geometry and UI scale with --reset-ui 2022-01-20 15:59:51 +02:00
Athanasius
538c06e342
systray: Out of paranoia, only .withdraw() on win32
Just in case a user gets the bright idea to set the config option
manually....
2021-11-12 18:54:35 +00:00
Athanasius
29461dd6e3
systray: Now correctly minimising to systray if required 2021-11-12 14:23:18 +00:00
Athanasius
ac824ceb13
systray: Withdraw window when oniconify() called
NB: Currently this doesn't work for the Default theme as its 'iconify'
doesn't go through this function.
2021-11-12 13:37:45 +00:00
Athanasius
4d069cb406
Attempting to re-enable Windows "minimize to system tray" support
1. It's not actually hiding the task bar icon currently.
2. As this touched prefs.py I've done a flake8 and mypy cleanup pass
   too.  But some of that will want reviewing later as I noqa'd some
   things.
2021-11-12 13:17:27 +00:00
Athanasius
6bec46be4e
CAPI: Implement a one-shot override of the Access Token
This allows you to force use of an expired token so as to test the code
paths for that without waiting up to 4 hours for the current one to
expire.

NB: The Access Token is *only* stored in the headers of the `requests`
object.
2021-11-06 10:41:33 +00:00
Athanasius
919136874d
CAPI: Re-auth when Access Token expired: Need to .close() first
The old code did this, and without it we enter a loop of:

1. CAPI says unauthorized
2. We call login()
3. But companion.session.state == STATE_OK, so do nothing
4. Re-scheduled CAPI request goes back to 1.
2021-11-06 08:41:09 +00:00
Athanasius
7a52ddd278
CAPI: Add retry of request after refreshing Access Token 2021-11-05 17:57:35 +00:00
Athanasius
8e32ecd216
CAPI: Actually try to use Refresh Token if CAPI says unauthorized
The refactor for threaded CAPI worker has inadvertently caused us to
always try *full* re-auth when the CAPI signals the Access Token is
expired.
2021-11-05 17:52:50 +00:00
Athanasius
8d55e9f02c
Merge pull request #1316 from EDCD/fix/1018/update-and-docked-status
CAPI: Avoid '... EDO Settlement?' for 'Update' in space
2021-10-20 15:05:28 +01:00
Athanasius
3f0f1fe39f
CAPI: Avoid '... EDO Settlement?' for 'Update' in space
1. Logged out in space
2. Logged back in
3. Run EDMC
4. Hit Update button, get "Docked but unknown station: EDO Settlement?"

In investigating this I realised that the entire else needed to be "if
docked according to CAPI".

Then it became clear that there was a redundant conditional, as the
enclosing one is already testing:

`capi_response.capi_data['lastStarport']['name'] != monitor.station:`

Making the:

`if last_station != monitor.station`

conditional un-necessary.
2021-10-20 14:50:03 +01:00
Athanasius
531302b7da
Notify user when 'File' > 'Status' fails
Rather than a silent failure, set a status line message and also play
the 'bad' sound to draw their attention to it.
2021-10-20 14:32:04 +01:00
Athanasius
62b5e4e7eb
EDMarketConnector.py: Fix isort order complaint 2021-10-17 14:03:07 +01:00
Athanasius
60e0386b04
Merge pull request #1283 from A-UNDERSCORE-D/fix/force-localwebserver-does-nothing
Remove protocol.protocolhandler singleton auto-init
2021-10-17 14:00:17 +01:00
Athanasius
dd8ec061d3
EDDN: Dummy tracking UI to determine layout 2021-10-10 15:40:41 +01:00
Athanasius
72f584481a
EDDN: Add --eddn-tracking-ui CL arg
This will only work on startup for now, with it present/active the EDDN
plugin will add a UI frame to show what it's tracking.

Intended for developer use only.
2021-10-10 15:01:16 +01:00
A_D
f6e4bcfcba
importing things before you use them is helpful. 2021-09-24 17:13:00 +02:00
A_D
c0351fec9b
missed an import 2021-09-24 17:06:51 +02:00
A_D
30b2d481c4
hack to fix --force-localserver-auth 2021-09-24 17:01:57 +02:00
A_D
5b68aad184
Remove protocol.protocolhandler singleton auto-init
In general, doing things like this on import is bad, but this was
changed specifically to remove a bug that causes
--force-localserver-auth to do nothing.

That is caused because while we were careful not to import protocol
until after we were done doing arg things, we did not check to make sure
something else didn't. Companion imports protocol, which thus always
instantiates WindowsProtocolHandler before we can modify some config
state to indicate that we want LinuxProtocolHandler.
2021-09-24 16:39:30 +02:00
Athanasius
f9875b5b9a
EDDN: Make use of new CL arg to use custom upload URL
This also entailed slightly reworking the way the EDDN code uses this
URL.  It was very generalised, so as to allow for the debug "just send
and log locally" code, but as the only URL is the 'upload' one much of
that seemed un-necessary.

So that code has been simplified.
2021-09-24 10:59:15 +01:00
Athanasius
e6e1cbd221
CL args: Group them in-code 2021-09-24 10:34:42 +01:00