summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2008-07-18 22:44:45 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-07-18 22:44:45 +0000
commit7aa55c4b6458f0eb051ba7154e84eb974f8b0f20 (patch)
treef40a72a9b7976f8e874d3977f76b6444b55d70a0 /examples
parent7213af80481a6bc12588a5e74944b5c47ec30df4 (diff)
downloadpygobject-7aa55c4b6458f0eb051ba7154e84eb974f8b0f20.tar.gz
improve example: show error message and allow sys.argv[1] to be specified
svn path=/trunk/; revision=833
Diffstat (limited to 'examples')
-rw-r--r--examples/gio/directory-async.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/examples/gio/directory-async.py b/examples/gio/directory-async.py
index 439e62e4..49d2a4b0 100644
--- a/examples/gio/directory-async.py
+++ b/examples/gio/directory-async.py
@@ -1,17 +1,27 @@
+import sys
+
import gobject
import gio
def next_files_done(enumerator, result):
- print 'done!'
for file_info in enumerator.next_files_finish(result):
print file_info.get_name()
loop.quit()
def enumerate_children_done(gfile, result):
- enumerator = gfile.enumerate_children_finish(result)
+ try:
+ enumerator = gfile.enumerate_children_finish(result)
+ except gobject.GError, e:
+ print 'ERROR:', e
+ loop.quit()
+ return
enumerator.next_files_async(10, next_files_done)
-gfile = gio.File("/")
+if len(sys.argv) >= 2:
+ uri = sys.argv[1]
+else:
+ uri = "/"
+gfile = gio.File(uri)
gfile.enumerate_children_async(
"standard::name", enumerate_children_done)