Permalink
Browse files

clean temp folders properly, we have seen some issues with folders th…

…at couldn't be cleaned.
  • Loading branch information...
1 parent dd8eda2 commit 2c8931c019e62267bff9536ad968d802e0aa5d08 @amet committed May 23, 2012
Showing with 10 additions and 16 deletions.
  1. +4 −8 script.xbmc.subtitles/resources/lib/gui.py
  2. +6 −8 script.xbmc.subtitles/resources/lib/utilities.py
@@ -6,7 +6,6 @@
import xbmc
import urllib
import socket
-import xbmcvfs
import xbmcgui
import unicodedata
@@ -402,13 +401,10 @@ def Extract_Subtitles( self, zip_subs, subtitle_lang, gui = True ):
self.show_service_list(gui)
def clean_temp( self ):
- dirs = [self.stream_sub_dir,self.tmp_sub_dir]
- for temp_dir in dirs:
- if not xbmcvfs.exists(temp_dir):
- os.makedirs(temp_dir)
- else:
- rem_files(temp_dir)
-
+ for temp_dir in [self.stream_sub_dir,self.tmp_sub_dir]:
+ rem_files(temp_dir)
+
+
def show_service_list(self,gui):
try:
select_index = self.service_list.index(self.service)
@@ -6,6 +6,7 @@
import xbmc
import xbmcvfs
import xbmcgui
+import shutil
_ = sys.modules[ "__main__" ].__language__
__scriptname__ = sys.modules[ "__main__" ].__scriptname__
@@ -166,14 +167,11 @@ def unpause():
xbmc.Player().pause()
def rem_files(directory):
- try:
- for root, dirs, files in os.walk(directory, topdown=False):
- for items in dirs:
- xbmcvfs.rmdir(os.path.join(root.encode("utf-8"), items.encode("utf-8")))
- for name in files:
- xbmcvfs.delete(os.path.join(root.encode("utf-8"), name.encode("utf-8")))
- except:
- pass
+ if xbmcvfs.exists(directory):
+ shutil.rmtree(directory)
+ xbmcvfs.mkdir(directory)
+
+
def copy_files( subtitle_file, file_path ):
subtitle_set = False

0 comments on commit 2c8931c

Please sign in to comment.