EDCD / EDMarketConnector

Downloads commodity market and other station data from the game Elite: Dangerous for use with all popular online and offline trading tools.
GNU General Public License v2.0
986 stars 156 forks source link

journal_lock.py needs to expanduser() to handle `~` #1494

Open Athanasius opened 2 years ago

Athanasius commented 2 years ago

We're not expanding ~ for the journal file locking. Pathlib, unfortunately, doesn't do this for you:

In [1]: import pathlib

In [2]: jd = '~/tmp'

In [3]: jdp = pathlib.Path(jd)

In [4]: jdp
Out[4]: PosixPath('~/tmp')

In [5]: jdln = jdp / 'test'

In [6]: jdln
Out[6]: PosixPath('~/tmp/decode-header.py')

In [7]: jdl = open(jdln, 'r')
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-7-d979539e9e63> in <module>
----> 1 jdl = open(jdln, 'r')

FileNotFoundError: [Errno 2] No such file or directory: '~/tmp/test'
Athanasius commented 2 years ago

Whilst we're at it, do a general pass on anything that could possibly be opening a file from a user-defined location.