factorio-updater
factorio-updater copied to clipboard
Use tempfile.gettempdir() instead of /tmp for --output-path default.
As title. Maybe someone wants to console update their Factorio on a platform where /tmp
isn't available or something.
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.
Yeah, but it can be even easier: https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir