def updateFactorio():
file_name = "/tmp/latestFactorio.tar.gz"
print("Downloading %s" % file_name)
r = requests.get(DOWNLOADURL, stream=True)
total_length = int(r.headers.get('content-length'))
if not os.path.isfile(file_name) or total_length != os.path.getsize(file_name):
with open(file_name, 'wb') as f:
for chunk in progress.bar(r.iter_content(chunk_size=1024), expected_size=(total_length/1024) + 1):
if chunk:
f.write(chunk)
f.flush()
#os.chmod(file_name, stat.S_IWUSR | stat.S_IRUSR)
else:
print("File already exists and file sizes match. Skipping download.")
if os.access(FACTORIOPATH, os.W_OK):
if os.path.isfile(file_name):
tar = tarfile.open(file_name, "r:gz")
tar.extractall(path="/tmp")
tar.close()
copytree("/tmp/factorio", FACTORIOPATH)
print("Success.")
else:
print("Help! Can't find %s, but I should have!" % (file_name))
sys.exit(1)
else:
print("Can't write to %s" % (FACTORIOPATH))
sys.exit(1)
评论列表
文章目录