1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-16 09:10:35 +03:00

2488 Commits

Author SHA1 Message Date
Athanasius
f1c50faafa logger.exception() doesn't need exc_info 2021-03-15 15:58:18 +00:00
Athanasius
fa49159de5 JournalLock: Catch when journal_dir is None
* If it's None then set journal_dir_path to None as well.  Setting '' or
  nothing results in '.' (CWD), which could cause other issues.
* As we do this in three places, it's in a helper function.
* New JournalLockResult.JOURNALDIR_IS_NONE to signal this.
* Fix checking of return from obtain_lock() to specifically reference
  JournalLockResult.ALREADY_LOCKED.
2021-03-15 11:20:46 +00:00
Athanasius
1cd0392527 Record if JournalLock.obtain_lock() succeeded, use in release_lock()
In the scenario of the default Journals location not even existing the
user needs might update it to a network mount.  When they do so we
attempt, and fail, to unlock the old location, despite it not being
locked.

So now we have this boolean so we know if we should even attempt
unlocking.
2021-03-13 22:32:40 +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
e76e76bbe4 Add MacOS pyobjc to requirements.txt 2021-03-13 22:30:24 +00:00
Athanasius
84590720ef journal_lock: Revert to deprecated config.get() method
Those changes are only in `develop` at this stage.
Release/4.2.0
2021-03-12 12:52:15 +00:00
Athanasius
c565422b54 Actually add journal_lock.py into this branch
I'd `git show develop:journal_lock.py > journal_lock.py` a copy in
before, but forgot to commit it, and then removed it when checking out
another branch complained.  D'oh!
2021-03-12 12:49:17 +00:00
Athanasius
c14dc1fb1d 4.2.0: Additional changelog entry about "CAPI: No commander data returned" 2021-03-12 12:44:39 +00:00
Athanasius
5b1bd01c56 Release 4.2.0: appversion and changelog 2021-03-12 12:39:42 +00:00
Athanasius
773629afbe Pre-Release 4.2.0-beta3: version and changelog Release/4.2.0-beta3 2021-03-09 12:43:48 +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
038d16671c Correct URL format Release/4.2.0-beta2 2021-03-06 19:16:56 +00:00
Athanasius
875ccd08f5 Document that GitHub renders runas command correctly 2021-03-06 19:12:12 +00:00
Athanasius
9d816eaa79 un-double the blackslashes in changelog 2021-03-06 19:09:41 +00:00
Athanasius
c461f5d45b 4.2.0-beta2: changelog: Attempt to cite actually tested runas command 2021-03-06 19:07:04 +00:00
Athanasius
8052998658 Pre-Release 4.2.0-beta2: version and changelog 2021-03-06 18:55:35 +00:00
Athanasius
71858357eb CAPI: Log if no commander in profile() data 2021-03-06 18:54:24 +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
5f3bd9be71 Add Steam and EGS to Frontier Auth audiences. 2021-03-06 18:54:12 +00:00
Athanasius
79ad7a596a Pre-Release 4.2.0-beta1: version and changelog Release/4.2.0-beta1 2021-03-06 11:09:05 +00:00
Athanasius
87859720ac
Merge pull request #882 from EDCD/enhancement/859-journal-lock-on-change
Update Journal lock if user changes directory
2021-03-05 16:18:40 +00:00
Athanasius
8c2609858f L10n: Removed extraneous 'WIBBLE'. 2021-03-05 16:13:10 +00:00
Athanasius
696d55a165 L10n: Add missing " character 2021-03-05 16:09:30 +00:00
Athanasius
d8e9748c88 Small tweak to "couldn't lock" message 2021-03-05 16:02:36 +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
Athanasius
f3ef653a8d Change journal changed locking strings to translations. 2021-03-05 15:46:30 +00:00
Athanasius
09cc677a42 L10n: Add new strings for changed journal locking 2021-03-05 15:44:35 +00:00
Athanasius
1663238cd0 Tweak comment about 'not locked' meaning doing edmc:// checks 2021-03-05 15:25:01 +00:00
Athanasius
f449286983 Implement retry of locking when journal dir changed.
In case the user does have another EDMC instance running that they need
to kill first.
2021-03-05 15:08:13 +00:00
Athanasius
447cd2c2d7 Remove unused monitor.JournalLock.self.journal_dir_lock 2021-03-05 14:18:34 +00:00
Athanasius
4884f75419 Change self.journal_dir* vars when updating lock.
* Also, need to seek(0) before unlock to be operating on correct range
of bytes with msvcrt.locking().
2021-03-05 13:46:10 +00:00
Athanasius
e9c31c3293 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().
2021-03-05 12:45:22 +00:00
Athanasius
c0e7be98f8 Move journal locking code into new monitor.JournalLock class 2021-03-05 12:03:54 +00:00
Athanasius
872f380831 PLUGINS.md: Correct and expand on monitor.game_running() documentation 2021-02-18 09:29:52 +00:00
Athanasius
9b1b34f273
Merge pull request #857 from EDCD/enhancement/856-CL-arg-force-local-webserver
Add `--force-localserver-for-auth` CL arg to EDMarketConnector
2021-01-23 09:05:36 +00:00
Athanasius
b0f52b3d55 'import fcntl' failing means we need to lie about no other instances. 2021-01-22 14:15:32 +00:00
Athanasius
e1757a3a99 protocol: Don't use win32-specific edmc://auth if --force-localserver-for-auth
Tested with a build/install and run with:

	"c:\Program Files (x86)\EDMarketConnector\EDMarketConnector.exe" --force-localserver-for-auth --trace

2021-01-22 12:57:11.020 - TRACE - protocol.ProtocolHandler.__init__:222: Web ser
ver listening on http://localhost:53657/auth
2021-01-22 13:11:42 +00:00
Athanasius
3b2b658881 Add --force-localserver-for-auth CL arg to EDMarketConnector 2021-01-22 13:11:42 +00:00
Athanasius
11b1c436a7 seek(0) before sys.stdout.truncate()
Without this we only truncate to where the file was when we did the
stdout/err redirect.

What I observed was it truncated out the "journal locking" output, but
not anything from a prior run of the program.
2021-01-22 13:10:03 +00:00
Athanasius
831367c30b Need to flush the journal dir lock file contents after write. 2021-01-20 14:45:09 +00:00
Athanasius
8f94a259be
Merge pull request #852 from EDCD/enhancement/process-dupe-check-using-folder-lock
Switch to using a journals folder lockfile to enforce single process
2021-01-19 20:44:37 +00:00
Athanasius
b3e4eafb14 Properly document the l_param passed to enumwindowsproc() 2021-01-19 20:40:56 +00:00
Athanasius
479bfe58eb Log truncate outside the 'else' & misc logging cleanups and comments
* The "truncate the stdout redirect" code was erroneously inside the
  else of a try.
* Added some comments about exceptions found on Linux when unable to
  open the journals_dir lock file
* Changed 'assuming another process running' logging to not split lines.
* "Couldn't open <journal lock file>" isn't inside no_other_instances()
  so made the message more obvious.
2021-01-19 12:39:32 +00:00
Athanasius
45619622af Catch when we can't open the journal_dir lockfile 2021-01-19 12:27:55 +00:00
Athanasius
0530eecc52 Fully set up logging early, and use it in no_other_instance() checks 2021-01-19 12:21:07 +00:00
Athanasius
7ed90aee83 Comment EnumWindows()/enumwindowsproc() to document function. 2021-01-19 11:54:17 +00:00
Athanasius
f86f1ac188 imports tweaks to pass isort 2021-01-18 22:27:53 +00:00
Athanasius
d2490673f4 Add some noqa: C901 & remove old SIGTERM -> stack trace
* We're not going to refactor those 'complex' sections any time soon, so
  clean up flake8 output for now.
* No-one still uses "send SIGTERM to see a stack trace".
2021-01-18 22:25:11 +00:00
Athanasius
2be09a5db1 Add back the "restore/foreground the existing window" code 2021-01-18 22:20:01 +00:00
Athanasius
35a476f209 Comments added, some noqa and split a line 2021-01-18 22:18:54 +00:00