Allow the win-install option to keep icons for both stable and testing version

This commit is contained in:
Veronica K. B. Olsen
2021-02-01 17:30:21 +01:00
parent 704103f9f1
commit 0e62284671
+18 -4
View File
@@ -669,7 +669,7 @@ def xdgInstall():
def winInstall(): def winInstall():
"""Will attempt to install icons and make a launcher for Windows. """Will attempt to install icons and make a launcher for Windows.
""" """
from nw import __version__ from nw import __version__, __hexversion__
try: try:
import win32com.client import win32com.client
except ImportError: except ImportError:
@@ -685,9 +685,13 @@ def winInstall():
print("===============") print("===============")
print("") print("")
nwTesting = not __hexversion__.endswith("f0")
wShell = win32com.client.Dispatch("WScript.Shell") wShell = win32com.client.Dispatch("WScript.Shell")
linkName = "novelWriter %s.lnk" % __version__ if nwTesting:
linkName = "novelWriter Testing %s.lnk" % __version__
else:
linkName = "novelWriter %s.lnk" % __version__
desktopDir = wShell.SpecialFolders("Desktop") desktopDir = wShell.SpecialFolders("Desktop")
desktopIcon = os.path.join(desktopDir, linkName) desktopIcon = os.path.join(desktopDir, linkName)
@@ -727,11 +731,21 @@ def winInstall():
if os.path.isfile(desktopIcon): if os.path.isfile(desktopIcon):
os.unlink(desktopIcon) os.unlink(desktopIcon)
print("Deleted: %s" % desktopIcon) print("Deleted: %s" % desktopIcon)
if os.path.isdir(startMenuProg): if os.path.isdir(startMenuProg):
for oldIcon in os.listdir(startMenuProg): for oldIcon in os.listdir(startMenuProg):
oldPath = os.path.join(startMenuProg, oldIcon) oldPath = os.path.join(startMenuProg, oldIcon)
os.unlink(oldPath) if not oldIcon.startswith("novelWriter"):
print("Deleted: %s" % oldPath) continue
isTesting = oldIcon.startswith("novelWriter Testing")
if isTesting and nwTesting:
os.unlink(oldPath)
print("Deleted: %s" % oldPath)
if not isTesting and not nwTesting:
os.unlink(oldPath)
print("Deleted: %s" % oldPath)
else: else:
os.mkdir(startMenuProg) os.mkdir(startMenuProg)
print("Created: %s" % startMenuProg) print("Created: %s" % startMenuProg)