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

612 Commits

Author SHA1 Message Date
Athanasius
4be52fd259 Add comment about how/when system and station text is updated
It took me hours to track this down, due to the use of
parent.children(), so let's try to shorten that next time.
2021-04-12 08:30:51 +01:00
Athanasius
f45f817fa2 EDDB plugin now setting Station name correctly on_foot
* monitor.on_foot is now monitor.state['on_foot'] as plugins need to
  access it.
* EDDB:journal_entry() now stores that in this.on_foot to check later.
* this.on_foot checked in cmdr_data() to actually set station name from
  that data if needs be.  This avoids setting it to STATION_UNDOCKED if
  data['commander']['docked'] is False, when we're on_foot.
2021-04-12 08:30:51 +01:00
Athanasius
a09512f3b3 Mostly refactoring companion.ship_file_name() into util_ships.py
* Also prevent "You're not docked at a station!" for on_foot.
2021-04-12 08:30:51 +01:00
Athanasius
b3cef1e29b Server Lagging check now works again.
Well, it doesn't now raise ServerLagging for a last Journal with a
LoadGame on-foot and in-station.

It does then cause "You're not docked at a station!" to show up.
2021-04-12 08:30:51 +01:00
Athanasius
b44320f47c Split large 'Server Lagging' test into multiple
Also adjusts the 'docked and station name matches' check to account for
being on-foot.
2021-04-12 08:30:51 +01:00
Athanasius
71fb362c52 EDMarketConnector.py: Two missing type annotations
Surprisingly window_title has nice simple types.
2021-04-01 14:45:53 +01:00
Athanasius
2f9789afdd Update all code to use config.appversion() as a function
This *also* caught some instances where appversion_nobuild should
already have been used, so those were both changed and updated to a
function call.
2021-04-01 14:45:52 +01:00
Athanasius
8b3294ecdd typeshed now handles tk 'name' parameter 2021-04-01 14:45:52 +01:00
Athanasius
bc33bf1b19 Attempt to get develop back to code state before rebase on main. 2021-04-01 14:45:51 +01:00
Athanasius
bc7767c5ce Also wrap as dict(data) in dump_capi_data() 2021-04-01 14:45:51 +01:00
A_D
e475ad6659 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-04-01 14:45:51 +01:00
Athanasius
e777727658 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.

# Conflicts:
#	EDMarketConnector.py
2021-04-01 14:45:50 +01:00
Athanasius
ba91aa4733 Two final s/getint/get_int/g instances.
Tested with firing up under debugger, switching to transparent theme,
repeatedly mousing in and out, switching back to Dark theme.
2021-04-01 14:45:50 +01:00
Athanasius
d39c0521da Move JournalLock class into its own file
Closes #891

# Conflicts:
#	journal_lock.py
#	monitor.py
2021-04-01 14:45:49 +01:00
Athanasius
55ee4485d1 Implement retry of locking when journal dir changed.
In case the user does have another EDMC instance running that they need
to kill first.

# Conflicts:
#	monitor.py
2021-04-01 14:45:49 +01:00
Athanasius
0cb0701ca8 Implement releasing of monitor.JournalLock()
* Implement JournalLock.release_lock().
* Renamed other methods to remove journaldir_ prefix.
* Slightly tweak the code flow for obtaining the lock.
* Implement JournalLock.update_lock(), called from AppWindow.postprefs().

# Conflicts:
#	EDMarketConnector.py
2021-04-01 14:45:49 +01:00
Athanasius
b3959cb8d2 Move journal locking code into new monitor.JournalLock class 2021-04-01 14:45:49 +01:00
Athanasius
5093fb58ee Add --force-localserver-for-auth CL arg to EDMarketConnector 2021-04-01 14:45:49 +01:00
Athanasius
409e851840 Port in the journals_dir locking and other changes
* Use a lock file in the journals_dir location to prevent more than one
  instance running against the same journals.  We no longer check just
  for a Windows handle.  So this is more correct on win32 *and* is now a
  thing on all other platforms.
* Adds `--suppress-dupe-process-popup` CL arg to suppress "we're a
  dupe!" popup to aid those using batch files to launch EDMC alongside
  the game.
* Two minor fixups of typos in PLUGINS.md.
* Misc noqa comments and other flake8 fixups.  We're now only missing
  type annotations in EDMarketConnector.py.

# Conflicts:
#	EDMarketConnector.py
2021-04-01 14:45:49 +01:00
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