eyeonus / Trade-Dangerous

Mozilla Public License 2.0
98 stars 31 forks source link

edmc_batch plugin does not ensure target folder exists before trying to open temp file #78

Closed AGSPhoenix closed 3 years ago

AGSPhoenix commented 3 years ago
C:\Users\Phoenix\Documents\cmder\tradedangerous
(venv) λ trade import -P edmc_batch -O files="C:\Users\Phoenix\Documents\test.prices"
Traceback (most recent call last):
  File "c:\users\phoenix\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\phoenix\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Phoenix\Documents\cmder\tradedangerous\venv\Scripts\trade.exe\__main__.py", line 7, in <module>
  File "c:\users\phoenix\documents\cmder\tradedangerous\venv\lib\site-packages\tradedangerous\trade.py", line 43, in main
    cli.main(sys.argv)
  File "c:\users\phoenix\documents\cmder\tradedangerous\venv\lib\site-packages\tradedangerous\cli.py", line 70, in main
    trade(argv)
  File "c:\users\phoenix\documents\cmder\tradedangerous\venv\lib\site-packages\tradedangerous\cli.py", line 125, in trade
    results = cmdenv.run(tdb)
  File "c:\users\phoenix\documents\cmder\tradedangerous\venv\lib\site-packages\tradedangerous\commands\commandenv.py", line 82, in run
    return self._cmd.run(results, self, tdb)
  File "c:\users\phoenix\documents\cmder\tradedangerous\venv\lib\site-packages\tradedangerous\commands\import_cmd.py", line 126, in run
    if not plugin.run():
  File "c:\users\phoenix\documents\cmder\tradedangerous\venv\lib\site-packages\tradedangerous\plugins\edmc_batch_plug.py", line 132, in run
    self.set_environment(self.sanitize_files(file_list))
  File "c:\users\phoenix\documents\cmder\tradedangerous\venv\lib\site-packages\tradedangerous\plugins\edmc_batch_plug.py", line 84, in set_environment
    temp_file = open(self.TEMP_FILE_PATH, "w")
FileNotFoundError: [Errno 2] No such file or directory: 'tmp/batch_prices.prices'

C:\Users\Phoenix\Documents\cmder\tradedangerous
(venv) λ where trade
C:\Users\Phoenix\Documents\cmder\tradedangerous\venv\Scripts\trade.exe

There is no tmp folder there, and looking at a Process Monitor capture, TD never tries to create it.

Direct link to troublesome line: https://github.com/eyeonus/Trade-Dangerous/blob/106bd7465f1e2d3a2d431cc7986ac37ac84b0360/tradedangerous/plugins/edmc_batch_plug.py#L84

eyeonus commented 3 years ago

Try it now. Well, not NOW now. Once pip gets the update and you've installed it "now".

eyeonus commented 3 years ago

Alright, it only took 5 hours of fixing Travis, but Pypi finally has a new version, so you can update now.

AGSPhoenix commented 3 years ago

A bugfix almost fast enough for a "30 minutes or it's free" joke, followed by 5 hours of wrangling your CI pipeline to actually deploy it. Ahh, software dev. Never change.

Thanks for the fix!