Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adjust for installations where venv was not configured. - Change update strategy to ensure update goes through on all platforms after compilation. - Make sure that paths work on both Windows & Linux. - Adjust update strategy to make it work on both Windows & Linux.
- Loading branch information
1 parent
9c6fee0
commit 9c5dd03
Showing
4 changed files
with
177 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,34 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import tempfile | ||
import os | ||
import requests | ||
import py7zr | ||
import time | ||
from pathlib import Path | ||
|
||
if len(sys.argv) != 3: | ||
sys.exit(3) | ||
import py7zr | ||
|
||
|
||
def main(): | ||
if len(sys.argv) != 3: | ||
sys.exit(3) | ||
|
||
tempPath = Path(sys.argv[1]) | ||
softwarePath = Path(sys.argv[2]) | ||
|
||
time.sleep(10) # Wait for a few seconds for the main application to close. | ||
|
||
input("\nPlease make sure that all LinkScope Client processes are closed, " | ||
"and then press Enter to begin the update.\n") | ||
print("Updating...\n") | ||
|
||
downloadUrl = sys.argv[1] | ||
softwarePath = sys.argv[2] | ||
with py7zr.SevenZipFile(tempPath, 'r') as archive: | ||
archive.extractall(path=softwarePath.parent) | ||
|
||
clientTempCompressedArchive = tempfile.mkstemp(suffix='.7z') | ||
tempPath = Path(clientTempCompressedArchive[1]) | ||
tempPath.unlink(missing_ok=True) | ||
|
||
with os.fdopen(clientTempCompressedArchive[0], 'wb') as tempArchive: | ||
with requests.get(downloadUrl, stream=True) as fileStream: | ||
for chunk in fileStream.iter_content(chunk_size=5 * 1024 * 1024): | ||
tempArchive.write(chunk) | ||
input("Update complete. Press Enter to exit.") | ||
|
||
with py7zr.SevenZipFile(tempPath, 'r') as archive: | ||
archive.extractall(path=softwarePath) | ||
|
||
tempPath.unlink(missing_ok=True) | ||
if __name__ == '__main__': | ||
try: | ||
main() | ||
except Exception as e: | ||
input(f"Update failed. Press Enter to exit. Reason: {repr(e)}") |