auto-install-gui: Fix whitespace

Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
Matthew Stidham
2021-12-22 12:19:38 -08:00
committed by shivam
parent ab03c067de
commit df6bf0126e

View File

@@ -11,7 +11,6 @@ import glob
import sys
import subprocess
# ===========ARGUMENT PARSING==============
parser = argparse.ArgumentParser()
parser.add_argument("--versionNumber", type=str, help="Specify version number to search for")
@@ -43,7 +42,6 @@ if len(webFiles) == 0:
print("Failed to find webfile with version number %s" % (ver))
sys.exit(1)
# =========CHECK DIR FOR FILES=============
filePath = "/home/lanforge/Downloads/"
dir = glob.glob(filePath + "LANforgeGUI_%s*" % ver)
@@ -51,13 +49,17 @@ dirFiles = []
for file in dir:
if ver in file:
fileTime = datetime.datetime.strptime(time.ctime(os.stat(file).st_ctime), "%a %b %d %H:%M:%S %Y") # Fri May 8 08:31:43 2020
fileTime = datetime.datetime.strptime(time.ctime(os.stat(file).st_ctime),
"%a %b %d %H:%M:%S %Y") # Fri May 8 08:31:43 2020
dirFiles.append({'filename': file[25:], 'timestamp': fileTime})
if len(dirFiles) == 0:
print("Unable to find file in {filePath} with version %s" % ver)
# sys.exit(1)
# ============FIND NEWEST FILES============
def findNewestVersion(filesArray):
newest = filesArray[0]
@@ -68,13 +70,13 @@ def findNewestVersion(filesArray):
return newest
newestWebFile = findNewestVersion(webFiles)
if len(dirFiles) != 0:
newestDirFile = findNewestVersion(dirFiles)
else:
newestDirFile = {'filename': 'placeholder', 'timestamp': datetime.datetime.strptime("0", "%H")}
# =======COMPARE WEB AND DIR FILES=========
if newestWebFile['timestamp'] > newestDirFile['timestamp']:
try:
@@ -86,7 +88,8 @@ if newestWebFile['timestamp'] > newestDirFile['timestamp']:
print("Found newer version of GUI")
print("Downloading %s from %s" % (newestWebFile['filename'], url))
# =====ATTEMPT DOWNLOAD AND INSTALL=========
subprocess.call(["curl", "-o", "%s%s" % (filePath, newestWebFile['filename']), "%s%s" % (url, newestWebFile['filename'])])
subprocess.call(
["curl", "-o", "%s%s" % (filePath, newestWebFile['filename']), "%s%s" % (url, newestWebFile['filename'])])
time.sleep(5)
except Exception as e:
print("%s Download failed. Please try again." % e)
@@ -100,16 +103,19 @@ if newestWebFile['timestamp'] > newestDirFile['timestamp']:
# time.sleep(90)
try:
if "/home/lanforge/.config/autostart/LANforge-auto.desktop" not in glob.glob("/home/lanforge/.config/autostart/*"):
if "/home/lanforge/.config/autostart/LANforge-auto.desktop" not in glob.glob(
"/home/lanforge/.config/autostart/*"):
print("Copying LANforge-auto.desktop to /home/lanforge/.config/autostart/")
subprocess.call(["cp", "/home/lanforge/%s/LANforge-auto.desktop" % (newestWebFile['filename'][:len(newestWebFile)-18]), "/home/lanforge/.config/autostart/"])
subprocess.call(["cp", "/home/lanforge/%s/LANforge-auto.desktop" % (
newestWebFile['filename'][:len(newestWebFile) - 18]), "/home/lanforge/.config/autostart/"])
except Exception as e:
print("%s\nCopy failed. Please try again" % e)
sys.exit(1)
try:
print("Attempting to install %s at /home/lanforge" % newestWebFile['filename'])
os.system("cd /home/lanforge/%s; sudo bash lfgui_install.bash" % (newestWebFile['filename'][:len(newestWebFile)-18]))
os.system("cd /home/lanforge/%s; sudo bash lfgui_install.bash" % (
newestWebFile['filename'][:len(newestWebFile) - 18]))
except Exception as e:
print("%s\nInstallation failed. Please Try again." % e)
sys.exit(1)
@@ -124,4 +130,3 @@ if newestWebFile['timestamp'] > newestDirFile['timestamp']:
else:
print("Current GUI version up to date")
sys.exit(0)