diff --git a/youtube_dl_gui/__init__.py b/youtube_dl_gui/__init__.py index d8c0fe2b..9822e399 100644 --- a/youtube_dl_gui/__init__.py +++ b/youtube_dl_gui/__init__.py @@ -51,6 +51,7 @@ get_config_path, get_locale_file, os_path_exists, + check_pers, YOUTUBEDL_BIN ) @@ -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() diff --git a/youtube_dl_gui/logmanager.py b/youtube_dl_gui/logmanager.py index 86e5834c..8aa9b86e 100644 --- a/youtube_dl_gui/logmanager.py +++ b/youtube_dl_gui/logmanager.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals + import os.path from time import strftime diff --git a/youtube_dl_gui/utils.py b/youtube_dl_gui/utils.py index 729c0079..104199b3 100644 --- a/youtube_dl_gui/utils.py +++ b/youtube_dl_gui/utils.py @@ -16,6 +16,7 @@ import sys import json import math +import errno import locale import subprocess @@ -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.