--- wallpapoz-0.4.1-svn92_trunk/src/wallpapoz.dircheck 2010-02-08 02:25:38.000000000 +0900 +++ wallpapoz-0.4.1-svn92_trunk/src/wallpapoz 2010-02-08 02:16:08.000000000 +0900 @@ -538,6 +538,9 @@ # if recursive, we use walktree if recursive_widget.get_active(): # looping with walktree method + if not os.path.isdir(cur_dir): + return + for (basepath, children) in self.walktree(cur_dir,False): for child in children: # get the filename @@ -553,7 +556,11 @@ # if not just looping the directory with ordinary fashion else: # looping all files in this directory - for file in os.listdir(cur_dir): + try: + dlist = os.listdir(cur_dir) + except OSError: + return + for file in dlist: # get the filename filename = os.path.join(cur_dir, file) # we interested in file, not directory @@ -575,6 +582,9 @@ # if recursive, we use walktree if recursive_widget.get_active(): # looping with walktree method + if not os.path.isdir(cur_dir): + return + for (basepath, children) in self.walktree(cur_dir,False): for child in children: # get the filename @@ -590,7 +600,11 @@ # if not, just looping with ordinary fashion else: # looping all files in this directory - for file in os.listdir(cur_dir): + try: + ddir = os.listdir(cur_dir) + except OSError: + return + for file in ddir: # get the filename filename = os.path.join(cur_dir, file) # we interested in file, not directory @@ -620,6 +634,9 @@ cur_dir = filechooser_widget.get_filename() # if recursive, we use walktree if recursive_widget.get_active(): + if not os.path.isdir(cur_dir): + return + # looping with walktree method for (basepath, children) in self.walktree(cur_dir,False): for child in children: @@ -636,7 +653,11 @@ # if not recursive, just looping the directory with ordinary fashion else: # looping all files in this directory - for file in os.listdir(cur_dir): + try: + dlist = os.listdir(cur_dir) + except OSError: + return + for file in dlist: # get the filename filename = os.path.join(cur_dir, file) # we interested in file, not directory @@ -1219,7 +1240,11 @@ # helping method def walktree (self, top = ".", depthfirst = True): - names = os.listdir(top) + try: + names = os.listdir(top) + except OSError: + names = [] + yield top, names if not depthfirst: yield top, names for name in names: