From 3e0bcfdb1c0bbc9bea7c2643a715975b8aede98f Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 9 May 2020 18:37:38 +0200 Subject: [PATCH 1/7] Added appPath and homePath to debug output --- nw/config.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nw/config.py b/nw/config.py index f0f21f32..4fb8278e 100644 --- a/nw/config.py +++ b/nw/config.py @@ -227,6 +227,9 @@ class Config: self.iconPath = path.join(self.assetPath,"icons") self.appIcon = path.join(self.iconPath, nwFiles.APP_ICON) + logger.verbose("App path: %s" % self.appPath) + logger.verbose("Home path: %s" % self.homePath) + # If config folder does not exist, make it. # This assumes that the os config folder itself exists. if not path.isdir(self.confPath): From df782e823d93c3b1b915eabcd9ecc30953ffd8ce Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 10 May 2020 23:55:56 +0200 Subject: [PATCH 2/7] Reduced the number of command line switches --- nw/__init__.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/nw/__init__.py b/nw/__init__.py index 8c5199d9..9426d840 100644 --- a/nw/__init__.py +++ b/nw/__init__.py @@ -92,7 +92,7 @@ def main(sysArgs=None): sysArgs = sys.argv[1:] # Valid Input Options - shortOpt = "hidvql:" + shortOpt = "hvq" longOpt = [ "help", "version", @@ -118,12 +118,12 @@ def main(sysArgs=None): "\n" "Usage:\n" " -h, --help Print this message.\n" - " --version Print program version and exit.\n" - " -i, --info Print additional runtime information.\n" - " -d, --debug Print debug output. Includes -i.\n" - " -v, --verbose Increase verbosity of debug output. Includes -d.\n" + " -v, --version Print program version and exit.\n" + " --info Print additional runtime information.\n" + " --debug Print debug output. Includes -i.\n" + " --verbose Increase verbosity of debug output. Includes -d.\n" " -q, --quiet Disable output to command line. Does not affect log file.\n" - " -l, --logfile= Specify log file.\n" + " --logfile= Specify log file.\n" " --style= Sets Qt5 style flag. Defaults to 'Fusion'.\n" " --config= Alternative config file.\n" " --data= Alternative user data path.\n" @@ -162,20 +162,20 @@ def main(sysArgs=None): if inOpt in ("-h","--help"): print(helpMsg) sys.exit() - elif inOpt == "--version": + elif inOptin ("-v", "--version"): print("%s %s Version %s" % (__package__,__status__,__version__)) sys.exit() - elif inOpt in ("-i", "--info"): + elif inOpt == "--info": debugLevel = logging.INFO - elif inOpt in ("-d", "--debug"): + elif inOpt == "--debug": debugLevel = logging.DEBUG logFormat = "[{asctime:}] {name:>30}:{lineno:<4d} {levelname:8} {message:}" - elif inOpt in ("-l","--logfile"): + elif inOpt == "--logfile": logFile = inArg toFile = True elif inOpt in ("-q","--quiet"): toStd = False - elif inOpt in ("-v","--verbose"): + elif inOpt == "--verbose": debugLevel = VERBOSE logFormat = "[{asctime:}] {name:>30}:{lineno:<4d} {levelname:8} {message:}" elif inOpt == "--style": From c3f1581acf80483b9d7e5829e3024d3d06255c8e Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 10 May 2020 23:56:41 +0200 Subject: [PATCH 3/7] oopsie --- nw/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nw/__init__.py b/nw/__init__.py index 9426d840..89b5e04d 100644 --- a/nw/__init__.py +++ b/nw/__init__.py @@ -162,7 +162,7 @@ def main(sysArgs=None): if inOpt in ("-h","--help"): print(helpMsg) sys.exit() - elif inOptin ("-v", "--version"): + elif inOpt in ("-v", "--version"): print("%s %s Version %s" % (__package__,__status__,__version__)) sys.exit() elif inOpt == "--info": From 41808ea9b84f2e007d1849d947519d1cd806751f Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 10 May 2020 23:58:44 +0200 Subject: [PATCH 4/7] Changed __status__ to Pre-Release --- nw/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nw/__init__.py b/nw/__init__.py index 89b5e04d..365d2b3b 100644 --- a/nw/__init__.py +++ b/nw/__init__.py @@ -44,7 +44,7 @@ __version__ = "0.5" __date__ = "2020-05-09" __maintainer__ = "Veronica Berglyd Olsen" __email__ = "code@vkbo.net" -__status__ = "Development" +__status__ = "Pre-Release" __url__ = "https://github.com/vkbo/novelWriter" __docurl__ = "https://novelwriter.readthedocs.io" __credits__ = [ From aab0b4a8460fcce467c2b095136c6d166482d337 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Mon, 11 May 2020 00:03:28 +0200 Subject: [PATCH 5/7] Fixed help text and added date to the version and help output --- nw/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nw/__init__.py b/nw/__init__.py index 365d2b3b..85b5cab4 100644 --- a/nw/__init__.py +++ b/nw/__init__.py @@ -108,7 +108,7 @@ def main(sysArgs=None): ] helpMsg = ( - "{appname} {version} ({status})\n" + "{appname} {version} ({status} {date})\n" "{copyright}\n" "\n" "This program is distributed in the hope that it will be useful,\n" @@ -120,8 +120,8 @@ def main(sysArgs=None): " -h, --help Print this message.\n" " -v, --version Print program version and exit.\n" " --info Print additional runtime information.\n" - " --debug Print debug output. Includes -i.\n" - " --verbose Increase verbosity of debug output. Includes -d.\n" + " --debug Print debug output. Includes --info.\n" + " --verbose Increase verbosity of debug output. Includes --debug.\n" " -q, --quiet Disable output to command line. Does not affect log file.\n" " --logfile= Specify log file.\n" " --style= Sets Qt5 style flag. Defaults to 'Fusion'.\n" @@ -132,7 +132,8 @@ def main(sysArgs=None): appname = __package__, version = __version__, status = __status__, - copyright = __copyright__ + copyright = __copyright__, + date = __date__, ) # Defaults @@ -163,7 +164,7 @@ def main(sysArgs=None): print(helpMsg) sys.exit() elif inOpt in ("-v", "--version"): - print("%s %s Version %s" % (__package__,__status__,__version__)) + print("%s %s Version %s [%s]" % (__package__,__status__,__version__,__date__)) sys.exit() elif inOpt == "--info": debugLevel = logging.INFO From 6d0b38e38a3d476ec86166cf8eda1626171b29a2 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Mon, 11 May 2020 19:25:06 +0200 Subject: [PATCH 6/7] Added hex version checking to the project file to warn the user if opening a file 'from the future'. --- nw/__init__.py | 1 + nw/core/project.py | 18 ++++++++++++++++++ sample/sampleNovel/nwProject.nwx | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/nw/__init__.py b/nw/__init__.py index 85b5cab4..3330c6b6 100644 --- a/nw/__init__.py +++ b/nw/__init__.py @@ -41,6 +41,7 @@ __author__ = "Veronica Berglyd Olsen" __copyright__ = "Copyright 2018–2020, Veronica Berglyd Olsen" __license__ = "GPLv3" __version__ = "0.5" +__hexversion__ = "0x000500f0" __date__ = "2020-05-09" __maintainer__ = "Veronica Berglyd Olsen" __email__ = "code@vkbo.net" diff --git a/nw/core/project.py b/nw/core/project.py index ca1d7a55..32d0cfdd 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -39,6 +39,8 @@ from hashlib import sha256 from time import time from shutil import make_archive +from PyQt5.QtWidgets import QMessageBox + from nw.gui.tools import OptionState from nw.core.tools import projectMaintenance from nw.core.document import NWDoc @@ -285,12 +287,15 @@ class NWProject(): nwxRoot = xRoot.tag appVersion = "Unknown" + hexVersion = "0x0" fileVersion = "Unknown" self.saveCount = 0 self.autoCount = 0 if "appVersion" in xRoot.attrib: appVersion = xRoot.attrib["appVersion"] + if "hexVersion" in xRoot.attrib: + hexVersion = xRoot.attrib["hexVersion"] if "fileVersion" in xRoot.attrib: fileVersion = xRoot.attrib["fileVersion"] if "saveCount" in xRoot.attrib: @@ -308,6 +313,18 @@ class NWProject(): ) return False + if int(hexVersion, 16) > int(nw.__hexversion__, 16): + msgBox = QMessageBox() + msgRes = msgBox.question(self.theParent, "Version Conflict", ( + "This project was saved by a newer version of %s, version %s. This is version %s. " + "If you continue to open the project, some attributes and settings may not be " + "preserved. Continue opening the project?" + ) % ( + nw.__package__, appVersion, nw.__version__ + )) + if msgRes != QMessageBox.Yes: + return False + for xChild in xRoot: if xChild.tag == "project": logger.debug("Found project meta") @@ -397,6 +414,7 @@ class NWProject(): logger.debug("Writing project meta") nwXML = etree.Element("novelWriterXML",attrib={ "appVersion" : str(nw.__version__), + "hexVersion" : str(nw.__hexversion__), "fileVersion" : "1.0", "saveCount" : str(self.saveCount), "autoCount" : str(self.autoCount), diff --git a/sample/sampleNovel/nwProject.nwx b/sample/sampleNovel/nwProject.nwx index a452021d..ad764dec 100644 --- a/sample/sampleNovel/nwProject.nwx +++ b/sample/sampleNovel/nwProject.nwx @@ -1,5 +1,5 @@ - + Sample Project Sample Project From 6754048c2ead20a205d009bba4787f0e5a4257b2 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Mon, 11 May 2020 19:27:53 +0200 Subject: [PATCH 7/7] Added show GUI check as this warning may break tests if not --- nw/core/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nw/core/project.py b/nw/core/project.py index 32d0cfdd..4a74e0d0 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -313,7 +313,7 @@ class NWProject(): ) return False - if int(hexVersion, 16) > int(nw.__hexversion__, 16): + if int(hexVersion, 16) > int(nw.__hexversion__, 16) and self.mainConf.showGUI: msgBox = QMessageBox() msgRes = msgBox.question(self.theParent, "Version Conflict", ( "This project was saved by a newer version of %s, version %s. This is version %s. "