Commit Graph
34 Commits
Author SHA1 Message Date
David Sangrey e897e4b022 Fix Implementation of Journal Locking 2026-06-01 23:18:49 -04:00
David Sangrey 31a19360c4 Add Updated Journallock Tests 2026-06-01 19:52:14 -04:00
David Sangrey 450370f842 Hand off custom journal lock to filelock package 2026-06-01 19:27:51 -04:00
David Sangrey beb68efae8 [2568] Fix Ships JSON Typo 2025-12-25 01:36:24 -05:00
David Sangrey 2041b3d3d3 [Minor] Update Type Hints and Alias Usages 2025-12-01 22:04:28 -05:00
David Muckle 3fc8251fa4 Squashed commit of the following:
commit 39b0aec5f2
Merge: 9c600bf8 2f3f7262
Author: David Muckle <dvdmuckle@dvdmuckle.xyz>
Date:   Thu Feb 27 09:29:09 2025 -0500

    Merge branch 'main' into expanduser-journal-path

commit 9c600bf847
Author: David Muckle <dvdmuckle@dvdmuckle.xyz>
Date:   Thu Feb 27 09:24:04 2025 -0500

    Expanduser journal path
2025-02-27 11:50:56 -05:00
David Sangrey 080d9f98f2 [1812] Handover Translations 2024-04-22 17:33:28 -04:00
David Sangrey 57cd75e75e [2186] Additional Files 2024-03-27 19:39:51 -04:00
David Sangrey ebd1813612 [2051] Revert Breaking Change 2023-11-17 11:37:36 -05:00
David Sangrey b2d5e13465 [2051] Update Supporting Files
Not touching any of the big ones, but some clarification updates to many of the supporting files.
2023-11-17 11:33:26 -05:00
Athanasius 25dfb0588a tests/journal_lock: Minor typing fixes. 2022-12-23 14:47:14 +00:00
Athanasius 37ca1c3c19 journal_lock: Remove un-needed noqa 2022-12-03 11:32:02 +00:00
Athanasius baf62f03fd pytest/coverage: Resolve the "which way around to have pragmas" issue
1. You end up either inverting the sense of a `coverage_conditional_plugin`
  pragma's name (versus what it actually tests), *or* where you put it in
  the code.
2. As the pragmas are only defined in once, in one place, it's better to
  invert the sense there, rather than in *every single use case*.
Then technically any 'other' branch isn't guaranteed to
2022-10-02 12:11:16 +01:00
Athanasius 1b0bbb9a56 tests: Improved coverage reporting
* Always report on coverage, if no tests failed.
* Remove `.coveragerc`, in favour of `pyproject.toml`.
* Use `coverage-conditional-plugin`:
  - Two rules added, `sys-platform-win32` and `sys-platform-not-win32`.
  - Those rules used so non-win32 code run on win32 doesn't cause coverage
    to be reported as less than 100%.

There's the assumption that !win32 means Linux, probably.
2022-09-30 19:25:22 +01:00
Athanasius ddf6669f35 tests: journal_lock: fix test_obtain_lock_with_tmpdir_ro()
* Set `tmpdir` properly for this test.
* Do **NOT** unset `JournalLock.journal_dir_lockfile_name` on release, as
  this is needed to remove the file
* Ensure prior test(s) release their locks, *and* remove the file.
2022-09-05 12:39:03 +01:00
A_D bff6175ee7 Update to use sys.platform over platform 2022-01-26 18:51:49 +02:00
Athanasius bb1faa67d4 journal_lock: Convert to logger.trace_if(...) 2021-08-13 15:14:02 +01:00
Athanasius 4f1f07957c journal_lock: LANG comments 2021-06-13 13:02:13 +01:00
Athanasius f2fd16307c JournalLock: Cleanup pytest coverage
* Some `# pragma: no cover' added where it's more pain to get coverage
  than to put up with lack of testing.

  We are choosing to NOT test retry_lock() or the call to it from
  update_lock() as it's tkinter stuff.
* Check `self.journal_dir_lockfile` exists before trying to call
  .close() on it.
* Note where platform checks means only one if branch gets run, so of
  course coverage will complain about the other one.
* Add test_release_lock_lie_locked() to test when not locked, but
  pretend we were so release_lock() returns False.
* Add test_update_lock_same() to check if an attempt is made to 'update'
  to the same directory.
2021-04-01 14:45:52 +01:00
Athanasius cfdf9fbf20 Re-factor JournalLock.obtain_lock() for 'ALREADY_LOCKED' test.
This splits the code for opening the lockfile away from that for
actually obtaining the lock.  It enables a test for trying to lock again
with the same file handle.
2021-04-01 14:45:52 +01:00
Athanasius f53dcd92e5 Fix small typo in JournalLock.set_path_from_journaldir() docstring 2021-04-01 14:45:51 +01:00
Athanasius 732cfa1192 journal_lock: No need for exc_info=True on logger.exception() 2021-04-01 14:45:51 +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 74afcb085a 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-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 9a82874c7e journal_lock: Now fully type-hinted. 2021-04-01 14:45:49 +01:00
Athanasius 6be73dc50e journal_lock: Fix import order & add/expand docstrings 2021-04-01 14:45:49 +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 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 84590720ef journal_lock: Revert to deprecated config.get() method
Those changes are only in `develop` at this stage.
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