Skip to content

Commit

Permalink
Merge pull request #365 from jeanslack/removing_external_drive
Browse files Browse the repository at this point in the history
Removing external drive
  • Loading branch information
jeanslack authored Oct 30, 2024
2 parents 58501e2 + a37a473 commit 604565e
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 30 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ License: GPL3
Change Log:

+------------------------------------+
Mon, 28 Oct 2024 V.5.0.21
Wed, 30 Oct 2024 V.5.0.21

* Update French language (thanks to Phil Aug).
* Update Spanish language (thanks to katnatek).
Expand All @@ -19,7 +19,15 @@ Mon, 28 Oct 2024 V.5.0.21
* Fixed some broken link.
* Fixed an issue when restoring the configuration directory, which copied
unnecessary files and directories.

* Fixed issue with using physically non-existent and access-denied output
paths (e.g. removing USB sticks, hard drives, etc.) which would inevitably
lead to an application reset during startup (Very annoying).
* Fixed NameError: name 'tarbal' is not defined. Did you mean: 'tarball'?
during presets download operation.
* Changed: Unlike portable mode, In installed mode output directories are no
longer automatically recreated if they do not exist.
* Changed the names of the default output directories when using the
application in portable mode (see Media/Transcoding + Media/Downloads).

+------------------------------------+
Sun, 28 July 2024 V.5.0.20
Expand Down
9 changes: 7 additions & 2 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ Installing on Linux/FreeBSD:
python3 -m pip install videomass

Optionally install yt-dlp:
python3 -m pip install yt-dlp
please read this before installing yt-dlp: https://github.com/yt-dlp/yt-dlp/pull/11255

python3 -m pip install "yt-dlp[default]"



Installing on Windows and MacOs:
Expand All @@ -110,7 +113,9 @@ Installing on Windows and MacOs:
python3 -m pip install videomass

Optionally install yt-dlp:
python3 -m pip install yt-dlp
please read this before installing yt-dlp: https://github.com/yt-dlp/yt-dlp/pull/11255

python3 -m pip install "yt-dlp[default]"


To Update on Windows, MacOs, Linux, FreeBSD:
Expand Down
13 changes: 11 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@ videomass (5.0.21-1) UNRELEASED; urgency=medium
* Fixed some broken link.
* Fixed an issue when restoring the configuration directory, which copied
unnecessary files and directories.

-- Gianluca Pernigotto <jeanlucperni@gmail.com> Mon, 28 Oct 2024 00:00:00 +0200
* Fixed issue with using physically non-existent and access-denied output
paths (e.g. removing USB sticks, hard drives, etc.) which would inevitably
lead to an application reset during startup (Very annoying).
* Fixed NameError: name 'tarbal' is not defined. Did you mean: 'tarball'?
during presets download operation.
* Changed: Unlike portable mode, In installed mode output directories are no
longer automatically recreated if they do not exist.
* Changed the names of the default output directories when using the
application in portable mode (see Media/Transcoding + Media/Downloads).

-- Gianluca Pernigotto <jeanlucperni@gmail.com> Wed, 30 Oct 2024 00:00:00 +0200

videomass (5.0.20-1) UNRELEASED; urgency=medium

Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-linux.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
videomass
yt-dlp
yt-dlp[default]
hatchling
build
wheel
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pypubsub
six
wxpython
requests
yt-dlp
yt-dlp[default]

# Requirements for Windows

6 changes: 3 additions & 3 deletions videomass/vdms_main/main_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Author: Gianluca Pernigotto <jeanlucperni@gmail.com>
Copyleft - 2024 Gianluca Pernigotto <jeanlucperni@gmail.com>
license: GPL3
Rev: June.24.2024
Rev: Oct.29.2024
Code checker: flake8, pylint
This file is part of Videomass.
Expand Down Expand Up @@ -867,8 +867,8 @@ def prst_downloader(self, event):
tarball = io_tools.get_github_releases(url, "tarball_url")

if tarball[0] in ['request error:', 'response error:']:
wx.MessageBox(f"{tarbal[0]} {tarbal[1]}",
f"{tarbal[0]}", wx.ICON_ERROR, self)
wx.MessageBox(f"{tarball[0]} {tarball[1]}",
f"{tarball[0]}", wx.ICON_ERROR, self)
return

name = f"Videomass-presets-{tarball[0].split('/v')[-1]}.tar.gz"
Expand Down
36 changes: 22 additions & 14 deletions videomass/vdms_sys/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,17 @@ def create_dirs(dirname, fconf):
if not os.path.exists(dirname):
try:
os.makedirs(dirname, mode=0o777)
except FileExistsError as err:
except Exception as err:
return {'ERROR': err}
except OSError as err:
os.remove(fconf) # force to restart on deleting
thismsg = ('Please try restarting Videomass to '
'restore default settings now.')
return {'ERROR': f'{err}\n{thismsg}'}

return {'R': None}


def restore_dirconf(dirconf, srcdata):
def restore_dirconf(dirconf, srcdata, portable):
"""
check existence of configuration directory
with possibility of restore.
This function is responsible for restoring the
configuration directory if it is missing and
populating it with its essential files.
Returns dict:
key == 'R'
key == ERROR (if any errors)
Expand All @@ -79,6 +75,17 @@ def restore_dirconf(dirconf, srcdata):
if drest:
return {'ERROR': drest}

if portable:
transoutdir = os.path.join(dirconf, "Media", "Transcoding")
dwlddir = os.path.join(dirconf, "Media", "Downloads")
try:
if not os.path.exists(transoutdir):
os.makedirs(transoutdir, mode=0o777)
if not os.path.exists(dwlddir):
os.makedirs(dwlddir, mode=0o777)
except Exception as err:
return {'ERROR': err}

return {'R': None}


Expand Down Expand Up @@ -111,6 +118,11 @@ def get_options(fileconf, makeportable):
conf.write_options()
data = {'R': conf.read_options()}

diff = conf.default_outputdirs(**data['R'])
if diff != data['R']:
conf.write_options(**diff) # write default outputdirs
data = {'R': conf.read_options()}

return data


Expand Down Expand Up @@ -159,9 +171,6 @@ def portable_paths(portdirname):
cache_dir = os.path.join(dir_conf, 'cache') # updates executable
trash_dir = os.path.join(dir_conf, "Trash")

if not os.path.exists(dir_conf):
os.makedirs(dir_conf, mode=0o777)

return file_conf, dir_conf, log_dir, cache_dir, trash_dir


Expand Down Expand Up @@ -307,6 +316,7 @@ def get_configuration(self):
# checks configuration directory
ckdconf = restore_dirconf(self.dataloc['confdir'],
self.dataloc['srcdata'],
self.makeportable,
)
if ckdconf.get('ERROR'):
return ckdconf
Expand All @@ -320,8 +330,6 @@ def get_configuration(self):
# create the required directories if not existing
requiredirs = (os.path.join(self.dataloc['cachedir'], 'tmp'),
self.dataloc['logdir'],
userconf['outputdir'],
userconf['ydlp-outputdir'],
self.dataloc['trashdir_default']
)
if not userconf['trashdir_loc'].strip():
Expand Down
27 changes: 22 additions & 5 deletions videomass/vdms_sys/settings_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Author: Gianluca Pernigotto <jeanlucperni@gmail.com>
Copyleft - 2024 Gianluca Pernigotto <jeanlucperni@gmail.com>
license: GPL3
Rev: Apr.09.2024
Rev: Oct.29.2024
Code checker: flake8, pylint
This file is part of Videomass.
Expand Down Expand Up @@ -301,10 +301,12 @@ def __init__(self, filename, makeportable=None):
self.filename = filename

if makeportable:
path = os.path.join(makeportable, "My_Files")
outputdir = os.path.relpath(path)
ConfigManager.DEFAULT_OPTIONS['outputdir'] = outputdir
ConfigManager.DEFAULT_OPTIONS['ydlp-outputdir'] = outputdir
trscodepath = os.path.join(makeportable, "Media", "Transcoding")
dwldpath = os.path.join(makeportable, "Media", "Downloads")
trscodedir = os.path.relpath(trscodepath)
dwlddir = os.path.relpath(dwldpath)
ConfigManager.DEFAULT_OPTIONS['outputdir'] = trscodedir
ConfigManager.DEFAULT_OPTIONS['ydlp-outputdir'] = dwlddir

def write_options(self, **options):
"""
Expand Down Expand Up @@ -338,3 +340,18 @@ def read_options(self):
return None

return options

def default_outputdirs(self, **options):
"""
Restores default output paths.
This method is needed to set the values of the `outputdir`
and `ydlp-outputdir` keys set to physically non-existent
filesystem paths (such as pendrives, hard-drives, etc.).
Returns a dictionary object.
"""
if not os.path.exists(options['outputdir']):
options['outputdir'] = f"{os.path.expanduser('~')}"
if not os.path.exists(options['ydlp-outputdir']):
options['ydlp-outputdir'] = f"{os.path.expanduser('~')}"

return options

0 comments on commit 604565e

Please sign in to comment.