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

177 Commits

Author SHA1 Message Date
A_D
ab58aa6355
autoformatted file 2020-07-27 15:15:52 +02:00
Athanasius
d7c2372417 Flake8 cleanup round #2 2020-07-27 10:14:16 +01:00
Athanasius
f9a23cc831 Clean up flake8 output for this branch 2020-07-27 09:37:10 +01:00
Athanasius
2e58d106bd logging.getLogger(appname) instead of import from EDMarketConnector
Using:

from EDMarketConnector import logger

causes issues if EDMarketConnector is already importing 'this' file.

So just get a logger using logger.getLogger(appname) instead.
`from config import appname` if needs be.
2020-07-27 06:57:52 +01:00
Athanasius
8e1f3b8a90 plugins/inara: Fix typo on except: 2020-07-27 06:57:52 +01:00
Athanasius
7d060aa325 plugins/inara: Convert to proper logging 2020-07-27 06:57:52 +01:00
Athanasius
7951463fba plugins/edsm: Converted to proper logging 2020-07-27 06:57:52 +01:00
Athanasius
6aa409388e plugins/eddn: Converted to proper logging 2020-07-27 06:57:52 +01:00
A_D
5aaf88b281 fix quoting style 2020-07-26 23:08:47 +01:00
A_D
87b7f639bb cleanup coriolis.py 2020-07-26 23:08:47 +01:00
Athanasius
b6f6365566 plugins/edsm: Fix missing line of code
Bad paste or something, who knows ?
2020-07-21 18:25:03 +01:00
Athanasius
29e3cba67e plugins/edsm: Align with code tested in inara plugin
* Use same state logic as Inara plugin now has.
* this.system_link for the Tk item, this.system is the system name.
* Ensure station text+link set on prefs change.
# Add a set of future TODO items.
2020-07-21 17:29:03 +01:00
Athanasius
99d1578780 plugins/eddb: Align with code tested in inara plugin
* Use same state logic as Inara plugin now has.
* this.system_link for the Tk item, this.system is the system name.
* List some tests to pass (and later to be implemented as unittests).
* Be paranoid about URIs, quote them.
* Ensure station text+link set on prefs change.
2020-07-21 17:29:03 +01:00
Athanasius
01d4c12027 plugins/inara: population recording fix, and misc cleanups 2020-07-21 17:29:03 +01:00
Athanasius
4c4511a66d plugins/eddb: Remove misleading comments about 'Only use CAPI...'
This is needed for "not even running the game" CAPI update to be useful.
2020-07-21 17:29:03 +01:00
Athanasius
e2c74ed11d plugins/inara: Removed commented out inara_notify_location() code 2020-07-21 17:29:03 +01:00
Athanasius
f7896f3b6a plugins/inara: Track more system/station info, fix URLs
* Track all of: this.system_address, this.system_population,
 this.system_marketid
* Use this.system_address if set (only from journal) for no-dupes Inara
 system URL.
* Added the "'x' if undocked and show system info" functionality from
  EDDB plugin.
* This version will set target station name/link if you request docking
 with it, whether that succeeds or not.  Cleared not only on Undock, but
 also FSDJump and SupercruiseEntry (in case you never actually docked).
* No longer bothering setting system and station URLs from Inara API
 response as we have working ones anyway.  So even those without Inara
 API Key set get the functionality now.
2020-07-21 17:29:03 +01:00
Athanasius
bb28a4fa2f plugins/inara.py: Add two TODOs
* Artie added a 'by-systemaddress' system lookup, use it.
* This means we probably no longer need to update URLs in the
 inara_notify_location() function.
2020-07-21 17:29:03 +01:00
Athanasius
4da1ae331d plugins/inara.py: Track system and station in cmdr_data, and update links
NB: Still need to ensure journal_entry() updates them and links
properly.
2020-07-21 17:29:03 +01:00
Athanasius
ec32849a17 plugins/eddb: Fallback to system_name if no system_address
* Cleans up imports.
* Fixes some '<tab># ...' to use 2 spaces.
* Add type hints to system_url().
* Always store, even if not current provider: this.{system_address,
  station_marketid,system_population}
2020-07-13 22:12:29 +01:00
Athanasius
f3e25f0340 EDDB system URL: Don't pick up system_address from CAPI at all 2020-07-13 21:03:57 +01:00
Athanasius
63f5db3785 plugins/inara.py makes no use of import companion
So remove it.
2020-07-12 19:24:16 +01:00
Athanasius
c25120e0aa plugins/edsm.py makes no use of import companion
So remove it.
2020-07-12 19:10:57 +01:00
A_D
f43141202b
Removed debug print 2020-07-11 20:55:18 +02:00
A_D
061fbddb2d
Fixed wording of comment on last_update_time 2020-07-11 20:53:48 +02:00
A_D
9b82464f88
Fixed updating inara cargo only on major events
This works by checking on _any_ event the status of the cargo vs the
current stored version. If the live cargo differs from the updated
cargo, _and_ we have not sent any update in the past 45 seconds (as this
would have contained the cargo anyway), we queue an actual send to the
API.

This unfortunately isn't checked only when docked, but on the plus side
miners will be happy to have their cargo updated relatively often.

Fixes #477. Possibly not quite what they wanted, but its about as close
as this will get
2020-07-11 20:53:47 +02:00
Athanasius
317a0f6b63 EDDB is default station provider, do station_marketid as needed
We need a better way to do provider defaults.  Heck, settings defaults period.
Let's assume we'll put in place a "standard" config file once we move to one.
2020-07-11 19:47:30 +01:00
Athanasius
6932fdc883 EDDB: Use CAPI for system_address/station_marketid only if not already set
See issue #586 - a user had incorrect system_address set, but only sometimes.

This could possibly be due to CAPI errors/lag, so only use it as the source
when the values aren't yet set.  Otherwise Journal should always have provided
the correct value in a timely manner.
2020-07-11 18:57:04 +01:00
Athanasius
ef3306e3f5 Remove all use of defunct 'anonymous' option
The UI for setting the 'anonymous' option was removed in
f17f5d3f257e2359d4728ce8c296d70dc5e7609f ("PKCE OAuth2 access to cAPI").
Since then there's been no way for a user to set, or unset, this option
(and the associated custom uploaderID).  However anyone with the registry keys
still set would have had them take effect.

This commit removes the last bits of code that were making use of it.

Note that the EDDN Relay anonymises all uploaderID values, so no listener
has been seeing the 'raw' values for a long time now.

close #575
2020-07-10 08:36:13 +01:00
Athanasius
cd02d1664a Change EDDB system_url to use SystemAddress
* This means storing this.system_address from both cmdr_data and journal_entry.  NB: If the current value in the event or data is 'None' it will retain the previous value.  Without this Journal entries without SystemAddress erase the stored value.
 * The station_url() fallback to system_url() similarly uses this.system_address in the call.

Addresses #512
2020-07-01 15:51:14 +01:00
Athanasius
f6b3109a09 Remove the last of the {stations,systems}.p code from EDDB plugin
There is one tiny regression for a very, very corner case.

  In 3.46 if you use EDDB as the 'Station' provider and:

	1. Dock at Station A, in System X
	2. Jump out to System Y, which is also populated
	3. Exit out of the game
	4. (Re-)Start EDMC
	5. Hit 'Update' to manually trigger CAPI data retrieval

you will see a "×" character as the Station Name, and can click on it to
take you to the EDDB *System* page.  It is only there because of EDMC
using systems.p to check if System Y is populated.

  With this version in that circumstance there's no way to know that
System Y is populated, so the code assumes not and doesn't show the
"×", and thus there's nothing to click to go to the EDDB *System* page
for System Y.

  But so long as the user is actually running the game and EDMC together
then populated status is detected from Journal events and the "×" will
be there whenever you're undocked but in a populated system.
  Caveat: We know Frontier have allowed some systems that are
technically populated, but show a Population of zero.  This code assumes
that means they're *not* populated.
2020-07-01 15:51:14 +01:00
Athanasius
0541e404ec Track system population in monitor, and use in eddb
EDDB station link now triggers off this.system_population, which is
received via monitor passing 'Population' through in Startup, Location,
FSDJump and CarrierJump events.

  One fewer use cases for systems.p (populated status in this case).
2020-07-01 15:51:14 +01:00
Athanasius
ad81339495 Check eddb.system_name is set before attempting to quote it
urllib.parse.quote does *not* like being passed None.
2020-07-01 15:51:14 +01:00
Athanasius
6ed7590ba9 Update eddb.station_marketid from CarrierJump as well
This shouldn't actually be necessary, the marketid shouln't change
because of a jump, and would have been picked up from the other events
anyway, but it should do no harm to set it again from this.
2020-07-01 15:51:14 +01:00
Athanasius
2df8610e42 eddb: Ensure system_name is quoted for URL 2020-07-01 15:51:14 +01:00
Athanasius
1a11202aea Implement tracking station MarketID, and use in eddb plugin
* Adds monitor.station_marketid, tracked at the same points as
   monitor.station (name).
 * Changes EDDB plugin to also track its own this.station_marketid so
   that it can be used in /market-id/ EDDB URL.
   This removes a use case for stations.p file.
2020-07-01 15:51:14 +01:00
Athanasius
553c7980c1 Change EDDB system_url() to using by-name URL
This removes a use case for systems.p file
2020-07-01 15:51:14 +01:00
Athanasius
89f113e190 Use Preferences Save Serial Number instead of flag
* new class `PrefsVersion` in prefs.py.  A singleton `prefsSaved` (note
   case) is created.
 * When new preferences are added and require defaults on first run the
   code should use:

     `if prefsVersion.shouldSetDefaults(<prior release version>, [<optional old test>]):`

   to check if defaults should be set in preferences.  So if prior release
   was '3.4.6.0' and you've added a new preference with defaults you should
   call this with '3.4.6.0' as the first argument.
   The <optional old test> is really only for historical purposes, as a
   fallback in case no 'PrefsVersion' has yet been set in the user's
   Registry/settings file.
 * Any code that adds such a new preference **MUST** make changes to the
   `versions` dictionary in the PrefsVersion class.
     1. Add the predicted next version to the dictionary, with number one
        higher than 'current'
     2. Set 'current' equal to that new value.
   Obviously if other post-last-release code has already done this then you
   don't need to.

   Failure to update the versions dictionary in this manner will lead to an
   Exception being raised, and the code the preferences are for failing
   (i.e. EDDN means no EDDN tab on Settings).

Closes #407
2020-07-01 15:33:42 +01:00
Athanasius
63c2ff52e9 Fix an Output/EDDN option combination causing defaults to get re-set
Change Output and EDDN options to only get set to defaults if key 'PrefsDidSave' is not present and true.  This gets a value of 0x1 saved any time preferences are applied.

The issue was that if you had sufficient options set such that the saved 'output' value was 0x0 then that would evaluate to false and cause the defaults to get set.

Fixes #407
2020-06-29 14:32:25 +01:00
Athanasius
259bb3bbd6 Merge branch 'release-final-python27' into python3 2020-06-21 16:43:02 +01:00
Jonathan Harris
c62d110448 Plugin migration 2020-06-21 16:33:13 +01:00
Athanasius
6ff9dbc3bf plugins/edsy.py: De-future 2020-06-21 16:23:01 +01:00
Athanasius
02bcbf2685 plugins/eddb.py: De-future 2020-06-21 16:23:01 +01:00
Athanasius
4a7f4cd450 plugins/inara.py: De-future 2020-06-21 16:23:01 +01:00
Athanasius
35867cd3f9 plugins/edsm.py: De-future 2020-06-21 16:23:01 +01:00
Athanasius
93a65b02f5 plugins/eddn.py: De-future 2020-06-21 16:23:01 +01:00
Athanasius
143d6e717a plugins/eddn.py: De-future 2020-06-21 16:23:01 +01:00
Athanasius
faf5bee834 Fixes plugins/eddn massaging of economies and prohibited data 2020-06-21 16:23:00 +01:00
Athanasius
753fdedbdf Fixes plugins/coriolis.py to appear in settings, and confirms click-through works
*) Code and imports brought in line with edsy plugin
  *) 'Coriolis' now appears in Settings > Configuration > Shipyard
    dropdown
  *) Confirmed that with this active a valid build opens on coriolis.io
2020-06-21 16:23:00 +01:00
Athanasius
0d893c1c56 Gets plugins/edsy.py working. The usual string vs. bytes shenanigans. 2020-06-21 16:23:00 +01:00