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

693 Commits

Author SHA1 Message Date
A_D
051245cf90 Renamed various config values to be backwards compatible 2021-04-01 14:45:48 +01:00
Athanasius
f38b2aa95e Revert testing 'True or' on console redirect 2021-04-01 14:45:48 +01:00
Athanasius
2ec767405f Move the 'duplicate' constants into a new constants.py
1. So now they're only defined in one place.
2. config.py does an import of them, and `from config import ...` then
   chains through, so no need to update other users.
3. No need to ' # noqa E402' the killswitch/config imports now.
2021-04-01 14:45:48 +01:00
Athanasius
9fcaee9c88 "Is there already a process?" check now works
1. Moved the rest of the __main__ code so it's all in one block again.
2. Duplicate defined applongname, and protocolhandler.redirect as
   protocolhandler_redirect so that the process checking works.
2021-04-01 14:45:48 +01:00
Athanasius
ce45a4d405 Fix console redirect to work with config.py now using logging.
1. We were now importing from config before the console redirect code
   runs.
2. That means that config.py's `logger = logging.getLogger(appname)`
   caused the logger to be set up whilst stdout/err were still pointing
   at the console.
3. So the redirect then had no effect on logging output.

This commit moves the import from config (and also killswitch, because
it also imports logging) to after the *moved* console redirect code.

NB: This needs the "detected a process already running" instance
checking.

NB: There's still a `True or ` for testing purposes EDMarketConnector.py:25

# Conflicts:
#	EDMarketConnector.py
2021-04-01 14:45:48 +01:00
Athanasius
2459c40c48 EDMarketConnector: call config.set_shutdown() in AppWindow.onexit() 2021-04-01 14:45:48 +01:00
A_D
37a6b13d08 Updated wording for killswitch popup 2021-04-01 14:45:48 +01:00
A_D
81e2cd2f92 Added warning popup on start
Popup shows on start when there are killswitches that match the current
version.
2021-04-01 14:45:48 +01:00
A_D
c96e59f7b3 Added fetch killswitch task on start 2021-04-01 14:45:47 +01:00
A_D
2a9ac882cd Added reset UI flag
Resets the ui theme to default and the transparency to default
2021-04-01 14:45:47 +01:00
A_D
ed7d79c2f7 Added UI transparency option 2021-04-01 14:45:47 +01:00
A_D
54c8558d35 Added comment to EDMarketConnectory.py
Covers the locale magic in l10n.py
2021-04-01 14:45:47 +01:00
A_D
59c14e6046 Suppressed exceptions in EDMarketConnector.py 2021-04-01 14:45:46 +01:00
A_D
42a0c058ea Fixed bool usage 2021-04-01 14:45:46 +01:00
A_D
a1576e9979 Fixed missing default keyword arg 2021-04-01 14:45:46 +01:00
A_D
bfe114ba10 Removed extranious parens 2021-04-01 14:45:46 +01:00
A_D
278480b99f replaced ors with defaults in config usage 2021-04-01 14:45:46 +01:00
A_D
f76e5d331e Removed cast calls 2021-04-01 14:45:46 +01:00
Athanasius
fd51ee5d05 Updated EDMarketConnector.py to new config
# Conflicts:
#	EDMarketConnector.py
2021-04-01 14:45:46 +01:00
Athanasius
bc3269f2f8 EDMarketConnector: popup for "already running"
* This also refactors code around so that isort and flake8 are happy
  about the module level imports.
2021-04-01 14:45:44 +01:00
Athanasius
c6083a2643 EDMarketConnector: Minor comments changes
# Conflicts:
#	EDMarketConnector.py
2021-04-01 14:45:44 +01:00
Athanasius
248493c16a EDMarketConnector: Change 'no other .exe runnig?' checks
* This is now done even before the stdout/err redirect.
* The function is now called no_other_instance_running() to make the
  conditional use of it read more naturally.
* For now this *append* logs to the plain log file.  **BUT** any
  subsequent write by the already-running process will be over the top
  of this, so a future commit will use a popup instead.

# Conflicts:
#	EDMarketConnector.py
2021-04-01 14:45:44 +01:00
Athanasius
3a57128e28 EDMarketConnector: Care about "are we already running?" check
1) Don't log in this check, we're a different process.
2) But we've stomped the plain log file already!
3) Python 3.8.6 seems to not like sys.exit(0) from that ctypes code, so
 `return False` instead and check the return from EnumWindows().
2021-04-01 14:45:44 +01:00
Athanasius
d0ee0b1148 EDMarketConnector: Add detailed logging to shutdown sequence 2021-04-01 14:45:44 +01:00
Athanasius
45ab19b6b1 Log when we detect browser running us again to pass Auth response. 2021-04-01 14:45:44 +01:00
Athanasius
7efd1a5aaa EDMarketConnector: Log when we exit because 'already running' 2021-04-01 14:45:44 +01:00
A_D
fe26359170 passed only what was needed to StatsDialog
passing the entire AppWindow just made a mess of typing
2021-04-01 14:45:44 +01:00
Athanasius
6ae6efaee9 EDMarketConnector: Annotate save_raw() complexity noqa 2021-04-01 14:45:43 +01:00
Athanasius
4ac9e9010e EDMarketConnector: Two minor cleanups. journal_event & dashboard_event
* journal_event() annotate the noqa complexity comment.
* dashboard_event() convert to 'bail early' to save indentiation.
2021-04-01 14:45:43 +01:00
Athanasius
07c7639345 EDMarketConnector: Switch to Optional[int] rather than Union... 2021-04-01 14:45:43 +01:00
Athanasius
e5e0eb0373 EDMarketConnector: Revert to tearoff=tk.FALSE
And added `# type: ignore` comments.

This is a mess.  On the tkinter side it *is* an int, default 0.  But
enough python stuff has assumed it's a bool for typeshed to define that
tearoff should be.  It doesn't match, mypy complains.
2021-04-01 14:45:43 +01:00
Athanasius
c1fdd27020 EDMarketConnector: More typing, and removal of retry_for_shipyard()
* retry_for_shipyard() was only called by itself (for further retry),
  and tried to call self.eddn.export_shipyard() which doesn't even
  exist.
  I suspect this has been unused code since the EDDN code was extracted
  out into an internal plugin.
* self.drag_offset given proper typing.
* All functions have at least some typing now.  Left the 'event' Tk
  arguments bare as mypy seems to infer without complaint.
2021-04-01 14:45:43 +01:00
Athanasius
5d8e2a80af EDMarketConnector: noqa CCR001
Some of our code is just cognitively complex.
2021-04-01 14:45:43 +01:00
Athanasius
58787bc65e EDMarketConnector: Final type annotation fixups.
* Ignore Tkinter 'name' complaints.  I've opened
  <https://github.com/python/typeshed/issues/4658> to get this
  fixed in typeshed.
* If checking `import update` so it's available.
* Don't annotate journal_event 'event' arg, as it's passed through Tk
  events mechanism, so let mypy infer it.
2021-04-01 14:45:43 +01:00
Athanasius
aafc419124 EDMarketConnector: Initialise self.updater with type, but None value
This allows the type to be known, but leaves the proper setting of the
value until later (after UI creation).
2021-04-01 14:45:43 +01:00
Athanasius
a038b30855 EDMarketConnector: Remove call to deprecated config.getpassword() 2021-04-01 14:45:43 +01:00
Athanasius
55f1e11f0b EDMarketConnector: Correct __init__ master type & misc 2021-04-01 14:45:43 +01:00
Athanasius
97f3af2568 EDMarketConnector: Refactor of getandsend() and journal_event() 2021-04-01 14:45:43 +01:00
Athanasius
da9e406e81 EDMarketConnector: Convert debug data dump to f-string & misc
* docstring indent on Class A.
* Minor white space adjustments.
2021-04-01 14:45:43 +01:00
Athanasius
8a3fa50c97 EDMarketConnector: Pass on docstrings & Misc.
* Removed a couple of E501 ignores tagged as now un-necessary.
2021-04-01 14:45:43 +01:00
Athanasius
2ddea7d4f1 Log when we detect edmc:// arg and attempt ShellExecute()
This is the code path for when something ignores the ddeexec registry
key and instead invokes EDMarketConnector.exe with the edmc://...
argument directly.

Our response is to try ShellExecute() to invoke the DDE path instead.
If the DDE path isn't set up (registry key
`Computer\HKEY_CLASSES_ROOT\edmc\shell\open\ddeexec` not present and
correct), then this will cause a loop of repeatedly invoking
EDMarketConnector.exe.

That key is inserted by the installer.  The only reasons for it to not
be there would be something blocking the installer from creating it or
something removing it after install.
2021-03-18 10:13:15 +00:00
Athanasius
d6e7cbce16 Suppress already_running_popup() if we have args.edmc 2021-03-18 09:54:24 +00:00
Athanasius
d9734a759d Specify 'edmc' argument to argparse
Else it complains that the Frontier Auth callback argument is an error.
2021-03-18 09:39:53 +00:00
Athanasius
2da5e0a666
Merge pull request #915 from A-UNDERSCORE-D/fix/908/capidata-not-dict
Ensured that CAPIData objects are JSON Serialisable
2021-03-15 17:14:08 +00:00
A_D
fbe3e7a6e5
Ensured that CAPIData objects are JSON Serialisable
While it isnt directly an issue in main (right now), the fix applies
here forward, so we may as well do it here and not deal with a headache
later.
2021-03-15 18:53:20 +02:00
Athanasius
4f524a0a35 Add extra logging for Frontier Auth, especially via edmc:// 2021-03-15 12:07:39 +00:00
Athanasius
60c67723ca Change JournalLock.obtain_lock() return to an Enum.
This way we can tell the difference between:

1. This process obtained the lock.
2. Another process has the lock.
3. We couldn't get the lock due to not being able to open the lock file
   read-write.

Case 3 is currently also returned if the configured journal directory
doesn't exist.  This will be the case on any MacOS system that never had
the game running.  Likely given the OS hasn't been supported for the
game in years now.
2021-03-13 22:32:33 +00:00
Athanasius
a6939c77d9 Backport of fix/891/force-localserver-for-auth_fix-journallock-import
* Move JournalLock into its own file.
2021-03-09 12:37:59 +00:00
Athanasius
67a91cf7d1 CAPI: Handle when we get no 'commander' in returned data.
I was testing the new Steam or Epic CAPI auth.  My EGS account hasn't
yet been used, so has no commander attached.  EDMC thinks the auth has
succeeded in this case, but hitting 'Update' causes it to error because
the returned data is empty.

So, add some checks for lack of 'commander' key and a specific message
"CAPI: No commander data returned" for status line.

Without this there's a KeyError exception thrown, causing the status
line to just get 'commander' in it, which isn't helpful.
2021-03-06 18:54:18 +00:00
Athanasius
e430c3b350 Refactor old no_other_instance_running() into handle_edmc_callback_or_foregrounding()
The actual duplicate process checks *used* to be done in this function,
but no longer are.  Instead it's now specifically performing the "is
this an edmc:// auth callback?" check, including the foreground of the
extant process if needs be.
2021-03-05 15:57:53 +00:00