From 3cae226a759be8e1c4e7ba749cb30309db470617 Mon Sep 17 00:00:00 2001 From: Gianluca Pernigotto Date: Tue, 15 Oct 2024 23:09:09 +0200 Subject: [PATCH 1/2] minor fixes --- CHANGELOG | 3 ++- debian/changelog | 3 ++- videomass/vdms_panels/concatenate.py | 25 ++++++---------------- videomass/vdms_panels/sequence_to_video.py | 6 ++---- videomass/vdms_panels/video_to_sequence.py | 10 ++++----- 5 files changed, 17 insertions(+), 30 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6b6b483a..468a7e81 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,7 +7,7 @@ License: GPL3 Change Log: +------------------------------------+ -Wed, 04 Sep 2024 V.5.0.21 +Sun, 13 Oct 2024 V.5.0.21 * Update French language (thanks to Phil Aug). * Update Spanish language (thanks to katnatek). @@ -16,6 +16,7 @@ Wed, 04 Sep 2024 V.5.0.21 * Improved build using pyproject.toml file. * Improved build using pyinstaller_setup.py file. * Improved requirements. + * Fixed some broken link. +------------------------------------+ diff --git a/debian/changelog b/debian/changelog index fceefe51..868d873d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,8 +7,9 @@ videomass (5.0.21-1) UNRELEASED; urgency=medium * Improved build using pyproject.toml file. * Improved build using pyinstaller_setup.py file. * Improved requirements. + * Fixed some broken link. - -- Gianluca Pernigotto Wed, 04 Sep 2024 16:00:00 +0200 + -- Gianluca Pernigotto Sun, 13 Oct 2024 12:00:00 +0200 videomass (5.0.20-1) UNRELEASED; urgency=medium diff --git a/videomass/vdms_panels/concatenate.py b/videomass/vdms_panels/concatenate.py index 3cecf53f..df678601 100644 --- a/videomass/vdms_panels/concatenate.py +++ b/videomass/vdms_panels/concatenate.py @@ -122,31 +122,20 @@ def __init__(self, parent): sizer_link2 = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(sizer_link2) self.lbl_msg3 = wx.StaticText(self, wx.ID_ANY, - label=_("For more details, see the " - "Videomass User Guide:") + label=_("Videomass Documentation:") ) - if self.appdata['GETLANG'] in self.appdata['SUPP_LANGs']: - lang = self.appdata['GETLANG'].split('_')[0] - page = (f"https://jeanslack.github.io/Videomass/" - f"Pages/User-guide-languages/{lang}/1-User_" - f"Interface_Overview_{lang}.pdf") - else: - page = ("https://jeanslack.github.io/Videomass/" - "Pages/User-guide-languages/en/1-User_" - "Interface_Overview_en.pdf" - ) - link2 = hpl.HyperLinkCtrl(self, -1, ("1.4 Concatenate media files " - "(demuxer)"), URL=page) + page = ("https://jeanslack.github.io/Videomass/User-guide/" + "User_Interface_Overview_en.pdf") + link2 = hpl.HyperLinkCtrl(self, -1, ("User Interface Overview"), + URL=page) sizer_link2.Add(self.lbl_msg3, 0, wx.ALL | wx.EXPAND, 5) sizer_link2.Add(link2) sizer_link1 = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(sizer_link1) self.lbl_msg2 = wx.StaticText(self, wx.ID_ANY, - label=_("For more information, " - "visit the official FFmpeg " - "documentation:") + label=_("Official FFmpeg documentation:") ) - link1 = hpl.HyperLinkCtrl(self, -1, "3.4 concat", + link1 = hpl.HyperLinkCtrl(self, -1, "Concat", URL="https://ffmpeg.org/ffmpeg-formats." "html#concat" ) diff --git a/videomass/vdms_panels/sequence_to_video.py b/videomass/vdms_panels/sequence_to_video.py index c63e77b2..b28ad5c2 100644 --- a/videomass/vdms_panels/sequence_to_video.py +++ b/videomass/vdms_panels/sequence_to_video.py @@ -205,11 +205,9 @@ def __init__(self, parent): sizer_link1 = wx.BoxSizer(wx.HORIZONTAL) fgs1.Add(sizer_link1) lbl_link = wx.StaticText(self, wx.ID_ANY, - label=_("For more information, " - "visit the official FFmpeg " - "documentation:") + label=_("Official FFmpeg documentation:") ) - link1 = hpl.HyperLinkCtrl(self, -1, ("FFmpeg Slideshow wiki"), + link1 = hpl.HyperLinkCtrl(self, -1, ("FFmpeg Slideshow Wiki"), URL="https://trac.ffmpeg.org/wiki/Slideshow" ) sizer_link1.Add(lbl_link, 0, wx.ALL | wx.EXPAND, 5) diff --git a/videomass/vdms_panels/video_to_sequence.py b/videomass/vdms_panels/video_to_sequence.py index cf364d7b..6c389723 100644 --- a/videomass/vdms_panels/video_to_sequence.py +++ b/videomass/vdms_panels/video_to_sequence.py @@ -178,15 +178,13 @@ def __init__(self, parent): sizer_link1 = wx.BoxSizer(wx.HORIZONTAL) fgs1.Add(sizer_link1) lbl_msg1 = wx.StaticText(self, wx.ID_ANY, - label=_("For more information, " - "visit the official FFmpeg " - "documentation:") + label=_("Official FFmpeg documentation:") ) - link1 = hpl.HyperLinkCtrl(self, -1, "4.19 image2", + link1 = hpl.HyperLinkCtrl(self, -1, "image2", URL="https://ffmpeg.org/ffmpeg-" - "formats.html#image2-2" + "formats.html#image2" ) - link2 = hpl.HyperLinkCtrl(self, -1, ("3.3 FFmpeg FAQ"), + link2 = hpl.HyperLinkCtrl(self, -1, ("FFmpeg FAQ"), URL="https://ffmpeg.org/faq.html#How-do-I-" "encode-movie-to-single-pictures_003f" ) From a8a2b0fc00497c7837813134fd6b7463a54356c3 Mon Sep 17 00:00:00 2001 From: Gianluca Pernigotto Date: Mon, 28 Oct 2024 18:34:49 +0100 Subject: [PATCH 2/2] minor fixes and code improvements --- CHANGELOG | 4 +- debian/changelog | 4 +- videomass/gui_app.py | 2 +- videomass/vdms_sys/configurator.py | 93 +++++++++++++----------------- 4 files changed, 47 insertions(+), 56 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 468a7e81..60f6fb49 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,7 +7,7 @@ License: GPL3 Change Log: +------------------------------------+ -Sun, 13 Oct 2024 V.5.0.21 +Mon, 28 Oct 2024 V.5.0.21 * Update French language (thanks to Phil Aug). * Update Spanish language (thanks to katnatek). @@ -17,6 +17,8 @@ Sun, 13 Oct 2024 V.5.0.21 * Improved build using pyinstaller_setup.py file. * Improved requirements. * Fixed some broken link. + * Fixed an issue when restoring the configuration directory, which copied + unnecessary files and directories. +------------------------------------+ diff --git a/debian/changelog b/debian/changelog index 868d873d..161b2432 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,8 +8,10 @@ videomass (5.0.21-1) UNRELEASED; urgency=medium * Improved build using pyinstaller_setup.py file. * Improved requirements. * Fixed some broken link. + * Fixed an issue when restoring the configuration directory, which copied + unnecessary files and directories. - -- Gianluca Pernigotto Sun, 13 Oct 2024 12:00:00 +0200 + -- Gianluca Pernigotto Mon, 28 Oct 2024 00:00:00 +0200 videomass (5.0.20-1) UNRELEASED; urgency=medium diff --git a/videomass/gui_app.py b/videomass/gui_app.py index 33a2d300..2a9ce6b3 100644 --- a/videomass/gui_app.py +++ b/videomass/gui_app.py @@ -72,7 +72,7 @@ def __init__(self, redirect=True, filename=None, **kwargs): # supported langs for online help (user guide) } self.data = DataSource(kwargs) # instance data - self.appset.update(self.data.get_fileconf()) # data system + self.appset.update(self.data.get_configuration()) # data system self.iconset = None wx.App.__init__(self, redirect, filename) # constructor diff --git a/videomass/vdms_sys/configurator.py b/videomass/vdms_sys/configurator.py index 216d6505..b999fecd 100644 --- a/videomass/vdms_sys/configurator.py +++ b/videomass/vdms_sys/configurator.py @@ -6,7 +6,7 @@ Author: Gianluca Pernigotto Copyleft - 2024 Gianluca Pernigotto license: GPL3 -Rev: June.14.2024 +Rev: Oct.28.2024 Code checker: flake8, pylint This file is part of Videomass. @@ -60,15 +60,21 @@ def create_dirs(dirname, fconf): return {'R': None} -def restore_presets_dir(dirconf, srcdata): +def restore_dirconf(dirconf, srcdata): """ - Restore preset directory from source if it doesn't exist. + check existence of configuration directory + with possibility of restore. Returns dict: key == 'R' key == ERROR (if any errors) """ + if not os.path.exists(dirconf): # create the configuration directory + try: + os.mkdir(dirconf, mode=0o777) + except FileNotFoundError as err: # parent directory does not exist + return {'ERROR': err} + if not os.path.exists(os.path.join(dirconf, "presets")): - # try to restoring presets directory on videomass dir drest = copydir_recursively(os.path.join(srcdata, "presets"), dirconf) if drest: return {'ERROR': drest} @@ -76,14 +82,13 @@ def restore_presets_dir(dirconf, srcdata): return {'R': None} -def get_options(dirconf, fileconf, srcdata, makeportable): +def get_options(fileconf, makeportable): """ Check the application options. Reads the `settings.json` file; if it does not exist or is unreadable try to restore - it. If `dirconf` does not exist try to restore both `dirconf` - and `settings.json`. If VERSION is not the same as the version - readed, it adds new missing items while preserving the old ones - with the same values. + it. If VERSION is not the same as the version readed, it adds + new missing items while preserving the old ones with the same + values. Returns dict: key == 'R' @@ -92,31 +97,19 @@ def get_options(dirconf, fileconf, srcdata, makeportable): conf = ConfigManager(fileconf, makeportable) version = ConfigManager.VERSION - if os.path.exists(dirconf): # i.e ~/.conf/videomass dir - if os.path.isfile(fileconf): - data = {'R': conf.read_options()} - if not data['R']: - conf.write_options() - data = {'R': conf.read_options()} - if float(data['R']['confversion']) != version: # conf version - data['R']['confversion'] = version - new = ConfigManager.DEFAULT_OPTIONS # model - data = {'R': {**new, **data['R']}} - conf.write_options(**data['R']) - else: - conf.write_options() - data = {'R': conf.read_options()} - - else: # try to restore entire configuration directory - dconf = copydir_recursively(srcdata, - os.path.dirname(dirconf), - "videomass", - ) - if dconf: - data = {'ERROR': dconf} - else: + if os.path.isfile(fileconf): + data = {'R': conf.read_options()} + if not data['R']: conf.write_options() data = {'R': conf.read_options()} + if float(data['R']['confversion']) != version: # conf version + data['R']['confversion'] = version + new = ConfigManager.DEFAULT_OPTIONS # model + data = {'R': {**new, **data['R']}} + conf.write_options(**data['R']) + else: + conf.write_options() + data = {'R': conf.read_options()} return data @@ -248,7 +241,7 @@ def data_location(kwargs): """ Determines data location and modes to make the app portable, fully portable or using conventional paths. - return data location. + Returns data location dict. """ if kwargs['make_portable']: portdir = kwargs['make_portable'] @@ -303,31 +296,27 @@ def __init__(self, kwargs): self.prg_icon = os.path.join(self.dataloc['icodir'], "videomass.png") # --------------------------------------------------------------------- - def get_fileconf(self): + def get_configuration(self): """ - Get settings.json configuration data and returns a dict object - with current data-set for bootstrap. + Get configuration data of the application. + Returns a dict object with current data-set for bootstrap. Note: If returns a dict key == ERROR it will raise a windowed fatal error in the gui_app bootstrap. """ + # checks configuration directory + ckdconf = restore_dirconf(self.dataloc['confdir'], + self.dataloc['srcdata'], + ) + if ckdconf.get('ERROR'): + return ckdconf + # handle configuration file - userconf = get_options(self.dataloc['confdir'], - self.dataloc['conffile'], - self.dataloc['srcdata'], - self.makeportable, - ) + userconf = get_options(self.dataloc['conffile'], self.makeportable) if userconf.get('ERROR'): return userconf userconf = userconf['R'] - # restore presets folder - presets_rest = restore_presets_dir(self.dataloc['confdir'], - self.dataloc['srcdata'], - ) - if presets_rest.get('ERROR'): - return presets_rest - # create the required directories if not existing requiredirs = (os.path.join(self.dataloc['cachedir'], 'tmp'), self.dataloc['logdir'], @@ -358,7 +347,7 @@ def _relativize(path, relative=self.relativepaths): try: return os.path.relpath(path) if relative else path except (ValueError, TypeError): - # return {'ERROR': f'{error}'} # use `as error` here + # return {'ERROR': f'{error}'} # used `as error` here return path return ({'ostype': platform.system(), @@ -386,11 +375,9 @@ def _relativize(path, relative=self.relativepaths): def icons_set(self, icontheme): """ - Determines icons set assignment defined on the configuration - file (see `Set icon themes map:`, on paragraph `6- GUI setup` - in the settings.json file). + Determines icons set assignment defined on the + configuration file. Returns a icontheme dict object. - """ keys = ('videomass', 'A/V-Conv', 'startconv', 'fileproperties', 'playback', 'concatenate', 'preview', 'clear',