[gDesklets] "Could not open display" error



In trying to run a script like ctrlinfo or test-control.py without X
running, I (and others) have been getting an error trying to display the
"Could not open display" error.  The problem looks like it stems from an
import of 'main' and I think I've tracked it down to the following code.
However, for the purposes of these scripts this variable isn't really
needed.  I wanted to get some feedback on the following patch before I
committed it.  It tries to show the error and the DISPLAY environment
variable, but if it doesn't exist it prints out some more information and
tries to stumble along (instead of calling sys.exit()).  Any thoughts?

Thanks,
Joe

--------------------------------------

--- main/__init__.py    2010-05-23 21:46:43 +0000
+++ main/__init__.py    2010-05-23 21:45:02 +0000
@@ -16,8 +16,11 @@
     # case the DISPLAY variable doesn't contain the screen number)
     DISPLAY =
vfs.escape_path(gtk.gdk.Display(os.environ["DISPLAY"]).get_name()).replace("/",
"_")
 except:
-    print "Error: could not open display", os.environ["DISPLAY"]
-    sys.exit(1)
+    try:
+        print >> sys.stderr, "Error: could not open display",
os.environ["DISPLAY"]
+    except:
+        print >> sys.stderr, "(could not get DISPLAY environment variable)"
+    DISPLAY = "0"


 # the name of the purge key



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