From 82e3db1ffbdef569c5e08a54a219780fa0779795 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Sat, 17 Feb 2018 11:10:42 -0500 Subject: [PATCH] Centralize version string getting. Still trying to work out how we should handle automatic version increments so we don't have to modify files all the time. Remove version file from repo (should only be a thing when building binaries) --- .gitignore | 1 + .version | 1 - config.py | 15 +++++++++------ gui/mainFrame.py | 2 +- pyfa.py | 8 ++++---- service/pycrest/eve.py | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) delete mode 100644 .version diff --git a/.gitignore b/.gitignore index 6cf50c952..4a31b497a 100644 --- a/.gitignore +++ b/.gitignore @@ -119,3 +119,4 @@ ENV/ eos.iml gitversion .version +/.version diff --git a/.version b/.version deleted file mode 100644 index 59d5e729e..000000000 --- a/.version +++ /dev/null @@ -1 +0,0 @@ -v1.2.3-221-g50dd74db \ No newline at end of file diff --git a/config.py b/config.py index 814f9ef0c..c951eb44f 100644 --- a/config.py +++ b/config.py @@ -20,8 +20,8 @@ debug = False saveInRoot = False # Version data -version = "1.35.0" -tag = "Stable" +version = "2.0.x" +tag = "git" expansionName = "YC120.2" expansionVersion = "1.1" evemonMinVersion = "4081" @@ -64,10 +64,13 @@ def getPyfaRoot(): return root -def getGitVersion(): - with open(os.path.join(pyfaPath, '.version')) as f: - version = f.readline() - return version +def getVersion(): + if os.path.isfile(os.path.join(pyfaPath, '.version')): + with open(os.path.join(pyfaPath, '.version')) as f: + gitVersion = f.readline() + return gitVersion + # if no version file exists, then user is running from source or not an official build + return version + " (git)" def getDefaultSave(): diff --git a/gui/mainFrame.py b/gui/mainFrame.py index 7b40c7d11..8fbb2e78a 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -359,7 +359,7 @@ class MainFrame(wx.Frame): def ShowAboutBox(self, evt): info = wx.adv.AboutDialogInfo() info.Name = "pyfa" - info.Version = config.getGitVersion() # gui.aboutData.versionString + info.Version = config.getVersion() # gui.aboutData.versionString # # try: # import matplotlib diff --git a/pyfa.py b/pyfa.py index 889178b6e..bbd801e33 100755 --- a/pyfa.py +++ b/pyfa.py @@ -95,10 +95,6 @@ if __name__ == "__main__": if options.rootsavedata is True: config.saveInRoot = True - # set title if it wasn't supplied by argument - if options.title is None: - options.title = "pyfa %s%s - Python Fitting Assistant" % (config.version, "" if config.tag.lower() != 'git' else " (git)") - config.debug = options.debug config.loggingLevel = config.LOGLEVEL_MAP.get(options.logginglevel.lower(), config.LOGLEVEL_MAP['error']) config.defPaths(options.savepath) @@ -131,6 +127,10 @@ if __name__ == "__main__": from gui.mainFrame import MainFrame + # set title if it wasn't supplied by argument + if options.title is None: + options.title = "pyfa %s - Python Fitting Assistant" % (config.getVersion()) + pyfa = wx.App(False) mf = MainFrame(options.title) ErrorHandler.SetParent(mf) diff --git a/service/pycrest/eve.py b/service/pycrest/eve.py index 9ea88ce23..6a30e9162 100644 --- a/service/pycrest/eve.py +++ b/service/pycrest/eve.py @@ -99,7 +99,7 @@ class APIConnection(object): if additional_headers is None: additional_headers = {} if user_agent is None: - user_agent = "pyfa/{0} ({1})".format(config.version, config.tag) + user_agent = "pyfa/{0}".format(config.getVersion) session.headers.update({ "User-Agent": user_agent, "Accept": "application/json",