pygobject r833 - trunk/examples/gio



Author: johan
Date: Fri Jul 18 22:44:45 2008
New Revision: 833
URL: http://svn.gnome.org/viewvc/pygobject?rev=833&view=rev

Log:
improve example: show error message and allow sys.argv[1] to be specified

Modified:
   trunk/examples/gio/directory-async.py

Modified: trunk/examples/gio/directory-async.py
==============================================================================
--- trunk/examples/gio/directory-async.py	(original)
+++ trunk/examples/gio/directory-async.py	Fri Jul 18 22:44:45 2008
@@ -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)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]