From e3e0ac94579de99dadef7d6ee538116e1152f57c Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 26 Oct 2021 10:45:11 -0500 Subject: [PATCH 01/11] Added an alias manager dialog in the application menu --- doc/changelog.md | 1 + src/controller/mainController.py | 8 ++++ src/controller/userAliasController.py | 53 ++++++++++++++++++++++++ src/wxUI/dialogs/userAliasDialogs.py | 59 +++++++++++++++++++++++++++ src/wxUI/view.py | 1 + 5 files changed, 122 insertions(+) create mode 100644 src/controller/userAliasController.py diff --git a/doc/changelog.md b/doc/changelog.md index 3b8931e7..e0c489bc 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -2,6 +2,7 @@ ## changes in this version +* Added an user alias manager, located in the application menu in the menu bar. From this dialog, it is possible to review, add, edit or remove user aliases for the current account. ([#401](https://github.com/manuelcortez/TWBlue/issues/401)) * TWBlue now closes the VLC player window automatically when a video reaches its end. ([#399](https://github.com/manuelcortez/TWBlue/issues/399)) * After a lot of time, TWBlue now uses a new default Soundpack, called FreakyBlue. This soundpack will be set by default in all new sessions created in the application. Thanks to [Andre Louis](https://twitter.com/FreakyFwoof) for the pack. ([#247](https://github.com/manuelcortez/TWBlue/issues/247)) * When reading a tweet, if the tweet contains more than 2 consecutive mentions, TWBlue will announce how many more users the tweet includes, as opposed to read every user in the conversation. You still can display the tweet to read all users. diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 7241707f..c3d97ff9 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -2,6 +2,7 @@ import platform system = platform.system() import application +import wx import requests from audio_services import youtube_utils import arrow @@ -24,6 +25,7 @@ from sessions.twitter import utils, compose from sessionmanager import manager, sessionManager from controller import buffers from . import messages +from . import userAliasController import sessions from sessions.twitter import session as session_ from pubsub import pub @@ -189,6 +191,7 @@ class Controller(object): widgetUtils.connect_event(self.view, widgetUtils.MENU, self.add_to_list, self.view.addToList) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.remove_from_list, self.view.removeFromList) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.update_buffer, self.view.update_buffer) + widgetUtils.connect_event(self.view, widgetUtils.MENU, self.manage_aliases, self.view.manageAliases) def set_systray_icon(self): self.systrayIcon = sysTrayIcon.SysTrayIcon() @@ -756,6 +759,11 @@ class Controller(object): buff.session.settings["user-aliases"][str(user_id)] = alias buff.session.settings.write() output.speak(_("Alias has been set correctly for {}.").format(user)) + pub.sendMessage("alias-added") + + def manage_aliases(self, *args, **kwargs): + buff = self.get_best_buffer() + alias_controller = userAliasController.userAliasController(buff.session.settings) def post_tweet(self, event=None): buffer = self.get_best_buffer() diff --git a/src/controller/userAliasController.py b/src/controller/userAliasController.py new file mode 100644 index 00000000..69a4fa8f --- /dev/null +++ b/src/controller/userAliasController.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +import widgetUtils +from pubsub import pub +from wxUI.dialogs import userAliasDialogs +from extra import autocompletionUsers + +class userAliasController(object): + def __init__(self, settings): + super(userAliasController, self).__init__() + self.settings = settings + self.dialog = userAliasDialogs.userAliasEditorDialog() + self.update_aliases_manager() + widgetUtils.connect_event(self.dialog.add, widgetUtils.BUTTON_PRESSED, self.on_add) + widgetUtils.connect_event(self.dialog.edit, widgetUtils.BUTTON_PRESSED, self.on_edit) + widgetUtils.connect_event(self.dialog.remove, widgetUtils.BUTTON_PRESSED, self.on_remove) + pub.subscribe(self.update_aliases_manager, "alias-added") + self.dialog.ShowModal() + + def update_aliases_manager(self): + self.dialog.users.Clear() + aliases = [self.settings["user-aliases"].get(k) for k in self.settings["user-aliases"].keys()] + if len(aliases) > 0: + self.dialog.users.InsertItems(aliases, 0) + self.dialog.on_selection_changes() + + def on_add(self, *args, **kwargs): + pub.sendMessage("execute-action", action="add_alias") + + def on_edit(self, *args, **kwargs): + selection = self.dialog.get_selected_user() + if selection != "": + edited = self.dialog.edit_alias_dialog(_("Edit alias for {}").format(selection)) + if edited == None or edited == "": + return + for user_key in self.settings["user-aliases"].keys(): + if self.settings["user-aliases"][user_key] == selection: + self.settings["user-aliases"][user_key] = edited + self.settings.write() + self.update_aliases_manager() + break + + def on_remove(self, *args, **kwargs): + selection = self.dialog.get_selected_user() + if selection == None or selection == "": + return + should_remove = self.dialog.remove_alias_dialog() + if should_remove: + for user_key in self.settings["user-aliases"].keys(): + if self.settings["user-aliases"][user_key] == selection: + self.settings["user-aliases"].pop(user_key) + self.settings.write() + self.update_aliases_manager() + break diff --git a/src/wxUI/dialogs/userAliasDialogs.py b/src/wxUI/dialogs/userAliasDialogs.py index 6fca9237..9156c0b5 100644 --- a/src/wxUI/dialogs/userAliasDialogs.py +++ b/src/wxUI/dialogs/userAliasDialogs.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import wx +import gettext from . import baseDialog class addAliasDialog(baseDialog.BaseWXDialog): @@ -34,3 +35,61 @@ class addAliasDialog(baseDialog.BaseWXDialog): def get_user(self): return (self.cb.GetValue(), self.alias.GetValue()) +class userAliasEditorDialog(wx.Dialog): + def __init__(self, *args, **kwds): + super(userAliasEditorDialog, self).__init__(parent=None) + self.SetTitle(_("Edit user aliases")) + main_sizer = wx.BoxSizer(wx.VERTICAL) + userListSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, _("Users")), wx.VERTICAL) + main_sizer.Add(userListSizer, 1, wx.EXPAND, 0) + self.users = wx.ListBox(self, wx.ID_ANY, choices=[]) + self.users.Bind(wx.EVT_LISTBOX, self.on_selection_changes) + userListSizer.Add(self.users, 0, 0, 0) + actionsSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, _("Actions")), wx.HORIZONTAL) + main_sizer.Add(actionsSizer, 1, wx.EXPAND, 0) + self.add = wx.Button(self, wx.ID_ANY, _("Add alias")) + self.add.SetToolTip(_("Adds a new user alias")) + actionsSizer.Add(self.add, 0, 0, 0) + self.edit = wx.Button(self, wx.ID_ANY, _("Edit")) + self.edit.SetToolTip(_("Edit the currently focused user Alias.")) + self.edit.Enable(False) + actionsSizer.Add(self.edit, 0, 0, 0) + self.remove = wx.Button(self, wx.ID_ANY, _("Remove")) + self.remove.SetToolTip(_("Remove the currently focused user alias.")) + self.remove.Enable(False) + actionsSizer.Add(self.remove, 0, 0, 0) + btnSizer = wx.StdDialogButtonSizer() + main_sizer.Add(btnSizer, 0, wx.ALIGN_RIGHT | wx.ALL, 4) + self.button_CLOSE = wx.Button(self, wx.ID_CLOSE, "") + btnSizer.AddButton(self.button_CLOSE) + btnSizer.Realize() + self.SetSizer(main_sizer) + main_sizer.Fit(self) + self.SetEscapeId(self.button_CLOSE.GetId()) + self.Layout() + + def on_selection_changes(self, *args, **kwargs): + selection = self.users.GetSelection() + if selection == -1: + self.enable_action_buttons(False) + else: + self.enable_action_buttons(True) + + def get_selected_user(self): + return self.users.GetStringSelection() + + def remove_alias_dialog(self, *args, **kwargs): + dlg = wx.MessageDialog(self, _("Are you sure you want to delete this user alias?"), _("Remove user alias"), wx.YES_NO) + if dlg.ShowModal() == wx.ID_YES: + return True + else: + return False + + def enable_action_buttons(self, enabled=True): + self.edit.Enable(enabled) + self.remove.Enable(enabled) + + def edit_alias_dialog(self, title): + dlg = wx.TextEntryDialog(self, title, _("User alias")) + if dlg.ShowModal() == wx.ID_OK: + return dlg.GetValue() \ No newline at end of file diff --git a/src/wxUI/view.py b/src/wxUI/view.py index 5e5f034b..2d260023 100644 --- a/src/wxUI/view.py +++ b/src/wxUI/view.py @@ -20,6 +20,7 @@ class mainFrame(wx.Frame): self.show_hide = app.Append(wx.ID_ANY, _(u"&Hide window")) self.menuitem_search = app.Append(wx.ID_ANY, _(u"&Search")) self.lists = app.Append(wx.ID_ANY, _(u"&Lists manager")) + self.manageAliases = app.Append(wx.ID_ANY, _("Manage user aliases")) self.keystroke_editor = app.Append(wx.ID_ANY, _(u"&Edit keystrokes")) self.account_settings = app.Append(wx.ID_ANY, _(u"Account se&ttings")) self.prefs = app.Append(wx.ID_PREFERENCES, _(u"&Global settings")) From b23be9c896abb60599f9f731acd5bc42d3a8f8d3 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 26 Oct 2021 12:40:57 -0500 Subject: [PATCH 02/11] Started to remove stable and snapshot update information files --- updates/stable.json | 6 ------ updates/{snapshots.json => updates.json} | 0 2 files changed, 6 deletions(-) delete mode 100644 updates/stable.json rename updates/{snapshots.json => updates.json} (100%) diff --git a/updates/stable.json b/updates/stable.json deleted file mode 100644 index ef63523b..00000000 --- a/updates/stable.json +++ /dev/null @@ -1,6 +0,0 @@ -{"current_version": "0.95", -"description": "The first version for the new generation of TWBlue.", -"date": "day_name_abr month day_numb, 2016", -"downloads": -{"Windows32": "http://twblue.es/pubs/twblue_ngen_0.80_x86.zip", -"Windows64": "http://twblue.es/pubs/twblue_ngen_0.80_x64.zip"}} \ No newline at end of file diff --git a/updates/snapshots.json b/updates/updates.json similarity index 100% rename from updates/snapshots.json rename to updates/updates.json From daac312658378cd1bc0e1b2a4b3bb6ded88cdbe3 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 26 Oct 2021 12:43:03 -0500 Subject: [PATCH 03/11] Removes snapshot information from app info --- src/application.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/application.py b/src/application.py index 64d123da..f2f3b370 100644 --- a/src/application.py +++ b/src/application.py @@ -3,15 +3,9 @@ import datetime name = 'TWBlue' short_name='twblue' -snapshot = True -if snapshot == False: - version = "0.95" - update_url = 'https://twblue.es/updates/stable.php' - mirror_update_url = 'https://raw.githubusercontent.com/manuelcortez/TWBlue/next-gen/updates/stable.json' -else: - version = "11" - update_url = 'https://twblue.es/updates/snapshot.php' - mirror_update_url = 'https://raw.githubusercontent.com/manuelcortez/TWBlue/next-gen/updates/snapshots.json' +version = "11" +update_url = 'https://twblue.es/updates/updates.php' +mirror_update_url = 'https://raw.githubusercontent.com/manuelcortez/TWBlue/next-gen/updates/updates.json' authors = ["Manuel Cortéz", "José Manuel Delicado"] authorEmail = "manuel@manuelcortez.net" copyright = "Copyright (C) 2013-2021, Manuel cortéz." From 2b059ee42e7a7ea8b9f7d724c23652bb1cbd1ef6 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 26 Oct 2021 13:02:24 -0500 Subject: [PATCH 04/11] Modified Nsis scripts to remove references to old snapshots code --- scripts/twblue.nsi | 14 +++--- scripts/twblue_snapshot.nsi | 95 ------------------------------------- 2 files changed, 7 insertions(+), 102 deletions(-) delete mode 100644 scripts/twblue_snapshot.nsi diff --git a/scripts/twblue.nsi b/scripts/twblue.nsi index f83fe05b..b1d35335 100644 --- a/scripts/twblue.nsi +++ b/scripts/twblue.nsi @@ -15,10 +15,10 @@ SetCompressor /solid lzma SetDatablockOptimize on VIAddVersionKey ProductName "TWBlue" VIAddVersionKey LegalCopyright "Copyright 2014-2021 Manuel Cortéz." -VIAddVersionKey ProductVersion "0.95" -VIAddVersionKey FileVersion "0.95" -VIProductVersion "0.95.0.0" -VIFileVersion "0.95.0.0" +VIAddVersionKey ProductVersion "11" +VIAddVersionKey FileVersion "11" +VIProductVersion "11.0.0.0" +VIFileVersion "11.0.0.0" !insertmacro MUI_PAGE_WELCOME !define MUI_LICENSEPAGE_RADIOBUTTONS !insertmacro MUI_PAGE_LICENSE "license.txt" @@ -72,10 +72,10 @@ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "D WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "InstallLocation" $INSTDIR WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "Publisher" "Manuel Cortéz" -WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "DisplayVersion" "0.95" -WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "URLInfoAbout" "http://twblue.es" +WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "DisplayVersion" "11" +WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "URLInfoAbout" "https://twblue.es" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "VersionMajor" 0 -WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "VersionMinor" 95 +WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "VersionMinor" 0 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "NoRepair" 1 SectionEnd diff --git a/scripts/twblue_snapshot.nsi b/scripts/twblue_snapshot.nsi deleted file mode 100644 index f7d20764..00000000 --- a/scripts/twblue_snapshot.nsi +++ /dev/null @@ -1,95 +0,0 @@ -!include "MUI2.nsh" -!include "LogicLib.nsh" -!include "x64.nsh" -Unicode true -CRCCheck on -ManifestSupportedOS all -XPStyle on -Name "TWBlue" -OutFile "TWBlue_snapshot_setup.exe" -InstallDir "$PROGRAMFILES\twblue" -InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "InstallLocation" -RequestExecutionLevel admin -SetCompress auto -SetCompressor /solid lzma -SetDatablockOptimize on -VIAddVersionKey ProductName "TWBlue Snapshot version" -VIAddVersionKey LegalCopyright "Copyright 2014-2021 Manuel Cortéz." -VIAddVersionKey ProductVersion "11" -VIAddVersionKey FileVersion "11" -VIProductVersion "11.0.0.0" -VIFileVersion "11.0.0.0" -!insertmacro MUI_PAGE_WELCOME -!define MUI_LICENSEPAGE_RADIOBUTTONS -!insertmacro MUI_PAGE_LICENSE "license.txt" -!insertmacro MUI_PAGE_DIRECTORY -var StartMenuFolder -!insertmacro MUI_PAGE_STARTMENU startmenu $StartMenuFolder -!insertmacro MUI_PAGE_INSTFILES -!define MUI_FINISHPAGE_LINK "Visit TWBlue website" -!define MUI_FINISHPAGE_LINK_LOCATION "https://twblue.es" -!define MUI_FINISHPAGE_RUN "$INSTDIR\TWBlue.exe" -!insertmacro MUI_PAGE_FINISH -!insertmacro MUI_UNPAGE_CONFIRM -!insertmacro MUI_UNPAGE_INSTFILES - !insertmacro MUI_LANGUAGE "English" -!insertmacro MUI_LANGUAGE "French" -!insertmacro MUI_LANGUAGE "Spanish" -!insertmacro MUI_LANGUAGE "Italian" -!insertmacro MUI_LANGUAGE "Finnish" -!insertmacro MUI_LANGUAGE "Russian" -!insertmacro MUI_LANGUAGE "PortugueseBR" -!insertmacro MUI_LANGUAGE "Polish" -!insertmacro MUI_LANGUAGE "German" -!insertmacro MUI_LANGUAGE "Hungarian" -!insertmacro MUI_LANGUAGE "Turkish" -!insertmacro MUI_LANGUAGE "Arabic" -!insertmacro MUI_LANGUAGE "Galician" -!insertmacro MUI_LANGUAGE "Catalan" -!insertmacro MUI_LANGUAGE "Basque" -!insertmacro MUI_LANGUAGE "Croatian" -!insertmacro MUI_LANGUAGE "Japanese" -!insertmacro MUI_LANGUAGE "SerbianLatin" -!insertmacro MUI_LANGUAGE "Romanian" -!insertmacro MUI_RESERVEFILE_LANGDLL -Section -SetShellVarContext All -SetOutPath "$INSTDIR" -${If} ${RunningX64} -File /r TWBlue64\* -${Else} -File /r TWBlue\* -${EndIf} -CreateShortCut "$DESKTOP\TWBlue.lnk" "$INSTDIR\TWBlue.exe" -!insertmacro MUI_STARTMENU_WRITE_BEGIN startmenu -CreateDirectory "$SMPROGRAMS\$StartMenuFolder" -CreateShortCut "$SMPROGRAMS\$StartMenuFolder\TWBlue.lnk" "$INSTDIR\TWBlue.exe" -CreateShortCut "$SMPROGRAMS\$StartMenuFolder\TWBlue on the web.lnk" "http://twblue.es" -CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe" -!insertmacro MUI_STARTMENU_WRITE_END -WriteUninstaller "$INSTDIR\Uninstall.exe" -WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "DisplayName" "TWBlue" -WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "UninstallString" '"$INSTDIR\uninstall.exe"' -WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "InstallLocation" $INSTDIR -WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "Publisher" "Manuel Cortéz" -WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "DisplayVersion" "11" -WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "URLInfoAbout" "https://twblue.es" -WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "VersionMajor" 0 -WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "VersionMinor" 0 -WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "NoModify" 1 -WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "NoRepair" 1 -SectionEnd -Section "Uninstall" -SetShellVarContext All -DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" -RMDir /r /REBOOTOK $INSTDIR -Delete "$DESKTOP\TWBlue.lnk" -!insertmacro MUI_STARTMENU_GETFOLDER startmenu $StartMenuFolder -RMDir /r "$SMPROGRAMS\$StartMenuFolder" -SectionEnd -Function .onInit -${If} ${RunningX64} -StrCpy $instdir "$programfiles64\twblue" -${EndIf} -!insertmacro MUI_LANGDLL_DISPLAY -FunctionEnd From d222740887a5c69708c3545aed845b2ab259fe6c Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 26 Oct 2021 13:04:49 -0500 Subject: [PATCH 05/11] Updated gitlab CI --- .gitlab-ci.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8f377e5a..06567285 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ stages: - make_installer - upload -snapshot32: +twblue32: tags: - shared-windows - windows @@ -21,7 +21,6 @@ snapshot32: - '&$env:PYTHON -V' - '&$env:PYTHON -m pip install --upgrade pip' - '&$env:PYTHON -m pip install --upgrade -r requirements.txt' - - '&$env:PYTHON -m pip uninstall enum34 -y' stage: build interruptible: true script: @@ -37,7 +36,7 @@ snapshot32: - '&$env:PYTHON make_archive.py' - cd .. - mv src/dist artifacts/TWBlue - - move src/twblue.zip artifacts/twblue_snapshot_x86.zip + - move src/twblue.zip artifacts/twblue_x86.zip only: - tags artifacts: @@ -45,7 +44,7 @@ snapshot32: - artifacts expire_in: 1 day -snapshot64: +twblue64: tags: - shared-windows - windows @@ -73,7 +72,7 @@ snapshot64: - '&$env:PYTHON make_archive.py' - cd .. - mv src/dist artifacts/TWBlue64 - - move src/twblue.zip artifacts/twblue_snapshot_x64.zip + - move src/twblue.zip artifacts/twblue_x64.zip only: - tags artifacts: @@ -96,8 +95,8 @@ generate_versions: - move artifacts/TWBlue scripts/ - move artifacts/TWBlue64 scripts/ - cd scripts - - '&$env:NSIS twblue_snapshot.nsi' - - move twblue_snapshot_setup.exe ../artifacts + - '&$env:NSIS twblue.nsi' + - move twblue_setup.exe ../artifacts only: - tags artifacts: From 72e6d030d51d0f3bf10633e03bfcc0e3cae0c21c Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 26 Oct 2021 13:10:57 -0500 Subject: [PATCH 06/11] Updater no longer will try to compare float numbers for updates --- src/update/update.py | 5 ++--- src/update/updater.py | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/update/update.py b/src/update/update.py index 64bfd7de..7f1b7cf2 100644 --- a/src/update/update.py +++ b/src/update/update.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals from logging import getLogger logger = getLogger('update') @@ -24,8 +23,8 @@ def perform_update(endpoint, current_version, app_name='', password=None, update if not available_update: logger.debug("No update available") return False - available_version = float(available_update['current_version']) - if not float(available_version) > float(current_version) or platform.system()+platform.architecture()[0][:2] not in available_update['downloads']: + available_version = available_update['current_version'] + if available_version == current_version or platform.system()+platform.architecture()[0][:2] not in available_update['downloads']: logger.debug("No update for this architecture") return False available_description = available_update.get('description', None) diff --git a/src/update/updater.py b/src/update/updater.py index 2bef784b..5214c1de 100644 --- a/src/update/updater.py +++ b/src/update/updater.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import -from __future__ import unicode_literals import application from . import update import platform From a82efd4dccc25fc2ca445593c3c3de1c0bca2e75 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 26 Oct 2021 13:16:31 -0500 Subject: [PATCH 07/11] Fixed a typo --- src/update/update.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/update/update.py b/src/update/update.py index 7f1b7cf2..d6b47f5c 100644 --- a/src/update/update.py +++ b/src/update/update.py @@ -41,10 +41,10 @@ def perform_update(endpoint, current_version, app_name='', password=None, update downloaded = download_update(update_url, download_path, requests_session=requests_session, progress_callback=progress_callback) extracted = extract_update(downloaded, update_path, password=password) bootstrap_path = move_bootstrap(extracted) - execute_bootstrap(bootstrap_path, extracted) - logger.info("Update prepared for installation.") if callable(update_complete_callback): update_complete_callback() + execute_bootstrap(bootstrap_path, extracted) + logger.info("Update prepared for installation.") def create_requests_session(app_name=None, version=None): user_agent = '' From cb1312d0c935d518132e5b30038251adb7786189 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 26 Oct 2021 13:38:21 -0500 Subject: [PATCH 08/11] Changed version in installer so it will be easier to replace it later by the authomatic script --- scripts/twblue.nsi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/twblue.nsi b/scripts/twblue.nsi index b1d35335..a2789cef 100644 --- a/scripts/twblue.nsi +++ b/scripts/twblue.nsi @@ -15,10 +15,10 @@ SetCompressor /solid lzma SetDatablockOptimize on VIAddVersionKey ProductName "TWBlue" VIAddVersionKey LegalCopyright "Copyright 2014-2021 Manuel Cortéz." -VIAddVersionKey ProductVersion "11" -VIAddVersionKey FileVersion "11" -VIProductVersion "11.0.0.0" -VIFileVersion "11.0.0.0" +VIAddVersionKey ProductVersion "0.95" +VIAddVersionKey FileVersion "0.95" +VIProductVersion "0.95" +VIFileVersion "0.95" !insertmacro MUI_PAGE_WELCOME !define MUI_LICENSEPAGE_RADIOBUTTONS !insertmacro MUI_PAGE_LICENSE "license.txt" @@ -72,7 +72,7 @@ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "D WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "InstallLocation" $INSTDIR WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "Publisher" "Manuel Cortéz" -WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "DisplayVersion" "11" +WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "DisplayVersion" "0.95" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "URLInfoAbout" "https://twblue.es" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "VersionMajor" 0 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\twblue" "VersionMinor" 0 From 9f48784ce453f2673faf55c818eb891bb7634724 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 26 Oct 2021 13:39:50 -0500 Subject: [PATCH 09/11] Added script to add next version in application.py and installer generation files --- src/write_version_data.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/write_version_data.py diff --git a/src/write_version_data.py b/src/write_version_data.py new file mode 100644 index 00000000..b13675b3 --- /dev/null +++ b/src/write_version_data.py @@ -0,0 +1,29 @@ +#! /usr/bin/env python# -*- coding: iso-8859-1 -*- +""" Write version info (taken from the last commit) to application.py. This method has been implemented this way for running updates. +This file is not intended to be called by the user. It will be used only by the Gitlab CI runner.""" +import requests +from codecs import open + +print("Writing version data for update...") +commit_info = requests.get("https://gitlab.com/api/v4/projects/23482196/repository/commits/next-gen") +commit_info = commit_info.json() +commit = commit_info["short_id"] +print("Got new version info: {commit}".format(commit=commit,)) +file = open("application.py", "r", encoding="utf-8") +lines = file.readlines() +lines[-1] = 'version = "{}"'.format(commit_info["created_at"][:10].replace("-", ".")) +file.close() +file2 = open("application.py", "w", encoding="utf-8") +file2.writelines(lines) +file2.close() +print("Wrote application.py with the new version info.") + +print("Updating next version on installer setup...") +file = open("..\\scripts\\twblue.nsi", "r", encoding="utf-8") +contents = file.read() +contents = contents.replace("0.95", commit_info["created_at"][:10].replace("-", ".")) +file.close() +file2 = open("..\\scripts\\twblue.nsi", "w", encoding="utf-8") +file2.write(contents) +file2.close() +print("done") From f7f303929ef09a6f29458989e625c89032c22935 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 26 Oct 2021 13:41:22 -0500 Subject: [PATCH 10/11] Updated CI config --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 06567285..25061019 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,6 +29,7 @@ twblue32: - '&$env:PYTHON documentation_importer.py' - cd ..\src - '&$env:PYTHON ..\doc\generator.py' + - '&$env:PYTHON write_version_data.py' - '&$env:PYTHON setup.py build' - cd .. - mkdir artifacts @@ -65,6 +66,7 @@ twblue64: - '&$env:PYTHON documentation_importer.py' - cd ..\src - '&$env:PYTHON ..\doc\generator.py' + - '&$env:PYTHON write_version_data.py' - '&$env:PYTHON setup.py build' - cd .. - mkdir artifacts From d888563fdae4007a9247f421bbb54cc12f4fa071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Manuel=20Delicado=20Alcolea?= Date: Wed, 27 Oct 2021 22:00:58 +0200 Subject: [PATCH 11/11] Updated Api keys --- mysc/keys/api_keys.c | 13 ------------- mysc/keys/api_keys.h | 4 ---- 2 files changed, 17 deletions(-) diff --git a/mysc/keys/api_keys.c b/mysc/keys/api_keys.c index a3c5ad09..f07628c9 100644 --- a/mysc/keys/api_keys.c +++ b/mysc/keys/api_keys.c @@ -5,19 +5,6 @@ return "key\0"; char *get_api_secret(){ return "secret_key\0"; } -char *get_dropbox_api_key(){ -return "key\0"; -} -char *get_dropbox_api_secret(){ -return "secret_key\0"; -} char *get_twishort_api_key(){ return "key\0"; } -char *get_bts_user(){ -return "user\0"; -} -char *get_bts_password(){ -return "pass\0"; -} - diff --git a/mysc/keys/api_keys.h b/mysc/keys/api_keys.h index 963403ce..9073733d 100644 --- a/mysc/keys/api_keys.h +++ b/mysc/keys/api_keys.h @@ -3,10 +3,6 @@ char *get_api_key(); char *get_api_secret(); -char *get_dropbox_api_key(); -char *get_dropbox_api_secret(); char *get_twishort_api_key(); -char *get_bts_user(); -char *get_bts_password(); #endif