1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-08 05:20:03 +03:00

Update all code to use config.appversion() as a function

This *also* caught some instances where appversion_nobuild should
already have been used, so those were both changed and updated to a
function call.
This commit is contained in:
Athanasius 2021-03-25 15:44:18 +00:00
parent dcc4f1c4f1
commit 2f9789afdd
11 changed files with 32 additions and 30 deletions

View File

@ -145,9 +145,9 @@ def main():
updater = Updater(provider='internal')
newversion: Optional[EDMCVersion] = updater.check_appcast()
if newversion:
print(f'{appversion} ({newversion.title!r} is available)')
print(f'{appversion()} ({newversion.title!r} is available)')
else:
print(appversion)
print(appversion())
return
@ -160,7 +160,7 @@ def main():
sys.exit(EXIT_ARGS)
edmclogger.set_channels_loglevel(args.loglevel)
logger.debug(f'Startup v{appversion} : Running on Python v{sys.version}')
logger.debug(f'Startup v{appversion()} : Running on Python v{sys.version}')
logger.debug(f'''Platform: {sys.platform}
argv[0]: {sys.argv[0]}
exec_prefix: {sys.exec_prefix}

View File

@ -1147,11 +1147,11 @@ class AppWindow(object):
# version <link to changelog>
ttk.Label(frame).grid(row=row, column=0) # spacer
row += 1
self.appversion_label = tk.Label(frame, text=appversion)
self.appversion_label = tk.Label(frame, text=appversion())
self.appversion_label.grid(row=row, column=0, sticky=tk.E)
self.appversion = HyperlinkLabel(frame, compound=tk.RIGHT, text=_('Release Notes'),
url='https://github.com/EDCD/EDMarketConnector/releases/tag/Release/'
f'{appversion_nobuild}',
f'{appversion_nobuild()}',
underline=True)
self.appversion.grid(row=row, column=2, sticky=tk.W)
row += 1
@ -1180,7 +1180,7 @@ class AppWindow(object):
self.protocol("WM_DELETE_WINDOW", self._destroy)
############################################################
logger.info(f'Current version is {appversion}')
logger.info(f'Current version is {appversion()}')
def apply(self) -> None:
"""Close the window."""
@ -1395,7 +1395,7 @@ def show_killswitch_poppup(root=None):
# Run the app
if __name__ == "__main__": # noqa: C901
logger.info(f'Startup v{appversion} : Running on Python v{sys.version}')
logger.info(f'Startup v{appversion()} : Running on Python v{sys.version}')
logger.debug(f'''Platform: {sys.platform} {sys.platform == "win32" and sys.getwindowsversion()}
argv[0]: {sys.argv[0]}
exec_prefix: {sys.exec_prefix}
@ -1493,7 +1493,7 @@ sys.path: {sys.path}'''
# abinit = A.B()
# Plain, not via `logger`
print(f'{applongname} {appversion}')
print(f'{applongname} {appversion()}')
Translations.install(config.get_str('language')) # Can generate errors so wait til log set up

View File

@ -55,7 +55,7 @@ SERVER_AUTH = 'https://auth.frontierstore.net'
URL_AUTH = '/auth'
URL_TOKEN = '/token'
USER_AGENT = f'EDCD-{appname}-{appversion}'
USER_AGENT = f'EDCD-{appname}-{appversion()}'
SERVER_LIVE = 'https://companion.orerve.net'
SERVER_BETA = 'https://pts-companion.orerve.net'

View File

@ -11,7 +11,7 @@ logger = EDMCLogging.get_main_logger()
DEFAULT_KILLSWITCH_URL = 'https://raw.githubusercontent.com/EDCD/EDMarketConnector/releases/killswitches.json'
_current_version: semantic_version.Version = semantic_version.Version(config.appversion)
_current_version: semantic_version.Version = semantic_version.Version(config.appversion_nobuild())
class KillSwitch(NamedTuple):

View File

@ -20,7 +20,7 @@ import killswitch
import myNotebook as nb # noqa: N813
import plug
from companion import CAPIData, category_map
from config import applongname, appversion, config
from config import applongname, appversion_nobuild, config
from EDMCLogging import get_main_logger
from myNotebook import Frame
from prefs import prefsVersion
@ -141,7 +141,7 @@ class EDDN:
('$schemaRef', msg['$schemaRef']),
('header', OrderedDict([
('softwareName', f'{applongname} [{system() if sys.platform != "darwin" else "Mac OS"}]'),
('softwareVersion', appversion),
('softwareVersion', appversion_nobuild()),
('uploaderID', uploader_id),
])),
('message', msg['message']),

View File

@ -573,7 +573,7 @@ def worker() -> None:
'commanderName': username.encode('utf-8'),
'apiKey': apikey,
'fromSoftware': applongname,
'fromSoftwareVersion': appversion,
'fromSoftwareVersion': appversion(),
'message': json.dumps(pending, ensure_ascii=False).encode('utf-8'),
}

View File

@ -1222,7 +1222,7 @@ def new_worker():
data = {
'header': {
'appName': applongname,
'appVersion': appversion,
'appVersion': appversion(),
'APIkey': creds.api_key,
'commanderName': creds.cmdr,
'commanderFrontierID': creds.fid

View File

@ -14,7 +14,7 @@ from typing import TYPE_CHECKING, Any, Callable, Optional, Type, Union
import myNotebook as nb # noqa: N813
import plug
from config import applongname, appversion, config
from config import applongname, appversion_nobuild, config
from EDMCLogging import edmclogger, get_main_logger
from hotkey import hotkeymgr
from l10n import Translations
@ -1122,7 +1122,7 @@ class PreferencesDialog(tk.Toplevel):
def apply(self) -> None:
"""Update the config with the options set on the dialog."""
config.set('PrefsVersion', prefsVersion.stringToSerial(appversion))
config.set('PrefsVersion', prefsVersion.stringToSerial(appversion_nobuild()))
config.set(
'output',
(self.out_td.get() and config.OUT_MKT_TD) +

View File

@ -21,7 +21,8 @@ from typing import Any, Generator, Set
import semantic_version
from config import (
appcmdname, applongname, appname, appversion, copyright, git_shorthash_from_head, update_feed, update_interval
appcmdname, applongname, appname, appversion, appversion_nobuild, copyright, git_shorthash_from_head, update_feed,
update_interval
)
from constants import GITVERSION_FILE
@ -52,7 +53,7 @@ else:
assert False, f'Unsupported platform {sys.platform}'
# Split version, as py2exe wants the 'base' for version
semver = semantic_version.Version.coerce(appversion)
semver = semantic_version.Version.coerce(appversion())
base_appversion = str(semver.truncate('patch'))
if dist_dir and len(dist_dir) > 1 and isdir(dist_dir):
@ -89,7 +90,6 @@ if sys.platform == 'darwin':
APP = 'EDMarketConnector.py'
APPCMD = 'EDMC.py'
SHORTappversion = ''.join(appversion.split('.')[:3])
PLUGINS = [
'plugins/coriolis.py',
'plugins/eddb.py',
@ -154,8 +154,8 @@ if sys.platform == 'darwin':
'CFBundleName': applongname,
'CFBundleIdentifier': f'uk.org.marginal.{appname.lower()}',
'CFBundleLocalizations': get_cfbundle_localizations(),
'CFBundleShortVersionString': appversion,
'CFBundleVersion': appversion,
'CFBundleShortVersionString': appversion(),
'CFBundleVersion': appversion(),
'CFBundleURLTypes': [
{
'CFBundleTypeRole': 'Viewer',
@ -228,7 +228,7 @@ elif sys.platform == 'win32':
setup(
name=applongname,
version=appversion,
version=appversion(),
windows=[
{
'dest_base': appname,
@ -237,7 +237,7 @@ setup(
'company_name': 'EDCD', # Used by WinSparkle
'product_name': appname, # Used by WinSparkle
'version': base_appversion,
'product_version': appversion,
'product_version': appversion(),
'copyright': copyright,
'other_resources': [(24, 1, open(f'{appname}.manifest').read())],
}
@ -249,7 +249,7 @@ setup(
'company_name': 'EDCD',
'product_name': appname,
'version': base_appversion,
'product_version': appversion,
'product_version': appversion(),
'copyright': copyright,
'other_resources': [(24, 1, open(f'{appcmdname}.manifest').read())],
}
@ -279,7 +279,7 @@ if sys.platform == 'darwin':
os.system(f'codesign --deep -v -s "Developer ID Application: {macdeveloperid}" {dist_dir}/{appname}.app')
# Make zip for distribution, preserving signature
package_filename = f'{appname}_mac_{appversion}.zip'
package_filename = f'{appname}_mac_{appversion_nobuild()}.zip'
os.system(f'cd {dist_dir}; ditto -ck --keepParent --sequesterRsrc {appname}.app ../{package_filename}; cd ..')
elif sys.platform == 'win32':
@ -288,7 +288,7 @@ elif sys.platform == 'win32':
if not exists(f'{dist_dir}/{appname}.wixobj'):
raise AssertionError(f'No {dist_dir}/{appname}.wixobj: candle.exe failed?')
package_filename = f'{appname}_win_{appversion}.msi'
package_filename = f'{appname}_win_{appversion_nobuild()}.msi'
os.system(rf'"{WIXPATH}\light.exe" -sacl -spdb -sw1076 {dist_dir}\{appname}.wixobj -out {package_filename}')
if not exists(package_filename):

2
td.py
View File

@ -34,7 +34,7 @@ def export(data):
'#\n# <item name> <sellCR> <buyCR> <demand> <stock> <timestamp>\n\n'
'@ {system}/{starport}\n'.format(
appname=applongname,
appversion=appversion,
appversion=appversion(),
platform=platform == 'darwin' and "Mac OS" or system(),
cmdr=data['commander']['name'].strip(),
system=data['lastSystem']['name'].strip(),

View File

@ -9,7 +9,8 @@ if TYPE_CHECKING:
import tkinter as tk
# ensure registry is set up on Windows before we start
from config import appname, appversion, appversion_nobuild, config, update_feed
from config import appname, appversion_nobuild, config, update_feed
class EDMCVersion(object):
"""
@ -29,6 +30,7 @@ class EDMCVersion(object):
self.title: str = title
self.sv: semantic_version.base.Version = sv
class Updater(object):
"""
Updater class to handle checking for updates, whether using internal code
@ -79,7 +81,7 @@ class Updater(object):
# NB: It 'accidentally' supports pre-release due to how it
# splits and compares strings:
# <https://github.com/vslavik/winsparkle/issues/214>
self.updater.win_sparkle_set_app_build_version(appversion_nobuild)
self.updater.win_sparkle_set_app_build_version(appversion_nobuild())
# set up shutdown callback
global root
@ -175,7 +177,7 @@ class Updater(object):
)
# Look for any remaining version greater than appversion
simple_spec = semantic_version.SimpleSpec('>' + appversion)
simple_spec = semantic_version.SimpleSpec('>' + appversion_nobuild())
newversion = simple_spec.select(items.keys())
if newversion: