Skip to content

Commit

Permalink
fix crash if datadir doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
bkiziuk committed May 31, 2019
1 parent 0fe1204 commit d51ce6d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
5 changes: 3 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
<disclaimer lang="hu_HU">Egy teljeskörű felirat asszisztens</disclaimer>
<disclaimer lang="pl_PL">Wszechstronny asystent napisów</disclaimer>
<disclaimer lang="sk_SK">Kompletný sprievodca titukly</disclaimer>
<news>v1.4.1 (2019-05-08)
- change definitions URL to update directly from SubsMagler master branch
<news>v1.4.1 (2019-06-01)
- change definitions URL to update directly from SubsMangler master branch
- fix creating data-dir before initiating external log file
v1.4.0 (2019-04-06)
- support for subtitles for internet streams
v1.3.1 (2019-04-01)
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v1.4.1 (2019-06-01)
- change definitions URL to update directly from SubsMangler master branch
- fix creating data-dir before initiating external log file
v1.4.0 (2019-04-06)
- support for subtitles for internet streams
v1.3.1 (2019-04-01)
Expand Down
16 changes: 16 additions & 0 deletions resources/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@
__addonlang__ = __addon__.getLocalizedString
__kodiversion__ = xbmc.getInfoLabel('System.BuildVersion')[:4]



# prepare datadir
# directory and file is local to the filesystem
# no need to use xbmcvfs
if not os.path.isdir(__addonworkdir__):
xbmc.log("SubsMangler: profile directory doesn't exist: " + __addonworkdir__.encode('utf-8') + " Trying to create.", level=xbmc.LOGNOTICE)
try:
os.mkdir(__addonworkdir__)
xbmc.log("SubsMangler: profile directory created: " + __addonworkdir__.encode('utf-8'), level=xbmc.LOGNOTICE)
except OSError as e:
xbmc.log("SubsMangler: Log: can't create directory: " + __addonworkdir__.encode('utf-8'), level=xbmc.LOGERROR)
xbmc.log("Exception: " + str(e.message).encode('utf-8'), xbmc.LOGERROR)



# prepare external log handler
# https://docs.python.org/2/library/logging.handlers.html
global logger
Expand Down
12 changes: 0 additions & 12 deletions resources/lib/smangler.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,6 @@ def PreparePlugin():
global ClockTick
ClockTick = 0

# prepare datadir
# directory and file is local to the filesystem
# no need to use xbmcvfs
if not os.path.isdir(common.__addonworkdir__):
xbmc.log("SubsMangler: profile directory doesn't exist: " + common.__addonworkdir__.encode('utf-8') + " Trying to create.", level=xbmc.LOGNOTICE)
try:
os.mkdir(common.__addonworkdir__)
xbmc.log("SubsMangler: profile directory created: " + common.__addonworkdir__.encode('utf-8'), level=xbmc.LOGNOTICE)
except OSError as e:
xbmc.log("SubsMangler: Log: can't create directory: " + common.__addonworkdir__.encode('utf-8'), level=xbmc.LOGERROR)
xbmc.log("Exception: " + str(e.message).encode('utf-8'), xbmc.LOGERROR)

# load settings
common.GetSettings()

Expand Down

0 comments on commit d51ce6d

Please sign in to comment.