|
Mamoru Tasaka |
2626ad8 |
--- wallpapoz-0.6.1/src/wallpapoz.dircheck 2011-07-24 00:54:43.000000000 +0900
|
|
Mamoru Tasaka |
2626ad8 |
+++ wallpapoz-0.6.1/src/wallpapoz 2011-12-30 14:28:16.000000000 +0900
|
|
Mamoru Tasaka |
2626ad8 |
@@ -536,6 +536,9 @@
|
|
|
590772b |
# if recursive, we use walktree
|
|
Mamoru Tasaka |
2626ad8 |
if recursive_widget.get_active():
|
|
Mamoru Tasaka |
2626ad8 |
# looping with walktree method
|
|
|
590772b |
+ if not os.path.isdir(cur_dir):
|
|
|
590772b |
+ return
|
|
|
590772b |
+
|
|
Mamoru Tasaka |
2626ad8 |
for (basepath, children) in self.walktree(cur_dir,False):
|
|
Mamoru Tasaka |
2626ad8 |
for child in children:
|
|
Mamoru Tasaka |
2626ad8 |
# get the filename
|
|
Mamoru Tasaka |
2626ad8 |
@@ -551,7 +554,11 @@
|
|
|
590772b |
# if not just looping the directory with ordinary fashion
|
|
Mamoru Tasaka |
2626ad8 |
else:
|
|
Mamoru Tasaka |
2626ad8 |
# looping all files in this directory
|
|
Mamoru Tasaka |
2626ad8 |
- for file in os.listdir(cur_dir):
|
|
|
590772b |
+ try:
|
|
|
590772b |
+ dlist = os.listdir(cur_dir)
|
|
|
590772b |
+ except OSError:
|
|
|
590772b |
+ return
|
|
Mamoru Tasaka |
2626ad8 |
+ for file in dlist:
|
|
Mamoru Tasaka |
2626ad8 |
# get the filename
|
|
Mamoru Tasaka |
2626ad8 |
filename = os.path.join(cur_dir, file)
|
|
Mamoru Tasaka |
2626ad8 |
# we interested in file, not directory
|
|
Mamoru Tasaka |
2626ad8 |
@@ -573,6 +580,9 @@
|
|
|
590772b |
# if recursive, we use walktree
|
|
Mamoru Tasaka |
2626ad8 |
if recursive_widget.get_active():
|
|
Mamoru Tasaka |
2626ad8 |
# looping with walktree method
|
|
|
590772b |
+ if not os.path.isdir(cur_dir):
|
|
|
590772b |
+ return
|
|
|
590772b |
+
|
|
Mamoru Tasaka |
2626ad8 |
for (basepath, children) in self.walktree(cur_dir,False):
|
|
Mamoru Tasaka |
2626ad8 |
for child in children:
|
|
Mamoru Tasaka |
2626ad8 |
# get the filename
|
|
Mamoru Tasaka |
2626ad8 |
@@ -588,7 +598,11 @@
|
|
|
590772b |
# if not, just looping with ordinary fashion
|
|
|
590772b |
else:
|
|
Mamoru Tasaka |
2626ad8 |
# looping all files in this directory
|
|
Mamoru Tasaka |
2626ad8 |
- for file in os.listdir(cur_dir):
|
|
|
590772b |
+ try:
|
|
|
590772b |
+ ddir = os.listdir(cur_dir)
|
|
|
590772b |
+ except OSError:
|
|
|
590772b |
+ return
|
|
Mamoru Tasaka |
2626ad8 |
+ for file in ddir:
|
|
Mamoru Tasaka |
2626ad8 |
# get the filename
|
|
Mamoru Tasaka |
2626ad8 |
filename = os.path.join(cur_dir, file)
|
|
Mamoru Tasaka |
2626ad8 |
# we interested in file, not directory
|
|
Mamoru Tasaka |
2626ad8 |
@@ -618,6 +632,9 @@
|
|
|
590772b |
cur_dir = filechooser_widget.get_filename()
|
|
|
590772b |
# if recursive, we use walktree
|
|
|
590772b |
if recursive_widget.get_active():
|
|
|
590772b |
+ if not os.path.isdir(cur_dir):
|
|
|
590772b |
+ return
|
|
|
590772b |
+
|
|
Mamoru Tasaka |
2626ad8 |
# looping with walktree method
|
|
Mamoru Tasaka |
2626ad8 |
for (basepath, children) in self.walktree(cur_dir,False):
|
|
Mamoru Tasaka |
2626ad8 |
for child in children:
|
|
Mamoru Tasaka |
2626ad8 |
@@ -634,7 +651,11 @@
|
|
|
590772b |
# if not recursive, just looping the directory with ordinary fashion
|
|
|
590772b |
else:
|
|
Mamoru Tasaka |
2626ad8 |
# looping all files in this directory
|
|
Mamoru Tasaka |
2626ad8 |
- for file in os.listdir(cur_dir):
|
|
|
590772b |
+ try:
|
|
|
590772b |
+ dlist = os.listdir(cur_dir)
|
|
|
590772b |
+ except OSError:
|
|
|
590772b |
+ return
|
|
Mamoru Tasaka |
2626ad8 |
+ for file in dlist:
|
|
Mamoru Tasaka |
2626ad8 |
# get the filename
|
|
Mamoru Tasaka |
2626ad8 |
filename = os.path.join(cur_dir, file)
|
|
Mamoru Tasaka |
2626ad8 |
# we interested in file, not directory
|
|
Mamoru Tasaka |
2626ad8 |
@@ -1210,7 +1231,11 @@
|
|
|
590772b |
|
|
|
590772b |
# helping method
|
|
|
590772b |
def walktree (self, top = ".", depthfirst = True):
|
|
|
590772b |
- names = os.listdir(top)
|
|
|
590772b |
+ try:
|
|
|
590772b |
+ names = os.listdir(top)
|
|
|
590772b |
+ except OSError:
|
|
|
590772b |
+ names = []
|
|
|
590772b |
+ yield top, names
|
|
|
590772b |
if not depthfirst:
|
|
|
590772b |
yield top, names
|
|
|
590772b |
for name in names:
|