[Xcb-commit] XcbPythonBinding.mdwn

XCB site xcb at freedesktop.org
Sun Jun 15 11:08:57 PDT 2008


 XcbPythonBinding.mdwn |   82 +++++++++++++++++++++++++-------------------------
 1 file changed, 42 insertions(+), 40 deletions(-)

New commits:
commit b0831d3877484f4251f0f30e9a892161faa7d88a
Author: XCB site <xcb at freedesktop.org>
Date:   Sun Jun 15 11:08:57 2008 -0700

    web commit by AstralStorm: forgot to indent

diff --git a/XcbPythonBinding.mdwn b/XcbPythonBinding.mdwn
index d9e992a..f1b94a3 100644
--- a/XcbPythonBinding.mdwn
+++ b/XcbPythonBinding.mdwn
@@ -171,43 +171,45 @@ The following complete program creates a window, sets a property, and does some
 The above example doesn't include XAuthority file parsing. To parse that file and connect to the X server,
 you can use code like this:
 
-import struct
-import os
-
-# Some libXau constants
-FamilyWild = 0
-FamilyLocal = 256
-# Some hacked libXau constants
-FamilyIPv6 = 6
-# FamilyWildIPv6 = ?
-
-
-def read_counted_string(f):
-    slen = struct.unpack("!H", f.read(2))[0]
-    return f.read(slen)
-
-# Grab XAuth data
-xauth={}
-xauthfile = open(os.environ["XAUTHORITY"])
-try:
-    while 1:
-        family = struct.unpack("!H", xauthfile.read(2))[0]
-        addr = read_counted_string(xauthfile)
-        if family != FamilyWild:
-            if family == FamilyLocal or family == FamilyIPv6:
-                addr = ""
-            else:
-                raise Exception("Unknown address family, fix me quickly")
-        number = read_counted_string(xauthfile)
-        name = read_counted_string(xauthfile)
-        data = read_counted_string(xauthfile)
-        xauth[addr + ":" + number] = name + ":" + data
-except struct.error:
-    pass
-finally:
-    xauthfile.close()
-
-try:
-    conn = xcb.connect(display=os.environ["DISPLAY"], auth=xauth[os.environ["DISPLAY"]])
-except KeyError:
-    conn = xcb.connect(display=os.environ["DISPLAY"])
+    import struct
+    import os
+
+    # Some libXau constants
+    FamilyWild = 0
+    FamilyLocal = 256
+    # Some hacked libXau constants
+    FamilyIPv6 = 6
+    # FamilyWildIPv6 = ?
+
+
+    def read_counted_string(f):
+        slen = struct.unpack("!H", f.read(2))[0]
+        return f.read(slen)
+
+    # Grab XAuth data
+    xauth={}
+    xauthfile = open(os.environ["XAUTHORITY"])
+    try:
+        while 1:
+            family = struct.unpack("!H", xauthfile.read(2))[0]
+            addr = read_counted_string(xauthfile)
+            if family != FamilyWild:
+                if family == FamilyLocal or family == FamilyIPv6:
+                    addr = ""
+                else:
+                    raise Exception("Unknown address family, fix me quickly")
+            number = read_counted_string(xauthfile)
+            name = read_counted_string(xauthfile)
+            data = read_counted_string(xauthfile)
+            xauth[addr + ":" + number] = name + ":" + data
+    except IOError:
+        pass
+    except struct.error:
+        pass
+    finally:
+        xauthfile.close()
+
+    try:
+        conn = xcb.connect(display=os.environ["DISPLAY"], auth=xauth[os.environ["DISPLAY"]])
+    except KeyError:
+        conn = xcb.connect(display=os.environ["DISPLAY"])


More information about the xcb-commit mailing list