Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for write permissions #401

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions youtube_dl_gui/__init__.py
Expand Up @@ -51,6 +51,7 @@
get_config_path,
get_locale_file,
os_path_exists,
check_pers,
YOUTUBEDL_BIN
)

Expand Down Expand Up @@ -83,10 +84,16 @@ def main():
"""The real main. Creates and calls the main app windows. """
youtubedl_path = os.path.join(opt_manager.options["youtubedl_path"], YOUTUBEDL_BIN)


app = wx.App()
if not check_pers():
wx.MessageBox(_("The path:{0} is not writable".format(config_path)), _("Permissions denied"), wx.OK | wx.ICON_ERROR)
return False

frame = MainFrame(opt_manager, log_manager)
frame.Show()


if opt_manager.options["disable_update"] and not os_path_exists(youtubedl_path):
wx.MessageBox(_("Failed to locate youtube-dl and updates are disabled"), _("Error"), wx.OK | wx.ICON_ERROR)
frame.close()
Expand Down
1 change: 1 addition & 0 deletions youtube_dl_gui/logmanager.py
Expand Up @@ -5,6 +5,7 @@

from __future__ import unicode_literals


import os.path
from time import strftime

Expand Down
12 changes: 12 additions & 0 deletions youtube_dl_gui/utils.py
Expand Up @@ -16,6 +16,7 @@
import sys
import json
import math
import errno
import locale
import subprocess

Expand Down Expand Up @@ -193,6 +194,17 @@ def get_config_path():
return os.path.join(path, __appname__.lower())


def check_pers():
path = get_config_path()
try:
with open(path + '/tst.log', 'w') as f:
# opened for writing. write to it here
return True
except IOError as x:
if x.errno == errno.EACCES:
print('Permissions Denied, check {0}'.format(path))
return False

def shutdown_sys(password=None):
"""Shuts down the system.
Returns True if no errors occur else False.
Expand Down