factorio-updater icon indicating copy to clipboard operation
factorio-updater copied to clipboard

Use tempfile.gettempdir() instead of /tmp for --output-path default.

Open narc0tiq opened this issue 7 years ago • 2 comments

As title. Maybe someone wants to console update their Factorio on a platform where /tmp isn't available or something.

narc0tiq avatar May 24 '17 07:05 narc0tiq

Running windows; sort-of related. I added a couple of lines since I don't have a /tmp folder in my drive root. First, when defining the default for -O: default=('/tmp' if os.name != 'nt' else './tmp')

((Side note; I'm also using Python 3...))

then I added if output_path=='./tmp' and not os.path.exists(output_path) and os.name=='nt': os.mkdir('./tmp') in the fetch_update() function, just before downloading. I also made a check to skip a file if it was already downloaded, but more properly should have just deleted the whole folder when I was finished. Also, there's lots of better ways to do this; just thought I would share.

CaptainDapper avatar Jan 18 '18 16:01 CaptainDapper

Yeah, but it can be even easier: https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir

narc0tiq avatar Jan 18 '18 17:01 narc0tiq