From 66b67e7725346b0924fe1f57992a5e30f630fac6 Mon Sep 17 00:00:00 2001 From: Declan Qian Date: Mon, 28 Dec 2015 08:51:27 +0800 Subject: [PATCH 001/279] change darwin socket path to /private/tmp --- Xlib/support/unix_connect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index 87a3a59d..2939895d 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -73,7 +73,7 @@ def get_display(display): def get_socket(dname, host, dno): try: # Darwin funky socket - if (uname[0] == 'Darwin') and host and host.startswith('/tmp/'): + if (uname[0] == 'Darwin') and host and host.startswith('/private/tmp/'): s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect(dname) @@ -97,7 +97,7 @@ def get_socket(dname, host, dno): def new_get_auth(sock, dname, host, dno): # Translate socket address into the xauth domain - if (uname[0] == 'Darwin') and host and host.startswith('/tmp/'): + if (uname[0] == 'Darwin') and host and host.startswith('/private/tmp/'): family = xauth.FamilyLocal addr = socket.gethostname() From 8a958a821653d4ba54e5de18c01dbdac963671bc Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 27 Mar 2016 16:28:17 +0300 Subject: [PATCH 002/279] Fix formatting (replace tabs with spaces). --- Xlib/keysymdef/xf86.py | 347 ++++++++++++++++++++--------------------- 1 file changed, 173 insertions(+), 174 deletions(-) diff --git a/Xlib/keysymdef/xf86.py b/Xlib/keysymdef/xf86.py index a0d79aef..2640535c 100644 --- a/Xlib/keysymdef/xf86.py +++ b/Xlib/keysymdef/xf86.py @@ -1,179 +1,178 @@ -XK_XF86_MonBrightnessUp = 0x1008FF02 -XK_XF86_MonBrightnessDown = 0x1008FF03 -XK_XF86_KbdLightOnOff = 0x1008FF04 -XK_XF86_KbdBrightnessUp = 0x1008FF05 -XK_XF86_KbdBrightnessDown = 0x1008FF06 +XK_XF86_MonBrightnessUp = 0x1008FF02 +XK_XF86_MonBrightnessDown = 0x1008FF03 +XK_XF86_KbdLightOnOff = 0x1008FF04 +XK_XF86_KbdBrightnessUp = 0x1008FF05 +XK_XF86_KbdBrightnessDown = 0x1008FF06 -XK_XF86_Standby = 0x1008FF10 -XK_XF86_AudioLowerVolume = 0x1008FF11 -XK_XF86_AudioMute = 0x1008FF12 -XK_XF86_AudioRaiseVolume = 0x1008FF13 -XK_XF86_AudioPlay = 0x1008FF14 -XK_XF86_AudioStop = 0x1008FF15 -XK_XF86_AudioPrev = 0x1008FF16 -XK_XF86_AudioNext = 0x1008FF17 -XK_XF86_HomePage = 0x1008FF18 -XK_XF86_Mail = 0x1008FF19 -XK_XF86_Start = 0x1008FF1A -XK_XF86_Search = 0x1008FF1B -XK_XF86_AudioRecord = 0x1008FF1C +XK_XF86_Standby = 0x1008FF10 +XK_XF86_AudioLowerVolume = 0x1008FF11 +XK_XF86_AudioMute = 0x1008FF12 +XK_XF86_AudioRaiseVolume = 0x1008FF13 +XK_XF86_AudioPlay = 0x1008FF14 +XK_XF86_AudioStop = 0x1008FF15 +XK_XF86_AudioPrev = 0x1008FF16 +XK_XF86_AudioNext = 0x1008FF17 +XK_XF86_HomePage = 0x1008FF18 +XK_XF86_Mail = 0x1008FF19 +XK_XF86_Start = 0x1008FF1A +XK_XF86_Search = 0x1008FF1B +XK_XF86_AudioRecord = 0x1008FF1C -XK_XF86_Calculator = 0x1008FF1D -XK_XF86_Memo = 0x1008FF1E -XK_XF86_ToDoList = 0x1008FF1F -XK_XF86_Calendar = 0x1008FF20 -XK_XF86_PowerDown = 0x1008FF21 -XK_XF86_ContrastAdjust = 0x1008FF22 -XK_XF86_RockerUp = 0x1008FF23 -XK_XF86_RockerDown = 0x1008FF24 -XK_XF86_RockerEnter = 0x1008FF25 +XK_XF86_Calculator = 0x1008FF1D +XK_XF86_Memo = 0x1008FF1E +XK_XF86_ToDoList = 0x1008FF1F +XK_XF86_Calendar = 0x1008FF20 +XK_XF86_PowerDown = 0x1008FF21 +XK_XF86_ContrastAdjust = 0x1008FF22 +XK_XF86_RockerUp = 0x1008FF23 +XK_XF86_RockerDown = 0x1008FF24 +XK_XF86_RockerEnter = 0x1008FF25 -XK_XF86_Back = 0x1008FF26 -XK_XF86_Forward = 0x1008FF27 -XK_XF86_Stop = 0x1008FF28 -XK_XF86_Refresh = 0x1008FF29 -XK_XF86_PowerOff = 0x1008FF2A -XK_XF86_WakeUp = 0x1008FF2B -XK_XF86_Eject = 0x1008FF2C -XK_XF86_ScreenSaver = 0x1008FF2D -XK_XF86_WWW = 0x1008FF2E -XK_XF86_Sleep = 0x1008FF2F -XK_XF86_Favorites = 0x1008FF30 -XK_XF86_AudioPause = 0x1008FF31 -XK_XF86_AudioMedia = 0x1008FF32 -XK_XF86_MyComputer = 0x1008FF33 -XK_XF86_VendorHome = 0x1008FF34 -XK_XF86_LightBulb = 0x1008FF35 -XK_XF86_Shop = 0x1008FF36 -XK_XF86_History = 0x1008FF37 -XK_XF86_OpenURL = 0x1008FF38 -XK_XF86_AddFavorite = 0x1008FF39 -XK_XF86_HotLinks = 0x1008FF3A -XK_XF86_BrightnessAdjust = 0x1008FF3B -XK_XF86_Finance = 0x1008FF3C -XK_XF86_Community = 0x1008FF3D -XK_XF86_AudioRewind = 0x1008FF3E -XK_XF86_XF86BackForward = 0x1008FF3F -XK_XF86_Launch0 = 0x1008FF40 -XK_XF86_Launch1 = 0x1008FF41 -XK_XF86_Launch2 = 0x1008FF42 -XK_XF86_Launch3 = 0x1008FF43 -XK_XF86_Launch4 = 0x1008FF44 -XK_XF86_Launch5 = 0x1008FF45 -XK_XF86_Launch6 = 0x1008FF46 -XK_XF86_Launch7 = 0x1008FF47 -XK_XF86_Launch8 = 0x1008FF48 -XK_XF86_Launch9 = 0x1008FF49 -XK_XF86_LaunchA = 0x1008FF4A -XK_XF86_LaunchB = 0x1008FF4B -XK_XF86_LaunchC = 0x1008FF4C -XK_XF86_LaunchD = 0x1008FF4D -XK_XF86_LaunchE = 0x1008FF4E -XK_XF86_LaunchF = 0x1008FF4F +XK_XF86_Back = 0x1008FF26 +XK_XF86_Forward = 0x1008FF27 +XK_XF86_Stop = 0x1008FF28 +XK_XF86_Refresh = 0x1008FF29 +XK_XF86_PowerOff = 0x1008FF2A +XK_XF86_WakeUp = 0x1008FF2B +XK_XF86_Eject = 0x1008FF2C +XK_XF86_ScreenSaver = 0x1008FF2D +XK_XF86_WWW = 0x1008FF2E +XK_XF86_Sleep = 0x1008FF2F +XK_XF86_Favorites = 0x1008FF30 +XK_XF86_AudioPause = 0x1008FF31 +XK_XF86_AudioMedia = 0x1008FF32 +XK_XF86_MyComputer = 0x1008FF33 +XK_XF86_VendorHome = 0x1008FF34 +XK_XF86_LightBulb = 0x1008FF35 +XK_XF86_Shop = 0x1008FF36 +XK_XF86_History = 0x1008FF37 +XK_XF86_OpenURL = 0x1008FF38 +XK_XF86_AddFavorite = 0x1008FF39 +XK_XF86_HotLinks = 0x1008FF3A +XK_XF86_BrightnessAdjust = 0x1008FF3B +XK_XF86_Finance = 0x1008FF3C +XK_XF86_Community = 0x1008FF3D +XK_XF86_AudioRewind = 0x1008FF3E +XK_XF86_XF86BackForward = 0x1008FF3F +XK_XF86_Launch0 = 0x1008FF40 +XK_XF86_Launch1 = 0x1008FF41 +XK_XF86_Launch2 = 0x1008FF42 +XK_XF86_Launch3 = 0x1008FF43 +XK_XF86_Launch4 = 0x1008FF44 +XK_XF86_Launch5 = 0x1008FF45 +XK_XF86_Launch6 = 0x1008FF46 +XK_XF86_Launch7 = 0x1008FF47 +XK_XF86_Launch8 = 0x1008FF48 +XK_XF86_Launch9 = 0x1008FF49 +XK_XF86_LaunchA = 0x1008FF4A +XK_XF86_LaunchB = 0x1008FF4B +XK_XF86_LaunchC = 0x1008FF4C +XK_XF86_LaunchD = 0x1008FF4D +XK_XF86_LaunchE = 0x1008FF4E +XK_XF86_LaunchF = 0x1008FF4F -XK_XF86_ApplicationLeft = 0x1008FF50 -XK_XF86_ApplicationRight = 0x1008FF51 -XK_XF86_Book = 0x1008FF52 -XK_XF86_CD = 0x1008FF53 -XK_XF86_Calculater = 0x1008FF54 -XK_XF86_Clear = 0x1008FF55 -XK_XF86_Close = 0x1008FF56 -XK_XF86_Copy = 0x1008FF57 -XK_XF86_Cut = 0x1008FF58 -XK_XF86_Display = 0x1008FF59 -XK_XF86_DOS = 0x1008FF5A -XK_XF86_Documents = 0x1008FF5B -XK_XF86_Excel = 0x1008FF5C -XK_XF86_Explorer = 0x1008FF5D -XK_XF86_Game = 0x1008FF5E -XK_XF86_Go = 0x1008FF5F -XK_XF86_iTouch = 0x1008FF60 -XK_XF86_LogOff = 0x1008FF61 -XK_XF86_Market = 0x1008FF62 -XK_XF86_Meeting = 0x1008FF63 -XK_XF86_MenuKB = 0x1008FF65 -XK_XF86_MenuPB = 0x1008FF66 -XK_XF86_MySites = 0x1008FF67 -XK_XF86_New = 0x1008FF68 -XK_XF86_News = 0x1008FF69 -XK_XF86_OfficeHome = 0x1008FF6A -XK_XF86_Open = 0x1008FF6B -XK_XF86_Option = 0x1008FF6C -XK_XF86_Paste = 0x1008FF6D -XK_XF86_Phone = 0x1008FF6E -XK_XF86_Q = 0x1008FF70 -XK_XF86_Reply = 0x1008FF72 -XK_XF86_Reload = 0x1008FF73 -XK_XF86_RotateWindows = 0x1008FF74 -XK_XF86_RotationPB = 0x1008FF75 -XK_XF86_RotationKB = 0x1008FF76 -XK_XF86_Save = 0x1008FF77 -XK_XF86_ScrollUp = 0x1008FF78 -XK_XF86_ScrollDown = 0x1008FF79 -XK_XF86_ScrollClick = 0x1008FF7A -XK_XF86_Send = 0x1008FF7B -XK_XF86_Spell = 0x1008FF7C -XK_XF86_SplitScreen = 0x1008FF7D -XK_XF86_Support = 0x1008FF7E -XK_XF86_TaskPane = 0x1008FF7F -XK_XF86_Terminal = 0x1008FF80 -XK_XF86_Tools = 0x1008FF81 -XK_XF86_Travel = 0x1008FF82 -XK_XF86_UserPB = 0x1008FF84 -XK_XF86_User1KB = 0x1008FF85 -XK_XF86_User2KB = 0x1008FF86 -XK_XF86_Video = 0x1008FF87 -XK_XF86_WheelButton = 0x1008FF88 -XK_XF86_Word = 0x1008FF89 -XK_XF86_Xfer = 0x1008FF8A -XK_XF86_ZoomIn = 0x1008FF8B -XK_XF86_ZoomOut = 0x1008FF8C - -XK_XF86_Away = 0x1008FF8D -XK_XF86_Messenger = 0x1008FF8E -XK_XF86_WebCam = 0x1008FF8F -XK_XF86_MailForward = 0x1008FF90 -XK_XF86_Pictures = 0x1008FF91 -XK_XF86_Music = 0x1008FF92 - -XK_XF86_Battery = 0x1008FF93 -XK_XF86_Bluetooth = 0x1008FF94 -XK_XF86_WLAN = 0x1008FF95 -XK_XF86_UWB = 0x1008FF96 - -XK_XF86_AudioForward = 0x1008FF97 -XK_XF86_AudioRepeat = 0x1008FF98 -XK_XF86_AudioRandomPlay = 0x1008FF99 -XK_XF86_Subtitle = 0x1008FF9A -XK_XF86_AudioCycleTrack = 0x1008FF9B -XK_XF86_CycleAngle = 0x1008FF9C -XK_XF86_FrameBack = 0x1008FF9D -XK_XF86_FrameForward = 0x1008FF9E -XK_XF86_Time = 0x1008FF9F -XK_XF86_Select = 0x1008FFA0 -XK_XF86_View = 0x1008FFA1 -XK_XF86_TopMenu = 0x1008FFA2 - -XK_XF86_Red = 0x1008FFA3 -XK_XF86_Green = 0x1008FFA4 -XK_XF86_Yellow = 0x1008FFA5 -XK_XF86_Blue = 0x1008FFA6 - -XK_XF86_Switch_VT_1 = 0x1008FE01 -XK_XF86_Switch_VT_2 = 0x1008FE02 -XK_XF86_Switch_VT_3 = 0x1008FE03 -XK_XF86_Switch_VT_4 = 0x1008FE04 -XK_XF86_Switch_VT_5 = 0x1008FE05 -XK_XF86_Switch_VT_6 = 0x1008FE06 -XK_XF86_Switch_VT_7 = 0x1008FE07 -XK_XF86_Switch_VT_8 = 0x1008FE08 -XK_XF86_Switch_VT_9 = 0x1008FE09 -XK_XF86_Switch_VT_10 = 0x1008FE0A -XK_XF86_Switch_VT_11 = 0x1008FE0B -XK_XF86_Switch_VT_12 = 0x1008FE0C - -XK_XF86_Ungrab = 0x1008FE20 -XK_XF86_ClearGrab = 0x1008FE21 -XK_XF86_Next_VMode = 0x1008FE22 -XK_XF86_Prev_VMode = 0x1008FE23 +XK_XF86_ApplicationLeft = 0x1008FF50 +XK_XF86_ApplicationRight = 0x1008FF51 +XK_XF86_Book = 0x1008FF52 +XK_XF86_CD = 0x1008FF53 +XK_XF86_Calculater = 0x1008FF54 +XK_XF86_Clear = 0x1008FF55 +XK_XF86_Close = 0x1008FF56 +XK_XF86_Copy = 0x1008FF57 +XK_XF86_Cut = 0x1008FF58 +XK_XF86_Display = 0x1008FF59 +XK_XF86_DOS = 0x1008FF5A +XK_XF86_Documents = 0x1008FF5B +XK_XF86_Excel = 0x1008FF5C +XK_XF86_Explorer = 0x1008FF5D +XK_XF86_Game = 0x1008FF5E +XK_XF86_Go = 0x1008FF5F +XK_XF86_iTouch = 0x1008FF60 +XK_XF86_LogOff = 0x1008FF61 +XK_XF86_Market = 0x1008FF62 +XK_XF86_Meeting = 0x1008FF63 +XK_XF86_MenuKB = 0x1008FF65 +XK_XF86_MenuPB = 0x1008FF66 +XK_XF86_MySites = 0x1008FF67 +XK_XF86_New = 0x1008FF68 +XK_XF86_News = 0x1008FF69 +XK_XF86_OfficeHome = 0x1008FF6A +XK_XF86_Open = 0x1008FF6B +XK_XF86_Option = 0x1008FF6C +XK_XF86_Paste = 0x1008FF6D +XK_XF86_Phone = 0x1008FF6E +XK_XF86_Q = 0x1008FF70 +XK_XF86_Reply = 0x1008FF72 +XK_XF86_Reload = 0x1008FF73 +XK_XF86_RotateWindows = 0x1008FF74 +XK_XF86_RotationPB = 0x1008FF75 +XK_XF86_RotationKB = 0x1008FF76 +XK_XF86_Save = 0x1008FF77 +XK_XF86_ScrollUp = 0x1008FF78 +XK_XF86_ScrollDown = 0x1008FF79 +XK_XF86_ScrollClick = 0x1008FF7A +XK_XF86_Send = 0x1008FF7B +XK_XF86_Spell = 0x1008FF7C +XK_XF86_SplitScreen = 0x1008FF7D +XK_XF86_Support = 0x1008FF7E +XK_XF86_TaskPane = 0x1008FF7F +XK_XF86_Terminal = 0x1008FF80 +XK_XF86_Tools = 0x1008FF81 +XK_XF86_Travel = 0x1008FF82 +XK_XF86_UserPB = 0x1008FF84 +XK_XF86_User1KB = 0x1008FF85 +XK_XF86_User2KB = 0x1008FF86 +XK_XF86_Video = 0x1008FF87 +XK_XF86_WheelButton = 0x1008FF88 +XK_XF86_Word = 0x1008FF89 +XK_XF86_Xfer = 0x1008FF8A +XK_XF86_ZoomIn = 0x1008FF8B +XK_XF86_ZoomOut = 0x1008FF8C +XK_XF86_Away = 0x1008FF8D +XK_XF86_Messenger = 0x1008FF8E +XK_XF86_WebCam = 0x1008FF8F +XK_XF86_MailForward = 0x1008FF90 +XK_XF86_Pictures = 0x1008FF91 +XK_XF86_Music = 0x1008FF92 + +XK_XF86_Battery = 0x1008FF93 +XK_XF86_Bluetooth = 0x1008FF94 +XK_XF86_WLAN = 0x1008FF95 +XK_XF86_UWB = 0x1008FF96 + +XK_XF86_AudioForward = 0x1008FF97 +XK_XF86_AudioRepeat = 0x1008FF98 +XK_XF86_AudioRandomPlay = 0x1008FF99 +XK_XF86_Subtitle = 0x1008FF9A +XK_XF86_AudioCycleTrack = 0x1008FF9B +XK_XF86_CycleAngle = 0x1008FF9C +XK_XF86_FrameBack = 0x1008FF9D +XK_XF86_FrameForward = 0x1008FF9E +XK_XF86_Time = 0x1008FF9F +XK_XF86_Select = 0x1008FFA0 +XK_XF86_View = 0x1008FFA1 +XK_XF86_TopMenu = 0x1008FFA2 + +XK_XF86_Red = 0x1008FFA3 +XK_XF86_Green = 0x1008FFA4 +XK_XF86_Yellow = 0x1008FFA5 +XK_XF86_Blue = 0x1008FFA6 + +XK_XF86_Switch_VT_1 = 0x1008FE01 +XK_XF86_Switch_VT_2 = 0x1008FE02 +XK_XF86_Switch_VT_3 = 0x1008FE03 +XK_XF86_Switch_VT_4 = 0x1008FE04 +XK_XF86_Switch_VT_5 = 0x1008FE05 +XK_XF86_Switch_VT_6 = 0x1008FE06 +XK_XF86_Switch_VT_7 = 0x1008FE07 +XK_XF86_Switch_VT_8 = 0x1008FE08 +XK_XF86_Switch_VT_9 = 0x1008FE09 +XK_XF86_Switch_VT_10 = 0x1008FE0A +XK_XF86_Switch_VT_11 = 0x1008FE0B +XK_XF86_Switch_VT_12 = 0x1008FE0C + +XK_XF86_Ungrab = 0x1008FE20 +XK_XF86_ClearGrab = 0x1008FE21 +XK_XF86_Next_VMode = 0x1008FE22 +XK_XF86_Prev_VMode = 0x1008FE23 From 2ee8143a2b212c1319e3878f48718cb7490f16a8 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Thu, 28 Apr 2016 19:38:54 +0300 Subject: [PATCH 003/279] Tests from test_events_le.py was fixed for Py3 --- Xlib/protocol/rq.py | 10 +++++----- test/test_events_be.py | 10 ++++++++-- test/test_events_le.py | 10 ++++++++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index acfd19f4..8bae413d 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -530,7 +530,7 @@ def pack_value(self, val): if self.type.check_value is not None: val = [self.type.check_value(v) for v in val] data = array(struct_to_array_codes[self.type.structcode], - val).tostring() + val).tobytes() else: data = [] for v in val: @@ -627,7 +627,7 @@ def parse_binary_value(self, data, display, length, format): ret = None elif format == 8: - ret = (8, str(data[:length])) + ret = (8, data[:length].decode()) data = data[length + ((4 - length % 4) % 4):] elif format == 16: @@ -662,7 +662,7 @@ def pack_value(self, value): val = list(val) size = fmt // 8 - data = array(array_unsigned_codes[size], val).tostring() + data = array(array_unsigned_codes[size], val).tobytes() dlen = len(val) dl = len(data) @@ -783,7 +783,7 @@ def pack_value(self, value): for i in range(len(v), keycodes): a.append(X.NoSymbol) - return a.tostring(), len(value), keycodes + return a.tobytes(), len(value), keycodes class ModifierMapping(ValueField): @@ -814,7 +814,7 @@ def pack_value(self, value): for i in range(len(v), keycodes): a.append(0) - return a.tostring(), len(value), keycodes + return a.tobytes(), len(value), keycodes class EventField(ValueField): structcode = None diff --git a/test/test_events_be.py b/test/test_events_be.py index d0514d30..0b425181 100755 --- a/test/test_events_be.py +++ b/test/test_events_be.py @@ -28,8 +28,14 @@ def __getitem__(self, key): def __getattr__(self, attr): return getattr(self.array, attr) - def __cmp__(self, other): - return cmp(self.array.tolist(), other) + def __lt__(self, other): + return self.array.tolist() < other + + def __gt__(self, other): + return self.array.tolist() > other + + def __eq__(self, other): + return self.array.tolist() == other rq.array = CmpArray diff --git a/test/test_events_le.py b/test/test_events_le.py index 63101028..2d9b40e0 100755 --- a/test/test_events_le.py +++ b/test/test_events_le.py @@ -37,8 +37,14 @@ def __getitem__(self, key): def __getattr__(self, attr): return getattr(self.array, attr) - def __cmp__(self, other): - return cmp(self.array.tolist(), other) + def __lt__(self, other): + return self.array.tolist() < other + + def __gt__(self, other): + return self.array.tolist() > other + + def __eq__(self, other): + return self.array.tolist() == other rq.array = CmpArray From fde39b9cecdbe90938288886e2d5c66f6d458e93 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Thu, 28 Apr 2016 19:42:34 +0300 Subject: [PATCH 004/279] TestRDB.testParseAndQuery() from test_rdb.py was fixed for Py3 --- Xlib/rdb.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Xlib/rdb.py b/Xlib/rdb.py index 17b1f003..9b7c5544 100644 --- a/Xlib/rdb.py +++ b/Xlib/rdb.py @@ -387,8 +387,14 @@ def __init__(self, path, dbs): self.skip = 1 self.db = dbs - def __cmp__(self, other): - return cmp(self.path, other.path) + def __lt__(self, other): + return self.path < other.path + + def __gt__(self, other): + return self.path > other.path + + def __eq__(self, other): + return self.path == other.path def match_length(self): return len(self.path) From 39b27b31661497d9b12d828543d8afe9bf8e2f81 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Thu, 28 Apr 2016 21:06:51 +0300 Subject: [PATCH 005/279] TestCreateWindow.testUnpackRequest0() from test_requests_le.py was fixed for Py3 --- Xlib/protocol/rq.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 8bae413d..55b82dfc 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -1291,11 +1291,23 @@ def __str__(self): def __repr__(self): return '%s(%s)' % (self.__class__, repr(self._data)) - def __cmp__(self, other): + def __lt__(self, other): if isinstance(other, DictWrapper): - return cmp(self._data, other._data) + return self._data < other._data else: - return cmp(self._data, other) + return self._data < other + + def __gt__(self, other): + if isinstance(other, DictWrapper): + return self._data > other._data + else: + return self._data > other + + def __eq__(self, other): + if isinstance(other, DictWrapper): + return self._data == other._data + else: + return self._data == other class Request(object): From f5e60950ef5f2e2b49ed7167012c868b842bd3b0 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Thu, 28 Apr 2016 21:34:12 +0300 Subject: [PATCH 006/279] tostring() was returned back --- Xlib/protocol/rq.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 55b82dfc..8690fcbf 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -530,7 +530,7 @@ def pack_value(self, val): if self.type.check_value is not None: val = [self.type.check_value(v) for v in val] data = array(struct_to_array_codes[self.type.structcode], - val).tobytes() + val).tostring() else: data = [] for v in val: @@ -662,7 +662,7 @@ def pack_value(self, value): val = list(val) size = fmt // 8 - data = array(array_unsigned_codes[size], val).tobytes() + data = array(array_unsigned_codes[size], val).tostring() dlen = len(val) dl = len(data) @@ -783,7 +783,7 @@ def pack_value(self, value): for i in range(len(v), keycodes): a.append(X.NoSymbol) - return a.tobytes(), len(value), keycodes + return a.tostring(), len(value), keycodes class ModifierMapping(ValueField): @@ -814,7 +814,7 @@ def pack_value(self, value): for i in range(len(v), keycodes): a.append(0) - return a.tobytes(), len(value), keycodes + return a.tostring(), len(value), keycodes class EventField(ValueField): structcode = None From 766c5c19887ccb0b5efa2bca10aca9e385f0b0f4 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Thu, 28 Apr 2016 22:07:38 +0300 Subject: [PATCH 007/279] TestChangeProperty tests from test_requests_le.py were fixed for Py3 --- test/test_requests_le.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/test_requests_le.py b/test/test_requests_le.py index 2d33cd84..c5ed8e50 100755 --- a/test/test_requests_le.py +++ b/test/test_requests_le.py @@ -28,8 +28,14 @@ def __getitem__(self, key): def __getattr__(self, attr): return getattr(self.array, attr) - def __cmp__(self, other): - return cmp(self.array.tolist(), other) + def __lt__(self, other): + return self.array.tolist() < other + + def __gt__(self, other): + return self.array.tolist() > other + + def __eq__(self, other): + return self.array.tolist() == other rq.array = CmpArray From 635f64ae372ee1bc6bb6737e381321a5fa051370 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Thu, 28 Apr 2016 22:12:18 +0300 Subject: [PATCH 008/279] TestSendEvent.testUnpackRequest0 from test_requests_le.py was fixed for Py3 --- Xlib/protocol/rq.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 8690fcbf..5135b668 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -1405,11 +1405,23 @@ def __repr__(self): kws = ', '.join(kwlist) return '%s(%s)' % (self.__class__, kws) - def __cmp__(self, other): + def __lt__(self, other): + if isinstance(other, Event): + return self._data < other._data + else: + return self._data < other + + def __gt__(self, other): if isinstance(other, Event): - return cmp(self._data, other._data) + return self._data > other._data else: - return cmp(self._data, other) + return self._data > other + + def __eq__(self, other): + if isinstance(other, Event): + return self._data == other._data + else: + return self._data == other def call_error_handler(handler, error, request): From ac287ac6716cea55ec443fc697e803a1d2b834fa Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Thu, 28 Apr 2016 22:30:15 +0300 Subject: [PATCH 009/279] TestListFonts tests from test_requests_le.py were fixed for Py3 --- Xlib/protocol/rq.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 5135b668..b33dc39f 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -536,7 +536,7 @@ def pack_value(self, val): for v in val: data.append(self.type.pack_value(v)) - data = b''.join(data) + data = ''.join(data).encode() if self.pad: dlen = len(data) @@ -880,7 +880,7 @@ def pack_value(self, val): def parse_binary(self, data, display): slen = _to_ord(data[0]) + 1 - return data[1:slen], data[slen:] + return data[1:slen].decode(), data[slen:] Str = StrClass() From d3807308eb46dafd8802de3161714838823e38f3 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Thu, 28 Apr 2016 23:57:32 +0300 Subject: [PATCH 010/279] TestGetFontPath.testPackReply0 from test_requests_le.py was fixed for Py3 --- Xlib/protocol/rq.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index b33dc39f..c31de2e8 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -536,7 +536,7 @@ def pack_value(self, val): for v in val: data.append(self.type.pack_value(v)) - data = ''.join(data).encode() + data = b''.join(data) if self.pad: dlen = len(data) @@ -876,7 +876,7 @@ class StrClass(object): structcode = None def pack_value(self, val): - return chr(len(val)) + val + return (chr(len(val)) + val).encode() def parse_binary(self, data, display): slen = _to_ord(data[0]) + 1 From a0b7c3b33c703a6510a83211ebff5b056f5b6aa9 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Sat, 30 Apr 2016 23:43:49 +0300 Subject: [PATCH 011/279] Fix problem with childwin.py example --- Xlib/protocol/rq.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index c31de2e8..19ebbf9c 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -396,7 +396,10 @@ def __init__(self, name, pad = 1): self.pad = pad def pack_value(self, val): - val_bytes = val.encode() + if isinstance(val, bytes): + val_bytes = val + else: + val_bytes = val.encode() slen = len(val_bytes) if self.pad: From 5ddc06b9e690a17d200a14d8f2cd516030dc6776 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Sun, 1 May 2016 00:43:21 +0300 Subject: [PATCH 012/279] Fix warnings in childwin.py --- Xlib/protocol/rq.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 19ebbf9c..acc50120 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -634,11 +634,11 @@ def parse_binary_value(self, data, display, length, format): data = data[length + ((4 - length % 4) % 4):] elif format == 16: - ret = (16, array(array_unsigned_codes[2], data[:2 * length].decode().encode())) + ret = (16, array(array_unsigned_codes[2], data[:2 * length])) data = data[2 * (length + length % 2):] elif format == 32: - ret = (32, array(array_unsigned_codes[4], data[:4 * length].decode().encode())) + ret = (32, array(array_unsigned_codes[4], data[:4 * length])) data = data[4 * length:] return ret, data From c4c684d2d4abc1a98f98c5085a1510925101de6a Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Fri, 6 May 2016 01:19:07 +0300 Subject: [PATCH 013/279] Fix version problem from security.py example --- Xlib/protocol/rq.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index acc50120..093d1266 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -416,7 +416,12 @@ def parse_binary_value(self, data, display, length, format): else: slen = length - return data[:length].decode(), data[slen:] + if sys.version_info < (3, 0): + data_str = data[:length] + else: + data_str = data[:length].decode() + + return data_str, data[slen:] class String16(ValueField): From f8f23b88062f56c690a9ce192b52134ad84008d3 Mon Sep 17 00:00:00 2001 From: Tatiana Khanova Date: Wed, 4 May 2016 09:39:51 +0300 Subject: [PATCH 014/279] Test commit --- test/test_xlib_display.py | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/test_xlib_display.py diff --git a/test/test_xlib_display.py b/test/test_xlib_display.py new file mode 100644 index 00000000..31242a8b --- /dev/null +++ b/test/test_xlib_display.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +import sys +import os +import unittest + +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +import Xlib.display +import Xlib.protocol.display + + +class TestXlibDisplay(unittest.TestCase): + def setUp(self): + self.display = Xlib.display.Display(":99.0") + + def test_display_instance(self): + print "1" + self.assertIsInstance(self.display, Xlib.display.Display) + + def test_default_DisplayName(self): + print "2" + self.assertEqual(self.display.get_display_name(), ":99.0") + + def test_default_screenNumber(self): + self.assertEqual(self.display.get_default_screen(), 0) + + def test_returns_no_events(self): + self.assertEqual(self.display.pending_events(), 0) + + def test_pointer_mapping_is_list(self): + self.assertIsInstance(self.display.get_pointer_mapping(), list) + + def test_set_get_pointer_mapping(self): + length = len(self.display.get_pointer_mapping()) + self.display.set_pointer_mapping([0] * length) + self.assertEqual(self.display.get_pointer_mapping(), [0] * length) + + +if __name__ == '__main__': + unittest.main() From ab84b4b545a596faa9e3706da1afd845d0388e9a Mon Sep 17 00:00:00 2001 From: Tatiana Khanova Date: Wed, 4 May 2016 10:07:52 +0300 Subject: [PATCH 015/279] fix auth --- test/test_xlib_display.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/test_xlib_display.py b/test/test_xlib_display.py index 31242a8b..4b2dac19 100644 --- a/test/test_xlib_display.py +++ b/test/test_xlib_display.py @@ -3,6 +3,7 @@ import sys import os import unittest +import subprocess sys.path.append(os.path.join(os.path.dirname(__file__), '..')) @@ -12,17 +13,22 @@ class TestXlibDisplay(unittest.TestCase): def setUp(self): + # Create authority file. + + self.authfile = os.path.join(os.getenv("HOME"), ".Xauthority") + self.cookie = "926e3f51b3540ca0d54bf2725c1af2b6" #subprocess.check_output(["`ps -ef | md5sum | cut -f 1 -d " "`"]) + os.system("xauth -f {} add :99.0 MIT-MAGIC-COOKIE-1 {}".format(self.authfile, self.cookie)) self.display = Xlib.display.Display(":99.0") def test_display_instance(self): print "1" self.assertIsInstance(self.display, Xlib.display.Display) - def test_default_DisplayName(self): + def test_default_display_name(self): print "2" self.assertEqual(self.display.get_display_name(), ":99.0") - def test_default_screenNumber(self): + def test_default_screen_number(self): self.assertEqual(self.display.get_default_screen(), 0) def test_returns_no_events(self): @@ -36,6 +42,9 @@ def test_set_get_pointer_mapping(self): self.display.set_pointer_mapping([0] * length) self.assertEqual(self.display.get_pointer_mapping(), [0] * length) + def tearDown(self): + os.remove(self.authfile) + if __name__ == '__main__': unittest.main() From 08e27849350609dc0d6d8bfb8ecfb2968c0490ed Mon Sep 17 00:00:00 2001 From: Tatiana Khanova Date: Wed, 4 May 2016 11:16:54 +0300 Subject: [PATCH 016/279] fixes --- test/test_xlib_display.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/test/test_xlib_display.py b/test/test_xlib_display.py index 4b2dac19..11ea772d 100644 --- a/test/test_xlib_display.py +++ b/test/test_xlib_display.py @@ -8,24 +8,22 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..')) import Xlib.display +import Xlib.error import Xlib.protocol.display class TestXlibDisplay(unittest.TestCase): def setUp(self): # Create authority file. - self.authfile = os.path.join(os.getenv("HOME"), ".Xauthority") - self.cookie = "926e3f51b3540ca0d54bf2725c1af2b6" #subprocess.check_output(["`ps -ef | md5sum | cut -f 1 -d " "`"]) - os.system("xauth -f {} add :99.0 MIT-MAGIC-COOKIE-1 {}".format(self.authfile, self.cookie)) + self.cookie = "926e3f51b3540ca0d54bf2725c1af2b6" + os.system("xauth -f {0} add :99.0 MIT-MAGIC-COOKIE-1 {1}".format(self.authfile, self.cookie)) self.display = Xlib.display.Display(":99.0") def test_display_instance(self): - print "1" - self.assertIsInstance(self.display, Xlib.display.Display) + self.assertTrue(isinstance(self.display, Xlib.display.Display)) def test_default_display_name(self): - print "2" self.assertEqual(self.display.get_display_name(), ":99.0") def test_default_screen_number(self): @@ -35,13 +33,23 @@ def test_returns_no_events(self): self.assertEqual(self.display.pending_events(), 0) def test_pointer_mapping_is_list(self): - self.assertIsInstance(self.display.get_pointer_mapping(), list) + self.assertTrue(isinstance(self.display.get_pointer_mapping(), list)) def test_set_get_pointer_mapping(self): length = len(self.display.get_pointer_mapping()) self.display.set_pointer_mapping([0] * length) self.assertEqual(self.display.get_pointer_mapping(), [0] * length) + def test_can_close_display(self): + self.display.close() + self.assertEqual(str(self.display.display.socket_error), "Display connection closed by client") + + def test_can_close_display_and_check_for_error(self): + self.display.close() + with self.assertRaises(Xlib.error.ConnectionClosedError, None) as e: + self.display.flush() + + def tearDown(self): os.remove(self.authfile) From 5e982f28b50144055fa14a917ff906421bdc148b Mon Sep 17 00:00:00 2001 From: Tatiana Khanova Date: Wed, 4 May 2016 13:38:20 +0300 Subject: [PATCH 017/279] more tests --- test/test_xlib_display.py | 118 +++++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 2 deletions(-) diff --git a/test/test_xlib_display.py b/test/test_xlib_display.py index 11ea772d..223581d6 100644 --- a/test/test_xlib_display.py +++ b/test/test_xlib_display.py @@ -10,6 +10,10 @@ import Xlib.display import Xlib.error import Xlib.protocol.display +import Xlib.protocol.event +import Xlib.protocol.rq +import Xlib.xobject.fontable +import Xlib.X class TestXlibDisplay(unittest.TestCase): @@ -46,9 +50,119 @@ def test_can_close_display(self): def test_can_close_display_and_check_for_error(self): self.display.close() - with self.assertRaises(Xlib.error.ConnectionClosedError, None) as e: - self.display.flush() + self.assertRaises(self.display.flush) + def test_return_fileno(self): + self.assertTrue(isinstance(self.display.fileno(), int)) + + def test_has_no_invalid_extension(self): + self.assertTrue(~self.display.has_extension("QQQ")) + + def test_has_valid_extension(self): + extensions = self.display.list_extensions() + if extensions: + self.assertTrue(~self.display.has_extension(extensions[0])) + + def test_can_create_resource_object(self): + self.assertTrue( + isinstance(self.display.create_resource_object("font", 0), Xlib.xobject.fontable.Font)) + + def test_get_default_screen_instance(self): + self.assertTrue(isinstance(self.display.screen(), Xlib.protocol.rq.DictWrapper)) + + def test_get_zero_screen_instance(self): + self.assertTrue(isinstance(self.display.screen(0), Xlib.protocol.rq.DictWrapper)) + + def test_default_screen_count(self): + self.assertEqual(self.display.screen_count(), 1) + + def test_cannot_add_existing_display_method(self): + self.assertRaises(AssertionError, self.display.extension_add_method, + "display", "extension_add_method", lambda x: x) + + def test_cannot_add_existing_font_method(self): + self.assertRaises(AssertionError, self.display.extension_add_method, "font", "__init__", lambda x: x) + + def test_can_add_extension_error(self): + self.display.add_extension_error(1, Xlib.error.XError) + self.assertEqual(self.display.display.error_classes[1], Xlib.error.XError) + + def test_keycode_to_keysym_for_invalid_index(self): + self.assertEqual(self.display.keycode_to_keysym(0, 0), Xlib.X.NoSymbol) + + def test_keysym_to_keycode_for_nosymbol(self): + self.assertEqual(self.display.keysym_to_keycode(Xlib.X.NoSymbol), 0) + + def test_keysym_to_keycode_for_valid_symbol(self): + self.assertEqual(self.display.keysym_to_keycode(65535L), 119) + + def test_keysym_to_keycodes_for_nosymbol(self): + self.assertEqual(self.display.keysym_to_keycodes(Xlib.X.NoSymbol), []) + + def test_refresh_keyboard_mapping_invalid_event(self): + self.assertRaises(TypeError, self.display.refresh_keyboard_mapping, Xlib.protocol.event.AnyEvent) + + def test_get_modifier_mapping(self): + self.assertEqual(len(self.display.get_modifier_mapping()), 8) + + def test_set_modifier_mapping(self): + mapping = self.display.get_modifier_mapping() + self.assertEqual(self.display.set_modifier_mapping(mapping), Xlib.X.MappingSuccess) + + def test_get_screensaver(self): + self.assertTrue(isinstance(self.display.get_screen_saver(), Xlib.protocol.request.GetScreenSaver)) + + def test_list_hosts(self): + self.assertTrue(isinstance(self.display.list_hosts(), Xlib.protocol.request.ListHosts)) + + def test_get_keyboard_control(self): + self.assertTrue( + isinstance(self.display.get_keyboard_control(), Xlib.protocol.request.GetKeyboardControl)) + + def test_change_keyboard_mapping(self): + kpt_mapping = self.display.get_keyboard_mapping(254, 1) + self.display.change_keyboard_mapping(254, kpt_mapping) + self.assertEqual(self.display.get_keyboard_mapping(254, 1), kpt_mapping) + + def test_get_font_path(self): + self.assertNotEqual(self.display.get_font_path(), []) + + def test_get_atom_name(self): + atom = self.display.get_atom(":99.0") + val = self.display.get_atom_name(atom) + self.assertEqual(val, ":99.0") + + def test_intern_atom(self): + atom = self.display.intern_atom(":99.0") + val = self.display.get_atom_name(atom) + self.assertEqual(val, ":99.0") + + def test_get_input_focus(self): + self.assertTrue(isinstance(self.display.get_input_focus(), Xlib.protocol.request.GetInputFocus)) + + def test_query_keymap(self): + self.assertTrue(isinstance(self.display.query_keymap(), list)) + + def test_open_invalid_font(self): + self.assertEqual(self.display.open_font("QQQ"), None) + + def test_list_fonts(self): + fonts = self.display.list_fonts("*", 1) + self.assertNotEqual(fonts, []) + + def test_lookup_valid_keysym(self): + self.assertNotEqual(self.display.lookup_string(65535L), None) + + def test_lookup_invalid_keysym(self): + self.assertEqual(self.display.lookup_string(-1), None) + + def test_rebind_string(self): + self.display.rebind_string(65535L, "qqq") + self.assertEqual(self.display.lookup_string(65535L), "qqq") + + def test_get_selection_owner(self): + atom = self.display.get_atom(":99.0") + self.assertEqual(self.display.get_selection_owner(atom), 0) def tearDown(self): os.remove(self.authfile) From ab1d7e403a58d25a0603b01931dfd2b4dc07fa8a Mon Sep 17 00:00:00 2001 From: Tatiana Khanova Date: Thu, 5 May 2016 08:58:48 +0300 Subject: [PATCH 018/279] fixed L integer --- test/test_xlib_display.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/test/test_xlib_display.py b/test/test_xlib_display.py index 223581d6..51ca32cc 100644 --- a/test/test_xlib_display.py +++ b/test/test_xlib_display.py @@ -21,14 +21,18 @@ def setUp(self): # Create authority file. self.authfile = os.path.join(os.getenv("HOME"), ".Xauthority") self.cookie = "926e3f51b3540ca0d54bf2725c1af2b6" - os.system("xauth -f {0} add :99.0 MIT-MAGIC-COOKIE-1 {1}".format(self.authfile, self.cookie)) - self.display = Xlib.display.Display(":99.0") + self.display_num = os.getenv("DISPLAY") + os.system("xauth -f {0} add {1} MIT-MAGIC-COOKIE-1 {2}".format(self.authfile, self.display_num, + self.cookie)) + self.display = Xlib.display.Display(self.display_num) + self.dummy_str = "qqq" + self.keysym = 65535 def test_display_instance(self): self.assertTrue(isinstance(self.display, Xlib.display.Display)) def test_default_display_name(self): - self.assertEqual(self.display.get_display_name(), ":99.0") + self.assertEqual(self.display.get_display_name(), self.display_num) def test_default_screen_number(self): self.assertEqual(self.display.get_default_screen(), 0) @@ -50,13 +54,13 @@ def test_can_close_display(self): def test_can_close_display_and_check_for_error(self): self.display.close() - self.assertRaises(self.display.flush) + self.assertRaises(Xlib.error.ConnectionClosedError, self.display.flush) def test_return_fileno(self): self.assertTrue(isinstance(self.display.fileno(), int)) def test_has_no_invalid_extension(self): - self.assertTrue(~self.display.has_extension("QQQ")) + self.assertTrue(~self.display.has_extension(self.dummy_str)) def test_has_valid_extension(self): extensions = self.display.list_extensions() @@ -94,7 +98,7 @@ def test_keysym_to_keycode_for_nosymbol(self): self.assertEqual(self.display.keysym_to_keycode(Xlib.X.NoSymbol), 0) def test_keysym_to_keycode_for_valid_symbol(self): - self.assertEqual(self.display.keysym_to_keycode(65535L), 119) + self.assertEqual(self.display.keysym_to_keycode(self.keysym), 119) def test_keysym_to_keycodes_for_nosymbol(self): self.assertEqual(self.display.keysym_to_keycodes(Xlib.X.NoSymbol), []) @@ -128,14 +132,14 @@ def test_get_font_path(self): self.assertNotEqual(self.display.get_font_path(), []) def test_get_atom_name(self): - atom = self.display.get_atom(":99.0") + atom = self.display.get_atom(self.display_num) val = self.display.get_atom_name(atom) - self.assertEqual(val, ":99.0") + self.assertEqual(val, self.display_num) def test_intern_atom(self): - atom = self.display.intern_atom(":99.0") + atom = self.display.intern_atom(self.display_num) val = self.display.get_atom_name(atom) - self.assertEqual(val, ":99.0") + self.assertEqual(val, self.display_num) def test_get_input_focus(self): self.assertTrue(isinstance(self.display.get_input_focus(), Xlib.protocol.request.GetInputFocus)) @@ -144,24 +148,24 @@ def test_query_keymap(self): self.assertTrue(isinstance(self.display.query_keymap(), list)) def test_open_invalid_font(self): - self.assertEqual(self.display.open_font("QQQ"), None) + self.assertEqual(self.display.open_font(self.dummy_str), None) def test_list_fonts(self): fonts = self.display.list_fonts("*", 1) self.assertNotEqual(fonts, []) def test_lookup_valid_keysym(self): - self.assertNotEqual(self.display.lookup_string(65535L), None) + self.assertNotEqual(self.display.lookup_string(self.keysym), None) def test_lookup_invalid_keysym(self): self.assertEqual(self.display.lookup_string(-1), None) def test_rebind_string(self): - self.display.rebind_string(65535L, "qqq") - self.assertEqual(self.display.lookup_string(65535L), "qqq") + self.display.rebind_string(self.keysym, self.dummy_str) + self.assertEqual(self.display.lookup_string(self.keysym), self.dummy_str) def test_get_selection_owner(self): - atom = self.display.get_atom(":99.0") + atom = self.display.get_atom(self.display_num) self.assertEqual(self.display.get_selection_owner(atom), 0) def tearDown(self): From 48bf84016b4046937429f993dd7c42285375c6d7 Mon Sep 17 00:00:00 2001 From: Tatiana Khanova Date: Thu, 5 May 2016 09:16:26 +0300 Subject: [PATCH 019/279] more fixes for Python3: exceptions, function arguments and imports --- Xlib/protocol/display.py | 6 +++--- Xlib/xobject/colormap.py | 2 +- Xlib/xobject/cursor.py | 6 +++--- Xlib/xobject/drawable.py | 16 ++++++++-------- Xlib/xobject/fontable.py | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 45730490..2685917a 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -517,7 +517,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) # Ignore errors caused by a signal recieved while blocking. # All other errors are re-raised. - except select.error, err: + except select.error as err: if err[0] != errno.EINTR: raise err @@ -532,7 +532,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) if ws: try: i = self.socket.send(self.data_send) - except socket.error, err: + except socket.error as err: self.close_internal('server: %s' % err[1]) raise self.socket_error @@ -548,7 +548,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) if recieving: try: bytes_recv = self.socket.recv(2048) - except socket.error, err: + except socket.error as err: self.close_internal('server: %s' % err[1]) raise self.socket_error diff --git a/Xlib/xobject/colormap.py b/Xlib/xobject/colormap.py index 3353da4b..d6ad23ea 100644 --- a/Xlib/xobject/colormap.py +++ b/Xlib/xobject/colormap.py @@ -19,7 +19,7 @@ from Xlib import error from Xlib.protocol import request -import resource +from . import resource import re diff --git a/Xlib/xobject/cursor.py b/Xlib/xobject/cursor.py index 574f5ce7..d693e694 100644 --- a/Xlib/xobject/cursor.py +++ b/Xlib/xobject/cursor.py @@ -18,7 +18,7 @@ from Xlib.protocol import request -import resource +from . import resource class Cursor(resource.Resource): __cursor__ = resource.Resource.__resource__ @@ -29,8 +29,8 @@ def free(self, onerror = None): cursor = self.id) self.display.free_resource_id(self.id) - def recolor(self, (fore_red, fore_green, fore_blue), - (back_red, back_green, back_blue), onerror = None): + def recolor(self, fore_red, fore_green, fore_blue, + back_red, back_green, back_blue, onerror = None): request.RecolorCursor(display = self.display, onerror = onerror, diff --git a/Xlib/xobject/drawable.py b/Xlib/xobject/drawable.py index 33e7b004..c8117a5f 100644 --- a/Xlib/xobject/drawable.py +++ b/Xlib/xobject/drawable.py @@ -20,13 +20,13 @@ from Xlib.protocol import request, rq # Other X resource objects -import resource -import colormap -import cursor -import fontable +from . import resource +from . import colormap +from . import cursor +from . import fontable # Inter-client communication conventions -import icccm +from . import icccm class Drawable(resource.Resource): __drawable__ = resource.Resource.__resource__ @@ -229,7 +229,7 @@ def put_pil_image(self, gc, x, y, image, onerror = None): unit = self.display.info.bitmap_format_scanline_unit stride = roundup(width * unit, pad) >> 3 else: - raise ValueError, 'Unknown data format' + raise ValueError('Unknown data format') maxlen = (self.display.info.max_request_length << 2) \ - request.PutImage._request.static_size @@ -798,8 +798,8 @@ def free(self, onerror = None): self.display.free_resource_id(self.id) def create_cursor(self, mask, - (fore_red, fore_green, fore_blue), - (back_red, back_green, back_blue), + fore_red, fore_green, fore_blue, + back_red, back_green, back_blue, x, y): cid = self.display.allocate_resource_id() request.CreateCursor(display = self.display, diff --git a/Xlib/xobject/fontable.py b/Xlib/xobject/fontable.py index befe85f8..8ce22229 100644 --- a/Xlib/xobject/fontable.py +++ b/Xlib/xobject/fontable.py @@ -18,8 +18,8 @@ from Xlib.protocol import request -import resource -import cursor +from . import resource +from . import cursor class Fontable(resource.Resource): __fontable__ = resource.Resource.__resource__ @@ -85,8 +85,8 @@ def close(self, onerror = None): self.display.free_resource_id(self.id) def create_glyph_cursor(self, mask, source_char, mask_char, - (fore_red, fore_green, fore_blue), - (back_red, back_green, back_blue)): + fore_red, fore_green, fore_blue, + back_red, back_green, back_blue): cid = self.display.allocate_resource_id() request.CreateGlyphCursor(display = self.display, From c46d01bd66b7920178bc576627b2829a90a84d95 Mon Sep 17 00:00:00 2001 From: Tatiana Khanova Date: Thu, 5 May 2016 22:19:03 +0300 Subject: [PATCH 020/279] fixed warning --- .travis.yml | 1 + test/test_xlib_display.py | 7 ------- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 32362068..5356670c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ before_script: - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" - sleep 3 # give xvfb some time to start + - xauth generate :99.0 . trusted # command to run tests script: nosetests --with-xunit --with-coverage --cover-html --cover-html-dir=Coverage_report --verbosity=3 test/testall.py diff --git a/test/test_xlib_display.py b/test/test_xlib_display.py index 51ca32cc..35e4e63c 100644 --- a/test/test_xlib_display.py +++ b/test/test_xlib_display.py @@ -19,11 +19,7 @@ class TestXlibDisplay(unittest.TestCase): def setUp(self): # Create authority file. - self.authfile = os.path.join(os.getenv("HOME"), ".Xauthority") - self.cookie = "926e3f51b3540ca0d54bf2725c1af2b6" self.display_num = os.getenv("DISPLAY") - os.system("xauth -f {0} add {1} MIT-MAGIC-COOKIE-1 {2}".format(self.authfile, self.display_num, - self.cookie)) self.display = Xlib.display.Display(self.display_num) self.dummy_str = "qqq" self.keysym = 65535 @@ -168,9 +164,6 @@ def test_get_selection_owner(self): atom = self.display.get_atom(self.display_num) self.assertEqual(self.display.get_selection_owner(atom), 0) - def tearDown(self): - os.remove(self.authfile) - if __name__ == '__main__': unittest.main() From 5569b53fb35e45769fbf9ea86c1c104e86486f70 Mon Sep 17 00:00:00 2001 From: Tatiana Khanova Date: Fri, 6 May 2016 09:03:58 +0300 Subject: [PATCH 021/279] temp fixes for python3 --- Xlib/protocol/display.py | 2 +- Xlib/support/connect.py | 11 ++++++++--- Xlib/support/unix_connect.py | 2 +- Xlib/xauth.py | 9 ++++----- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 2685917a..3f785394 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -998,7 +998,7 @@ class ConnectionSetupRequest(rq.GetAttrData): def __init__(self, display, *args, **keys): - self._binary = apply(self._request.to_binary, args, keys) + self._binary = self._request.to_binary(*args, **keys) self._data = None # Don't bother about locking, since no other threads have diff --git a/Xlib/support/connect.py b/Xlib/support/connect.py index 6670817d..a9ae2669 100644 --- a/Xlib/support/connect.py +++ b/Xlib/support/connect.py @@ -17,6 +17,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys +import os +import imp # List the modules which contain the corresponding functions @@ -60,7 +62,8 @@ def get_display(display): """ modname = _display_mods.get(platform, _default_display_mod) - mod = __import__(modname, globals()) + mod = imp.load_source(modname, os.path.join(os.path.dirname(__file__), modname + ".py")) + # mod = __import__(modname, globals()) return mod.get_display(display) @@ -74,7 +77,8 @@ def get_socket(dname, host, dno): """ modname = _socket_mods.get(platform, _default_socket_mod) - mod = __import__(modname, globals()) + mod = imp.load_source(modname, os.path.join(os.path.dirname(__file__), modname + ".py")) + #mod = __import__(modname, globals()) return mod.get_socket(dname, host, dno) @@ -89,5 +93,6 @@ def get_auth(sock, dname, host, dno): """ modname = _auth_mods.get(platform, _default_auth_mod) - mod = __import__(modname, globals()) + mod = imp.load_source(modname, os.path.join(os.path.dirname(__file__), modname + ".py")) + #mod = __import__(modname, globals()) return mod.get_auth(sock, dname, host, dno) diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index b5354cb5..c178e151 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -85,7 +85,7 @@ def get_socket(dname, host, dno): else: s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect('/tmp/.X11-unix/X%d' % dno) - except socket.error, val: + except socket.error as val: raise error.DisplayConnectionError(dname, str(val)) # Make sure that the connection isn't inherited in child processes diff --git a/Xlib/xauth.py b/Xlib/xauth.py index be738aba..dc58bcd7 100644 --- a/Xlib/xauth.py +++ b/Xlib/xauth.py @@ -40,7 +40,7 @@ def __init__(self, filename = None): try: raw = open(filename, 'rb').read() - except IOError, err: + except IOError as err: raise error.XauthError('~/.Xauthority: %s' % err) self.entries = [] @@ -82,12 +82,11 @@ def __init__(self, filename = None): break self.entries.append((family, addr, num, name, data)) - except struct.error, e: - print "Xlib.xauth: warning, failed to parse part of xauthority file (%s), aborting all further parsing" % filename - #pass + except struct.error as e: + print("Xlib.xauth: warning, failed to parse part of xauthority file {0}, aborting all further parsing".format(filename)) if len(self.entries) == 0: - print "Xlib.xauth: warning, no xauthority details available" + print("Xlib.xauth: warning, no xauthority details available") # raise an error? this should get partially caught by the XNoAuthError in get_best_auth.. def __len__(self): From 3a5d405925a026a7808f156b5373156fdb520bb4 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Fri, 13 May 2016 17:34:58 +0300 Subject: [PATCH 022/279] Add run_examples.py --- examples/run_examples.py | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 examples/run_examples.py diff --git a/examples/run_examples.py b/examples/run_examples.py new file mode 100644 index 00000000..793dc438 --- /dev/null +++ b/examples/run_examples.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# +# examples/run_examples.py -- run some examples. +# +# GUI Application automation and testing library +# Copyright (C) 2016 Intel Corporation +# Copyright (C) 2012 Michael Herrmann +# Copyright (C) 2010 Mark Mc Mahon +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA + +import sys +import os + +examples_folder = os.path.abspath(os.path.dirname(__file__)) + "/" + +import subprocess +import unittest + +from subprocess import call + +class TestExamples(unittest.TestCase): + def test_eventthread(self): + self.assertEqual(subprocess.call(examples_folder + "eventthread.py"), 0) + + def test_get_selection(self): + self.assertEqual(subprocess.call([examples_folder + "get_selection.py", "PRIMARY"]), 0) + self.assertEqual(subprocess.call([examples_folder + "get_selection.py", "SECONDARY"]), 0) + self.assertEqual(subprocess.call([examples_folder + "get_selection.py", "CLIPBOARD"]), 0) + + def test_profilex(self): + self.assertEqual(subprocess.call([examples_folder + "profilex.py", examples_folder + "profilex_output"]), 0) + subprocess.call(["rm", examples_folder + "profilex_output"]) + + def test_record_demo(self): + self.assertEqual(subprocess.call(examples_folder + "record_demo.py"), 0) + + def test_security(self): + self.assertEqual(subprocess.call([examples_folder + "security.py", "--generate"]), 0) + self.assertEqual(subprocess.call([examples_folder + "security.py", "--revoke"]), 0) + + def test_xfixes(self): + self.assertEqual(subprocess.call(examples_folder + "xfixes.py"), 0) + + def test_xlsatoms(self): + self.assertEqual(subprocess.call(examples_folder + "xlsatoms.py"), 0) + +if __name__ == '__main__': + unittest.main() + + From 5a7bb9e6f06c80175979f7e4ceb512a3ef5a6250 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Fri, 13 May 2016 17:35:24 +0300 Subject: [PATCH 023/279] Add titles to examples --- examples/eventthread.py | 13 +++++++++++-- examples/get_selection.py | 3 +++ examples/profilex.py | 3 +++ examples/record_demo.py | 3 +++ examples/security.py | 2 ++ examples/threadtest.py | 3 ++- examples/xfixes.py | 6 +++++- examples/xinerama.py | 4 +++- examples/xinput.py | 4 ++++ examples/xlsatoms.py | 13 +++++++++++-- examples/xrandr.py | 4 +++- 11 files changed, 50 insertions(+), 8 deletions(-) diff --git a/examples/eventthread.py b/examples/eventthread.py index 2a7d50bf..ccef119f 100755 --- a/examples/eventthread.py +++ b/examples/eventthread.py @@ -19,10 +19,19 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -import sys, time +print("\n__________________________________________________________________") +print("eventthread.py -- tests multithreaded event handling -- is running") + +import sys +import os + +# Change path so we find Xlib +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +import time from threading import Thread -from Xlib import X, Xatom, threaded +from Xlib import Xatom, threaded from Xlib.display import Display diff --git a/examples/get_selection.py b/examples/get_selection.py index 6a02a0b2..8d9996ab 100755 --- a/examples/get_selection.py +++ b/examples/get_selection.py @@ -19,6 +19,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +print("\n________________________________________________________________") +print("get_selection.py -- demonstrate getting selections -- is running") + import sys import os diff --git a/examples/profilex.py b/examples/profilex.py index 548a1a1a..73ebba50 100755 --- a/examples/profilex.py +++ b/examples/profilex.py @@ -3,6 +3,9 @@ # Program to generate profiling data. Run with one argument, # the profile stats file to generate. +print("\n_______________________________________________________________") +print("profilex.py -- program to generate profiling data -- is running") + import sys import os diff --git a/examples/record_demo.py b/examples/record_demo.py index 0315eba5..6b85b08d 100755 --- a/examples/record_demo.py +++ b/examples/record_demo.py @@ -21,6 +21,9 @@ # Simple demo for the RECORD extension # Not very much unlike the xmacrorec2 program in the xmacro package. +print("\n_____________________________________________________________") +print("record_demo.py -- demonstrate record extension -- is running") + import sys import os diff --git a/examples/security.py b/examples/security.py index 1fc7af52..b86093a7 100755 --- a/examples/security.py +++ b/examples/security.py @@ -19,6 +19,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +print("\n_______________________________________________________________") +print("security.py -- demonstrate the SECURITY extension -- is running") import sys, os from optparse import OptionParser diff --git a/examples/threadtest.py b/examples/threadtest.py index ed074dd8..7a174f7d 100755 --- a/examples/threadtest.py +++ b/examples/threadtest.py @@ -3,7 +3,8 @@ import sys import os -sys.path[1:1] = [os.path.join(sys.path[0], '..')] +# Change path so we find Xlib +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib import display, X, threaded import time diff --git a/examples/xfixes.py b/examples/xfixes.py index f74299ad..3c0e390b 100755 --- a/examples/xfixes.py +++ b/examples/xfixes.py @@ -19,8 +19,12 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +print("\n___________________________________________________________") +print("xfixes.py -- demonstrate the XFIXES extension -- is running") -import sys, os, time +import sys +import os +import time # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) diff --git a/examples/xinerama.py b/examples/xinerama.py index 72e00530..d2aa8b51 100755 --- a/examples/xinerama.py +++ b/examples/xinerama.py @@ -19,7 +19,9 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -import sys, os, pprint +import sys +import os +import pprint # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) diff --git a/examples/xinput.py b/examples/xinput.py index 57cdbd98..294f39f6 100755 --- a/examples/xinput.py +++ b/examples/xinput.py @@ -20,6 +20,10 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys +import os + +# Change path so we find Xlib +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from Xlib.display import Display from Xlib.ext import xinput diff --git a/examples/xlsatoms.py b/examples/xlsatoms.py index 363a352f..9fc831b8 100755 --- a/examples/xlsatoms.py +++ b/examples/xlsatoms.py @@ -23,8 +23,17 @@ ''' -import sys,re -from Xlib import X,display,error +print("\n_____________________________________________________________") +print("xlsatoms.py -- demonstrate list atoms on X server -- is running") + +import sys +import os + +# Change path so we find Xlib +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +import re +from Xlib import display, error from optparse import OptionParser parser = OptionParser() diff --git a/examples/xrandr.py b/examples/xrandr.py index 9d9f6bcd..8b83c0ea 100755 --- a/examples/xrandr.py +++ b/examples/xrandr.py @@ -19,7 +19,9 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -import sys, os, pprint +import sys +import os +import pprint # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) From 33b18bab602eb16b10e5fc65ed26971204dfbd7c Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Fri, 13 May 2016 17:38:14 +0300 Subject: [PATCH 024/279] Add script running examples to travis --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5356670c..44488ec7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,8 @@ before_script: - xauth generate :99.0 . trusted # command to run tests -script: nosetests --with-xunit --with-coverage --cover-html --cover-html-dir=Coverage_report --verbosity=3 test/testall.py +script: + nosetests --with-xunit --with-coverage --cover-html --cover-html-dir=Coverage_report --verbosity=3 test/testall.py examples/run_examples.py after_success: - - codecov \ No newline at end of file + - codecov From 95a83e5293da68f5db685cfac7c3a469dd1f3fd0 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Fri, 13 May 2016 18:39:58 +0300 Subject: [PATCH 025/279] Delete titles from examples --- examples/eventthread.py | 3 --- examples/get_selection.py | 3 --- examples/profilex.py | 2 -- examples/record_demo.py | 2 -- examples/security.py | 3 --- examples/xfixes.py | 3 --- examples/xlsatoms.py | 3 --- 7 files changed, 19 deletions(-) diff --git a/examples/eventthread.py b/examples/eventthread.py index ccef119f..7b92cd3a 100755 --- a/examples/eventthread.py +++ b/examples/eventthread.py @@ -19,9 +19,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -print("\n__________________________________________________________________") -print("eventthread.py -- tests multithreaded event handling -- is running") - import sys import os diff --git a/examples/get_selection.py b/examples/get_selection.py index 8d9996ab..6a02a0b2 100755 --- a/examples/get_selection.py +++ b/examples/get_selection.py @@ -19,9 +19,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -print("\n________________________________________________________________") -print("get_selection.py -- demonstrate getting selections -- is running") - import sys import os diff --git a/examples/profilex.py b/examples/profilex.py index 73ebba50..999e2f4d 100755 --- a/examples/profilex.py +++ b/examples/profilex.py @@ -3,8 +3,6 @@ # Program to generate profiling data. Run with one argument, # the profile stats file to generate. -print("\n_______________________________________________________________") -print("profilex.py -- program to generate profiling data -- is running") import sys import os diff --git a/examples/record_demo.py b/examples/record_demo.py index 6b85b08d..928a0706 100755 --- a/examples/record_demo.py +++ b/examples/record_demo.py @@ -21,8 +21,6 @@ # Simple demo for the RECORD extension # Not very much unlike the xmacrorec2 program in the xmacro package. -print("\n_____________________________________________________________") -print("record_demo.py -- demonstrate record extension -- is running") import sys import os diff --git a/examples/security.py b/examples/security.py index b86093a7..2a2f8aec 100755 --- a/examples/security.py +++ b/examples/security.py @@ -19,9 +19,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -print("\n_______________________________________________________________") -print("security.py -- demonstrate the SECURITY extension -- is running") - import sys, os from optparse import OptionParser diff --git a/examples/xfixes.py b/examples/xfixes.py index 3c0e390b..93fae8a5 100755 --- a/examples/xfixes.py +++ b/examples/xfixes.py @@ -19,9 +19,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -print("\n___________________________________________________________") -print("xfixes.py -- demonstrate the XFIXES extension -- is running") - import sys import os import time diff --git a/examples/xlsatoms.py b/examples/xlsatoms.py index 9fc831b8..17644ca7 100755 --- a/examples/xlsatoms.py +++ b/examples/xlsatoms.py @@ -23,9 +23,6 @@ ''' -print("\n_____________________________________________________________") -print("xlsatoms.py -- demonstrate list atoms on X server -- is running") - import sys import os From 2f5574303b59c01ed0a13ab7578bf78234aca450 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Fri, 13 May 2016 18:47:56 +0300 Subject: [PATCH 026/279] Use popen to hide the output of green tests --- examples/run_examples.py | 53 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/examples/run_examples.py b/examples/run_examples.py index 793dc438..d649e30a 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -26,41 +26,44 @@ import sys import os - -examples_folder = os.path.abspath(os.path.dirname(__file__)) + "/" - import subprocess import unittest -from subprocess import call +examples_folder = os.path.abspath(os.path.dirname(__file__)) + "/" + +def run_example(path): + proc = subprocess.Popen(path, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + res = proc.communicate() + if proc.returncode: + print(res[1]) + return proc.returncode class TestExamples(unittest.TestCase): - def test_eventthread(self): - self.assertEqual(subprocess.call(examples_folder + "eventthread.py"), 0) - - def test_get_selection(self): - self.assertEqual(subprocess.call([examples_folder + "get_selection.py", "PRIMARY"]), 0) - self.assertEqual(subprocess.call([examples_folder + "get_selection.py", "SECONDARY"]), 0) - self.assertEqual(subprocess.call([examples_folder + "get_selection.py", "CLIPBOARD"]), 0) + def test_eventthread(self): + self.assertEqual(run_example(examples_folder + "eventthread.py"), 0) - def test_profilex(self): - self.assertEqual(subprocess.call([examples_folder + "profilex.py", examples_folder + "profilex_output"]), 0) - subprocess.call(["rm", examples_folder + "profilex_output"]) + def test_get_selection(self): + self.assertEqual(run_example(examples_folder + "get_selection.py PRIMARY"), 0) + self.assertEqual(run_example(examples_folder + "get_selection.py SECONDARY"), 0) + self.assertEqual(run_example(examples_folder + "get_selection.py CLIPBOARD"), 0) - def test_record_demo(self): - self.assertEqual(subprocess.call(examples_folder + "record_demo.py"), 0) + def test_profilex(self): + self.assertEqual(run_example(examples_folder + "profilex.py " + examples_folder + "profilex_output"), 0) + subprocess.call(["rm", examples_folder + "profilex_output"]) - def test_security(self): - self.assertEqual(subprocess.call([examples_folder + "security.py", "--generate"]), 0) - self.assertEqual(subprocess.call([examples_folder + "security.py", "--revoke"]), 0) + def test_record_demo(self): + self.assertEqual(run_example(examples_folder + "record_demo.py"), 0) - def test_xfixes(self): - self.assertEqual(subprocess.call(examples_folder + "xfixes.py"), 0) + def test_security(self): + self.assertEqual(run_example(examples_folder + "security.py --generate"), 0) + self.assertEqual(run_example(examples_folder + "security.py --revoke"), 0) - def test_xlsatoms(self): - self.assertEqual(subprocess.call(examples_folder + "xlsatoms.py"), 0) + def test_xfixes(self): + self.assertEqual(run_example(examples_folder + "xfixes.py"), 0) -if __name__ == '__main__': - unittest.main() + def test_xlsatoms(self): + self.assertEqual(run_example(examples_folder + "xlsatoms.py"), 0) +if __name__ == '__main__': + unittest.main() From d92a6fb667e70a617fd5bd940b4e4268e83e7909 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Fri, 13 May 2016 18:55:26 +0300 Subject: [PATCH 027/279] Add docstrings --- examples/run_examples.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/run_examples.py b/examples/run_examples.py index d649e30a..9b39504a 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -39,29 +39,37 @@ def run_example(path): return proc.returncode class TestExamples(unittest.TestCase): + """ Run some of examples """ def test_eventthread(self): + """ Run eventthread.py -- Tests multithreaded event handling """ self.assertEqual(run_example(examples_folder + "eventthread.py"), 0) def test_get_selection(self): + """ Run get_selection.py -- demonstrate getting selections """ self.assertEqual(run_example(examples_folder + "get_selection.py PRIMARY"), 0) self.assertEqual(run_example(examples_folder + "get_selection.py SECONDARY"), 0) self.assertEqual(run_example(examples_folder + "get_selection.py CLIPBOARD"), 0) def test_profilex(self): + """ Run profilex.py -- program to generate profiling data """ self.assertEqual(run_example(examples_folder + "profilex.py " + examples_folder + "profilex_output"), 0) subprocess.call(["rm", examples_folder + "profilex_output"]) def test_record_demo(self): + """ Run record_demo.py -- demonstrate record extension """ self.assertEqual(run_example(examples_folder + "record_demo.py"), 0) def test_security(self): + """ Run security.py -- demonstrate the SECURITY extension """ self.assertEqual(run_example(examples_folder + "security.py --generate"), 0) self.assertEqual(run_example(examples_folder + "security.py --revoke"), 0) def test_xfixes(self): + """ Run xfixes.py -- demonstrate the XFIXES extension """ self.assertEqual(run_example(examples_folder + "xfixes.py"), 0) def test_xlsatoms(self): + """ Run xlsatoms.py -- show list atoms on X server """ self.assertEqual(run_example(examples_folder + "xlsatoms.py"), 0) From 10504411b6cc71b6decf36db5b0305381dc51035 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Fri, 13 May 2016 19:02:58 +0300 Subject: [PATCH 028/279] Comment failing tests --- examples/run_examples.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/run_examples.py b/examples/run_examples.py index 9b39504a..22fc990c 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -40,9 +40,11 @@ def run_example(path): class TestExamples(unittest.TestCase): """ Run some of examples """ - def test_eventthread(self): - """ Run eventthread.py -- Tests multithreaded event handling """ - self.assertEqual(run_example(examples_folder + "eventthread.py"), 0) + +# TODO +# def test_eventthread(self): +# """ Run eventthread.py -- Tests multithreaded event handling """ +# self.assertEqual(run_example(examples_folder + "eventthread.py"), 0) def test_get_selection(self): """ Run get_selection.py -- demonstrate getting selections """ @@ -55,9 +57,10 @@ def test_profilex(self): self.assertEqual(run_example(examples_folder + "profilex.py " + examples_folder + "profilex_output"), 0) subprocess.call(["rm", examples_folder + "profilex_output"]) - def test_record_demo(self): - """ Run record_demo.py -- demonstrate record extension """ - self.assertEqual(run_example(examples_folder + "record_demo.py"), 0) +# TODO +# def test_record_demo(self): +# """ Run record_demo.py -- demonstrate record extension """ +# self.assertEqual(run_example(examples_folder + "record_demo.py"), 0) def test_security(self): """ Run security.py -- demonstrate the SECURITY extension """ From 51fd9e0136e3c11fc31a544767be373f2b9d2cdb Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Fri, 13 May 2016 19:07:04 +0300 Subject: [PATCH 029/279] Delete test_xlsatoms --- examples/run_examples.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/examples/run_examples.py b/examples/run_examples.py index 22fc990c..688bd449 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -71,10 +71,5 @@ def test_xfixes(self): """ Run xfixes.py -- demonstrate the XFIXES extension """ self.assertEqual(run_example(examples_folder + "xfixes.py"), 0) - def test_xlsatoms(self): - """ Run xlsatoms.py -- show list atoms on X server """ - self.assertEqual(run_example(examples_folder + "xlsatoms.py"), 0) - - if __name__ == '__main__': unittest.main() From ea383fcc882cf71278234ad806d37e1ab3ea5a39 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Fri, 13 May 2016 19:22:30 +0300 Subject: [PATCH 030/279] Add test_xlsatoms --- examples/run_examples.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/run_examples.py b/examples/run_examples.py index 688bd449..22fc990c 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -71,5 +71,10 @@ def test_xfixes(self): """ Run xfixes.py -- demonstrate the XFIXES extension """ self.assertEqual(run_example(examples_folder + "xfixes.py"), 0) + def test_xlsatoms(self): + """ Run xlsatoms.py -- show list atoms on X server """ + self.assertEqual(run_example(examples_folder + "xlsatoms.py"), 0) + + if __name__ == '__main__': unittest.main() From 08f35ac92e50598cb200f2f3d6207348c4e5ad99 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Fri, 13 May 2016 19:36:18 +0300 Subject: [PATCH 031/279] Comment test_xlsatoms --- examples/run_examples.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/run_examples.py b/examples/run_examples.py index 22fc990c..aaa88362 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -71,9 +71,10 @@ def test_xfixes(self): """ Run xfixes.py -- demonstrate the XFIXES extension """ self.assertEqual(run_example(examples_folder + "xfixes.py"), 0) - def test_xlsatoms(self): - """ Run xlsatoms.py -- show list atoms on X server """ - self.assertEqual(run_example(examples_folder + "xlsatoms.py"), 0) +# TODO +# def test_xlsatoms(self): +# """ Run xlsatoms.py -- show list atoms on X server """ +# self.assertEqual(run_example(examples_folder + "xlsatoms.py"), 0) if __name__ == '__main__': From 7b6359e173f96bcb5b2de69b4ef6d475003778f3 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Fri, 13 May 2016 22:16:39 +0300 Subject: [PATCH 032/279] Add docstring to run_examples.py --- examples/run_examples.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/run_examples.py b/examples/run_examples.py index aaa88362..25f4c36e 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -32,6 +32,7 @@ examples_folder = os.path.abspath(os.path.dirname(__file__)) + "/" def run_example(path): + """ Returns returncode of example """ proc = subprocess.Popen(path, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) res = proc.communicate() if proc.returncode: From aa2b2c87d5dbba3f1164a6ad5ce656ebc35bade8 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Sat, 14 May 2016 00:49:54 +0300 Subject: [PATCH 033/279] Comment test_security - it falls on Python 3 --- examples/run_examples.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/run_examples.py b/examples/run_examples.py index 25f4c36e..0b3f18d7 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -63,10 +63,11 @@ def test_profilex(self): # """ Run record_demo.py -- demonstrate record extension """ # self.assertEqual(run_example(examples_folder + "record_demo.py"), 0) - def test_security(self): - """ Run security.py -- demonstrate the SECURITY extension """ - self.assertEqual(run_example(examples_folder + "security.py --generate"), 0) - self.assertEqual(run_example(examples_folder + "security.py --revoke"), 0) +# TODO Python 3 +# def test_security(self): +# """ Run security.py -- demonstrate the SECURITY extension """ +# self.assertEqual(run_example(examples_folder + "security.py --generate"), 0) +# self.assertEqual(run_example(examples_folder + "security.py --revoke"), 0) def test_xfixes(self): """ Run xfixes.py -- demonstrate the XFIXES extension """ From c1bff425ddf8c1360387848686ba98e1e349ef4c Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Sat, 14 May 2016 01:52:19 +0300 Subject: [PATCH 034/279] Uncomment test_security --- examples/run_examples.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/run_examples.py b/examples/run_examples.py index 0b3f18d7..25f4c36e 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -63,11 +63,10 @@ def test_profilex(self): # """ Run record_demo.py -- demonstrate record extension """ # self.assertEqual(run_example(examples_folder + "record_demo.py"), 0) -# TODO Python 3 -# def test_security(self): -# """ Run security.py -- demonstrate the SECURITY extension """ -# self.assertEqual(run_example(examples_folder + "security.py --generate"), 0) -# self.assertEqual(run_example(examples_folder + "security.py --revoke"), 0) + def test_security(self): + """ Run security.py -- demonstrate the SECURITY extension """ + self.assertEqual(run_example(examples_folder + "security.py --generate"), 0) + self.assertEqual(run_example(examples_folder + "security.py --revoke"), 0) def test_xfixes(self): """ Run xfixes.py -- demonstrate the XFIXES extension """ From c4569d2a49fb8f4a9c0becfb7ed0190cc43bd701 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Sat, 14 May 2016 02:08:28 +0300 Subject: [PATCH 035/279] Fix error message format --- examples/run_examples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/run_examples.py b/examples/run_examples.py index 25f4c36e..0b52c262 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -36,7 +36,7 @@ def run_example(path): proc = subprocess.Popen(path, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) res = proc.communicate() if proc.returncode: - print(res[1]) + print(res[1].decode()) return proc.returncode class TestExamples(unittest.TestCase): From 10efe9513c79ab07d421d5f811e565e85f1d4f1b Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Sat, 14 May 2016 02:25:29 +0300 Subject: [PATCH 036/279] Uncomment test_eventthread --- examples/run_examples.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/run_examples.py b/examples/run_examples.py index 0b52c262..1bb6fb13 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -42,10 +42,9 @@ def run_example(path): class TestExamples(unittest.TestCase): """ Run some of examples """ -# TODO -# def test_eventthread(self): -# """ Run eventthread.py -- Tests multithreaded event handling """ -# self.assertEqual(run_example(examples_folder + "eventthread.py"), 0) + def test_eventthread(self): + """ Run eventthread.py -- Tests multithreaded event handling """ + self.assertEqual(run_example(examples_folder + "eventthread.py"), 0) def test_get_selection(self): """ Run get_selection.py -- demonstrate getting selections """ From 4b862596e4afc10cf3ba8072425ec0a91f0d3a56 Mon Sep 17 00:00:00 2001 From: Svetlana Filicheva Date: Sat, 14 May 2016 02:42:25 +0300 Subject: [PATCH 037/279] Comment test_eventthread --- examples/run_examples.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/run_examples.py b/examples/run_examples.py index 1bb6fb13..0b52c262 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -42,9 +42,10 @@ def run_example(path): class TestExamples(unittest.TestCase): """ Run some of examples """ - def test_eventthread(self): - """ Run eventthread.py -- Tests multithreaded event handling """ - self.assertEqual(run_example(examples_folder + "eventthread.py"), 0) +# TODO +# def test_eventthread(self): +# """ Run eventthread.py -- Tests multithreaded event handling """ +# self.assertEqual(run_example(examples_folder + "eventthread.py"), 0) def test_get_selection(self): """ Run get_selection.py -- demonstrate getting selections """ From 1f64ac04f2476319b6e99909ff639cfb9cc2c1ce Mon Sep 17 00:00:00 2001 From: Sebastian Olsson Date: Wed, 22 Jun 2016 09:44:12 +0000 Subject: [PATCH 038/279] Fixed broken subprocess calls when running Py2 with Py3 as the default. --- examples/run_examples.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/run_examples.py b/examples/run_examples.py index 0b52c262..39e65184 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -33,7 +33,8 @@ def run_example(path): """ Returns returncode of example """ - proc = subprocess.Popen(path, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + cmd = "{} {}".format(sys.executable, path) + proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) res = proc.communicate() if proc.returncode: print(res[1].decode()) From 4853bfbea69e38a944944d7a779f03f0eea3eba2 Mon Sep 17 00:00:00 2001 From: Sebastian Olsson Date: Wed, 22 Jun 2016 09:55:06 +0000 Subject: [PATCH 039/279] Added indices for backwards compatibility with Py2.6. --- examples/run_examples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/run_examples.py b/examples/run_examples.py index 39e65184..8de4d7d7 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -33,7 +33,7 @@ def run_example(path): """ Returns returncode of example """ - cmd = "{} {}".format(sys.executable, path) + cmd = "{0} {1}".format(sys.executable, path) proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) res = proc.communicate() if proc.returncode: From 59a040f20d6f2bae2e15434bff5daa16a5203800 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 30 Oct 2015 16:40:25 +0100 Subject: [PATCH 040/279] record: fix extension (without changing API) --- Xlib/ext/record.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Xlib/ext/record.py b/Xlib/ext/record.py index a6a34e00..424c672f 100644 --- a/Xlib/ext/record.py +++ b/Xlib/ext/record.py @@ -43,8 +43,10 @@ rq.Card16('first'), rq.Card16('last')) Record_ExtRange = rq.Struct( - rq.Object('major_range', Record_Range8), - rq.Object('minor_range', Record_Range16)) + rq.Card8('major_range_first'), + rq.Card8('major_range_last'), + rq.Card16('minor_range_first'), + rq.Card16('minor_range_last')) Record_Range = rq.Struct( rq.Object('core_requests', Record_Range8), rq.Object('core_replies', Record_Range8), From c17ad41fe379056903b8735f3c77dd43d780e016 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 30 Oct 2015 22:22:09 +0100 Subject: [PATCH 041/279] protocol: fix handling of generic events Make sure we start a new iteration of the parse_response loop upon handling a response, so the code does not try to parse left over received data based on the previous request type. --- Xlib/protocol/display.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 3f785394..a4a6a6cf 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -651,8 +651,10 @@ def parse_response(self, request): if rtype == 1: gotreq = self.parse_request_response(request) or gotreq + continue elif rtype & 0x7f == ge.GenericEventCode: self.parse_event_response(rtype) + continue else: raise AssertionError(rtype) From 7609c95e0a5a8ad6115b5a34dc71d7e0a369e7b4 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 23 Nov 2015 10:51:38 +0100 Subject: [PATCH 042/279] test: update genprottest.py - fix C warnings (missing "string.h" include) - use random instead of deprecated whrandom - use assertEqual instead of deprecated assert_ - improve assertions messages for binary checks - automatically skip test with wrong endianness - fix invalid use of '//' in generated C code --- test/__init__.py | 79 ++++++++++++++++++++++++ test/gen/genprottest.py | 131 ++++++++++++++-------------------------- 2 files changed, 124 insertions(+), 86 deletions(-) create mode 100644 test/__init__.py diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 00000000..0f85c937 --- /dev/null +++ b/test/__init__.py @@ -0,0 +1,79 @@ + +import unittest +import binascii +import difflib +import struct +import array + +import Xlib.protocol.event +import Xlib.protocol.rq + + +class CmpArray(object): + + def __init__(self, *args, **kws): + self.array = array.array(*args, **kws) + + def __len__(self): + return len(self.array) + + def __getitem__(self, key): + if isinstance(key, slice): + x = key.start + y = key.stop + return list(self.array[x:y]) + else: + return self.array[key] + + def __getattr__(self, attr): + return getattr(self.array, attr) + + def __eq__(self, other): + return self.array.tolist() == other + +Xlib.protocol.rq.array = CmpArray + + +class DummyDisplay(object): + + def get_resource_class(self, x): + return None + + event_classes = Xlib.protocol.event.event_class + + +class TestCase(unittest.TestCase): + + def assertBinaryEqual(self, bin1, bin2): + if bin1 == bin2: + return + self.fail('binary contents differ:\n' + bindiff(bin1, bin2)) + + def assertBinaryEmpty(self, bin): + if 0 == len(bin): + return + self.fail('binary content not empty:\n' + ''.join(tohex(bin))) + +class BigEndianTest(TestCase): + @classmethod + def setUpClass(cls): + if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 1: + raise unittest.SkipTest('big-endian tests, skipping on this system') + +class LittleEndianTest(TestCase): + @classmethod + def setUpClass(cls): + if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 0: + raise unittest.SkipTest('little-endian tests, skipping on this system') + + +def tohex(bin): + hex = [] + for i in range(0, len(bin), 16): + hex.append(binascii.hexlify(bin[i:i+16]) + '\n') + return hex + +def bindiff(bin1, bin2): + hex1 = tohex(bin1) + hex2 = tohex(bin2) + return ''.join(difflib.ndiff(hex1, hex2)) diff --git a/test/gen/genprottest.py b/test/gen/genprottest.py index 1275acc9..b6993c08 100755 --- a/test/gen/genprottest.py +++ b/test/gen/genprottest.py @@ -1,17 +1,21 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 import sys import os -sys.path.insert(1, os.path.join(sys.path[0], '../..')) +sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../../..'))) import types import struct -from whrandom import randint, choice +from random import randint, choice, seed from Xlib.protocol import request, structs, rq, event from Xlib import X, XK + + +seed(42) + MINI_DEF = (('CARD8', 'reqType'), ('BYTE', 'pad'), ('CARD16', 'length')) @@ -181,14 +185,14 @@ def build_request(endian): elif parts[0] == 'REPLY': reply_bins[parts[1]] = parts[2] - fpy = open('test_requests_%s.py' % endian, 'w') - os.chmod('test_requests_%s.py' % endian, 0755) + fpy = open('../test_requests_%s.py' % endian, 'w') + os.chmod('../test_requests_%s.py' % endian, 0755) if endian == 'be': - e = 'Big-endian' + e = 'BigEndian' v = 1 else: - e = 'Little-endian' + e = 'LittleEndian' v = 0 fpy.write(PY_HEADER % { 'endname': e, 'endvalue': v }) @@ -196,7 +200,7 @@ def build_request(endian): for code, req in reqlist: name = req.__name__ - fpy.write('\n\nclass Test%s(unittest.TestCase):\n' % name) + fpy.write('\n\nclass Test%s(EndianTest):\n' % name) fpy.write(' def setUp(self):\n') i = 0 @@ -233,30 +237,29 @@ def build_request(endian): fpy.write(''' def testPackRequest%(n)d(self): bin = request.%(req)s._request.to_binary(*(), **self.req_args_%(n)d) - self.assert_(bin == self.req_bin_%(n)d, tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_%(n)d) def testUnpackRequest%(n)d(self): args, remain = request.%(req)s._request.parse_binary(self.req_bin_%(n)d, dummy_display, 1) - self.assert_(len(remain) == 0, tohex(remain)) - self.assert_(args == self.req_args_%(n)d, args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_%(n)d) ''' % { 'req': req.__name__, 'n': i }) for i in range(0, replies + 1): fpy.write(''' def testPackReply%(n)d(self): bin = request.%(req)s._reply.to_binary(*(), **self.reply_args_%(n)d) - self.assert_(bin == self.reply_bin_%(n)d, tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_%(n)d) def testUnpackReply%(n)d(self): args, remain = request.%(req)s._reply.parse_binary(self.reply_bin_%(n)d, dummy_display, 1) - self.assert_(len(remain) == 0, tohex(remain)) - self.assert_(args == self.reply_args_%(n)d, args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_%(n)d) ''' % { 'req': req.__name__, 'n': i }) fpy.write(''' if __name__ == "__main__": - check_endian() unittest.main() ''') @@ -350,14 +353,14 @@ def build_event(endian): if parts[0] == 'EVENT': evt_bins[parts[1]] = parts[2] - fpy = open('test_events_%s.py' % endian, 'w') - os.chmod('test_events_%s.py' % endian, 0755) + fpy = open('../test_events_%s.py' % endian, 'w') + os.chmod('../test_events_%s.py' % endian, 0755) if endian == 'be': - e = 'Big-endian' + e = 'BigEndian' v = 1 else: - e = 'Little-endian' + e = 'LittleEndian' v = 0 fpy.write(PY_HEADER % { 'endname': e, 'endvalue': v }) @@ -368,7 +371,7 @@ def build_event(endian): name = evt.__name__ - fpy.write('\n\nclass Test%s(unittest.TestCase):\n' % name) + fpy.write('\n\nclass Test%s(EndianTest):\n' % name) fpy.write(' def setUp(self):\n') i = 0 @@ -395,18 +398,17 @@ def build_event(endian): fpy.write(''' def testPack%(n)d(self): bin = event.%(evt)s._fields.to_binary(*(), **self.evt_args_%(n)d) - self.assert_(bin == self.evt_bin_%(n)d, tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_%(n)d) def testUnpack%(n)d(self): args, remain = event.%(evt)s._fields.parse_binary(self.evt_bin_%(n)d, dummy_display, 1) - self.assert_(len(remain) == 0, tohex(remain)) - self.assert_(args == self.evt_args_%(n)d, args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_%(n)d) ''' % { 'evt': evt.__name__, 'n': i }) fpy.write(''' if __name__ == "__main__": - check_endian() unittest.main() ''') @@ -790,14 +792,14 @@ def rand(x, rmin = rmin, rmax = rmax): assert f == 'length' fc.write(' assert(sizeof(data) % 4 == 0);\n') - fc.write(' data.xstruct.length = sizeof(data) // 4;\n') + fc.write(' data.xstruct.length = sizeof(data) / 4;\n') elif isinstance(pyf, rq.ReplyLength): assert f == 'length' fc.write(' assert(sizeof(data) % 4 == 0);\n') fc.write(' assert(sizeof(data) >= 32);\n') - fc.write(' data.xstruct.length = (sizeof(data) - 32) // 4;\n') + fc.write(' data.xstruct.length = (sizeof(data) - 32) / 4;\n') elif isinstance(pyf, rq.LengthOf): fc.write(' data.xstruct.%s = %d;\n' % (f, varfs[pyf.name][1])) @@ -874,8 +876,17 @@ def cstring(s): def build_args(args): kwlist = [] - for kw, val in args.items(): - kwlist.append(" '%s': %s,\n" % (kw, repr(val))) + for kw, val in sorted(args.items(), key=lambda i: i[0]): + if isinstance(val, rq.Event): + members = val._data.keys() + members.remove('send_event') + kwlist.append(" '%s': event.%s(%s),\n" % ( + kw, val.__class__.__name__, + ', '.join('%s=%s' % (m, val._data[m]) + for m in sorted(members)), + )) + else: + kwlist.append(" '%s': %s,\n" % (kw, repr(val))) return '{\n' + ''.join(kwlist) + ' }' @@ -986,6 +997,7 @@ def build_bin(bin): #include #include #include +#include #include void output(char *name, void *data, int length) @@ -1007,70 +1019,17 @@ def build_bin(bin): ''' -PY_HEADER = r'''#!/usr/bin/env python +PY_HEADER = r'''#!/usr/bin/env python2 -import sys, os -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) +import sys, os, difflib +sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest from Xlib.protocol import request, rq, event -import Xlib.protocol.event - -import struct -import array - -class CmpArray(object): - def __init__(self, *args, **kws): - self.array = array.array(*args, **kws) - - def __len__(self): - return len(self.array) +from . import %(endname)sTest as EndianTest +from . import DummyDisplay - def __getitem__(self, key): - if isinstance(key, slice): - x = key.start - y = key.stop - return list(self.array[x:y]) - else: - return self.array[key] - - def __getattr__(self, attr): - return getattr(self.array, attr) - - def __cmp__(self, other): - return cmp(self.array.tolist(), other) - -rq.array = CmpArray - -def tohex(bin): - bin = ''.join(map(lambda c: '\\x%%02x' %% ord(c), bin)) - - bins = [] - for i in range(0, len(bin), 16): - bins.append(bin[i:i+16]) - - bins2 = [] - for i in range(0, len(bins), 2): - try: - bins2.append("'%%s' '%%s'" %% (bins[i], bins[i + 1])) - except IndexError: - bins2.append("'%%s'" %% bins[i]) - - return ' \\\n '.join(bins2) - -class DummyDisplay: - def get_resource_class(self, x): - return None - - event_classes = Xlib.protocol.event.event_class dummy_display = DummyDisplay() - - -def check_endian(): - if struct.unpack('BB', struct.pack('H', 0x0100))[0] != %(endvalue)d: - sys.stderr.write('%(endname)s tests, skipping on this system.\n') - sys.exit(0) - ''' if __name__ == '__main__': From 3362695636bc13f66621ae85fcf4c4285ad12025 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 15:55:55 +0200 Subject: [PATCH 043/279] test: add gen/.gitignore --- test/gen/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test/gen/.gitignore diff --git a/test/gen/.gitignore b/test/gen/.gitignore new file mode 100644 index 00000000..e41b14be --- /dev/null +++ b/test/gen/.gitignore @@ -0,0 +1,4 @@ +/genevent +/genevent.c +/genrequest +/genrequest.c From 560ebcb93ed7ba53ba0ccbf4cd00e0eb1a05b15a Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 15:56:39 +0200 Subject: [PATCH 044/279] test: update little-endian tests --- test/test_events_le.py | 967 +++---- test/test_requests_le.py | 5495 +++++++++++++------------------------- 2 files changed, 2253 insertions(+), 4209 deletions(-) diff --git a/test/test_events_le.py b/test/test_events_le.py index 2d9b40e0..b8ff9c07 100755 --- a/test/test_events_le.py +++ b/test/test_events_le.py @@ -1,923 +1,638 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 -import sys, os -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) +import sys, os, difflib +sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest from Xlib.protocol import request, rq, event -import Xlib.protocol.event +from . import LittleEndianTest as EndianTest +from . import DummyDisplay -import struct -import array - -if sys.version_info[0] >= 3: - def _ordb(i): - """Integer representation of a byte indexed from a byte string - Py3""" - return i -else: - def _ordb(c): - """Integer representation of a byte indexed from a byte string - Py2""" - return ord(c) - -class CmpArray(object): - def __init__(self, *args, **kws): - self.array = array.array(*args, **kws) - - def __len__(self): - return len(self.array) - - def __getitem__(self, key): - if isinstance(key, slice): - x = key.start - y = key.stop - return list(self.array[x:y]) - else: - return self.array[key] - - def __getattr__(self, attr): - return getattr(self.array, attr) - - def __lt__(self, other): - return self.array.tolist() < other - - def __gt__(self, other): - return self.array.tolist() > other - - def __eq__(self, other): - return self.array.tolist() == other - -rq.array = CmpArray - -def tohex(bin): - bin = ''.join(map(lambda c: '\\x%02x' % _ordb(c), bin)) - - bins = [] - for i in range(0, len(bin), 16): - bins.append(bin[i:i+16]) - - bins2 = [] - for i in range(0, len(bins), 2): - try: - bins2.append("'%s' '%s'" % (bins[i], bins[i + 1])) - except IndexError: - bins2.append("'%s'" % bins[i]) - - return ' \\\n '.join(bins2) - -class DummyDisplay: - def get_resource_class(self, x): - return None - - event_classes = Xlib.protocol.event.event_class dummy_display = DummyDisplay() -def check_endian(): - if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 0: - sys.stderr.write('Little-endian tests, skipping on this system.\n') - sys.exit(0) - - - -class TestKeymapNotify(unittest.TestCase): +class TestKeymapNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'type': 173, - 'data': [130, 181, 177, 244, 167, 144, 216, 185, 228, 220, 254, 130, 239, 213, 142, 240, 233, 248, 161, 238, 160, 205, 212, 205, 166, 156, 241, 169, 198, 147, 144], + 'data': [236, 252, 232, 206, 210, 131, 246, 234, 162, 151, 217, 167, 171, 128, 239, 200, 179, 146, 209, 131, 223, 155, 181, 171, 175, 220, 227, 200, 138, 134, 148], + 'type': 207, } - self.evt_bin_0 = b'\xad\x82\xb5\xb1' b'\xf4\xa7\x90\xd8' \ - b'\xb9\xe4\xdc\xfe' b'\x82\xef\xd5\x8e' \ - b'\xf0\xe9\xf8\xa1' b'\xee\xa0\xcd\xd4' \ - b'\xcd\xa6\x9c\xf1' b'\xa9\xc6\x93\x90' + self.evt_bin_0 = '\xcf\xec\xfc\xe8' '\xce\xd2\x83\xf6' \ + '\xea\xa2\x97\xd9' '\xa7\xab\x80\xef' \ + '\xc8\xb3\x92\xd1' '\x83\xdf\x9b\xb5' \ + '\xab\xaf\xdc\xe3' '\xc8\x8a\x86\x94' def testPack0(self): bin = event.KeymapNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.KeymapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestExpose(unittest.TestCase): +class TestExpose(EndianTest): def setUp(self): self.evt_args_0 = { - 'count': 31063, - 'width': 57024, - 'window': 1993119152, - 'y': 29154, - 'x': 15652, - 'type': 192, - 'sequence_number': 45668, - 'height': 29709, + 'count': 7686, + 'height': 49538, + 'sequence_number': 18018, + 'type': 214, + 'width': 18088, + 'window': 1421524673, + 'x': 31959, + 'y': 29112, } - self.evt_bin_0 = b'\xc0\x00\x64\xb2' b'\xb0\x95\xcc\x76' \ - b'\x24\x3d\xe2\x71' b'\xc0\xde\x0d\x74' \ - b'\x57\x79\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xd6\x00\x62\x46' '\xc1\xbe\xba\x54' \ + '\xd7\x7c\xb8\x71' '\xa8\x46\x82\xc1' \ + '\x06\x1e\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.Expose._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.Expose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestGraphicsExpose(unittest.TestCase): +class TestGraphicsExpose(EndianTest): def setUp(self): self.evt_args_0 = { - 'count': 7002, - 'width': 21650, - 'major_event': 238, - 'minor_event': 44368, - 'y': 2412, - 'x': 50041, - 'drawable': 950531249, - 'type': 138, - 'sequence_number': 9516, - 'height': 10465, + 'count': 757, + 'drawable': 1457059207, + 'height': 26058, + 'major_event': 166, + 'minor_event': 39379, + 'sequence_number': 18746, + 'type': 183, + 'width': 3220, + 'x': 32023, + 'y': 43806, } - self.evt_bin_0 = b'\x8a\x00\x2c\x25' b'\xb1\xf4\xa7\x38' \ - b'\x79\xc3\x6c\x09' b'\x92\x54\xe1\x28' \ - b'\x50\xad\x5a\x1b' b'\xee\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xb7\x00\x3a\x49' '\x87\xf5\xd8\x56' \ + '\x17\x7d\x1e\xab' '\x94\x0c\xca\x65' \ + '\xd3\x99\xf5\x02' '\xa6\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.GraphicsExpose._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.GraphicsExpose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestNoExpose(unittest.TestCase): +class TestNoExpose(EndianTest): def setUp(self): self.evt_args_0 = { - 'minor_event': 49058, - 'window': 1389793826, - 'type': 198, - 'major_event': 149, - 'sequence_number': 51301, + 'major_event': 128, + 'minor_event': 21675, + 'sequence_number': 9214, + 'type': 155, + 'window': 548772746, } - self.evt_bin_0 = b'\xc6\x00\x65\xc8' b'\x22\x92\xd6\x52' \ - b'\xa2\xbf\x95\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\x9b\x00\xfe\x23' '\x8a\x9b\xb5\x20' \ + '\xab\x54\x80\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.NoExpose._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.NoExpose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestVisibilityNotify(unittest.TestCase): +class TestVisibilityNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'window': 848538738, - 'type': 233, - 'state': 239, - 'sequence_number': 38248, + 'sequence_number': 11725, + 'state': 218, + 'type': 223, + 'window': 816529890, } - self.evt_bin_0 = b'\xe9\x00\x68\x95' b'\x72\xac\x93\x32' \ - b'\xef\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xdf\x00\xcd\x2d' '\xe2\x41\xab\x30' \ + '\xda\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.VisibilityNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.VisibilityNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestCreateNotify(unittest.TestCase): +class TestCreateNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'width': 24559, - 'window': 1328254552, - 'parent': 112487253, - 'override': 0, - 'y': -31372, - 'x': -13676, - 'border_width': 32812, - 'type': 230, - 'sequence_number': 14268, - 'height': 8803, + 'border_width': 56534, + 'height': 60389, + 'override': 1, + 'parent': 1731314417, + 'sequence_number': 54657, + 'type': 192, + 'width': 1479, + 'window': 154841762, + 'x': -4750, + 'y': -31393, } - self.evt_bin_0 = b'\xe6\x00\xbc\x37' b'\x55\x6b\xb4\x06' \ - b'\x58\x8e\x2b\x4f' b'\x94\xca\x74\x85' \ - b'\xef\x5f\x63\x22' b'\x2c\x80\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xc0\x00\x81\xd5' '\xf1\xc2\x31\x67' \ + '\xa2\xb2\x3a\x09' '\x72\xed\x5f\x85' \ + '\xc7\x05\xe5\xeb' '\xd6\xdc\x01\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.CreateNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.CreateNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestDestroyNotify(unittest.TestCase): +class TestDestroyNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'window': 1384567865, - 'type': 183, - 'event': 1596763581, - 'sequence_number': 37839, + 'event': 897029110, + 'sequence_number': 46572, + 'type': 201, + 'window': 247390922, } - self.evt_bin_0 = b'\xb7\x00\xcf\x93' b'\xbd\xad\x2c\x5f' \ - b'\x39\xd4\x86\x52' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xc9\x00\xec\xb5' '\xf6\x93\x77\x35' \ + '\xca\xe2\xbe\x0e' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.DestroyNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.DestroyNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestUnmapNotify(unittest.TestCase): +class TestUnmapNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'window': 1267184116, - 'type': 192, - 'event': 913541146, - 'sequence_number': 55135, - 'from_configure': 0, + 'event': 1720839242, + 'from_configure': 1, + 'sequence_number': 21456, + 'type': 130, + 'window': 1327438921, } - self.evt_bin_0 = b'\xc0\x00\x5f\xd7' b'\x1a\x88\x73\x36' \ - b'\xf4\xb1\x87\x4b' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\x82\x00\xd0\x53' '\x4a\xec\x91\x66' \ + '\x49\x1c\x1f\x4f' '\x01\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.UnmapNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.UnmapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestMapNotify(unittest.TestCase): +class TestMapNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'override': 0, - 'window': 2002432488, - 'type': 216, - 'event': 1566597012, - 'sequence_number': 8920, + 'event': 1813526544, + 'override': 1, + 'sequence_number': 6009, + 'type': 245, + 'window': 522567740, } - self.evt_bin_0 = b'\xd8\x00\xd8\x22' b'\x94\x5f\x60\x5d' \ - b'\xe8\xb1\x5a\x77' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xf5\x00\x79\x17' '\x10\x38\x18\x6c' \ + '\x3c\xc0\x25\x1f' '\x01\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.MapNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.MapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestMapRequest(unittest.TestCase): +class TestMapRequest(EndianTest): def setUp(self): self.evt_args_0 = { - 'window': 1740270413, - 'type': 242, - 'parent': 1188866605, - 'sequence_number': 6729, + 'parent': 666354749, + 'sequence_number': 26091, + 'type': 195, + 'window': 729142504, } - self.evt_bin_0 = b'\xf2\x00\x49\x1a' b'\x2d\xaa\xdc\x46' \ - b'\x4d\x6b\xba\x67' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xc3\x00\xeb\x65' '\x3d\xc4\xb7\x27' \ + '\xe8\xd4\x75\x2b' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.MapRequest._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.MapRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestReparentNotify(unittest.TestCase): +class TestReparentNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'override': 0, - 'window': 918878719, - 'parent': 1046822430, - 'y': -10755, - 'x': -11814, - 'type': 185, - 'event': 1344092894, - 'sequence_number': 31034, + 'event': 1096286586, + 'override': 1, + 'parent': 1095145830, + 'sequence_number': 11231, + 'type': 170, + 'window': 244928407, + 'x': -3314, + 'y': -21409, } - self.evt_bin_0 = b'\xb9\x00\x3a\x79' b'\xde\x3a\x1d\x50' \ - b'\xff\xf9\xc4\x36' b'\x1e\x3e\x65\x3e' \ - b'\xda\xd1\xfd\xd5' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xaa\x00\xdf\x2b' '\x7a\x01\x58\x41' \ + '\x97\x4f\x99\x0e' '\x66\x99\x46\x41' \ + '\x0e\xf3\x5f\xac' '\x01\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.ReparentNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ReparentNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestConfigureNotify(unittest.TestCase): +class TestConfigureNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'y': -32583, - 'above_sibling': 1143940649, - 'height': 44365, - 'width': 24191, - 'window': 1699527401, - 'override': 1, - 'x': -23713, - 'border_width': 51797, - 'type': 191, - 'event': 2102634753, - 'sequence_number': 21818, + 'above_sibling': 423690578, + 'border_width': 50707, + 'event': 507433541, + 'height': 11820, + 'override': 0, + 'sequence_number': 53461, + 'type': 232, + 'width': 43047, + 'window': 314542502, + 'x': -13183, + 'y': -8052, } - self.evt_bin_0 = b'\xbf\x00\x3a\x55' b'\x01\xa9\x53\x7d' \ - b'\xe9\xba\x4c\x65' b'\x29\x26\x2f\x44' \ - b'\x5f\xa3\xb9\x80' b'\x7f\x5e\x4d\xad' \ - b'\x55\xca\x01\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xe8\x00\xd5\xd0' '\x45\xd2\x3e\x1e' \ + '\xa6\x89\xbf\x12' '\x52\x01\x41\x19' \ + '\x81\xcc\x8c\xe0' '\x27\xa8\x2c\x2e' \ + '\x13\xc6\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.ConfigureNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ConfigureNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestConfigureRequest(unittest.TestCase): +class TestConfigureRequest(EndianTest): def setUp(self): self.evt_args_0 = { - 'parent': 1484835068, - 'width': 46666, - 'value_mask': 41755, - 'stack_mode': 155, - 'height': 27280, - 'sibling': 1153557246, - 'window': 549283037, - 'y': -1019, - 'x': -11524, - 'border_width': 41299, - 'type': 140, - 'sequence_number': 48820, + 'border_width': 4713, + 'height': 10110, + 'parent': 1984611127, + 'sequence_number': 29560, + 'sibling': 1364316652, + 'stack_mode': 225, + 'type': 224, + 'value_mask': 29123, + 'width': 41200, + 'window': 1212265415, + 'x': -12463, + 'y': -4669, } - self.evt_bin_0 = b'\x8c\x9b\xb4\xbe' b'\xfc\xc8\x80\x58' \ - b'\xdd\x64\xbd\x20' b'\xfe\xe2\xc1\x44' \ - b'\xfc\xd2\x05\xfc' b'\x4a\xb6\x90\x6a' \ - b'\x53\xa1\x1b\xa3' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xe0\xe1\x78\x73' '\x37\xc3\x4a\x76' \ + '\xc7\xb3\x41\x48' '\xec\xd1\x51\x51' \ + '\x51\xcf\xc3\xed' '\xf0\xa0\x7e\x27' \ + '\x69\x12\xc3\x71' '\x00\x00\x00\x00' def testPack0(self): bin = event.ConfigureRequest._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ConfigureRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestGravityNotify(unittest.TestCase): +class TestGravityNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'window': 1471159096, - 'y': -26841, - 'x': -10882, - 'type': 191, - 'event': 860169186, - 'sequence_number': 48472, + 'event': 120690564, + 'sequence_number': 18186, + 'type': 166, + 'window': 1089529951, + 'x': -22676, + 'y': -18075, } - self.evt_bin_0 = b'\xbf\x00\x58\xbd' b'\xe2\x23\x45\x33' \ - b'\x38\x1b\xb0\x57' b'\x7e\xd5\x27\x97' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xa6\x00\x0a\x47' '\x84\x97\x31\x07' \ + '\x5f\xe8\xf0\x40' '\x6c\xa7\x65\xb9' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.GravityNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.GravityNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestResizeRequest(unittest.TestCase): +class TestResizeRequest(EndianTest): def setUp(self): self.evt_args_0 = { - 'width': 8842, - 'window': 995086195, - 'type': 139, - 'sequence_number': 9443, - 'height': 58942, + 'height': 56089, + 'sequence_number': 54549, + 'type': 135, + 'width': 56674, + 'window': 164839077, } - self.evt_bin_0 = b'\x8b\x00\xe3\x24' b'\x73\xcf\x4f\x3b' \ - b'\x8a\x22\x3e\xe6' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\x87\x00\x15\xd5' '\xa5\x3e\xd3\x09' \ + '\x62\xdd\x19\xdb' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.ResizeRequest._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ResizeRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestPropertyNotify(unittest.TestCase): +class TestPropertyNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'window': 1763395006, - 'time': 936540618, - 'atom': 47197280, - 'type': 205, - 'state': 241, - 'sequence_number': 47586, + 'atom': 1190414551, + 'sequence_number': 33357, + 'state': 242, + 'time': 1700429414, + 'type': 206, + 'window': 993700932, } - self.evt_bin_0 = b'\xcd\x00\xe2\xb9' b'\xbe\x45\x1b\x69' \ - b'\x60\x2c\xd0\x02' b'\xca\x79\xd2\x37' \ - b'\xf1\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xce\x00\x4d\x82' '\x44\xac\x3a\x3b' \ + '\xd7\x48\xf4\x46' '\x66\x7e\x5a\x65' \ + '\xf2\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.PropertyNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.PropertyNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestSelectionClear(unittest.TestCase): +class TestSelectionClear(EndianTest): def setUp(self): self.evt_args_0 = { - 'window': 336291153, - 'atom': 256452607, - 'type': 232, - 'sequence_number': 26660, - 'time': 1732839301, + 'atom': 1021439924, + 'sequence_number': 53120, + 'time': 1399833091, + 'type': 185, + 'window': 690517929, } - self.evt_bin_0 = b'\xe8\x00\x24\x68' b'\x85\x07\x49\x67' \ - b'\x51\x65\x0b\x14' b'\xff\x27\x49\x0f' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xb9\x00\x80\xcf' '\x03\xc2\x6f\x53' \ + '\xa9\x77\x28\x29' '\xb4\xef\xe1\x3c' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.SelectionClear._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.SelectionClear._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestSelectionRequest(unittest.TestCase): +class TestSelectionRequest(EndianTest): def setUp(self): self.evt_args_0 = { - 'requestor': 264947265, - 'selection': 1535909824, - 'target': 607705863, - 'time': 1423586793, - 'owner': 764886771, - 'property': 1148098854, + 'owner': 1930866783, + 'property': 370621667, + 'requestor': 737570035, + 'selection': 1533999683, + 'sequence_number': 4295, + 'target': 1083543199, + 'time': 222327341, 'type': 147, - 'sequence_number': 20571, } - self.evt_bin_0 = b'\x93\x00\x5b\x50' b'\xe9\x35\xda\x54' \ - b'\xf3\x3e\x97\x2d' b'\x41\xc6\xca\x0f' \ - b'\xc0\x1f\x8c\x5b' b'\x07\xdb\x38\x24' \ - b'\x26\x99\x6e\x44' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\x93\x00\xc7\x10' '\x2d\x72\x40\x0d' \ + '\x5f\xb0\x16\x73' '\xf3\x6c\xf6\x2b' \ + '\x43\xfa\x6e\x5b' '\x9f\x8e\x95\x40' \ + '\xe3\x3c\x17\x16' '\x00\x00\x00\x00' def testPack0(self): bin = event.SelectionRequest._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.SelectionRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestSelectionNotify(unittest.TestCase): +class TestSelectionNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'requestor': 971528625, - 'selection': 327380230, - 'target': 1874329297, - 'time': 1022248107, - 'property': 1791820478, - 'type': 133, - 'sequence_number': 30741, + 'property': 607556330, + 'requestor': 1122624134, + 'selection': 340960018, + 'sequence_number': 28832, + 'target': 800734635, + 'time': 943687849, + 'type': 159, } - self.evt_bin_0 = b'\x85\x00\x15\x78' b'\xab\x44\xee\x3c' \ - b'\xb1\x59\xe8\x39' b'\x06\x6d\x83\x13' \ - b'\xd1\xfe\xb7\x6f' b'\xbe\x02\xcd\x6a' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\x9f\x00\xa0\x70' '\xa9\x88\x3f\x38' \ + '\x86\xe2\xe9\x42' '\x12\xa3\x52\x14' \ + '\xab\x3d\xba\x2f' '\xea\x92\x36\x24' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.SelectionNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.SelectionNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestColormapNotify(unittest.TestCase): +class TestColormapNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'window': 1353796539, - 'colormap': 659729309, + 'colormap': 1694865742, 'new': 1, - 'type': 211, - 'state': 168, - 'sequence_number': 8684, + 'sequence_number': 22344, + 'state': 136, + 'type': 180, + 'window': 1283976465, } - self.evt_bin_0 = b'\xd3\x00\xec\x21' b'\xbb\x4b\xb1\x50' \ - b'\x9d\xab\x52\x27' b'\x01\xa8\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xb4\x00\x48\x57' '\x11\xed\x87\x4c' \ + '\x4e\x99\x05\x65' '\x01\x88\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.ColormapNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ColormapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) -class TestClientMessage(unittest.TestCase): +class TestClientMessage(EndianTest): def setUp(self): self.evt_args_0 = { - 'type': 237, - 'window': 1804643202, - 'client_type': 455293257, + 'client_type': 1554224294, 'data': (8, '01234567890123456789'), - 'sequence_number': 14854, + 'sequence_number': 44540, + 'type': 140, + 'window': 610247893, } - self.evt_bin_0 = b'\xed\x08\x06\x3a' b'\x82\xab\x90\x6b' \ - b'\x49\x39\x23\x1b' b'\x30\x31\x32\x33' \ - b'\x34\x35\x36\x37' b'\x38\x39\x30\x31' \ - b'\x32\x33\x34\x35' b'\x36\x37\x38\x39' + self.evt_bin_0 = '\x8c\x08\xfc\xad' '\xd5\xa4\x5f\x24' \ + '\xa6\x94\xa3\x5c' '\x30\x31\x32\x33' \ + '\x34\x35\x36\x37' '\x38\x39\x30\x31' \ + '\x32\x33\x34\x35' '\x36\x37\x38\x39' self.evt_args_1 = { - 'type': 160, - 'window': 948875838, - 'client_type': 212297388, + 'client_type': 715933209, 'data': (16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), - 'sequence_number': 28171, + 'sequence_number': 59422, + 'type': 212, + 'window': 1875362098, } - self.evt_bin_1 = b'\xa0\x10\x0b\x6e' b'\x3e\xb2\x8e\x38' \ - b'\xac\x66\xa7\x0c' b'\x01\x00\x02\x00' \ - b'\x03\x00\x04\x00' b'\x05\x00\x06\x00' \ - b'\x07\x00\x08\x00' b'\x09\x00\x0a\x00' + self.evt_bin_1 = '\xd4\x10\x1e\xe8' '\x32\xc1\xc7\x6f' \ + '\x19\x46\xac\x2a' '\x01\x00\x02\x00' \ + '\x03\x00\x04\x00' '\x05\x00\x06\x00' \ + '\x07\x00\x08\x00' '\x09\x00\x0a\x00' self.evt_args_2 = { - 'type': 243, - 'window': 581929030, - 'client_type': 966878718, + 'client_type': 2078114542, 'data': (32, [1, 2, 3, 4, 5]), - 'sequence_number': 63569, + 'sequence_number': 9488, + 'type': 202, + 'window': 751277030, } - self.evt_bin_2 = b'\xf3\x20\x51\xf8' b'\x46\x88\xaf\x22' \ - b'\xfe\x65\xa1\x39' b'\x01\x00\x00\x00' \ - b'\x02\x00\x00\x00' b'\x03\x00\x00\x00' \ - b'\x04\x00\x00\x00' b'\x05\x00\x00\x00' + self.evt_bin_2 = '\xca\x20\x10\x25' '\xe6\x93\xc7\x2c' \ + '\xee\x82\xdd\x7b' '\x01\x00\x00\x00' \ + '\x02\x00\x00\x00' '\x03\x00\x00\x00' \ + '\x04\x00\x00\x00' '\x05\x00\x00\x00' def testPack0(self): bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) def testPack1(self): bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_1) - try: - assert bin == self.evt_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_1) def testUnpack1(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_1) def testPack2(self): bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_2) - try: - assert bin == self.evt_bin_2 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_2) def testUnpack2(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_2, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_2 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_2) -class TestMappingNotify(unittest.TestCase): +class TestMappingNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'first_keycode': 246, - 'request': 189, - 'type': 198, - 'count': 201, - 'sequence_number': 32665, + 'count': 167, + 'first_keycode': 248, + 'request': 204, + 'sequence_number': 25843, + 'type': 217, } - self.evt_bin_0 = b'\xc6\x00\x99\x7f' b'\xbd\xf6\xc9\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = '\xd9\x00\xf3\x64' '\xcc\xf8\xa7\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = event.MappingNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.MappingNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) if __name__ == "__main__": - check_endian() unittest.main() diff --git a/test/test_requests_le.py b/test/test_requests_le.py index c5ed8e50..e79db09d 100755 --- a/test/test_requests_le.py +++ b/test/test_requests_le.py @@ -1,5607 +1,3936 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 -import sys, os -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) +import sys, os, difflib +sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest from Xlib.protocol import request, rq, event -import Xlib.protocol.event +from . import LittleEndianTest as EndianTest +from . import DummyDisplay -import struct -import array - -class CmpArray(object): - def __init__(self, *args, **kws): - self.array = array.array(*args, **kws) - - def __len__(self): - return len(self.array) - - def __getitem__(self, key): - if isinstance(key, slice): - x = key.start - y = key.stop - return list(self.array[x:y]) - else: - return self.array[key] - - def __getattr__(self, attr): - return getattr(self.array, attr) - - def __lt__(self, other): - return self.array.tolist() < other - - def __gt__(self, other): - return self.array.tolist() > other - - def __eq__(self, other): - return self.array.tolist() == other - -rq.array = CmpArray - -def tohex(bin): - bin = ''.join(map(lambda c: '\\x%02x' % ord(c), bin)) - - bins = [] - for i in range(0, len(bin), 16): - bins.append(bin[i:i+16]) - - bins2 = [] - for i in range(0, len(bins), 2): - try: - bins2.append("'%s' '%s'" % (bins[i], bins[i + 1])) - except IndexError: - bins2.append("'%s'" % bins[i]) - - return ' \\\n '.join(bins2) - -class DummyDisplay: - def get_resource_class(self, x): - return None - - event_classes = Xlib.protocol.event.event_class dummy_display = DummyDisplay() -def check_endian(): - if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 0: - sys.stderr.write('Little-endian tests, skipping on this system.\n') - sys.exit(0) - - - -class TestCreateWindow(unittest.TestCase): +class TestCreateWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'wid': 632893089, - 'parent': 563083824, - 'visual': 811875917, - 'height': 62043, - 'width': 55071, - 'depth': 198, - 'attrs': {'cursor': 788158760, 'override_redirect': 1, 'bit_gravity': 6, 'event_mask': 894192179, 'border_pixel': 1365270572, 'background_pixel': 712927020, 'save_under': 0, 'colormap': 980005049, 'do_not_propagate_mask': 667770563, 'backing_store': 1, 'win_gravity': 6, 'backing_planes': 885526468, 'border_pixmap': 513882421, 'backing_pixel': 1693821982, 'background_pixmap': 1314139736}, - 'y': -29423, - 'x': -5822, - 'border_width': 29625, - 'window_class': 2, - } - self.req_bin_0 = b'\x01\xc6\x17\x00' b'\xa1\x2e\xb9\x25' \ - b'\x30\xfa\x8f\x21' b'\x42\xe9\x11\x8d' \ - b'\x1f\xd7\x5b\xf2' b'\xb9\x73\x02\x00' \ - b'\x4d\x3e\x64\x30' b'\xff\x7f\x00\x00' \ - b'\x58\x2e\x54\x4e' b'\x2c\x67\x7e\x2a' \ - b'\x35\x39\xa1\x1e' b'\x2c\x60\x60\x51' \ - b'\x06\x00\x00\x00' b'\x06\x00\x00\x00' \ - b'\x01\x00\x00\x00' b'\xc4\x0f\xc8\x34' \ - b'\x1e\xac\xf5\x64' b'\x01\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x33\x4a\x4c\x35' \ - b'\xc3\x5e\xcd\x27' b'\xb9\xb0\x69\x3a' \ - b'\x28\x59\xfa\x2e' + 'attrs': {'cursor': 1395639147, 'override_redirect': 0, 'bit_gravity': 7, 'event_mask': 1085274634, 'border_pixel': 479392317, 'background_pixel': 53774084, 'save_under': 0, 'colormap': 427053108, 'do_not_propagate_mask': 57049357, 'backing_store': 2, 'win_gravity': 6, 'backing_planes': 186759559, 'border_pixmap': 590668475, 'backing_pixel': 906108093, 'background_pixmap': 1373182223}, + 'border_width': 22467, + 'depth': 197, + 'height': 45830, + 'parent': 1265465337, + 'visual': 2055602223, + 'wid': 473443720, + 'width': 52859, + 'window_class': 0, + 'x': -6451, + 'y': -32557, + } + self.req_bin_0 = '\x01\xc5\x17\x00' '\x88\x2d\x38\x1c' \ + '\xf9\x77\x6d\x4b' '\xcd\xe6\xd3\x80' \ + '\x7b\xce\x06\xb3' '\xc3\x57\x00\x00' \ + '\x2f\x00\x86\x7a' '\xff\x7f\x00\x00' \ + '\x0f\x19\xd9\x51' '\x04\x87\x34\x03' \ + '\xbb\xe2\x34\x23' '\x3d\xf2\x92\x1c' \ + '\x07\x00\x00\x00' '\x06\x00\x00\x00' \ + '\x02\x00\x00\x00' '\x87\xb9\x21\x0b' \ + '\xbd\x1c\x02\x36' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x0a\xfa\xaf\x40' \ + '\x0d\x81\x66\x03' '\x34\x50\x74\x19' \ + '\x6b\xc3\x2f\x53' def testPackRequest0(self): bin = request.CreateWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestChangeWindowAttributes(unittest.TestCase): +class TestChangeWindowAttributes(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 560274578, - 'attrs': {'cursor': 1238338372, 'override_redirect': 0, 'bit_gravity': 6, 'event_mask': 1980992429, 'border_pixel': 310964771, 'background_pixel': 1268171782, 'save_under': 1, 'colormap': 171538239, 'do_not_propagate_mask': 135558419, 'backing_store': 2, 'win_gravity': 10, 'backing_planes': 252687930, 'border_pixmap': 287169917, 'backing_pixel': 1114685309, 'background_pixmap': 2004887498}, + 'attrs': {'cursor': 1239881989, 'override_redirect': 0, 'bit_gravity': 5, 'event_mask': 1781144133, 'border_pixel': 1819990287, 'background_pixel': 199229639, 'save_under': 1, 'colormap': 1850510540, 'do_not_propagate_mask': 1328286054, 'backing_store': 2, 'win_gravity': 7, 'backing_planes': 1151571451, 'border_pixmap': 207756035, 'backing_pixel': 2089751951, 'background_pixmap': 722874758}, + 'window': 1513075857, } - self.req_bin_0 = b'\x02\x00\x12\x00' b'\x92\x1c\x65\x21' \ - b'\xff\x7f\x00\x00' b'\xca\x27\x80\x77' \ - b'\x06\xc4\x96\x4b' b'\x7d\xdd\x1d\x11' \ - b'\x23\xf2\x88\x12' b'\x06\x00\x00\x00' \ - b'\x0a\x00\x00\x00' b'\x02\x00\x00\x00' \ - b'\x3a\xb6\x0f\x0f' b'\x7d\xbf\x70\x42' \ - b'\x00\x00\x00\x00' b'\x01\x00\x00\x00' \ - b'\xad\x8b\x13\x76' b'\x13\x75\x14\x08' \ - b'\x3f\x77\x39\x0a' b'\x44\x8b\xcf\x49' + self.req_bin_0 = '\x02\x00\x12\x00' '\x91\xb4\x2f\x5a' \ + '\xff\x7f\x00\x00' '\x86\x31\x16\x2b' \ + '\xc7\x00\xe0\x0b' '\x03\x1b\x62\x0c' \ + '\x0f\xd9\x7a\x6c' '\x05\x00\x00\x00' \ + '\x07\x00\x00\x00' '\x02\x00\x00\x00' \ + '\xfb\x95\xa3\x44' '\x8f\x15\x8f\x7c' \ + '\x00\x00\x00\x00' '\x01\x00\x00\x00' \ + '\x45\x1a\x2a\x6a' '\x66\x09\x2c\x4f' \ + '\xcc\x8c\x4c\x6e' '\x05\x19\xe7\x49' def testPackRequest0(self): bin = request.ChangeWindowAttributes._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGetWindowAttributes(unittest.TestCase): +class TestGetWindowAttributes(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1672572666, + 'window': 98469647, } - self.req_bin_0 = b'\x03\x00\x02\x00' b'\xfa\x6e\xb1\x63' + self.req_bin_0 = '\x03\x00\x02\x00' '\x0f\x87\xde\x05' self.reply_args_0 = { - 'do_not_propagate_mask': 33915, - 'your_event_mask': 172607058, - 'override_redirect': 0, - 'bit_gravity': 128, - 'all_event_masks': 1036583348, - 'save_under': 1, - 'visual': 1419731381, - 'map_state': 169, - 'win_class': 16168, - 'backing_bit_planes': 849532878, - 'backing_store': 215, - 'win_gravity': 140, - 'map_is_installed': 1, - 'backing_pixel': 933754009, - 'sequence_number': 38504, - 'colormap': 56062036, - } - self.reply_bin_0 = b'\x01\xd7\x68\x96' b'\x03\x00\x00\x00' \ - b'\xb5\x61\x9f\x54' b'\x28\x3f\x80\x8c' \ - b'\xce\xd7\xa2\x32' b'\x99\xf4\xa7\x37' \ - b'\x01\x01\xa9\x00' b'\x54\x70\x57\x03' \ - b'\xb4\x01\xc9\x3d' b'\x52\xc6\x49\x0a' \ - b'\x7b\x84\x00\x00' + 'all_event_masks': 1308124489, + 'backing_bit_planes': 1365145824, + 'backing_pixel': 783512764, + 'backing_store': 157, + 'bit_gravity': 140, + 'colormap': 1391668458, + 'do_not_propagate_mask': 47853, + 'map_is_installed': 0, + 'map_state': 162, + 'override_redirect': 1, + 'save_under': 0, + 'sequence_number': 19147, + 'visual': 171412272, + 'win_class': 15452, + 'win_gravity': 163, + 'your_event_mask': 367571768, + } + self.reply_bin_0 = '\x01\x9d\xcb\x4a' '\x03\x00\x00\x00' \ + '\x30\x8b\x37\x0a' '\x5c\x3c\x8c\xa3' \ + '\xe0\x78\x5e\x51' '\xbc\x74\xb3\x2e' \ + '\x00\x00\xa2\x01' '\xea\x2c\xf3\x52' \ + '\x49\x65\xf8\x4d' '\x38\xb3\xe8\x15' \ + '\xed\xba\x00\x00' def testPackRequest0(self): bin = request.GetWindowAttributes._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetWindowAttributes._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetWindowAttributes._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestDestroyWindow(unittest.TestCase): +class TestDestroyWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 533632985, + 'window': 350959010, } - self.req_bin_0 = b'\x04\x00\x02\x00' b'\xd9\x97\xce\x1f' + self.req_bin_0 = '\x04\x00\x02\x00' '\xa2\x35\xeb\x14' def testPackRequest0(self): bin = request.DestroyWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.DestroyWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestDestroySubWindows(unittest.TestCase): +class TestDestroySubWindows(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 490680451, + 'window': 814915023, } - self.req_bin_0 = b'\x05\x00\x02\x00' b'\x83\x30\x3f\x1d' + self.req_bin_0 = '\x05\x00\x02\x00' '\xcf\x9d\x92\x30' def testPackRequest0(self): bin = request.DestroySubWindows._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.DestroySubWindows._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestChangeSaveSet(unittest.TestCase): +class TestChangeSaveSet(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1974200014, - 'mode': 0, + 'mode': 1, + 'window': 1374412611, } - self.req_bin_0 = b'\x06\x00\x02\x00' b'\xce\xe6\xab\x75' + self.req_bin_0 = '\x06\x01\x02\x00' '\x43\xdf\xeb\x51' def testPackRequest0(self): bin = request.ChangeSaveSet._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeSaveSet._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestReparentWindow(unittest.TestCase): +class TestReparentWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'y': -12763, - 'x': -18160, - 'window': 2127670410, - 'parent': 1913134105, + 'parent': 1470218577, + 'window': 1196069502, + 'x': -5365, + 'y': -7538, } - self.req_bin_0 = b'\x07\x00\x04\x00' b'\x8a\xac\xd1\x7e' \ - b'\x19\x1c\x08\x72' b'\x10\xb9\x25\xce' + self.req_bin_0 = '\x07\x00\x04\x00' '\x7e\x92\x4a\x47' \ + '\x51\xc1\xa1\x57' '\x0b\xeb\x8e\xe2' def testPackRequest0(self): bin = request.ReparentWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ReparentWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestMapWindow(unittest.TestCase): +class TestMapWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 962670079, + 'window': 491927514, } - self.req_bin_0 = b'\x08\x00\x02\x00' b'\xff\x2d\x61\x39' + self.req_bin_0 = '\x08\x00\x02\x00' '\xda\x37\x52\x1d' def testPackRequest0(self): bin = request.MapWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.MapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestMapSubwindows(unittest.TestCase): +class TestMapSubwindows(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 447820952, + 'window': 68998181, } - self.req_bin_0 = b'\x09\x00\x02\x00' b'\x98\x34\xb1\x1a' + self.req_bin_0 = '\x09\x00\x02\x00' '\x25\xd4\x1c\x04' def testPackRequest0(self): bin = request.MapSubwindows._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.MapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestUnmapWindow(unittest.TestCase): +class TestUnmapWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1130502889, + 'window': 677475124, } - self.req_bin_0 = b'\x0a\x00\x02\x00' b'\xe9\x1a\x62\x43' + self.req_bin_0 = '\x0a\x00\x02\x00' '\x34\x73\x61\x28' def testPackRequest0(self): bin = request.UnmapWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UnmapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestUnmapSubwindows(unittest.TestCase): +class TestUnmapSubwindows(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 2009442907, + 'window': 575017142, } - self.req_bin_0 = b'\x0b\x00\x02\x00' b'\x5b\xaa\xc5\x77' + self.req_bin_0 = '\x0b\x00\x02\x00' '\xb6\x10\x46\x22' def testPackRequest0(self): bin = request.UnmapSubwindows._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UnmapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestConfigureWindow(unittest.TestCase): +class TestConfigureWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 2092974410, - 'attrs': {'sibling': 1102940930, 'width': 52077, 'y': -11332, 'x': -11514, 'border_width': -6900, 'stack_mode': 4, 'height': 62050}, + 'attrs': {'width': 61485, 'stack_mode': 4, 'height': 43079, 'sibling': 849652645, 'y': -1871, 'x': -25855, 'border_width': -11291}, + 'window': 985412314, } - self.req_bin_0 = b'\x0c\x00\x0a\x00' b'\x4a\x41\xc0\x7c' \ - b'\x7f\x00\x00\x00' b'\x06\xd3\x00\x00' \ - b'\xbc\xd3\x00\x00' b'\x6d\xcb\x00\x00' \ - b'\x62\xf2\x00\x00' b'\x0c\xe5\x00\x00' \ - b'\x02\x8b\xbd\x41' b'\x04\x00\x00\x00' + self.req_bin_0 = '\x0c\x00\x0a\x00' '\xda\x32\xbc\x3a' \ + '\x7f\x00\x00\x00' '\x01\x9b\x00\x00' \ + '\xb1\xf8\x00\x00' '\x2d\xf0\x00\x00' \ + '\x47\xa8\x00\x00' '\xe5\xd3\x00\x00' \ + '\xa5\xab\xa4\x32' '\x04\x00\x00\x00' def testPackRequest0(self): bin = request.ConfigureWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ConfigureWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestCirculateWindow(unittest.TestCase): +class TestCirculateWindow(EndianTest): def setUp(self): self.req_args_0 = { 'direction': 0, - 'window': 1132872732, + 'window': 529677912, } - self.req_bin_0 = b'\x0d\x00\x02\x00' b'\x1c\x44\x86\x43' + self.req_bin_0 = '\x0d\x00\x02\x00' '\x58\x3e\x92\x1f' def testPackRequest0(self): bin = request.CirculateWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CirculateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGetGeometry(unittest.TestCase): +class TestGetGeometry(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 2036121058, + 'drawable': 1205557634, } - self.req_bin_0 = b'\x0e\x00\x02\x00' b'\xe2\xbd\x5c\x79' + self.req_bin_0 = '\x0e\x00\x02\x00' '\x82\x59\xdb\x47' self.reply_args_0 = { - 'width': 65264, - 'depth': 253, - 'y': -12126, - 'x': -29040, - 'border_width': 19896, - 'root': 493091314, - 'sequence_number': 36173, - 'height': 9014, + 'border_width': 6190, + 'depth': 161, + 'height': 33517, + 'root': 1928066656, + 'sequence_number': 38417, + 'width': 65375, + 'x': -19783, + 'y': -25638, } - self.reply_bin_0 = b'\x01\xfd\x4d\x8d' b'\x00\x00\x00\x00' \ - b'\xf2\xf9\x63\x1d' b'\x90\x8e\xa2\xd0' \ - b'\xf0\xfe\x36\x23' b'\xb8\x4d\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\xa1\x11\x96' '\x00\x00\x00\x00' \ + '\x60\xf6\xeb\x72' '\xb9\xb2\xda\x9b' \ + '\x5f\xff\xed\x82' '\x2e\x18\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetGeometry._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetGeometry._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetGeometry._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetGeometry._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestQueryTree(unittest.TestCase): +class TestQueryTree(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 884880831, + 'window': 101244093, } - self.req_bin_0 = b'\x0f\x00\x02\x00' b'\xbf\x35\xbe\x34' + self.req_bin_0 = '\x0f\x00\x02\x00' '\xbd\xdc\x08\x06' self.reply_args_0 = { - 'parent': 701348115, - 'root': 400550453, - 'children': [1089242139, 925689046, 1668140638, 775016596, 1024466546, 1245533043, 1733661379], - 'sequence_number': 10033, + 'children': [235528064, 1347454529, 1700991108, 906619494, 136486082, 819561703, 2139154628], + 'parent': 1848519458, + 'root': 2085376831, + 'sequence_number': 34796, } - self.reply_bin_0 = b'\x01\x00\x31\x27' b'\x07\x00\x00\x00' \ - b'\x35\xea\xdf\x17' b'\x13\xb9\xcd\x29' \ - b'\x07\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x1b\x84\xec\x40' b'\xd6\xe4\x2c\x37' \ - b'\x5e\xce\x6d\x63' b'\x94\xd0\x31\x2e' \ - b'\x72\x1e\x10\x3d' b'\x73\x53\x3d\x4a' \ - b'\xc3\x92\x55\x67' + self.reply_bin_0 = '\x01\x00\xec\x87' '\x07\x00\x00\x00' \ + '\x3f\x53\x4c\x7c' '\x22\x2b\x2e\x6e' \ + '\x07\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x80\xdf\x09\x0e' '\x41\x86\x50\x50' \ + '\x84\x10\x63\x65' '\x66\xea\x09\x36' \ + '\xc2\x9c\x22\x08' '\xe7\x84\xd9\x30' \ + '\xc4\xe8\x80\x7f' def testPackRequest0(self): bin = request.QueryTree._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryTree._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryTree._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryTree._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestInternAtom(unittest.TestCase): +class TestInternAtom(EndianTest): def setUp(self): self.req_args_0 = { 'name': 'fuzzy_prop', 'only_if_exists': 0, } - self.req_bin_0 = b'\x10\x00\x05\x00' b'\x0a\x00\x00\x00' \ - b'\x66\x75\x7a\x7a' b'\x79\x5f\x70\x72' \ - b'\x6f\x70\x00\x00' + self.req_bin_0 = '\x10\x00\x05\x00' '\x0a\x00\x00\x00' \ + '\x66\x75\x7a\x7a' '\x79\x5f\x70\x72' \ + '\x6f\x70\x00\x00' self.reply_args_0 = { - 'sequence_number': 14401, - 'atom': 1112752381, + 'atom': 1463982728, + 'sequence_number': 47304, } - self.reply_bin_0 = b'\x01\x00\x41\x38' b'\x00\x00\x00\x00' \ - b'\xfd\x40\x53\x42' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\x00\xc8\xb8' '\x00\x00\x00\x00' \ + '\x88\x9a\x42\x57' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.InternAtom._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.InternAtom._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.InternAtom._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.InternAtom._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestGetAtomName(unittest.TestCase): +class TestGetAtomName(EndianTest): def setUp(self): self.req_args_0 = { - 'atom': 1234624354, + 'atom': 1153165348, } - self.req_bin_0 = b'\x11\x00\x02\x00' b'\x62\xdf\x96\x49' + self.req_bin_0 = '\x11\x00\x02\x00' '\x24\xe8\xbb\x44' self.reply_args_0 = { 'name': 'WM_CLASS', - 'sequence_number': 2504, + 'sequence_number': 17674, } - self.reply_bin_0 = b'\x01\x00\xc8\x09' b'\x02\x00\x00\x00' \ - b'\x08\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x57\x4d\x5f\x43' b'\x4c\x41\x53\x53' + self.reply_bin_0 = '\x01\x00\x0a\x45' '\x02\x00\x00\x00' \ + '\x08\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x57\x4d\x5f\x43' '\x4c\x41\x53\x53' def testPackRequest0(self): bin = request.GetAtomName._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetAtomName._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetAtomName._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetAtomName._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestChangeProperty(unittest.TestCase): +class TestChangeProperty(EndianTest): def setUp(self): self.req_args_0 = { - 'type': 1211092921, - 'window': 1252285733, - 'property': 237459721, 'data': (8, ''), - 'mode': 2, + 'mode': 1, + 'property': 933688309, + 'type': 974400040, + 'window': 239614693, } - self.req_bin_0 = b'\x12\x02\x06\x00' b'\x25\x5d\xa4\x4a' \ - b'\x09\x59\x27\x0e' b'\xb9\xcf\x2f\x48' \ - b'\x08\x00\x00\x00' b'\x00\x00\x00\x00' + self.req_bin_0 = '\x12\x01\x06\x00' '\xe5\x3a\x48\x0e' \ + '\xf5\xf3\xa6\x37' '\x28\x2a\x14\x3a' \ + '\x08\x00\x00\x00' '\x00\x00\x00\x00' self.req_args_1 = { - 'type': 347282449, - 'window': 25619481, - 'property': 633953573, 'data': (8, 'foo'), - 'mode': 1, + 'mode': 2, + 'property': 565671953, + 'type': 1075033221, + 'window': 1880888002, } - self.req_bin_1 = b'\x12\x01\x07\x00' b'\x19\xec\x86\x01' \ - b'\x25\x5d\xc9\x25' b'\x11\x1c\xb3\x14' \ - b'\x08\x00\x00\x00' b'\x03\x00\x00\x00' \ - b'\x66\x6f\x6f\x00' + self.req_bin_1 = '\x12\x02\x07\x00' '\xc2\x12\x1c\x70' \ + '\x11\x78\xb7\x21' '\x85\xb4\x13\x40' \ + '\x08\x00\x00\x00' '\x03\x00\x00\x00' \ + '\x66\x6f\x6f\x00' self.req_args_2 = { - 'type': 1524334051, - 'window': 481797824, - 'property': 658642629, 'data': (8, 'zoom'), - 'mode': 1, + 'mode': 0, + 'property': 1869432878, + 'type': 640951286, + 'window': 1959859086, } - self.req_bin_2 = b'\x12\x01\x07\x00' b'\xc0\xa6\xb7\x1c' \ - b'\xc5\x16\x42\x27' b'\xe3\x7d\xdb\x5a' \ - b'\x08\x00\x00\x00' b'\x04\x00\x00\x00' \ - b'\x7a\x6f\x6f\x6d' + self.req_bin_2 = '\x12\x00\x07\x00' '\x8e\x13\xd1\x74' \ + '\x2e\x48\x6d\x6f' '\xf6\x23\x34\x26' \ + '\x08\x00\x00\x00' '\x04\x00\x00\x00' \ + '\x7a\x6f\x6f\x6d' self.req_args_3 = { - 'type': 1895805524, - 'window': 211607059, - 'property': 27240430, 'data': (16, []), - 'mode': 2, + 'mode': 1, + 'property': 328275349, + 'type': 1637495037, + 'window': 1307779197, } - self.req_bin_3 = b'\x12\x02\x06\x00' b'\x13\xde\x9c\x0c' \ - b'\xee\xa7\x9f\x01' b'\x54\xb2\xff\x70' \ - b'\x10\x00\x00\x00' b'\x00\x00\x00\x00' + self.req_bin_3 = '\x12\x01\x06\x00' '\x7d\x20\xf3\x4d' \ + '\x95\x15\x91\x13' '\xfd\x30\x9a\x61' \ + '\x10\x00\x00\x00' '\x00\x00\x00\x00' self.req_args_4 = { - 'type': 549788841, - 'window': 1498238012, - 'property': 1869628209, 'data': (16, [1, 2, 3]), - 'mode': 0, + 'mode': 1, + 'property': 1138956616, + 'type': 1293636, + 'window': 1672102137, } - self.req_bin_4 = b'\x12\x00\x08\x00' b'\x3c\x4c\x4d\x59' \ - b'\x31\x43\x70\x6f' b'\xa9\x1c\xc5\x20' \ - b'\x10\x00\x00\x00' b'\x03\x00\x00\x00' \ - b'\x01\x00\x02\x00' b'\x03\x00\x00\x00' + self.req_bin_4 = '\x12\x01\x08\x00' '\xf9\x40\xaa\x63' \ + '\x48\x19\xe3\x43' '\x44\xbd\x13\x00' \ + '\x10\x00\x00\x00' '\x03\x00\x00\x00' \ + '\x01\x00\x02\x00' '\x03\x00\x00\x00' self.req_args_5 = { - 'type': 1083661140, - 'window': 2019310438, - 'property': 394292367, 'data': (16, [1, 2, 3, 4]), - 'mode': 2, + 'mode': 0, + 'property': 1995228731, + 'type': 1887048810, + 'window': 41890245, } - self.req_bin_5 = b'\x12\x02\x08\x00' b'\x66\x3b\x5c\x78' \ - b'\x8f\x6c\x80\x17' b'\x54\x5b\x97\x40' \ - b'\x10\x00\x00\x00' b'\x04\x00\x00\x00' \ - b'\x01\x00\x02\x00' b'\x03\x00\x04\x00' + self.req_bin_5 = '\x12\x00\x08\x00' '\xc5\x31\x7f\x02' \ + '\x3b\xc6\xec\x76' '\x6a\x14\x7a\x70' \ + '\x10\x00\x00\x00' '\x04\x00\x00\x00' \ + '\x01\x00\x02\x00' '\x03\x00\x04\x00' self.req_args_6 = { - 'type': 761479544, - 'window': 1274166929, - 'property': 1743863777, 'data': (32, []), 'mode': 2, + 'property': 124455087, + 'type': 1885519250, + 'window': 660426938, } - self.req_bin_6 = b'\x12\x02\x06\x00' b'\x91\x3e\xf2\x4b' \ - b'\xe1\x3f\xf1\x67' b'\x78\x41\x63\x2d' \ - b'\x20\x00\x00\x00' b'\x00\x00\x00\x00' + self.req_bin_6 = '\x12\x02\x06\x00' '\xba\x50\x5d\x27' \ + '\xaf\x08\x6b\x07' '\x92\xbd\x62\x70' \ + '\x20\x00\x00\x00' '\x00\x00\x00\x00' self.req_args_7 = { - 'type': 956119085, - 'window': 1018715281, - 'property': 686054590, 'data': (32, [1, 2, 3]), - 'mode': 1, + 'mode': 2, + 'property': 1043690258, + 'type': 148693751, + 'window': 183999310, } - self.req_bin_7 = b'\x12\x01\x09\x00' b'\x91\x5c\xb8\x3c' \ - b'\xbe\x5c\xe4\x28' b'\x2d\x38\xfd\x38' \ - b'\x20\x00\x00\x00' b'\x03\x00\x00\x00' \ - b'\x01\x00\x00\x00' b'\x02\x00\x00\x00' \ - b'\x03\x00\x00\x00' + self.req_bin_7 = '\x12\x02\x09\x00' '\x4e\x9b\xf7\x0a' \ + '\x12\x73\x35\x3e' '\xf7\xe2\xdc\x08' \ + '\x20\x00\x00\x00' '\x03\x00\x00\x00' \ + '\x01\x00\x00\x00' '\x02\x00\x00\x00' \ + '\x03\x00\x00\x00' def testPackRequest0(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_1) - try: - assert bin == self.req_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_1) def testPackRequest2(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_2) - try: - assert bin == self.req_bin_2 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_2) def testUnpackRequest2(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_2, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_2 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_2) def testPackRequest3(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_3) - try: - assert bin == self.req_bin_3 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_3) def testUnpackRequest3(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_3, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_3 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_3) def testPackRequest4(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_4) - try: - assert bin == self.req_bin_4 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_4) def testUnpackRequest4(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_4, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_4 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_4) def testPackRequest5(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_5) - try: - assert bin == self.req_bin_5 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_5) def testUnpackRequest5(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_5, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_5 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_5) def testPackRequest6(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_6) - try: - assert bin == self.req_bin_6 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_6) def testUnpackRequest6(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_6, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_6 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_6) def testPackRequest7(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_7) - try: - assert bin == self.req_bin_7 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_7) def testUnpackRequest7(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_7, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_7 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_7) -class TestDeleteProperty(unittest.TestCase): +class TestDeleteProperty(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1858113940, - 'property': 754854074, + 'property': 1644632259, + 'window': 1633396400, } - self.req_bin_0 = b'\x13\x00\x03\x00' b'\x94\x91\xc0\x6e' \ - b'\xba\x28\xfe\x2c' + self.req_bin_0 = '\x13\x00\x03\x00' '\xb0\xa6\x5b\x61' \ + '\xc3\x18\x07\x62' def testPackRequest0(self): bin = request.DeleteProperty._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.DeleteProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGetProperty(unittest.TestCase): +class TestGetProperty(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1675634394, - 'long_offset': 11483536, - 'property': 1943700626, - 'type': 223769899, - 'long_length': 1748032051, 'delete': 0, + 'long_length': 908719612, + 'long_offset': 1873544049, + 'property': 1180723730, + 'type': 569252941, + 'window': 1020695522, } - self.req_bin_0 = b'\x14\x00\x06\x00' b'\xda\x26\xe0\x63' \ - b'\x92\x84\xda\x73' b'\x2b\x75\x56\x0d' \ - b'\x90\x39\xaf\x00' b'\x33\xda\x30\x68' + self.req_bin_0 = '\x14\x00\x06\x00' '\xe2\x93\xd6\x3c' \ + '\x12\x6a\x60\x46' '\x4d\x1c\xee\x21' \ + '\x71\x03\xac\x6f' '\xfc\xf5\x29\x36' self.reply_args_0 = { - 'bytes_after': 1264377294, - 'property_type': 1306970370, - 'sequence_number': 34281, + 'bytes_after': 1567532733, + 'property_type': 1158159724, + 'sequence_number': 14082, 'value': (8, ''), } - self.reply_bin_0 = b'\x01\x08\xe9\x85' b'\x00\x00\x00\x00' \ - b'\x02\xc9\xe6\x4d' b'\xce\xdd\x5c\x4b' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\x08\x02\x37' '\x00\x00\x00\x00' \ + '\x6c\x1d\x08\x45' '\xbd\xa6\x6e\x5d' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' self.reply_args_1 = { - 'bytes_after': 902042689, - 'property_type': 1846820627, - 'sequence_number': 50371, + 'bytes_after': 2137067287, + 'property_type': 669450745, + 'sequence_number': 13387, 'value': (8, 'foo'), } - self.reply_bin_1 = b'\x01\x08\xc3\xc4' b'\x01\x00\x00\x00' \ - b'\x13\x3f\x14\x6e' b'\x41\x14\xc4\x35' \ - b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x66\x6f\x6f\x00' + self.reply_bin_1 = '\x01\x08\x4b\x34' '\x01\x00\x00\x00' \ + '\xf9\x01\xe7\x27' '\x17\x0f\x61\x7f' \ + '\x03\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x66\x6f\x6f\x00' self.reply_args_2 = { - 'bytes_after': 1782597051, - 'property_type': 1613677639, - 'sequence_number': 58679, + 'bytes_after': 1111517270, + 'property_type': 940849590, + 'sequence_number': 42680, 'value': (8, 'zoom'), } - self.reply_bin_2 = b'\x01\x08\x37\xe5' b'\x01\x00\x00\x00' \ - b'\x47\xc4\x2e\x60' b'\xbb\x45\x40\x6a' \ - b'\x04\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x7a\x6f\x6f\x6d' + self.reply_bin_2 = '\x01\x08\xb8\xa6' '\x01\x00\x00\x00' \ + '\xb6\x39\x14\x38' '\x56\x68\x40\x42' \ + '\x04\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x7a\x6f\x6f\x6d' self.reply_args_3 = { - 'bytes_after': 1107167742, - 'property_type': 1964967674, - 'sequence_number': 49647, + 'bytes_after': 726076595, + 'property_type': 482584667, + 'sequence_number': 8155, 'value': (16, []), } - self.reply_bin_3 = b'\x01\x10\xef\xc1' b'\x00\x00\x00\x00' \ - b'\xfa\x06\x1f\x75' b'\xfe\x09\xfe\x41' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_3 = '\x01\x10\xdb\x1f' '\x00\x00\x00\x00' \ + '\x5b\xa8\xc3\x1c' '\xb3\x0c\x47\x2b' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' self.reply_args_4 = { - 'bytes_after': 1602466976, - 'property_type': 638663972, - 'sequence_number': 58268, + 'bytes_after': 472964335, + 'property_type': 494218080, + 'sequence_number': 38660, 'value': (16, [1, 2, 3]), } - self.reply_bin_4 = b'\x01\x10\x9c\xe3' b'\x02\x00\x00\x00' \ - b'\x24\x3d\x11\x26' b'\xa0\xb4\x83\x5f' \ - b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x01\x00\x02\x00' b'\x03\x00\x00\x00' + self.reply_bin_4 = '\x01\x10\x04\x97' '\x02\x00\x00\x00' \ + '\x60\x2b\x75\x1d' '\xef\xdc\x30\x1c' \ + '\x03\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x01\x00\x02\x00' '\x03\x00\x00\x00' self.reply_args_5 = { - 'bytes_after': 651542717, - 'property_type': 947428838, - 'sequence_number': 26901, + 'bytes_after': 491699268, + 'property_type': 1355307456, + 'sequence_number': 4890, 'value': (16, [1, 2, 3, 4]), } - self.reply_bin_5 = b'\x01\x10\x15\x69' b'\x02\x00\x00\x00' \ - b'\xe6\x9d\x78\x38' b'\xbd\xc0\xd5\x26' \ - b'\x04\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x01\x00\x02\x00' b'\x03\x00\x04\x00' + self.reply_bin_5 = '\x01\x10\x1a\x13' '\x02\x00\x00\x00' \ + '\xc0\x59\xc8\x50' '\x44\xbc\x4e\x1d' \ + '\x04\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x01\x00\x02\x00' '\x03\x00\x04\x00' self.reply_args_6 = { - 'bytes_after': 602498418, - 'property_type': 43558782, - 'sequence_number': 11175, + 'bytes_after': 152225892, + 'property_type': 1846062163, + 'sequence_number': 59361, 'value': (32, []), } - self.reply_bin_6 = b'\x01\x20\xa7\x2b' b'\x00\x00\x00\x00' \ - b'\x7e\xa7\x98\x02' b'\x72\x65\xe9\x23' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_6 = '\x01\x20\xe1\xe7' '\x00\x00\x00\x00' \ + '\x53\xac\x08\x6e' '\x64\xc8\x12\x09' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' self.reply_args_7 = { - 'bytes_after': 1661909208, - 'property_type': 607057672, - 'sequence_number': 4347, + 'bytes_after': 460121536, + 'property_type': 1436640532, + 'sequence_number': 15792, 'value': (32, [1, 2, 3]), } - self.reply_bin_7 = b'\x01\x20\xfb\x10' b'\x03\x00\x00\x00' \ - b'\x08\xf7\x2e\x24' b'\xd8\xb8\x0e\x63' \ - b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x01\x00\x00\x00' b'\x02\x00\x00\x00' \ - b'\x03\x00\x00\x00' + self.reply_bin_7 = '\x01\x20\xb0\x3d' '\x03\x00\x00\x00' \ + '\x14\x65\xa1\x55' '\xc0\xe5\x6c\x1b' \ + '\x03\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x01\x00\x00\x00' '\x02\x00\x00\x00' \ + '\x03\x00\x00\x00' def testPackRequest0(self): bin = request.GetProperty._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) def testPackReply1(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_1) - try: - assert bin == self.reply_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_1) def testUnpackReply1(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_1) def testPackReply2(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_2) - try: - assert bin == self.reply_bin_2 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_2) def testUnpackReply2(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_2, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_2 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_2) def testPackReply3(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_3) - try: - assert bin == self.reply_bin_3 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_3) def testUnpackReply3(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_3, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_3 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_3) def testPackReply4(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_4) - try: - assert bin == self.reply_bin_4 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_4) def testUnpackReply4(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_4, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_4 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_4) def testPackReply5(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_5) - try: - assert bin == self.reply_bin_5 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_5) def testUnpackReply5(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_5, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_5 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_5) def testPackReply6(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_6) - try: - assert bin == self.reply_bin_6 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_6) def testUnpackReply6(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_6, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_6 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_6) def testPackReply7(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_7) - try: - assert bin == self.reply_bin_7 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_7) def testUnpackReply7(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_7, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_7 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_7) -class TestListProperties(unittest.TestCase): +class TestListProperties(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1002132678, + 'window': 284194396, } - self.req_bin_0 = b'\x15\x00\x02\x00' b'\xc6\x54\xbb\x3b' + self.req_bin_0 = '\x15\x00\x02\x00' '\x5c\x76\xf0\x10' self.reply_args_0 = { - 'sequence_number': 58554, - 'atoms': [497337753, 1561366096, 1429910722, 371682445, 1693790956, 124266489, 819023111, 1575252239, 1958056613, 76461795, 2044963121, 1187630009, 890357857, 639310702, 1708479530, 336050724, 1163834063, 1164094286, 1626309474, 136351014, 1163110454, 1416739018, 1380223836], - } - self.reply_bin_0 = b'\x01\x00\xba\xe4' b'\x17\x00\x00\x00' \ - b'\x17\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x99\xc5\xa4\x1d' b'\x50\x8e\x10\x5d' \ - b'\xc2\xb4\x3a\x55' b'\x8d\x6c\x27\x16' \ - b'\xec\x32\xf5\x64' b'\xf9\x27\x68\x07' \ - b'\x07\x4d\xd1\x30' b'\x0f\x71\xe4\x5d' \ - b'\xa5\x92\xb5\x74' b'\xe3\xb6\x8e\x04' \ - b'\x31\xa9\xe3\x79' b'\xb9\xcb\xc9\x46' \ - b'\x61\xc8\x11\x35' b'\x6e\x1b\x1b\x26' \ - b'\x2a\x54\xd5\x65' b'\x24\xba\x07\x14' \ - b'\xcf\xb2\x5e\x45' b'\x4e\xab\x62\x45' \ - b'\x62\x83\xef\x60' b'\x26\x8d\x20\x08' \ - b'\x36\xa8\x53\x45' b'\xca\xb8\x71\x54' \ - b'\x5c\x8b\x44\x52' + 'atoms': [2009005759, 1226333816, 1015087858, 1684971497, 1734099213, 408955234, 208216521, 925712651, 909665942, 1002962766, 1565696219, 1446060760, 2113479735, 211409854, 864661769, 728690095, 1850436746, 534034650, 408523590, 963426393, 906021810, 598218424, 536504426], + 'sequence_number': 60526, + } + self.reply_bin_0 = '\x01\x00\x6e\xec' '\x17\x00\x00\x00' \ + '\x17\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\xbf\xfe\xbe\x77' '\x78\x5e\x18\x49' \ + '\xf2\x02\x81\x3c' '\xe9\x9f\x6e\x64' \ + '\x0d\x41\x5c\x67' '\x62\x29\x60\x18' \ + '\xc9\x21\x69\x0c' '\x0b\x41\x2d\x37' \ + '\x96\x66\x38\x36' '\x4e\xff\xc7\x3b' \ + '\xdb\xa0\x52\x5d' '\xd8\x22\x31\x56' \ + '\x37\x24\xf9\x7d' '\xbe\xdb\x99\x0c' \ + '\x09\xb1\x89\x33' '\xaf\xed\x6e\x2b' \ + '\x8a\x6c\x4b\x6e' '\xda\xb8\xd4\x1f' \ + '\x46\x93\x59\x18' '\x59\xb8\x6c\x39' \ + '\xb2\xcb\x00\x36' '\xb8\x16\xa8\x23' \ + '\x6a\x68\xfa\x1f' def testPackRequest0(self): bin = request.ListProperties._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListProperties._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListProperties._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListProperties._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestSetSelectionOwner(unittest.TestCase): +class TestSetSelectionOwner(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1573750861, - 'selection': 984224380, - 'time': 2112448956, + 'selection': 1849742203, + 'time': 1181844078, + 'window': 951652523, } - self.req_bin_0 = b'\x16\x00\x04\x00' b'\x4d\x88\xcd\x5d' \ - b'\x7c\x12\xaa\x3a' b'\xbc\x69\xe9\x7d' + self.req_bin_0 = '\x16\x00\x04\x00' '\xab\x10\xb9\x38' \ + '\x7b\xd3\x40\x6e' '\x6e\x82\x71\x46' def testPackRequest0(self): bin = request.SetSelectionOwner._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGetSelectionOwner(unittest.TestCase): +class TestGetSelectionOwner(EndianTest): def setUp(self): self.req_args_0 = { - 'selection': 1209066471, + 'selection': 108699831, } - self.req_bin_0 = b'\x17\x00\x02\x00' b'\xe7\xe3\x10\x48' + self.req_bin_0 = '\x17\x00\x02\x00' '\xb7\xa0\x7a\x06' self.reply_args_0 = { - 'owner': 1608499874, - 'sequence_number': 40856, + 'owner': 1795366313, + 'sequence_number': 65489, } - self.reply_bin_0 = b'\x01\x00\x98\x9f' b'\x00\x00\x00\x00' \ - b'\xa2\xc2\xdf\x5f' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\x00\xd1\xff' '\x00\x00\x00\x00' \ + '\xa9\x1d\x03\x6b' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetSelectionOwner._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetSelectionOwner._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetSelectionOwner._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestConvertSelection(unittest.TestCase): +class TestConvertSelection(EndianTest): def setUp(self): self.req_args_0 = { - 'property': 116271887, - 'requestor': 163844177, - 'selection': 246355390, - 'target': 1621875689, - 'time': 385931637, + 'property': 357205026, + 'requestor': 2080905648, + 'selection': 1989362772, + 'target': 1822570126, + 'time': 1042940084, } - self.req_bin_0 = b'\x18\x00\x06\x00' b'\x51\x10\xc4\x09' \ - b'\xbe\x15\xaf\x0e' b'\xe9\xdb\xab\x60' \ - b'\x0f\x2b\xee\x06' b'\x75\xd9\x00\x17' + self.req_bin_0 = '\x18\x00\x06\x00' '\xb0\x19\x08\x7c' \ + '\x54\x44\x93\x76' '\x8e\x36\xa2\x6c' \ + '\x22\x84\x4a\x15' '\xb4\x00\x2a\x3e' def testPackRequest0(self): bin = request.ConvertSelection._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ConvertSelection._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestSendEvent(unittest.TestCase): +class TestSendEvent(EndianTest): def setUp(self): self.req_args_0 = { - 'event_mask': 985979728, - 'destination': 1646910168, + 'destination': 977158744, + 'event': event.Expose(count=17568, height=64576, sequence_number=0, type=12, width=24995, window=459070357, x=26435, y=4083), + 'event_mask': 908439472, 'propagate': 1, - 'event': Xlib.protocol.event.Expose(count = 7721, width = 18606, window = 1339231972, y = 45287, x = 46510, type = 12, sequence_number = 0, height = 44735), } - self.req_bin_0 = b'\x19\x01\x0b\x00' b'\xd8\xda\x29\x62' \ - b'\x50\xdb\xc4\x3a' b'\x0c\x00\x00\x00' \ - b'\xe4\x0e\xd3\x4f' b'\xae\xb5\xe7\xb0' \ - b'\xae\x48\xbf\xae' b'\x29\x1e\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' + self.req_bin_0 = '\x19\x01\x0b\x00' '\x58\x42\x3e\x3a' \ + '\xb0\xaf\x25\x36' '\x0c\x00\x00\x00' \ + '\x95\xdb\x5c\x1b' '\x43\x67\xf3\x0f' \ + '\xa3\x61\x40\xfc' '\xa0\x44\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SendEvent._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SendEvent._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGrabPointer(unittest.TestCase): +class TestGrabPointer(EndianTest): def setUp(self): self.req_args_0 = { - 'cursor': 1773330151, + 'confine_to': 637221294, + 'cursor': 2080289570, + 'event_mask': 36536, + 'grab_window': 2137654247, 'keyboard_mode': 0, - 'pointer_mode': 1, - 'event_mask': 27410, - 'confine_to': 1526915530, - 'time': 1195309735, - 'grab_window': 1295558486, 'owner_events': 1, + 'pointer_mode': 1, + 'time': 1243807782, } - self.req_bin_0 = b'\x1a\x01\x06\x00' b'\x56\xa7\x38\x4d' \ - b'\x12\x6b\x01\x00' b'\xca\xe1\x02\x5b' \ - b'\xe7\xde\xb2\x69' b'\xa7\xfa\x3e\x47' + self.req_bin_0 = '\x1a\x01\x06\x00' '\xe7\x03\x6a\x7f' \ + '\xb8\x8e\x01\x00' '\xae\x39\xfb\x25' \ + '\x22\xb3\xfe\x7b' '\x26\x00\x23\x4a' self.reply_args_0 = { - 'status': 166, - 'sequence_number': 9454, + 'sequence_number': 49083, + 'status': 197, } - self.reply_bin_0 = b'\x01\xa6\xee\x24' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\xc5\xbb\xbf' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GrabPointer._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GrabPointer._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GrabPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestUngrabPointer(unittest.TestCase): +class TestUngrabPointer(EndianTest): def setUp(self): self.req_args_0 = { - 'time': 1647345145, + 'time': 122823278, } - self.req_bin_0 = b'\x1b\x00\x02\x00' b'\xf9\x7d\x30\x62' + self.req_bin_0 = '\x1b\x00\x02\x00' '\x6e\x22\x52\x07' def testPackRequest0(self): bin = request.UngrabPointer._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGrabButton(unittest.TestCase): +class TestGrabButton(EndianTest): def setUp(self): self.req_args_0 = { - 'cursor': 1510380761, - 'keyboard_mode': 0, - 'modifiers': 62613, - 'pointer_mode': 1, - 'event_mask': 23716, - 'confine_to': 2062912931, - 'button': 169, - 'grab_window': 2055413885, - 'owner_events': 0, + 'button': 204, + 'confine_to': 172098347, + 'cursor': 399109422, + 'event_mask': 55921, + 'grab_window': 1079895555, + 'keyboard_mode': 1, + 'modifiers': 44333, + 'owner_events': 1, + 'pointer_mode': 0, } - self.req_bin_0 = b'\x1c\x00\x06\x00' b'\x7d\x20\x83\x7a' \ - b'\xa4\x5c\x01\x00' b'\xa3\x8d\xf5\x7a' \ - b'\xd9\x94\x06\x5a' b'\xa9\x00\x95\xf4' + self.req_bin_0 = '\x1c\x01\x06\x00' '\x03\xe6\x5d\x40' \ + '\x71\xda\x00\x01' '\x2b\x03\x42\x0a' \ + '\x2e\xed\xc9\x17' '\xcc\x00\x2d\xad' def testPackRequest0(self): bin = request.GrabButton._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestUngrabButton(unittest.TestCase): +class TestUngrabButton(EndianTest): def setUp(self): self.req_args_0 = { - 'button': 220, - 'modifiers': 32389, - 'grab_window': 1891977189, + 'button': 158, + 'grab_window': 257512222, + 'modifiers': 58373, } - self.req_bin_0 = b'\x1d\xdc\x03\x00' b'\xe5\x47\xc5\x70' \ - b'\x85\x7e\x00\x00' + self.req_bin_0 = '\x1d\x9e\x03\x00' '\x1e\x53\x59\x0f' \ + '\x05\xe4\x00\x00' def testPackRequest0(self): bin = request.UngrabButton._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestChangeActivePointerGrab(unittest.TestCase): +class TestChangeActivePointerGrab(EndianTest): def setUp(self): self.req_args_0 = { - 'cursor': 777967884, - 'event_mask': 12743, - 'time': 197998305, + 'cursor': 528792833, + 'event_mask': 40689, + 'time': 1276746733, } - self.req_bin_0 = b'\x1e\x00\x04\x00' b'\x0c\xd9\x5e\x2e' \ - b'\xe1\x36\xcd\x0b' b'\xc7\x31\x00\x00' + self.req_bin_0 = '\x1e\x00\x04\x00' '\x01\xbd\x84\x1f' \ + '\xed\x9b\x19\x4c' '\xf1\x9e\x00\x00' def testPackRequest0(self): bin = request.ChangeActivePointerGrab._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeActivePointerGrab._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGrabKeyboard(unittest.TestCase): +class TestGrabKeyboard(EndianTest): def setUp(self): self.req_args_0 = { - 'keyboard_mode': 1, - 'time': 1696403859, - 'pointer_mode': 0, - 'grab_window': 316814295, + 'grab_window': 1253453980, + 'keyboard_mode': 0, 'owner_events': 0, + 'pointer_mode': 1, + 'time': 1122698607, } - self.req_bin_0 = b'\x1f\x00\x04\x00' b'\xd7\x33\xe2\x12' \ - b'\x93\x11\x1d\x65' b'\x00\x01\x00\x00' + self.req_bin_0 = '\x1f\x00\x04\x00' '\x9c\x30\xb6\x4a' \ + '\x6f\x05\xeb\x42' '\x01\x00\x00\x00' self.reply_args_0 = { - 'status': 239, - 'sequence_number': 46747, + 'sequence_number': 15837, + 'status': 219, } - self.reply_bin_0 = b'\x01\xef\x9b\xb6' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\xdb\xdd\x3d' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GrabKeyboard._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GrabKeyboard._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GrabKeyboard._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestUngrabKeyboard(unittest.TestCase): +class TestUngrabKeyboard(EndianTest): def setUp(self): self.req_args_0 = { - 'time': 4211611, + 'time': 849983231, } - self.req_bin_0 = b'\x20\x00\x02\x00' b'\x9b\x43\x40\x00' + self.req_bin_0 = '\x20\x00\x02\x00' '\xff\xb6\xa9\x32' def testPackRequest0(self): bin = request.UngrabKeyboard._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGrabKey(unittest.TestCase): +class TestGrabKey(EndianTest): def setUp(self): self.req_args_0 = { + 'grab_window': 644284698, + 'key': 224, 'keyboard_mode': 0, - 'modifiers': 62007, - 'key': 175, - 'pointer_mode': 0, - 'grab_window': 882662093, + 'modifiers': 20896, 'owner_events': 1, + 'pointer_mode': 0, } - self.req_bin_0 = b'\x21\x01\x04\x00' b'\xcd\x5a\x9c\x34' \ - b'\x37\xf2\xaf\x00' b'\x00\x00\x00\x00' + self.req_bin_0 = '\x21\x01\x04\x00' '\x1a\x01\x67\x26' \ + '\xa0\x51\xe0\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GrabKey._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestUngrabKey(unittest.TestCase): +class TestUngrabKey(EndianTest): def setUp(self): self.req_args_0 = { - 'modifiers': 18590, - 'grab_window': 1389213966, - 'key': 141, + 'grab_window': 2139101088, + 'key': 255, + 'modifiers': 5038, } - self.req_bin_0 = b'\x22\x8d\x03\x00' b'\x0e\xb9\xcd\x52' \ - b'\x9e\x48\x00\x00' + self.req_bin_0 = '\x22\xff\x03\x00' '\xa0\x17\x80\x7f' \ + '\xae\x13\x00\x00' def testPackRequest0(self): bin = request.UngrabKey._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestAllowEvents(unittest.TestCase): +class TestAllowEvents(EndianTest): def setUp(self): self.req_args_0 = { - 'mode': 7, - 'time': 1088990319, + 'mode': 1, + 'time': 569561709, } - self.req_bin_0 = b'\x23\x07\x02\x00' b'\x6f\xac\xe8\x40' + self.req_bin_0 = '\x23\x01\x02\x00' '\x6d\xd2\xf2\x21' def testPackRequest0(self): bin = request.AllowEvents._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllowEvents._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGrabServer(unittest.TestCase): +class TestGrabServer(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = b'\x24\x00\x01\x00' + self.req_bin_0 = '\x24\x00\x01\x00' def testPackRequest0(self): bin = request.GrabServer._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestUngrabServer(unittest.TestCase): +class TestUngrabServer(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = b'\x25\x00\x01\x00' + self.req_bin_0 = '\x25\x00\x01\x00' def testPackRequest0(self): bin = request.UngrabServer._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestQueryPointer(unittest.TestCase): +class TestQueryPointer(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 358895460, + 'window': 2004163626, } - self.req_bin_0 = b'\x26\x00\x02\x00' b'\x64\x4f\x64\x15' + self.req_bin_0 = '\x26\x00\x02\x00' '\x2a\x1c\x75\x77' self.reply_args_0 = { + 'child': 338813940, + 'mask': 42947, + 'root': 793594698, + 'root_x': -5661, + 'root_y': -9894, 'same_screen': 1, - 'child': 2139990686, - 'win_x': -30717, - 'root_y': -18418, - 'root_x': -2403, - 'root': 1853596468, - 'mask': 14486, - 'sequence_number': 29530, - 'win_y': -19690, + 'sequence_number': 57654, + 'win_x': -12881, + 'win_y': -671, } - self.reply_bin_0 = b'\x01\x01\x5a\x73' b'\x00\x00\x00\x00' \ - b'\x34\xa3\x7b\x6e' b'\x9e\xaa\x8d\x7f' \ - b'\x9d\xf6\x0e\xb8' b'\x03\x88\x16\xb3' \ - b'\x96\x38\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\x01\x36\xe1' '\x00\x00\x00\x00' \ + '\x4a\x4b\x4d\x2f' '\xf4\xe3\x31\x14' \ + '\xe3\xe9\x5a\xd9' '\xaf\xcd\x61\xfd' \ + '\xc3\xa7\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryPointer._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryPointer._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestGetMotionEvents(unittest.TestCase): +class TestGetMotionEvents(EndianTest): def setUp(self): self.req_args_0 = { - 'start': 2110367101, - 'window': 528148429, - 'stop': 1808786083, + 'start': 1754729754, + 'stop': 642956890, + 'window': 16865017, } - self.req_bin_0 = b'\x27\x00\x04\x00' b'\xcd\xe7\x7a\x1f' \ - b'\x7d\xa5\xc9\x7d' b'\xa3\xe2\xcf\x6b' + self.req_bin_0 = '\x27\x00\x04\x00' '\xf9\x56\x01\x01' \ + '\x1a\x0d\x97\x68' '\x5a\xbe\x52\x26' self.reply_args_0 = { - 'events': [{'y': -23108, 'x': -3461, 'time': 984326273}, {'y': -4096, 'x': -4908, 'time': 488459157}, {'y': -29782, 'x': -8325, 'time': 1162935901}, {'y': -26418, 'x': -10559, 'time': 275816904}, {'y': -3941, 'x': -2216, 'time': 656439277}], - 'sequence_number': 42652, + 'events': [{'y': -28402, 'x': -2241, 'time': 1424638477}, {'y': -14782, 'x': -29288, 'time': 247939153}, {'y': -9437, 'x': -13104, 'time': 584911019}, {'y': -24186, 'x': -12148, 'time': 437274091}, {'y': -5259, 'x': -3333, 'time': 1049147683}], + 'sequence_number': 6281, } - self.reply_bin_0 = b'\x01\x00\x9c\xa6' b'\x0a\x00\x00\x00' \ - b'\x05\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x81\xa0\xab\x3a' b'\x7b\xf2\xbc\xa5' \ - b'\x95\x4b\x1d\x1d' b'\xd4\xec\x00\xf0' \ - b'\x5d\xfe\x50\x45' b'\x7b\xdf\xaa\x8b' \ - b'\xc8\xa1\x70\x10' b'\xc1\xd6\xce\x98' \ - b'\xed\x77\x20\x27' b'\x58\xf7\x9b\xf0' + self.reply_bin_0 = '\x01\x00\x89\x18' '\x0a\x00\x00\x00' \ + '\x05\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x0d\x42\xea\x54' '\x3f\xf7\x0e\x91' \ + '\x51\x40\xc7\x0e' '\x98\x8d\x42\xc6' \ + '\xab\x08\xdd\x22' '\xd0\xcc\x23\xdb' \ + '\xeb\x45\x10\x1a' '\x8c\xd0\x86\xa1' \ + '\x23\xb9\x88\x3e' '\xfb\xf2\x75\xeb' def testPackRequest0(self): bin = request.GetMotionEvents._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetMotionEvents._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetMotionEvents._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetMotionEvents._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestTranslateCoords(unittest.TestCase): +class TestTranslateCoords(EndianTest): def setUp(self): self.req_args_0 = { - 'dst_wid': 246042608, - 'src_wid': 1251919501, - 'src_x': -18176, - 'src_y': -309, + 'dst_wid': 594213659, + 'src_wid': 909659821, + 'src_x': -32653, + 'src_y': -7697, } - self.req_bin_0 = b'\x28\x00\x04\x00' b'\x8d\xc6\x9e\x4a' \ - b'\xf0\x4f\xaa\x0e' b'\x00\xb9\xcb\xfe' + self.req_bin_0 = '\x28\x00\x04\x00' '\xad\x4e\x38\x36' \ + '\x1b\xfb\x6a\x23' '\x73\x80\xef\xe1' self.reply_args_0 = { - 'y': -24269, - 'x': -29750, - 'sequence_number': 39515, - 'same_screen': 0, - 'child': 1548917071, + 'child': 1591798213, + 'same_screen': 1, + 'sequence_number': 17356, + 'x': -14832, + 'y': -18863, } - self.reply_bin_0 = b'\x01\x00\x5b\x9a' b'\x00\x00\x00\x00' \ - b'\x4f\x99\x52\x5c' b'\xca\x8b\x33\xa1' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\x01\xcc\x43' '\x00\x00\x00\x00' \ + '\xc5\xe9\xe0\x5e' '\x10\xc6\x51\xb6' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.TranslateCoords._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.TranslateCoords._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.TranslateCoords._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.TranslateCoords._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestWarpPointer(unittest.TestCase): +class TestWarpPointer(EndianTest): def setUp(self): self.req_args_0 = { - 'src_x': -1322, - 'dst_x': -15518, - 'src_width': 45129, - 'src_height': 8451, - 'src_y': -13238, - 'dst_y': -26121, - 'dst_window': 2139748563, - 'src_window': 1945176770, + 'dst_window': 161645563, + 'dst_x': -13829, + 'dst_y': -27954, + 'src_height': 54738, + 'src_width': 35872, + 'src_window': 20830424, + 'src_x': -4056, + 'src_y': -3379, } - self.req_bin_0 = b'\x29\x00\x06\x00' b'\xc2\x0a\xf1\x73' \ - b'\xd3\xf8\x89\x7f' b'\xd6\xfa\x4a\xcc' \ - b'\x49\xb0\x03\x21' b'\x62\xc3\xf7\x99' + self.req_bin_0 = '\x29\x00\x06\x00' '\xd8\xd8\x3d\x01' \ + '\xfb\x83\xa2\x09' '\x28\xf0\xcd\xf2' \ + '\x20\x8c\xd2\xd5' '\xfb\xc9\xce\x92' def testPackRequest0(self): bin = request.WarpPointer._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.WarpPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestSetInputFocus(unittest.TestCase): +class TestSetInputFocus(EndianTest): def setUp(self): self.req_args_0 = { + 'focus': 662025099, 'revert_to': 0, - 'focus': 1068495705, - 'time': 342883486, + 'time': 1930554666, } - self.req_bin_0 = b'\x2a\x00\x03\x00' b'\x59\xf3\xaf\x3f' \ - b'\x9e\xfc\x6f\x14' + self.req_bin_0 = '\x2a\x00\x03\x00' '\x8b\xb3\x75\x27' \ + '\x2a\xed\x11\x73' def testPackRequest0(self): bin = request.SetInputFocus._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGetInputFocus(unittest.TestCase): +class TestGetInputFocus(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = b'\x2b\x00\x01\x00' + self.req_bin_0 = '\x2b\x00\x01\x00' self.reply_args_0 = { - 'revert_to': 129, - 'focus': 1884243837, - 'sequence_number': 9052, + 'focus': 1930432580, + 'revert_to': 229, + 'sequence_number': 56442, } - self.reply_bin_0 = b'\x01\x81\x5c\x23' b'\x00\x00\x00\x00' \ - b'\x7d\x47\x4f\x70' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\xe5\x7a\xdc' '\x00\x00\x00\x00' \ + '\x44\x10\x10\x73' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetInputFocus._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetInputFocus._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetInputFocus._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestQueryKeymap(unittest.TestCase): +class TestQueryKeymap(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = b'\x2c\x00\x01\x00' + self.req_bin_0 = '\x2c\x00\x01\x00' self.reply_args_0 = { - 'map': [175, 212, 207, 139, 156, 192, 230, 219, 136, 198, 152, 156, 229, 233, 221, 209, 131, 229, 209, 249, 130, 189, 183, 135, 238, 149, 131, 204, 162, 229, 149, 246], - 'sequence_number': 19383, + 'map': [154, 159, 141, 227, 241, 180, 207, 147, 247, 238, 252, 231, 240, 131, 222, 170, 247, 230, 238, 231, 162, 228, 141, 239, 237, 156, 232, 186, 167, 229, 157, 131], + 'sequence_number': 12863, } - self.reply_bin_0 = b'\x01\x00\xb7\x4b' b'\x02\x00\x00\x00' \ - b'\xaf\xd4\xcf\x8b' b'\x9c\xc0\xe6\xdb' \ - b'\x88\xc6\x98\x9c' b'\xe5\xe9\xdd\xd1' \ - b'\x83\xe5\xd1\xf9' b'\x82\xbd\xb7\x87' \ - b'\xee\x95\x83\xcc' b'\xa2\xe5\x95\xf6' + self.reply_bin_0 = '\x01\x00\x3f\x32' '\x02\x00\x00\x00' \ + '\x9a\x9f\x8d\xe3' '\xf1\xb4\xcf\x93' \ + '\xf7\xee\xfc\xe7' '\xf0\x83\xde\xaa' \ + '\xf7\xe6\xee\xe7' '\xa2\xe4\x8d\xef' \ + '\xed\x9c\xe8\xba' '\xa7\xe5\x9d\x83' def testPackRequest0(self): bin = request.QueryKeymap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryKeymap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryKeymap._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryKeymap._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestOpenFont(unittest.TestCase): +class TestOpenFont(EndianTest): def setUp(self): self.req_args_0 = { + 'fid': 704981195, 'name': 'foofont', - 'fid': 1809550053, } - self.req_bin_0 = b'\x2d\x00\x05\x00' b'\xe5\x8a\xdb\x6b' \ - b'\x07\x00\x00\x00' b'\x66\x6f\x6f\x66' \ - b'\x6f\x6e\x74\x00' + self.req_bin_0 = '\x2d\x00\x05\x00' '\xcb\x28\x05\x2a' \ + '\x07\x00\x00\x00' '\x66\x6f\x6f\x66' \ + '\x6f\x6e\x74\x00' def testPackRequest0(self): bin = request.OpenFont._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.OpenFont._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestCloseFont(unittest.TestCase): +class TestCloseFont(EndianTest): def setUp(self): self.req_args_0 = { - 'font': 405865016, + 'font': 1856192698, } - self.req_bin_0 = b'\x2e\x00\x02\x00' b'\x38\x02\x31\x18' + self.req_bin_0 = '\x2e\x00\x02\x00' '\xba\x40\xa3\x6e' def testPackRequest0(self): bin = request.CloseFont._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CloseFont._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestQueryFont(unittest.TestCase): +class TestQueryFont(EndianTest): def setUp(self): self.req_args_0 = { - 'font': 173413537, + 'font': 2076380709, } - self.req_bin_0 = b'\x2f\x00\x02\x00' b'\xa1\x14\x56\x0a' + self.req_bin_0 = '\x2f\x00\x02\x00' '\x25\x0e\xc3\x7b' self.reply_args_0 = { - 'max_bounds': {'left_side_bearing': -27346, 'descent': -13574, 'right_side_bearing': -29649, 'attributes': 58157, 'character_width': -6055, 'ascent': -4810}, 'all_chars_exist': 0, - 'font_ascent': -15846, - 'font_descent': -913, - 'draw_direction': 165, - 'min_char_or_byte2': 53512, - 'default_char': 28435, - 'max_char_or_byte2': 48394, - 'min_bounds': {'left_side_bearing': -8151, 'descent': -28819, 'right_side_bearing': -31752, 'attributes': 52666, 'character_width': -19612, 'ascent': -9876}, - 'char_infos': [{'left_side_bearing': -20738, 'descent': -15296, 'right_side_bearing': -2753, 'attributes': 64507, 'character_width': -12227, 'ascent': -13881}, {'left_side_bearing': -10754, 'descent': -1625, 'right_side_bearing': -9647, 'attributes': 29864, 'character_width': -26871, 'ascent': -11229}, {'left_side_bearing': -30834, 'descent': -16816, 'right_side_bearing': -27729, 'attributes': 56962, 'character_width': -4251, 'ascent': -12215}], - 'max_byte1': 219, - 'min_byte1': 195, - 'properties': [{'name': 515636466, 'value': 1798456662}], - 'sequence_number': 52469, - } - self.reply_bin_0 = b'\x01\x00\xf5\xcc' b'\x12\x00\x00\x00' \ - b'\x29\xe0\xf8\x83' b'\x64\xb3\x6c\xd9' \ - b'\x6d\x8f\xba\xcd' b'\x00\x00\x00\x00' \ - b'\x2e\x95\x2f\x8c' b'\x59\xe8\x36\xed' \ - b'\xfa\xca\x2d\xe3' b'\x00\x00\x00\x00' \ - b'\x08\xd1\x0a\xbd' b'\x13\x6f\x01\x00' \ - b'\xa5\xc3\xdb\x00' b'\x1a\xc2\x6f\xfc' \ - b'\x03\x00\x00\x00' b'\xf2\xfc\xbb\x1e' \ - b'\x56\x45\x32\x6b' b'\xfe\xae\x3f\xf5' \ - b'\x3d\xd0\xc7\xc9' b'\x40\xc4\xfb\xfb' \ - b'\xfe\xd5\x51\xda' b'\x09\x97\x23\xd4' \ - b'\xa7\xf9\xa8\x74' b'\x8e\x87\xaf\x93' \ - b'\x65\xef\x49\xd0' b'\x50\xbe\x82\xde' + 'char_infos': [{'descent': -29018, 'right_side_bearing': -868, 'character_width': -15335, 'left_side_bearing': -19774, 'attributes': 63603, 'ascent': -2231}, {'descent': -18640, 'right_side_bearing': -1474, 'character_width': -24137, 'left_side_bearing': -26963, 'attributes': 47815, 'ascent': -29244}, {'descent': -14022, 'right_side_bearing': -13059, 'character_width': -16141, 'left_side_bearing': -22570, 'attributes': 16884, 'ascent': -20245}], + 'default_char': 20446, + 'draw_direction': 180, + 'font_ascent': -19099, + 'font_descent': -2194, + 'max_bounds': {'descent': -22562, 'right_side_bearing': -30493, 'character_width': -11172, 'left_side_bearing': -20927, 'attributes': 55614, 'ascent': -22033}, + 'max_byte1': 165, + 'max_char_or_byte2': 19861, + 'min_bounds': {'descent': -8645, 'right_side_bearing': -2675, 'character_width': -15262, 'left_side_bearing': -32714, 'attributes': 44034, 'ascent': -9378}, + 'min_byte1': 179, + 'min_char_or_byte2': 47241, + 'properties': [{'name': 599463600, 'value': 1377595039}], + 'sequence_number': 46525, + } + self.reply_bin_0 = '\x01\x00\xbd\xb5' '\x12\x00\x00\x00' \ + '\x36\x80\x8d\xf5' '\x62\xc4\x5e\xdb' \ + '\x3b\xde\x02\xac' '\x00\x00\x00\x00' \ + '\x41\xae\xe3\x88' '\x5c\xd4\xef\xa9' \ + '\xde\xa7\x3e\xd9' '\x00\x00\x00\x00' \ + '\x89\xb8\x95\x4d' '\xde\x4f\x01\x00' \ + '\xb4\xb3\xa5\x00' '\x65\xb5\x6e\xf7' \ + '\x03\x00\x00\x00' '\xb0\x16\xbb\x23' \ + '\x9f\x6e\x1c\x52' '\xc2\xb2\x9c\xfc' \ + '\x19\xc4\x49\xf7' '\xa6\x8e\x73\xf8' \ + '\xad\x96\x3e\xfa' '\xb7\xa1\xc4\x8d' \ + '\x30\xb7\xc7\xba' '\xd6\xa7\xfd\xcc' \ + '\xf3\xc0\xeb\xb0' '\x3a\xc9\xf4\x41' def testPackRequest0(self): bin = request.QueryFont._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryFont._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryFont._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryFont._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestQueryTextExtents(unittest.TestCase): +class TestQueryTextExtents(EndianTest): def setUp(self): self.req_args_0 = { - 'font': 1637171782, + 'font': 1454550358, 'string': (102, 111, 111), } - self.req_bin_0 = b'\x30\x01\x04\x00' b'\x46\x42\x95\x61' \ - b'\x00\x66\x00\x6f' b'\x00\x6f\x00\x00' + self.req_bin_0 = '\x30\x01\x04\x00' '\x56\xad\xb2\x56' \ + '\x00\x66\x00\x6f' '\x00\x6f\x00\x00' self.reply_args_0 = { - 'font_descent': -10581, - 'overall_left': -1212859291, - 'draw_direction': 195, - 'overall_right': -813911398, - 'overall_descent': -19862, - 'overall_ascent': -32654, - 'font_ascent': -22971, - 'sequence_number': 6206, - 'overall_width': -127705892, - } - self.reply_bin_0 = b'\x01\xc3\x3e\x18' b'\x00\x00\x00\x00' \ - b'\x45\xa6\xab\xd6' b'\x72\x80\x6a\xb2' \ - b'\xdc\x5c\x63\xf8' b'\x65\x3c\xb5\xb7' \ - b'\x9a\xb2\x7c\xcf' b'\x00\x00\x00\x00' + 'draw_direction': 243, + 'font_ascent': -22984, + 'font_descent': -14953, + 'overall_ascent': -32755, + 'overall_descent': -23440, + 'overall_left': -902013824, + 'overall_right': -741556933, + 'overall_width': -1224334048, + 'sequence_number': 40436, + } + self.reply_bin_0 = '\x01\xf3\xf4\x9d' '\x00\x00\x00\x00' \ + '\x38\xa6\x97\xc5' '\x0d\x80\x70\xa4' \ + '\x20\x25\x06\xb7' '\x80\x5c\x3c\xca' \ + '\x3b\xbd\xcc\xd3' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryTextExtents._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryTextExtents._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryTextExtents._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryTextExtents._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestListFonts(unittest.TestCase): +class TestListFonts(EndianTest): def setUp(self): self.req_args_0 = { + 'max_names': 30610, 'pattern': 'bhazr', - 'max_names': 57427, } - self.req_bin_0 = b'\x31\x00\x04\x00' b'\x53\xe0\x05\x00' \ - b'\x62\x68\x61\x7a' b'\x72\x00\x00\x00' + self.req_bin_0 = '\x31\x00\x04\x00' '\x92\x77\x05\x00' \ + '\x62\x68\x61\x7a' '\x72\x00\x00\x00' self.reply_args_0 = { 'fonts': ['fie', 'fuzzy', 'foozooom'], - 'sequence_number': 39409, + 'sequence_number': 29120, } - self.reply_bin_0 = b'\x01\x00\xf1\x99' b'\x05\x00\x00\x00' \ - b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x03\x66\x69\x65' b'\x05\x66\x75\x7a' \ - b'\x7a\x79\x08\x66' b'\x6f\x6f\x7a\x6f' \ - b'\x6f\x6f\x6d\x00' + self.reply_bin_0 = '\x01\x00\xc0\x71' '\x05\x00\x00\x00' \ + '\x03\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x03\x66\x69\x65' '\x05\x66\x75\x7a' \ + '\x7a\x79\x08\x66' '\x6f\x6f\x7a\x6f' \ + '\x6f\x6f\x6d\x00' def testPackRequest0(self): bin = request.ListFonts._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListFonts._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListFonts._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListFonts._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestListFontsWithInfo(unittest.TestCase): +class TestListFontsWithInfo(EndianTest): def setUp(self): self.req_args_0 = { + 'max_names': 14206, 'pattern': 'bhazr2', - 'max_names': 52288, } - self.req_bin_0 = b'\x32\x00\x04\x00' b'\x40\xcc\x06\x00' \ - b'\x62\x68\x61\x7a' b'\x72\x32\x00\x00' + self.req_bin_0 = '\x32\x00\x04\x00' '\x7e\x37\x06\x00' \ + '\x62\x68\x61\x7a' '\x72\x32\x00\x00' self.reply_args_0 = { - 'max_bounds': {'left_side_bearing': -9255, 'descent': -26305, 'right_side_bearing': -6756, 'attributes': 49084, 'character_width': -4462, 'ascent': -3529}, 'all_chars_exist': 1, - 'font_ascent': -26930, + 'default_char': 5010, + 'draw_direction': 181, + 'font_ascent': -16695, + 'font_descent': -24836, + 'max_bounds': {'descent': -31974, 'right_side_bearing': -10894, 'character_width': -25465, 'left_side_bearing': -8347, 'attributes': 16239, 'ascent': -26294}, + 'max_byte1': 152, + 'max_char_or_byte2': 55726, + 'min_bounds': {'descent': -21871, 'right_side_bearing': -30012, 'character_width': -16010, 'left_side_bearing': -27251, 'attributes': 53682, 'ascent': -12190}, + 'min_byte1': 208, + 'min_char_or_byte2': 31272, 'name': 'fontfont', - 'replies_hint': 1755082535, - 'font_descent': -25033, - 'draw_direction': 229, - 'min_char_or_byte2': 65093, - 'default_char': 39019, - 'max_char_or_byte2': 45170, - 'min_bounds': {'left_side_bearing': -8350, 'descent': -16956, 'right_side_bearing': -19578, 'attributes': 27352, 'character_width': -20897, 'ascent': -9972}, - 'max_byte1': 221, - 'min_byte1': 158, - 'properties': [{'name': 213588122, 'value': 1789263183}], - 'sequence_number': 43812, - } - self.reply_bin_0 = b'\x01\x08\x24\xab' b'\x0b\x00\x00\x00' \ - b'\x62\xdf\x86\xb3' b'\x5f\xae\x0c\xd9' \ - b'\xc4\xbd\xd8\x6a' b'\x00\x00\x00\x00' \ - b'\xd9\xdb\x9c\xe5' b'\x92\xee\x37\xf2' \ - b'\x3f\x99\xbc\xbf' b'\x00\x00\x00\x00' \ - b'\x45\xfe\x72\xb0' b'\x6b\x98\x01\x00' \ - b'\xe5\x9e\xdd\x01' b'\xce\x96\x37\x9e' \ - b'\x27\x6f\x9c\x68' b'\x9a\x18\xbb\x0c' \ - b'\x4f\xfd\xa5\x6a' b'\x66\x6f\x6e\x74' \ - b'\x66\x6f\x6e\x74' + 'properties': [{'name': 1016194121, 'value': 1935277562}], + 'replies_hint': 1408896390, + 'sequence_number': 52220, + } + self.reply_bin_0 = '\x01\x08\xfc\xcb' '\x0b\x00\x00\x00' \ + '\x8d\x95\xc4\x8a' '\x76\xc1\x62\xd0' \ + '\x91\xaa\xb2\xd1' '\x00\x00\x00\x00' \ + '\x65\xdf\x72\xd5' '\x87\x9c\x4a\x99' \ + '\x1a\x83\x6f\x3f' '\x00\x00\x00\x00' \ + '\x28\x7a\xae\xd9' '\x92\x13\x01\x00' \ + '\xb5\xd0\x98\x01' '\xc9\xbe\xfc\x9e' \ + '\x86\x0d\xfa\x53' '\x49\xe4\x91\x3c' \ + '\xfa\xfd\x59\x73' '\x66\x6f\x6e\x74' \ + '\x66\x6f\x6e\x74' def testPackRequest0(self): bin = request.ListFontsWithInfo._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListFontsWithInfo._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListFontsWithInfo._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListFontsWithInfo._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestSetFontPath(unittest.TestCase): +class TestSetFontPath(EndianTest): def setUp(self): self.req_args_0 = { 'path': ['foo', 'bar', 'gazonk'], } - self.req_bin_0 = b'\x33\x00\x06\x00' b'\x03\x00\x00\x00' \ - b'\x03\x66\x6f\x6f' b'\x03\x62\x61\x72' \ - b'\x06\x67\x61\x7a' b'\x6f\x6e\x6b\x00' + self.req_bin_0 = '\x33\x00\x06\x00' '\x03\x00\x00\x00' \ + '\x03\x66\x6f\x6f' '\x03\x62\x61\x72' \ + '\x06\x67\x61\x7a' '\x6f\x6e\x6b\x00' self.req_args_1 = { 'path': [], } - self.req_bin_1 = b'\x33\x00\x02\x00' b'\x00\x00\x00\x00' + self.req_bin_1 = '\x33\x00\x02\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SetFontPath._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.SetFontPath._request.to_binary(*(), **self.req_args_1) - try: - assert bin == self.req_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.SetFontPath._request.parse_binary(self.req_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_1) -class TestGetFontPath(unittest.TestCase): +class TestGetFontPath(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = b'\x34\x00\x01\x00' + self.req_bin_0 = '\x34\x00\x01\x00' self.reply_args_0 = { 'paths': ['path1', 'path2232'], - 'sequence_number': 17086, + 'sequence_number': 617, } - self.reply_bin_0 = b'\x01\x00\xbe\x42' b'\x04\x00\x00\x00' \ - b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x05\x70\x61\x74' b'\x68\x31\x08\x70' \ - b'\x61\x74\x68\x32' b'\x32\x33\x32\x00' + self.reply_bin_0 = '\x01\x00\x69\x02' '\x04\x00\x00\x00' \ + '\x02\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x05\x70\x61\x74' '\x68\x31\x08\x70' \ + '\x61\x74\x68\x32' '\x32\x33\x32\x00' self.reply_args_1 = { 'paths': [], - 'sequence_number': 8511, + 'sequence_number': 49278, } - self.reply_bin_1 = b'\x01\x00\x3f\x21' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_1 = '\x01\x00\x7e\xc0' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetFontPath._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetFontPath._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) def testPackReply1(self): bin = request.GetFontPath._reply.to_binary(*(), **self.reply_args_1) - try: - assert bin == self.reply_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_1) def testUnpackReply1(self): args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_1) -class TestCreatePixmap(unittest.TestCase): +class TestCreatePixmap(EndianTest): def setUp(self): self.req_args_0 = { - 'width': 32332, - 'depth': 179, - 'pid': 847631690, - 'drawable': 1358709134, - 'height': 16464, + 'depth': 226, + 'drawable': 913032172, + 'height': 62792, + 'pid': 228953027, + 'width': 11737, } - self.req_bin_0 = b'\x35\xb3\x04\x00' b'\x4a\xd5\x85\x32' \ - b'\x8e\x41\xfc\x50' b'\x4c\x7e\x50\x40' + self.req_bin_0 = '\x35\xe2\x04\x00' '\xc3\x8b\xa5\x0d' \ + '\xec\xc3\x6b\x36' '\xd9\x2d\x48\xf5' def testPackRequest0(self): bin = request.CreatePixmap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreatePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestFreePixmap(unittest.TestCase): +class TestFreePixmap(EndianTest): def setUp(self): self.req_args_0 = { - 'pixmap': 1323266674, + 'pixmap': 1112337390, } - self.req_bin_0 = b'\x36\x00\x02\x00' b'\x72\x72\xdf\x4e' + self.req_bin_0 = '\x36\x00\x02\x00' '\xee\xeb\x4c\x42' def testPackRequest0(self): bin = request.FreePixmap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestCreateGC(unittest.TestCase): +class TestCreateGC(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 830249906, - 'attrs': {'function': 14, 'foreground': 814230008, 'background': 2072616911, 'clip_x_origin': -6987, 'subwindow_mode': 0, 'cap_style': 1, 'fill_style': 3, 'tile_stipple_y_origin': -25870, 'font': 264499208, 'graphics_exposures': 0, 'join_style': 2, 'line_width': 36600, 'stipple': 870974399, 'dash_offset': 49599, 'clip_y_origin': -5712, 'tile_stipple_x_origin': -32365, 'arc_mode': 0, 'tile': 1597988019, 'line_style': 2, 'plane_mask': 1650697305, 'clip_mask': 402937862, 'fill_rule': 0, 'dashes': 136}, - 'cid': 779296774, - } - self.req_bin_0 = b'\x37\x00\x1b\x00' b'\x06\x20\x73\x2e' \ - b'\xb2\x9b\x7c\x31' b'\xff\xff\x7f\x00' \ - b'\x0e\x00\x00\x00' b'\x59\xa4\x63\x62' \ - b'\xf8\x29\x88\x30' b'\xcf\x9f\x89\x7b' \ - b'\xf8\x8e\x00\x00' b'\x02\x00\x00\x00' \ - b'\x01\x00\x00\x00' b'\x02\x00\x00\x00' \ - b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\xb3\x5c\x3f\x5f' b'\xbf\x03\xea\x33' \ - b'\x93\x81\x00\x00' b'\xf2\x9a\x00\x00' \ - b'\x08\xf0\xc3\x0f' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\xb5\xe4\x00\x00' \ - b'\xb0\xe9\x00\x00' b'\x06\x58\x04\x18' \ - b'\xbf\xc1\x00\x00' b'\x88\x00\x00\x00' \ - b'\x00\x00\x00\x00' + 'attrs': {'stipple': 1544647467, 'background': 980279926, 'subwindow_mode': 1, 'fill_style': 3, 'font': 1176575685, 'graphics_exposures': 1, 'tile': 1315686229, 'tile_stipple_x_origin': -16228, 'dashes': 226, 'function': 0, 'foreground': 1821798372, 'clip_x_origin': -17214, 'cap_style': 3, 'tile_stipple_y_origin': -5552, 'join_style': 1, 'line_width': 59029, 'dash_offset': 53663, 'clip_y_origin': -24275, 'arc_mode': 1, 'line_style': 2, 'plane_mask': 535198434, 'clip_mask': 530992626, 'fill_rule': 1}, + 'cid': 1345956480, + 'drawable': 589741066, + } + self.req_bin_0 = '\x37\x00\x1b\x00' '\x80\xaa\x39\x50' \ + '\x0a\xbc\x26\x23' '\xff\xff\x7f\x00' \ + '\x00\x00\x00\x00' '\xe2\x7a\xe6\x1f' \ + '\xe4\x6f\x96\x6c' '\x76\xe2\x6d\x3a' \ + '\x95\xe6\x00\x00' '\x02\x00\x00\x00' \ + '\x03\x00\x00\x00' '\x01\x00\x00\x00' \ + '\x03\x00\x00\x00' '\x01\x00\x00\x00' \ + '\x55\xc7\x6b\x4e' '\x2b\x73\x11\x5c' \ + '\x9c\xc0\x00\x00' '\x50\xea\x00\x00' \ + '\xc5\x1e\x21\x46' '\x01\x00\x00\x00' \ + '\x01\x00\x00\x00' '\xc2\xbc\x00\x00' \ + '\x2d\xa1\x00\x00' '\xf2\x4d\xa6\x1f' \ + '\x9f\xd1\x00\x00' '\xe2\x00\x00\x00' \ + '\x01\x00\x00\x00' def testPackRequest0(self): bin = request.CreateGC._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateGC._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestChangeGC(unittest.TestCase): +class TestChangeGC(EndianTest): def setUp(self): self.req_args_0 = { - 'gc': 1996372624, - 'attrs': {'function': 15, 'foreground': 1817174045, 'background': 840850119, 'clip_x_origin': -28415, 'subwindow_mode': 1, 'cap_style': 0, 'fill_style': 0, 'tile_stipple_y_origin': -24832, 'font': 240535139, 'graphics_exposures': 1, 'join_style': 2, 'line_width': 64290, 'stipple': 1739313208, 'dash_offset': 53189, 'clip_y_origin': -2802, 'tile_stipple_x_origin': -4548, 'arc_mode': 1, 'tile': 1091199324, 'line_style': 2, 'plane_mask': 1403123174, 'clip_mask': 1604118463, 'fill_rule': 1, 'dashes': 186}, - } - self.req_bin_0 = b'\x38\x00\x1a\x00' b'\x90\x3a\xfe\x76' \ - b'\xff\xff\x7f\x00' b'\x0f\x00\x00\x00' \ - b'\xe6\xf5\xa1\x53' b'\x1d\xe0\x4f\x6c' \ - b'\xc7\x5a\x1e\x32' b'\x22\xfb\x00\x00' \ - b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x01\x00\x00\x00' b'\x5c\x61\x0a\x41' \ - b'\x38\xd0\xab\x67' b'\x3c\xee\x00\x00' \ - b'\x00\x9f\x00\x00' b'\x63\x46\x56\x0e' \ - b'\x01\x00\x00\x00' b'\x01\x00\x00\x00' \ - b'\x01\x91\x00\x00' b'\x0e\xf5\x00\x00' \ - b'\xbf\xe7\x9c\x5f' b'\xc5\xcf\x00\x00' \ - b'\xba\x00\x00\x00' b'\x01\x00\x00\x00' + 'attrs': {'stipple': 1165278526, 'background': 686615653, 'subwindow_mode': 1, 'fill_style': 2, 'font': 902289335, 'graphics_exposures': 1, 'tile': 875351804, 'tile_stipple_x_origin': -19144, 'dashes': 128, 'function': 1, 'foreground': 583551477, 'clip_x_origin': -9978, 'cap_style': 0, 'tile_stipple_y_origin': -25991, 'join_style': 2, 'line_width': 50468, 'dash_offset': 45232, 'clip_y_origin': -4695, 'arc_mode': 0, 'line_style': 0, 'plane_mask': 613643341, 'clip_mask': 1644117194, 'fill_rule': 0}, + 'gc': 1618091665, + } + self.req_bin_0 = '\x38\x00\x1a\x00' '\x91\x1e\x72\x60' \ + '\xff\xff\x7f\x00' '\x01\x00\x00\x00' \ + '\x4d\x74\x93\x24' '\xf5\x49\xc8\x22' \ + '\x65\xec\xec\x28' '\x24\xc5\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x02\x00\x00\x00' '\x02\x00\x00\x00' \ + '\x00\x00\x00\x00' '\xfc\xce\x2c\x34' \ + '\x3e\xbd\x74\x45' '\x38\xb5\x00\x00' \ + '\x79\x9a\x00\x00' '\xb7\xd7\xc7\x35' \ + '\x01\x00\x00\x00' '\x01\x00\x00\x00' \ + '\x06\xd9\x00\x00' '\xa9\xed\x00\x00' \ + '\xca\x3c\xff\x61' '\xb0\xb0\x00\x00' \ + '\x80\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.ChangeGC._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeGC._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestCopyGC(unittest.TestCase): +class TestCopyGC(EndianTest): def setUp(self): self.req_args_0 = { - 'src_gc': 1605257018, - 'dst_gc': 2046321491, - 'mask': 996538407, + 'dst_gc': 2047479112, + 'mask': 899879427, + 'src_gc': 1832775121, } - self.req_bin_0 = b'\x39\x00\x04\x00' b'\x3a\x47\xae\x5f' \ - b'\x53\x63\xf8\x79' b'\x27\xf8\x65\x3b' + self.req_bin_0 = '\x39\x00\x04\x00' '\xd1\xed\x3d\x6d' \ + '\x48\x0d\x0a\x7a' '\x03\x12\xa3\x35' def testPackRequest0(self): bin = request.CopyGC._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyGC._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestSetDashes(unittest.TestCase): +class TestSetDashes(EndianTest): def setUp(self): self.req_args_0 = { - 'dash_offset': 34958, - 'gc': 2119954025, - 'dashes': [146, 217, 181, 229, 212, 175, 201, 251, 248], + 'dash_offset': 11030, + 'dashes': [223, 197, 205, 156, 156, 183, 131, 171, 214], + 'gc': 868302473, } - self.req_bin_0 = b'\x3a\x00\x06\x00' b'\x69\xee\x5b\x7e' \ - b'\x8e\x88\x09\x00' b'\x92\xd9\xb5\xe5' \ - b'\xd4\xaf\xc9\xfb' b'\xf8\x00\x00\x00' + self.req_bin_0 = '\x3a\x00\x06\x00' '\x89\x3e\xc1\x33' \ + '\x16\x2b\x09\x00' '\xdf\xc5\xcd\x9c' \ + '\x9c\xb7\x83\xab' '\xd6\x00\x00\x00' def testPackRequest0(self): bin = request.SetDashes._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetDashes._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestSetClipRectangles(unittest.TestCase): +class TestSetClipRectangles(EndianTest): def setUp(self): self.req_args_0 = { - 'ordering': 3, - 'gc': 2028835270, - 'y_origin': -15522, - 'rectangles': [{'y': -27524, 'x': -27245, 'height': 31014, 'width': 52432}, {'y': -8991, 'x': -11302, 'height': 9053, 'width': 11072}], - 'x_origin': -26003, + 'gc': 991525136, + 'ordering': 0, + 'rectangles': [{'y': -28619, 'x': -17572, 'height': 2016, 'width': 40876}, {'y': -14418, 'x': -19958, 'height': 42214, 'width': 2025}], + 'x_origin': -31134, + 'y_origin': -20443, } - self.req_bin_0 = b'\x3b\x03\x07\x00' b'\xc6\x91\xed\x78' \ - b'\x6d\x9a\x5e\xc3' b'\x93\x95\x7c\x94' \ - b'\xd0\xcc\x26\x79' b'\xda\xd3\xe1\xdc' \ - b'\x40\x2b\x5d\x23' + self.req_bin_0 = '\x3b\x00\x07\x00' '\x10\x79\x19\x3b' \ + '\x62\x86\x25\xb0' '\x5c\xbb\x35\x90' \ + '\xac\x9f\xe0\x07' '\x0a\xb2\xae\xc7' \ + '\xe9\x07\xe6\xa4' self.req_args_1 = { - 'ordering': 1, - 'gc': 155607949, - 'y_origin': -32694, + 'gc': 701940136, + 'ordering': 0, 'rectangles': [], - 'x_origin': -23382, + 'x_origin': -8019, + 'y_origin': -20442, } - self.req_bin_1 = b'\x3b\x01\x03\x00' b'\x8d\x63\x46\x09' \ - b'\xaa\xa4\x4a\x80' + self.req_bin_1 = '\x3b\x00\x03\x00' '\xa8\xc1\xd6\x29' \ + '\xad\xe0\x26\xb0' def testPackRequest0(self): bin = request.SetClipRectangles._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.SetClipRectangles._request.to_binary(*(), **self.req_args_1) - try: - assert bin == self.req_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_1) -class TestFreeGC(unittest.TestCase): +class TestFreeGC(EndianTest): def setUp(self): self.req_args_0 = { - 'gc': 533809208, + 'gc': 1614945050, } - self.req_bin_0 = b'\x3c\x00\x02\x00' b'\x38\x48\xd1\x1f' + self.req_bin_0 = '\x3c\x00\x02\x00' '\x1a\x1b\x42\x60' def testPackRequest0(self): bin = request.FreeGC._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeGC._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestClearArea(unittest.TestCase): +class TestClearArea(EndianTest): def setUp(self): self.req_args_0 = { - 'width': 25049, - 'window': 451215820, - 'y': -6435, - 'x': -30623, - 'exposures': 0, - 'height': 27400, + 'exposures': 1, + 'height': 65529, + 'width': 35469, + 'window': 541797992, + 'x': -30105, + 'y': -32138, } - self.req_bin_0 = b'\x3d\x00\x04\x00' b'\xcc\x01\xe5\x1a' \ - b'\x61\x88\xdd\xe6' b'\xd9\x61\x08\x6b' + self.req_bin_0 = '\x3d\x01\x04\x00' '\x68\x2e\x4b\x20' \ + '\x67\x8a\x76\x82' '\x8d\x8a\xf9\xff' def testPackRequest0(self): bin = request.ClearArea._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ClearArea._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestCopyArea(unittest.TestCase): +class TestCopyArea(EndianTest): def setUp(self): self.req_args_0 = { - 'dst_y': -10208, - 'dst_x': -3325, - 'gc': 544091206, - 'src_x': -14979, - 'src_y': -25188, - 'dst_drawable': 1518430886, - 'height': 46849, - 'width': 46860, - 'src_drawable': 197047820, - } - self.req_bin_0 = b'\x3e\x00\x07\x00' b'\x0c\xb6\xbe\x0b' \ - b'\xa6\x6a\x81\x5a' b'\x46\x2c\x6e\x20' \ - b'\x7d\xc5\x9c\x9d' b'\x03\xf3\x20\xd8' \ - b'\x0c\xb7\x01\xb7' + 'dst_drawable': 1396196736, + 'dst_x': -1894, + 'dst_y': -26287, + 'gc': 1677699535, + 'height': 10203, + 'src_drawable': 751576716, + 'src_x': -11578, + 'src_y': -8246, + 'width': 1586, + } + self.req_bin_0 = '\x3e\x00\x07\x00' '\x8c\x26\xcc\x2c' \ + '\x80\x45\x38\x53' '\xcf\xa9\xff\x63' \ + '\xc6\xd2\xca\xdf' '\x9a\xf8\x51\x99' \ + '\x32\x06\xdb\x27' def testPackRequest0(self): bin = request.CopyArea._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyArea._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestCopyPlane(unittest.TestCase): +class TestCopyPlane(EndianTest): def setUp(self): self.req_args_0 = { - 'dst_y': -24783, - 'dst_x': -17393, - 'bit_plane': 121248642, - 'gc': 2016534076, - 'src_x': -15677, - 'src_y': -24535, - 'dst_drawable': 626526507, - 'height': 9260, - 'width': 12445, - 'src_drawable': 1825271175, - } - self.req_bin_0 = b'\x3f\x00\x08\x00' b'\x87\x6d\xcb\x6c' \ - b'\x2b\x09\x58\x25' b'\x3c\xde\x31\x78' \ - b'\xc3\xc2\x29\xa0' b'\x0f\xbc\x31\x9f' \ - b'\x9d\x30\x2c\x24' b'\x82\x1b\x3a\x07' + 'bit_plane': 246015498, + 'dst_drawable': 1437673583, + 'dst_x': -7834, + 'dst_y': -27313, + 'gc': 1211144030, + 'height': 49080, + 'src_drawable': 271114743, + 'src_x': -25682, + 'src_y': -10027, + 'width': 39897, + } + self.req_bin_0 = '\x3f\x00\x08\x00' '\xf7\xe1\x28\x10' \ + '\x6f\x28\xb1\x55' '\x5e\x97\x30\x48' \ + '\xae\x9b\xd5\xd8' '\x66\xe1\x4f\x95' \ + '\xd9\x9b\xb8\xbf' '\x0a\xe6\xa9\x0e' def testPackRequest0(self): bin = request.CopyPlane._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyPlane._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestPolyPoint(unittest.TestCase): +class TestPolyPoint(EndianTest): def setUp(self): self.req_args_0 = { - 'coord_mode': 0, - 'drawable': 1127406891, - 'points': [{'y': -18047, 'x': -19763}, {'y': -5351, 'x': -20174}, {'y': -10573, 'x': -29362}], - 'gc': 1752128743, + 'coord_mode': 1, + 'drawable': 851848467, + 'gc': 1535501063, + 'points': [{'y': -1403, 'x': -6131}, {'y': -31934, 'x': -29254}, {'y': -10746, 'x': -22626}], } - self.req_bin_0 = b'\x40\x00\x06\x00' b'\x2b\xdd\x32\x43' \ - b'\xe7\x5c\x6f\x68' b'\xcd\xb2\x81\xb9' \ - b'\x32\xb1\x19\xeb' b'\x4e\x8d\xb3\xd6' + self.req_bin_0 = '\x40\x01\x06\x00' '\x13\x2d\xc6\x32' \ + '\x07\xe3\x85\x5b' '\x0d\xe8\x85\xfa' \ + '\xba\x8d\x42\x83' '\x9e\xa7\x06\xd6' def testPackRequest0(self): bin = request.PolyPoint._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyPoint._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestPolyLine(unittest.TestCase): +class TestPolyLine(EndianTest): def setUp(self): self.req_args_0 = { - 'coord_mode': 1, - 'drawable': 1354888255, - 'points': [{'y': -22360, 'x': -25237}, {'y': -21145, 'x': -28948}, {'y': -16928, 'x': -3515}, {'y': -25838, 'x': -12335}, {'y': -31134, 'x': -12944}], - 'gc': 1308624032, + 'coord_mode': 0, + 'drawable': 919972239, + 'gc': 795836146, + 'points': [{'y': -10315, 'x': -30298}, {'y': -29455, 'x': -12375}, {'y': -5123, 'x': -7653}, {'y': -28833, 'x': -13247}, {'y': -7323, 'x': -781}], } - self.req_bin_0 = b'\x41\x01\x08\x00' b'\x3f\xf4\xc1\x50' \ - b'\xa0\x04\x00\x4e' b'\x6b\x9d\xa8\xa8' \ - b'\xec\x8e\x67\xad' b'\x45\xf2\xe0\xbd' \ - b'\xd1\xcf\x12\x9b' b'\x70\xcd\x62\x86' + self.req_bin_0 = '\x41\x00\x08\x00' '\x8f\xa9\xd5\x36' \ + '\xf2\x7e\x6f\x2f' '\xa6\x89\xb5\xd7' \ + '\xa9\xcf\xf1\x8c' '\x1b\xe2\xfd\xeb' \ + '\x41\xcc\x5f\x8f' '\xf3\xfc\x65\xe3' def testPackRequest0(self): bin = request.PolyLine._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyLine._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestPolySegment(unittest.TestCase): +class TestPolySegment(EndianTest): def setUp(self): self.req_args_0 = { - 'segments': [{'y1': -3160, 'x2': -5139, 'x1': -2249, 'y2': -26872}], - 'gc': 2022424938, - 'drawable': 158182613, + 'drawable': 226701618, + 'gc': 2063278158, + 'segments': [{'y1': -21674, 'x2': -5146, 'x1': -16318, 'y2': -6032}], } - self.req_bin_0 = b'\x42\x00\x05\x00' b'\xd5\xac\x6d\x09' \ - b'\x6a\xc1\x8b\x78' b'\x37\xf7\xa8\xf3' \ - b'\xed\xeb\x08\x97' + self.req_bin_0 = '\x42\x00\x05\x00' '\x32\x31\x83\x0d' \ + '\x4e\x20\xfb\x7a' '\x42\xc0\x56\xab' \ + '\xe6\xeb\x70\xe8' def testPackRequest0(self): bin = request.PolySegment._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolySegment._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestPolyRectangle(unittest.TestCase): +class TestPolyRectangle(EndianTest): def setUp(self): self.req_args_0 = { - 'gc': 1036376211, - 'drawable': 2136753875, - 'rectangles': [{'y': -29358, 'x': -6957, 'height': 19230, 'width': 32377}, {'y': -23694, 'x': -2777, 'height': 48827, 'width': 42548}, {'y': -22773, 'x': -12641, 'height': 9809, 'width': 30955}], + 'drawable': 576422975, + 'gc': 1829049801, + 'rectangles': [{'y': -5825, 'x': -12104, 'height': 28684, 'width': 46429}, {'y': -1378, 'x': -8911, 'height': 53015, 'width': 17886}, {'y': -17049, 'x': -15271, 'height': 47977, 'width': 28690}], } - self.req_bin_0 = b'\x43\x00\x09\x00' b'\xd3\x46\x5c\x7f' \ - b'\x93\xd8\xc5\x3d' b'\xd3\xe4\x52\x8d' \ - b'\x79\x7e\x1e\x4b' b'\x27\xf5\x72\xa3' \ - b'\x34\xa6\xbb\xbe' b'\x9f\xce\x0b\xa7' \ - b'\xeb\x78\x51\x26' + self.req_bin_0 = '\x43\x00\x09\x00' '\x3f\x84\x5b\x22' \ + '\xc9\x15\x05\x6d' '\xb8\xd0\x3f\xe9' \ + '\x5d\xb5\x0c\x70' '\x31\xdd\x9e\xfa' \ + '\xde\x45\x17\xcf' '\x59\xc4\x67\xbd' \ + '\x12\x70\x69\xbb' def testPackRequest0(self): bin = request.PolyRectangle._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestPolyArc(unittest.TestCase): +class TestPolyArc(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 2066514582, - 'gc': 956699423, - 'arcs': [{'width': 36714, 'angle1': -22260, 'angle2': -28493, 'y': -394, 'x': -6756, 'height': 63498}, {'width': 31212, 'angle1': -5166, 'angle2': -19039, 'y': -11179, 'x': -20569, 'height': 27113}, {'width': 62033, 'angle1': -18595, 'angle2': -26291, 'y': -8396, 'x': -7987, 'height': 11428}], + 'arcs': [{'height': 16175, 'width': 57808, 'angle1': -17659, 'angle2': -12925, 'y': -29951, 'x': -5759}, {'height': 12126, 'width': 55806, 'angle1': -25872, 'angle2': -6829, 'y': -31835, 'x': -20446}, {'height': 18290, 'width': 46029, 'angle1': -32438, 'angle2': -1944, 'y': -4147, 'x': -21703}], + 'drawable': 183912361, + 'gc': 1546366910, } - self.req_bin_0 = b'\x44\x00\x0c\x00' b'\x96\x82\x2c\x7b' \ - b'\x1f\x13\x06\x39' b'\x9c\xe5\x76\xfe' \ - b'\x6a\x8f\x0a\xf8' b'\x0c\xa9\xb3\x90' \ - b'\xa7\xaf\x55\xd4' b'\xec\x79\xe9\x69' \ - b'\xd2\xeb\xa1\xb5' b'\xcd\xe0\x34\xdf' \ - b'\x51\xf2\xa4\x2c' b'\x5d\xb7\x4d\x99' + self.req_bin_0 = '\x44\x00\x0c\x00' '\xa9\x47\xf6\x0a' \ + '\xbe\xaf\x2b\x5c' '\x81\xe9\x01\x8b' \ + '\xd0\xe1\x2f\x3f' '\x05\xbb\x83\xcd' \ + '\x22\xb0\xa5\x83' '\xfe\xd9\x5e\x2f' \ + '\xf0\x9a\x53\xe5' '\x39\xab\xcd\xef' \ + '\xcd\xb3\x72\x47' '\x4a\x81\x68\xf8' def testPackRequest0(self): bin = request.PolyArc._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyArc._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestFillPoly(unittest.TestCase): +class TestFillPoly(EndianTest): def setUp(self): self.req_args_0 = { - 'coord_mode': 1, - 'drawable': 526750870, - 'points': [{'y': -765, 'x': -11821}, {'y': -10853, 'x': -1907}, {'y': -29710, 'x': -468}], - 'gc': 112110920, - 'shape': 0, + 'coord_mode': 0, + 'drawable': 199889986, + 'gc': 475925659, + 'points': [{'y': -8118, 'x': -16883}, {'y': -11768, 'x': -10315}, {'y': -6988, 'x': -16810}], + 'shape': 2, } - self.req_bin_0 = b'\x45\x00\x07\x00' b'\x96\x94\x65\x1f' \ - b'\x48\xad\xae\x06' b'\x00\x01\x00\x00' \ - b'\xd3\xd1\x03\xfd' b'\x8d\xf8\x9b\xd5' \ - b'\x2c\xfe\xf2\x8b' + self.req_bin_0 = '\x45\x00\x07\x00' '\x42\x14\xea\x0b' \ + '\x9b\x0c\x5e\x1c' '\x02\x00\x00\x00' \ + '\x0d\xbe\x4a\xe0' '\xb5\xd7\x08\xd2' \ + '\x56\xbe\xb4\xe4' def testPackRequest0(self): bin = request.FillPoly._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FillPoly._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestPolyFillRectangle(unittest.TestCase): +class TestPolyFillRectangle(EndianTest): def setUp(self): self.req_args_0 = { - 'gc': 468793444, - 'drawable': 878946804, - 'rectangles': [{'y': -29169, 'x': -18095, 'height': 15301, 'width': 12078}, {'y': -7148, 'x': -18997, 'height': 7501, 'width': 17120}], + 'drawable': 539934343, + 'gc': 259164168, + 'rectangles': [{'y': -17381, 'x': -13860, 'height': 28032, 'width': 34914}, {'y': -22013, 'x': -8516, 'height': 17941, 'width': 46138}], } - self.req_bin_0 = b'\x46\x00\x07\x00' b'\xf4\xa9\x63\x34' \ - b'\x64\x38\xf1\x1b' b'\x51\xb9\x0f\x8e' \ - b'\x2e\x2f\xc5\x3b' b'\xcb\xb5\x14\xe4' \ - b'\xe0\x42\x4d\x1d' + self.req_bin_0 = '\x46\x00\x07\x00' '\x87\xbe\x2e\x20' \ + '\x08\x88\x72\x0f' '\xdc\xc9\x1b\xbc' \ + '\x62\x88\x80\x6d' '\xbc\xde\x03\xaa' \ + '\x3a\xb4\x15\x46' def testPackRequest0(self): bin = request.PolyFillRectangle._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyFillRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestPolyFillArc(unittest.TestCase): +class TestPolyFillArc(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 1286339124, - 'gc': 1256983120, - 'arcs': [{'width': 62526, 'angle1': -17496, 'angle2': -20949, 'y': -21843, 'x': -31746, 'height': 59073}], + 'arcs': [{'height': 50011, 'width': 35237, 'angle1': -26749, 'angle2': -25733, 'y': -28881, 'x': -26507}], + 'drawable': 1039842351, + 'gc': 1556052490, } - self.req_bin_0 = b'\x47\x00\x06\x00' b'\x34\xfa\xab\x4c' \ - b'\x50\x0a\xec\x4a' b'\xfe\x83\xad\xaa' \ - b'\x3e\xf4\xc1\xe6' b'\xa8\xbb\x2b\xae' + self.req_bin_0 = '\x47\x00\x06\x00' '\x2f\xbc\xfa\x3d' \ + '\x0a\x7a\xbf\x5c' '\x75\x98\x2f\x8f' \ + '\xa5\x89\x5b\xc3' '\x83\x97\x7b\x9b' def testPackRequest0(self): bin = request.PolyFillArc._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyFillArc._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestPutImage(unittest.TestCase): +class TestPutImage(EndianTest): def setUp(self): self.req_args_0 = { - 'dst_y': -18744, - 'width': 39512, - 'left_pad': 222, - 'gc': 1858057277, - 'dst_x': -9189, - 'format': 2, - 'drawable': 935710750, 'data': 'bit map data', - 'depth': 218, - 'height': 16464, + 'depth': 196, + 'drawable': 1126680250, + 'dst_x': -25372, + 'dst_y': -26934, + 'format': 2, + 'gc': 607782076, + 'height': 12927, + 'left_pad': 129, + 'width': 6818, } - self.req_bin_0 = b'\x48\x02\x09\x00' b'\x1e\xd0\xc5\x37' \ - b'\x3d\xb4\xbf\x6e' b'\x58\x9a\x50\x40' \ - b'\x1b\xdc\xc8\xb6' b'\xde\xda\x00\x00' \ - b'\x62\x69\x74\x20' b'\x6d\x61\x70\x20' \ - b'\x64\x61\x74\x61' + self.req_bin_0 = '\x48\x02\x09\x00' '\xba\xc6\x27\x43' \ + '\xbc\x04\x3a\x24' '\xa2\x1a\x7f\x32' \ + '\xe4\x9c\xca\x96' '\x81\xc4\x00\x00' \ + '\x62\x69\x74\x20' '\x6d\x61\x70\x20' \ + '\x64\x61\x74\x61' def testPackRequest0(self): bin = request.PutImage._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PutImage._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGetImage(unittest.TestCase): +class TestGetImage(EndianTest): def setUp(self): self.req_args_0 = { - 'width': 47689, + 'drawable': 2092284116, 'format': 1, - 'y': -2692, - 'x': -32705, - 'drawable': 377616775, - 'plane_mask': 849117586, - 'height': 24480, + 'height': 56949, + 'plane_mask': 1054187334, + 'width': 8499, + 'x': -14777, + 'y': -10093, } - self.req_bin_0 = b'\x49\x01\x05\x00' b'\x87\xf9\x81\x16' \ - b'\x3f\x80\x7c\xf5' b'\x49\xba\xa0\x5f' \ - b'\x92\x81\x9c\x32' + self.req_bin_0 = '\x49\x01\x05\x00' '\xd4\xb8\xb5\x7c' \ + '\x47\xc6\x93\xd8' '\x33\x21\x75\xde' \ + '\x46\x9f\xd5\x3e' self.reply_args_0 = { - 'depth': 249, 'data': 'this is real ly imag e b-map', - 'visual': 141686402, - 'sequence_number': 47197, + 'depth': 239, + 'sequence_number': 37730, + 'visual': 1008057036, } - self.reply_bin_0 = b'\x01\xf9\x5d\xb8' b'\x07\x00\x00\x00' \ - b'\x82\xf6\x71\x08' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x74\x68\x69\x73' b'\x20\x69\x73\x20' \ - b'\x72\x65\x61\x6c' b'\x20\x6c\x79\x20' \ - b'\x69\x6d\x61\x67' b'\x20\x65\x20\x62' \ - b'\x2d\x6d\x61\x70' + self.reply_bin_0 = '\x01\xef\x62\x93' '\x07\x00\x00\x00' \ + '\xcc\xba\x15\x3c' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x74\x68\x69\x73' '\x20\x69\x73\x20' \ + '\x72\x65\x61\x6c' '\x20\x6c\x79\x20' \ + '\x69\x6d\x61\x67' '\x20\x65\x20\x62' \ + '\x2d\x6d\x61\x70' def testPackRequest0(self): bin = request.GetImage._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetImage._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetImage._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetImage._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestPolyText8(unittest.TestCase): +class TestPolyText8(EndianTest): def setUp(self): self.req_args_0 = { - 'y': -7036, + 'drawable': 945936210, + 'gc': 395971420, 'items': [{'string': 'zoo', 'delta': 2}, 16909060, {'string': 'ie', 'delta': 0}], - 'drawable': 1736403224, - 'gc': 1348241590, - 'x': -27139, + 'x': -31098, + 'y': -2172, } - self.req_bin_0 = b'\x4a\x00\x08\x00' b'\x18\x69\x7f\x67' \ - b'\xb6\x88\x5c\x50' b'\xfd\x95\x84\xe4' \ - b'\x03\x02\x7a\x6f' b'\x6f\xff\x01\x02' \ - b'\x03\x04\x02\x00' b'\x69\x65\x00\x00' + self.req_bin_0 = '\x4a\x00\x08\x00' '\x52\xd7\x61\x38' \ + '\x5c\x0b\x9a\x17' '\x86\x86\x84\xf7' \ + '\x03\x02\x7a\x6f' '\x6f\xff\x01\x02' \ + '\x03\x04\x02\x00' '\x69\x65\x00\x00' def testPackRequest0(self): bin = request.PolyText8._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyText8._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestPolyText16(unittest.TestCase): +class TestPolyText16(EndianTest): def setUp(self): self.req_args_0 = { - 'y': -10535, + 'drawable': 1025949844, + 'gc': 1765491562, 'items': [{'string': (4131, 18), 'delta': 2}, 16909060], - 'drawable': 1669371472, - 'gc': 327278878, - 'x': -31319, + 'x': -19740, + 'y': -30360, } - self.req_bin_0 = b'\x4b\x00\x07\x00' b'\x50\x96\x80\x63' \ - b'\x1e\xe1\x81\x13' b'\xa9\x85\xd9\xd6' \ - b'\x02\x02\x10\x23' b'\x00\x12\xff\x01' \ - b'\x02\x03\x04\x00' + self.req_bin_0 = '\x4b\x00\x07\x00' '\x94\xc0\x26\x3d' \ + '\x6a\x43\x3b\x69' '\xe4\xb2\x68\x89' \ + '\x02\x02\x10\x23' '\x00\x12\xff\x01' \ + '\x02\x03\x04\x00' def testPackRequest0(self): bin = request.PolyText16._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyText16._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestImageText8(unittest.TestCase): +class TestImageText8(EndianTest): def setUp(self): self.req_args_0 = { - 'y': -3727, - 'x': -15149, - 'drawable': 2131605072, - 'gc': 581816261, + 'drawable': 1351748646, + 'gc': 115186633, 'string': 'showme', + 'x': -27918, + 'y': -14469, } - self.req_bin_0 = b'\x4c\x06\x06\x00' b'\x50\xb6\x0d\x7f' \ - b'\xc5\xcf\xad\x22' b'\xd3\xc4\x71\xf1' \ - b'\x73\x68\x6f\x77' b'\x6d\x65\x00\x00' + self.req_bin_0 = '\x4c\x06\x06\x00' '\x26\x0c\x92\x50' \ + '\xc9\x9b\xdd\x06' '\xf2\x92\x7b\xc7' \ + '\x73\x68\x6f\x77' '\x6d\x65\x00\x00' def testPackRequest0(self): bin = request.ImageText8._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ImageText8._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestImageText16(unittest.TestCase): +class TestImageText16(EndianTest): def setUp(self): self.req_args_0 = { - 'y': -1074, - 'x': -2847, - 'drawable': 1442818198, - 'gc': 145495998, + 'drawable': 652527416, + 'gc': 2134423313, 'string': (115, 104, 111, 119, 109, 111, 114, 101), + 'x': -28917, + 'y': -7914, } - self.req_bin_0 = b'\x4d\x08\x08\x00' b'\x96\xa8\xff\x55' \ - b'\xbe\x17\xac\x08' b'\xe1\xf4\xce\xfb' \ - b'\x00\x73\x00\x68' b'\x00\x6f\x00\x77' \ - b'\x00\x6d\x00\x6f' b'\x00\x72\x00\x65' + self.req_bin_0 = '\x4d\x08\x08\x00' '\x38\xc7\xe4\x26' \ + '\x11\xb7\x38\x7f' '\x0b\x8f\x16\xe1' \ + '\x00\x73\x00\x68' '\x00\x6f\x00\x77' \ + '\x00\x6d\x00\x6f' '\x00\x72\x00\x65' def testPackRequest0(self): bin = request.ImageText16._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ImageText16._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestCreateColormap(unittest.TestCase): +class TestCreateColormap(EndianTest): def setUp(self): self.req_args_0 = { - 'alloc': 0, - 'window': 1386427589, - 'visual': 1165319270, - 'mid': 1982619692, + 'alloc': 1, + 'mid': 1698116715, + 'visual': 1122247262, + 'window': 484710181, } - self.req_bin_0 = b'\x4e\x00\x04\x00' b'\x2c\x60\x2c\x76' \ - b'\xc5\x34\xa3\x52' b'\x66\x5c\x75\x45' + self.req_bin_0 = '\x4e\x01\x04\x00' '\x6b\x34\x37\x65' \ + '\x25\x17\xe4\x1c' '\x5e\x22\xe4\x42' def testPackRequest0(self): bin = request.CreateColormap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestFreeColormap(unittest.TestCase): +class TestFreeColormap(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 1948229362, + 'cmap': 967508457, } - self.req_bin_0 = b'\x4f\x00\x02\x00' b'\xf2\x9e\x1f\x74' + self.req_bin_0 = '\x4f\x00\x02\x00' '\xe9\x01\xab\x39' def testPackRequest0(self): bin = request.FreeColormap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestCopyColormapAndFree(unittest.TestCase): +class TestCopyColormapAndFree(EndianTest): def setUp(self): self.req_args_0 = { - 'src_cmap': 836376231, - 'mid': 1781544437, + 'mid': 950772638, + 'src_cmap': 1847203012, } - self.req_bin_0 = b'\x50\x00\x03\x00' b'\xf5\x35\x30\x6a' \ - b'\xa7\x16\xda\x31' + self.req_bin_0 = '\x50\x00\x03\x00' '\x9e\xa3\xab\x38' \ + '\xc4\x14\x1a\x6e' def testPackRequest0(self): bin = request.CopyColormapAndFree._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyColormapAndFree._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestInstallColormap(unittest.TestCase): +class TestInstallColormap(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 1065317214, + 'cmap': 2126076595, } - self.req_bin_0 = b'\x51\x00\x02\x00' b'\x5e\x73\x7f\x3f' + self.req_bin_0 = '\x51\x00\x02\x00' '\xb3\x5a\xb9\x7e' def testPackRequest0(self): bin = request.InstallColormap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.InstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestUninstallColormap(unittest.TestCase): +class TestUninstallColormap(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 1636916558, + 'cmap': 655844603, } - self.req_bin_0 = b'\x52\x00\x02\x00' b'\x4e\x5d\x91\x61' + self.req_bin_0 = '\x52\x00\x02\x00' '\xfb\x64\x17\x27' def testPackRequest0(self): bin = request.UninstallColormap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UninstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestListInstalledColormaps(unittest.TestCase): +class TestListInstalledColormaps(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 198767900, + 'window': 1333670852, } - self.req_bin_0 = b'\x53\x00\x02\x00' b'\x1c\xf5\xd8\x0b' + self.req_bin_0 = '\x53\x00\x02\x00' '\xc4\x33\x7e\x4f' self.reply_args_0 = { - 'cmaps': [6854304, 441133660], - 'sequence_number': 56438, + 'cmaps': [1309197997, 1589346714], + 'sequence_number': 62114, } - self.reply_bin_0 = b'\x01\x00\x76\xdc' b'\x02\x00\x00\x00' \ - b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\xa0\x96\x68\x00' b'\x5c\x2a\x4b\x1a' + self.reply_bin_0 = '\x01\x00\xa2\xf2' '\x02\x00\x00\x00' \ + '\x02\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\xad\xc6\x08\x4e' '\x9a\x81\xbb\x5e' def testPackRequest0(self): bin = request.ListInstalledColormaps._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListInstalledColormaps._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListInstalledColormaps._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListInstalledColormaps._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestAllocColor(unittest.TestCase): +class TestAllocColor(EndianTest): def setUp(self): self.req_args_0 = { - 'blue': 57892, - 'cmap': 1775908575, - 'green': 61383, - 'red': 8870, + 'blue': 10508, + 'cmap': 446273048, + 'green': 43368, + 'red': 14031, } - self.req_bin_0 = b'\x54\x00\x04\x00' b'\xdf\x36\xda\x69' \ - b'\xa6\x22\xc7\xef' b'\x24\xe2\x00\x00' + self.req_bin_0 = '\x54\x00\x04\x00' '\x18\x96\x99\x1a' \ + '\xcf\x36\x68\xa9' '\x0c\x29\x00\x00' self.reply_args_0 = { - 'blue': 22111, - 'green': 27536, - 'red': 54369, - 'sequence_number': 52666, - 'pixel': 1186287049, + 'blue': 29664, + 'green': 430, + 'pixel': 1275226450, + 'red': 5156, + 'sequence_number': 11602, } - self.reply_bin_0 = b'\x01\x00\xba\xcd' b'\x00\x00\x00\x00' \ - b'\x61\xd4\x90\x6b' b'\x5f\x56\x00\x00' \ - b'\xc9\x4d\xb5\x46' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\x00\x52\x2d' '\x00\x00\x00\x00' \ + '\x24\x14\xae\x01' '\xe0\x73\x00\x00' \ + '\x52\x69\x02\x4c' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.AllocColor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocColor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocColor._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestAllocNamedColor(unittest.TestCase): +class TestAllocNamedColor(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 695059054, + 'cmap': 625521008, 'name': 'octarin', } - self.req_bin_0 = b'\x55\x00\x05\x00' b'\x6e\xc2\x6d\x29' \ - b'\x07\x00\x00\x00' b'\x6f\x63\x74\x61' \ - b'\x72\x69\x6e\x00' + self.req_bin_0 = '\x55\x00\x05\x00' '\x70\xb1\x48\x25' \ + '\x07\x00\x00\x00' '\x6f\x63\x74\x61' \ + '\x72\x69\x6e\x00' self.reply_args_0 = { - 'exact_red': 45174, - 'screen_blue': 21718, - 'exact_green': 45002, - 'exact_blue': 55971, - 'screen_green': 47979, - 'screen_red': 60497, - 'sequence_number': 38835, - 'pixel': 580415589, + 'exact_blue': 45128, + 'exact_green': 29895, + 'exact_red': 46147, + 'pixel': 1518195288, + 'screen_blue': 41059, + 'screen_green': 51685, + 'screen_red': 60568, + 'sequence_number': 15366, } - self.reply_bin_0 = b'\x01\x00\xb3\x97' b'\x00\x00\x00\x00' \ - b'\x65\x70\x98\x22' b'\x76\xb0\xca\xaf' \ - b'\xa3\xda\x51\xec' b'\x6b\xbb\xd6\x54' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\x00\x06\x3c' '\x00\x00\x00\x00' \ + '\x58\xd2\x7d\x5a' '\x43\xb4\xc7\x74' \ + '\x48\xb0\x98\xec' '\xe5\xc9\x63\xa0' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.AllocNamedColor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocNamedColor._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocNamedColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestAllocColorCells(unittest.TestCase): +class TestAllocColorCells(EndianTest): def setUp(self): self.req_args_0 = { + 'cmap': 2005042093, + 'colors': 28009, 'contiguous': 1, - 'cmap': 2071194037, - 'colors': 16292, - 'planes': 14978, + 'planes': 35805, } - self.req_bin_0 = b'\x56\x01\x03\x00' b'\xb5\xe9\x73\x7b' \ - b'\xa4\x3f\x82\x3a' + self.req_bin_0 = '\x56\x01\x03\x00' '\xad\x83\x82\x77' \ + '\x69\x6d\xdd\x8b' self.reply_args_0 = { - 'pixels': [1664874569, 198876857, 135035151, 1499807858, 600240169, 1403510863, 757170725, 929995606, 155550883, 642439566, 971734621, 1359474267, 609593319, 669993327, 1837906914, 1355959290, 835285748], - 'masks': [50898278, 362272940, 1106373487], - 'sequence_number': 57786, - } - self.reply_bin_0 = b'\x01\x00\xba\xe1' b'\x14\x00\x00\x00' \ - b'\x11\x00\x03\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x49\xf8\x3b\x63' b'\xb9\x9e\xda\x0b' \ - b'\x0f\x79\x0c\x08' b'\x72\x40\x65\x59' \ - b'\x29\xf0\xc6\x23' b'\x4f\xe0\xa7\x53' \ - b'\x25\x82\x21\x2d' b'\x56\x9b\x6e\x37' \ - b'\xa3\x84\x45\x09' b'\x8e\xd9\x4a\x26' \ - b'\x5d\x7e\xeb\x39' b'\x5b\xee\x07\x51' \ - b'\xe7\xa7\x55\x24' b'\x6f\x49\xef\x27' \ - b'\xe2\x3b\x8c\x6d' b'\xfa\x4b\xd2\x50' \ - b'\xf4\x72\xc9\x31' b'\x66\xa5\x08\x03' \ - b'\xac\xd8\x97\x15' b'\x6f\xeb\xf1\x41' + 'masks': [927811713, 692224741, 537710104], + 'pixels': [1390808070, 1950804725, 1775188259, 153412312, 356371138, 660636713, 1608390912, 1222391062, 619833140, 267104833, 1478945126, 1502686323, 2024385568, 1074788553, 1060450333, 172807825, 85663305], + 'sequence_number': 6217, + } + self.reply_bin_0 = '\x01\x00\x49\x18' '\x14\x00\x00\x00' \ + '\x11\x00\x03\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x06\x0c\xe6\x52' '\xf5\xea\x46\x74' \ + '\x23\x39\xcf\x69' '\xd8\xe2\x24\x09' \ + '\xc2\xca\x3d\x15' '\x29\x84\x60\x27' \ + '\x00\x19\xde\x5f' '\x16\x35\xdc\x48' \ + '\x34\xe7\xf1\x24' '\x41\xb2\xeb\x0f' \ + '\x66\xe9\x26\x58' '\x73\x2c\x91\x59' \ + '\x20\xac\xa9\x78' '\xc9\xf8\x0f\x40' \ + '\x1d\x30\x35\x3f' '\x91\xd6\x4c\x0a' \ + '\x49\x1e\x1b\x05' '\x81\x48\x4d\x37' \ + '\xe5\x82\x42\x29' '\x18\xce\x0c\x20' self.reply_args_1 = { - 'pixels': [], 'masks': [], - 'sequence_number': 49324, + 'pixels': [], + 'sequence_number': 63049, } - self.reply_bin_1 = b'\x01\x00\xac\xc0' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_1 = '\x01\x00\x49\xf6' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.AllocColorCells._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocColorCells._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocColorCells._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) def testPackReply1(self): bin = request.AllocColorCells._reply.to_binary(*(), **self.reply_args_1) - try: - assert bin == self.reply_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_1) def testUnpackReply1(self): args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_1) -class TestAllocColorPlanes(unittest.TestCase): +class TestAllocColorPlanes(EndianTest): def setUp(self): self.req_args_0 = { - 'blue': 34241, - 'colors': 11903, - 'cmap': 2107895767, - 'green': 33790, + 'blue': 17849, + 'cmap': 1235258520, + 'colors': 62323, 'contiguous': 1, - 'red': 37700, + 'green': 44142, + 'red': 65508, } - self.req_bin_0 = b'\x57\x01\x04\x00' b'\xd7\xef\xa3\x7d' \ - b'\x7f\x2e\x44\x93' b'\xfe\x83\xc1\x85' + self.req_bin_0 = '\x57\x01\x04\x00' '\x98\x8c\xa0\x49' \ + '\x73\xf3\xe4\xff' '\x6e\xac\xb9\x45' self.reply_args_0 = { - 'red_mask': 931105404, - 'blue_mask': 874671906, - 'pixels': [1675913921, 1252164172, 37816631, 1472651082], - 'sequence_number': 17565, - 'green_mask': 1072565720, + 'blue_mask': 1363213739, + 'green_mask': 1257012974, + 'pixels': [86459759, 1624090919, 1010427525, 1399128813], + 'red_mask': 389798617, + 'sequence_number': 60057, } - self.reply_bin_0 = b'\x01\x00\x9d\x44' b'\x04\x00\x00\x00' \ - b'\x04\x00\x00\x00' b'\x7c\x8a\x7f\x37' \ - b'\xd8\x0d\xee\x3f' b'\x22\x6f\x22\x34' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\xc1\x6a\xe4\x63' b'\x4c\x82\xa2\x4a' \ - b'\x37\x09\x41\x02' b'\x4a\xdf\xc6\x57' + self.reply_bin_0 = '\x01\x00\x99\xea' '\x04\x00\x00\x00' \ + '\x04\x00\x00\x00' '\xd9\xda\x3b\x17' \ + '\xee\x7e\xec\x4a' '\xab\xfd\x40\x51' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x6f\x45\x27\x05' '\x27\xa9\xcd\x60' \ + '\x85\xe6\x39\x3c' '\xed\x02\x65\x53' def testPackRequest0(self): bin = request.AllocColorPlanes._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocColorPlanes._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocColorPlanes._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocColorPlanes._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestFreeColors(unittest.TestCase): +class TestFreeColors(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 32694046, - 'plane_mask': 1074378407, - 'pixels': [2014216051, 1664038241, 1220941033, 1378294408, 197757808, 793595544, 1289781247, 713684847, 1724469541, 1432124373, 1426727603, 1787792301, 406458839, 1918513211, 441394489, 988895943, 146997744], - } - self.req_bin_0 = b'\x58\x00\x14\x00' b'\x1e\xdf\xf2\x01' \ - b'\xa7\xb6\x09\x40' b'\x73\x7f\x0e\x78' \ - b'\x61\x35\x2f\x63' b'\xe9\x14\xc6\x48' \ - b'\x88\x1a\x27\x52' b'\x70\x8b\xc9\x0b' \ - b'\x98\x4e\x4d\x2f' b'\xff\x7f\xe0\x4c' \ - b'\x6f\xf7\x89\x2a' b'\x25\x51\xc9\x66' \ - b'\xd5\x7b\x5c\x55' b'\xb3\x22\x0a\x55' \ - b'\xad\x8b\x8f\x6a' b'\xd7\x11\x3a\x18' \ - b'\x3b\x30\x5a\x72' b'\x39\x25\x4f\x1a' \ - b'\xc7\x5a\xf1\x3a' b'\xf0\x01\xc3\x08' + 'cmap': 1105118848, + 'pixels': [1056006429, 196001131, 747283410, 715818017, 1439122371, 1841977117, 708291896, 1489672946, 618989649, 2029791261, 1747131973, 1181352956, 976766929, 675465375, 694269519, 2083457789, 867998373], + 'plane_mask': 2121970633, + } + self.req_bin_0 = '\x58\x00\x14\x00' '\x80\xc6\xde\x41' \ + '\xc9\xb3\x7a\x7e' '\x1d\x61\xf1\x3e' \ + '\x6b\xbd\xae\x0b' '\xd2\xa3\x8a\x2c' \ + '\x21\x84\xaa\x2a' '\xc3\x43\xc7\x55' \ + '\x1d\x57\xca\x6d' '\x38\xad\x37\x2a' \ + '\xf2\x9a\xca\x58' '\x51\x08\xe5\x24' \ + '\x1d\x28\xfc\x78' '\x45\x1e\x23\x68' \ + '\xfc\x03\x6a\x46' '\xd1\x47\x38\x3a' \ + '\x9f\xc8\x42\x28' '\x4f\xb6\x61\x29' \ + '\xfd\x0a\x2f\x7c' '\xa5\x9a\xbc\x33' def testPackRequest0(self): bin = request.FreeColors._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeColors._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestStoreColors(unittest.TestCase): +class TestStoreColors(EndianTest): def setUp(self): self.req_args_0 = { - 'items': [{'blue': 3577, 'flags': 221, 'green': 15650, 'pixel': 330879354, 'red': 30294}, {'blue': 18226, 'flags': 219, 'green': 45614, 'pixel': 302874221, 'red': 54265}, {'blue': 32215, 'flags': 160, 'green': 48737, 'pixel': 1699694808, 'red': 60115}, {'blue': 28524, 'flags': 209, 'green': 37615, 'pixel': 710550693, 'red': 50488}], - 'cmap': 1791140577, + 'cmap': 200224662, + 'items': [{'blue': 12501, 'flags': 174, 'green': 27232, 'pixel': 1412337360, 'red': 35676}, {'blue': 13544, 'flags': 198, 'green': 49868, 'pixel': 1624465264, 'red': 41082}, {'blue': 8182, 'flags': 252, 'green': 45837, 'pixel': 1992166823, 'red': 28856}, {'blue': 36214, 'flags': 198, 'green': 10594, 'pixel': 1307567581, 'red': 15877}], } - self.req_bin_0 = b'\x59\x00\x0e\x00' b'\xe1\xa2\xc2\x6a' \ - b'\x7a\xd1\xb8\x13' b'\x56\x76\x22\x3d' \ - b'\xf9\x0d\xdd\x00' b'\x6d\x7e\x0d\x12' \ - b'\xf9\xd3\x2e\xb2' b'\x32\x47\xdb\x00' \ - b'\xd8\x48\x4f\x65' b'\xd3\xea\x61\xbe' \ - b'\xd7\x7d\xa0\x00' b'\xa5\x24\x5a\x2a' \ - b'\x38\xc5\xef\x92' b'\x6c\x6f\xd1\x00' + self.req_bin_0 = '\x59\x00\x0e\x00' '\x96\x2f\xef\x0b' \ + '\xd0\x8e\x2e\x54' '\x5c\x8b\x60\x6a' \ + '\xd5\x30\xae\x00' '\x70\x5f\xd3\x60' \ + '\x7a\xa0\xcc\xc2' '\xe8\x34\xc6\x00' \ + '\xa7\x0d\xbe\x76' '\xb8\x70\x0d\xb3' \ + '\xf6\x1f\xfc\x00' '\xdd\xe5\xef\x4d' \ + '\x05\x3e\x62\x29' '\x76\x8d\xc6\x00' def testPackRequest0(self): bin = request.StoreColors._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.StoreColors._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestStoreNamedColor(unittest.TestCase): +class TestStoreNamedColor(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 869324276, - 'flags': 169, + 'cmap': 1960507691, + 'flags': 255, 'name': 'blue', - 'pixel': 413175613, + 'pixel': 990987101, } - self.req_bin_0 = b'\x5a\xa9\x05\x00' b'\xf4\xd5\xd0\x33' \ - b'\x3d\x8f\xa0\x18' b'\x04\x00\x00\x00' \ - b'\x62\x6c\x75\x65' + self.req_bin_0 = '\x5a\xff\x05\x00' '\x2b\xf9\xda\x74' \ + '\x5d\x43\x11\x3b' '\x04\x00\x00\x00' \ + '\x62\x6c\x75\x65' def testPackRequest0(self): bin = request.StoreNamedColor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.StoreNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestQueryColors(unittest.TestCase): +class TestQueryColors(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 1750052450, - 'pixels': [1673396539, 1897675292, 1453845591, 816818886, 897340342, 1782049962, 796231465, 722380604], + 'cmap': 523457697, + 'pixels': [252314471, 1787024858, 1070286120, 1538912496, 1092826517, 587223111, 1792566854, 2105060613], } - self.req_bin_0 = b'\x5b\x00\x0a\x00' b'\x62\xae\x4f\x68' \ - b'\x3b\x01\xbe\x63' b'\x1c\x3a\x1c\x71' \ - b'\x57\xec\xa7\x56' b'\xc6\xaa\xaf\x30' \ - b'\xb6\x53\x7c\x35' b'\xaa\xec\x37\x6a' \ - b'\x29\x87\x75\x2f' b'\x3c\xa7\x0e\x2b' + self.req_bin_0 = '\x5b\x00\x0a\x00' '\xa1\x54\x33\x1f' \ + '\x67\x03\x0a\x0f' '\xda\xd5\x83\x6a' \ + '\x28\x45\xcb\x3f' '\xf0\xf0\xb9\x5b' \ + '\x95\x35\x23\x41' '\x47\x50\x00\x23' \ + '\x46\x66\xd8\x6a' '\x05\xad\x78\x7d' self.reply_args_0 = { - 'colors': [{'blue': 63820, 'green': 60107, 'red': 62261}, {'blue': 54480, 'green': 48839, 'red': 10033}, {'blue': 31765, 'green': 31737, 'red': 43117}, {'blue': 50953, 'green': 52009, 'red': 14234}, {'blue': 55150, 'green': 30330, 'red': 55956}], - 'sequence_number': 10895, - } - self.reply_bin_0 = b'\x01\x00\x8f\x2a' b'\x0a\x00\x00\x00' \ - b'\x05\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x35\xf3\xcb\xea' b'\x4c\xf9\x00\x00' \ - b'\x31\x27\xc7\xbe' b'\xd0\xd4\x00\x00' \ - b'\x6d\xa8\xf9\x7b' b'\x15\x7c\x00\x00' \ - b'\x9a\x37\x29\xcb' b'\x09\xc7\x00\x00' \ - b'\x94\xda\x7a\x76' b'\x6e\xd7\x00\x00' + 'colors': [{'blue': 33433, 'green': 60435, 'red': 25296}, {'blue': 18289, 'green': 56659, 'red': 57658}, {'blue': 61243, 'green': 27343, 'red': 51827}, {'blue': 18719, 'green': 53821, 'red': 33401}, {'blue': 65464, 'green': 38571, 'red': 19745}], + 'sequence_number': 32219, + } + self.reply_bin_0 = '\x01\x00\xdb\x7d' '\x0a\x00\x00\x00' \ + '\x05\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\xd0\x62\x13\xec' '\x99\x82\x00\x00' \ + '\x3a\xe1\x53\xdd' '\x71\x47\x00\x00' \ + '\x73\xca\xcf\x6a' '\x3b\xef\x00\x00' \ + '\x79\x82\x3d\xd2' '\x1f\x49\x00\x00' \ + '\x21\x4d\xab\x96' '\xb8\xff\x00\x00' self.req_args_1 = { - 'cmap': 340337174, + 'cmap': 1183862146, 'pixels': [], } - self.req_bin_1 = b'\x5b\x00\x02\x00' b'\x16\x22\x49\x14' + self.req_bin_1 = '\x5b\x00\x02\x00' '\x82\x4d\x90\x46' def testPackRequest0(self): bin = request.QueryColors._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryColors._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.QueryColors._request.to_binary(*(), **self.req_args_1) - try: - assert bin == self.req_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.QueryColors._request.parse_binary(self.req_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_1) def testPackReply0(self): bin = request.QueryColors._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryColors._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestLookupColor(unittest.TestCase): +class TestLookupColor(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 2120409969, + 'cmap': 319162028, 'name': 'octarin', } - self.req_bin_0 = b'\x5c\x00\x05\x00' b'\x71\xe3\x62\x7e' \ - b'\x07\x00\x00\x00' b'\x6f\x63\x74\x61' \ - b'\x72\x69\x6e\x00' + self.req_bin_0 = '\x5c\x00\x05\x00' '\xac\x06\x06\x13' \ + '\x07\x00\x00\x00' '\x6f\x63\x74\x61' \ + '\x72\x69\x6e\x00' self.reply_args_0 = { - 'exact_red': 63730, - 'screen_blue': 9467, - 'exact_green': 24400, - 'exact_blue': 27493, - 'screen_green': 15878, - 'screen_red': 26587, - 'sequence_number': 2933, + 'exact_blue': 35731, + 'exact_green': 36285, + 'exact_red': 22785, + 'screen_blue': 12571, + 'screen_green': 21261, + 'screen_red': 29980, + 'sequence_number': 35414, } - self.reply_bin_0 = b'\x01\x00\x75\x0b' b'\x00\x00\x00\x00' \ - b'\xf2\xf8\x50\x5f' b'\x65\x6b\xdb\x67' \ - b'\x06\x3e\xfb\x24' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\x00\x56\x8a' '\x00\x00\x00\x00' \ + '\x01\x59\xbd\x8d' '\x93\x8b\x1c\x75' \ + '\x0d\x53\x1b\x31' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.LookupColor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.LookupColor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.LookupColor._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.LookupColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestCreateCursor(unittest.TestCase): +class TestCreateCursor(EndianTest): def setUp(self): self.req_args_0 = { - 'fore_blue': 45533, - 'cid': 1389570470, - 'fore_green': 32059, - 'mask': 1475520754, - 'back_blue': 7481, - 'fore_red': 42911, - 'source': 2060548957, - 'back_green': 9237, - 'y': 31911, - 'x': 731, - 'back_red': 30886, - } - self.req_bin_0 = b'\x5d\x00\x08\x00' b'\xa6\x29\xd3\x52' \ - b'\x5d\x7b\xd1\x7a' b'\xf2\xa8\xf2\x57' \ - b'\x9f\xa7\x3b\x7d' b'\xdd\xb1\xa6\x78' \ - b'\x15\x24\x39\x1d' b'\xdb\x02\xa7\x7c' + 'back_blue': 25459, + 'back_green': 53224, + 'back_red': 46293, + 'cid': 1497886291, + 'fore_blue': 48870, + 'fore_green': 3105, + 'fore_red': 50883, + 'mask': 501621762, + 'source': 1227954148, + 'x': 43581, + 'y': 53834, + } + self.req_bin_0 = '\x5d\x00\x08\x00' '\x53\xee\x47\x59' \ + '\xe4\x17\x31\x49' '\x02\x24\xe6\x1d' \ + '\xc3\xc6\x21\x0c' '\xe6\xbe\xd5\xb4' \ + '\xe8\xcf\x73\x63' '\x3d\xaa\x4a\xd2' def testPackRequest0(self): bin = request.CreateCursor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestCreateGlyphCursor(unittest.TestCase): +class TestCreateGlyphCursor(EndianTest): def setUp(self): self.req_args_0 = { - 'fore_blue': 25271, - 'mask_char': 19164, - 'cid': 1841424177, - 'mask': 277453392, - 'fore_green': 51196, - 'fore_red': 9195, - 'source': 21529898, - 'back_green': 55277, - 'back_blue': 7419, - 'source_char': 50271, - 'back_red': 13590, - } - self.req_bin_0 = b'\x5e\x00\x08\x00' b'\x31\xe7\xc1\x6d' \ - b'\x2a\x85\x48\x01' b'\x50\x9a\x89\x10' \ - b'\x5f\xc4\xdc\x4a' b'\xeb\x23\xfc\xc7' \ - b'\xb7\x62\x16\x35' b'\xed\xd7\xfb\x1c' + 'back_blue': 47417, + 'back_green': 30084, + 'back_red': 34590, + 'cid': 2106292170, + 'fore_blue': 28999, + 'fore_green': 57323, + 'fore_red': 57030, + 'mask': 79562119, + 'mask_char': 38782, + 'source': 1063743249, + 'source_char': 33045, + } + self.req_bin_0 = '\x5e\x00\x08\x00' '\xca\x77\x8b\x7d' \ + '\x11\x6f\x67\x3f' '\x87\x05\xbe\x04' \ + '\x15\x81\x7e\x97' '\xc6\xde\xeb\xdf' \ + '\x47\x71\x1e\x87' '\x84\x75\x39\xb9' def testPackRequest0(self): bin = request.CreateGlyphCursor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateGlyphCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestFreeCursor(unittest.TestCase): +class TestFreeCursor(EndianTest): def setUp(self): self.req_args_0 = { - 'cursor': 830435200, + 'cursor': 880461049, } - self.req_bin_0 = b'\x5f\x00\x02\x00' b'\x80\x6f\x7f\x31' + self.req_bin_0 = '\x5f\x00\x02\x00' '\xf9\xc4\x7a\x34' def testPackRequest0(self): bin = request.FreeCursor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestRecolorCursor(unittest.TestCase): +class TestRecolorCursor(EndianTest): def setUp(self): self.req_args_0 = { - 'cursor': 602252227, - 'back_red': 6018, - 'fore_blue': 64036, - 'back_green': 49024, - 'back_blue': 15439, - 'fore_green': 39148, - 'fore_red': 48154, + 'back_blue': 42677, + 'back_green': 45475, + 'back_red': 22357, + 'cursor': 1406154815, + 'fore_blue': 63525, + 'fore_green': 30904, + 'fore_red': 10332, } - self.req_bin_0 = b'\x60\x00\x05\x00' b'\xc3\xa3\xe5\x23' \ - b'\x1a\xbc\xec\x98' b'\x24\xfa\x82\x17' \ - b'\x80\xbf\x4f\x3c' + self.req_bin_0 = '\x60\x00\x05\x00' '\x3f\x38\xd0\x53' \ + '\x5c\x28\xb8\x78' '\x25\xf8\x55\x57' \ + '\xa3\xb1\xb5\xa6' def testPackRequest0(self): bin = request.RecolorCursor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.RecolorCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestQueryBestSize(unittest.TestCase): +class TestQueryBestSize(EndianTest): def setUp(self): self.req_args_0 = { - 'width': 52832, - 'item_class': 1, - 'drawable': 1606665099, - 'height': 4701, + 'drawable': 1830398758, + 'height': 25063, + 'item_class': 2, + 'width': 56353, } - self.req_bin_0 = b'\x61\x01\x03\x00' b'\x8b\xc3\xc3\x5f' \ - b'\x60\xce\x5d\x12' + self.req_bin_0 = '\x61\x02\x03\x00' '\x26\xab\x19\x6d' \ + '\x21\xdc\xe7\x61' self.reply_args_0 = { - 'width': 33709, - 'sequence_number': 43788, - 'height': 12826, + 'height': 49829, + 'sequence_number': 20927, + 'width': 47173, } - self.reply_bin_0 = b'\x01\x00\x0c\xab' b'\x00\x00\x00\x00' \ - b'\xad\x83\x1a\x32' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\x00\xbf\x51' '\x00\x00\x00\x00' \ + '\x45\xb8\xa5\xc2' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryBestSize._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryBestSize._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryBestSize._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryBestSize._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestQueryExtension(unittest.TestCase): +class TestQueryExtension(EndianTest): def setUp(self): self.req_args_0 = { 'name': 'XTRA', } - self.req_bin_0 = b'\x62\x00\x03\x00' b'\x04\x00\x00\x00' \ - b'\x58\x54\x52\x41' + self.req_bin_0 = '\x62\x00\x03\x00' '\x04\x00\x00\x00' \ + '\x58\x54\x52\x41' self.reply_args_0 = { - 'first_event': 163, - 'first_error': 166, - 'major_opcode': 215, - 'present': 1, - 'sequence_number': 3124, + 'first_error': 245, + 'first_event': 208, + 'major_opcode': 136, + 'present': 0, + 'sequence_number': 57205, } - self.reply_bin_0 = b'\x01\x00\x34\x0c' b'\x00\x00\x00\x00' \ - b'\x01\xd7\xa3\xa6' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\x00\x75\xdf' '\x00\x00\x00\x00' \ + '\x00\x88\xd0\xf5' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryExtension._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryExtension._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryExtension._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryExtension._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestListExtensions(unittest.TestCase): +class TestListExtensions(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = b'\x63\x00\x01\x00' + self.req_bin_0 = '\x63\x00\x01\x00' self.reply_args_0 = { 'names': ['XTRA', 'XTRA-II'], - 'sequence_number': 21122, + 'sequence_number': 65367, } - self.reply_bin_0 = b'\x01\x02\x82\x52' b'\x04\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x04\x58\x54\x52' b'\x41\x07\x58\x54' \ - b'\x52\x41\x2d\x49' b'\x49\x00\x00\x00' + self.reply_bin_0 = '\x01\x02\x57\xff' '\x04\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x04\x58\x54\x52' '\x41\x07\x58\x54' \ + '\x52\x41\x2d\x49' '\x49\x00\x00\x00' def testPackRequest0(self): bin = request.ListExtensions._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListExtensions._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListExtensions._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListExtensions._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) - - -class TestChangeKeyboardMapping(unittest.TestCase): - def setUp(self): - self.req_args_0 = { - 'first_keycode': 131, - 'keysyms': [[1479273593, 495399194, 1752874714], [183124138, 826800766, 542058728], [519501686, 1358630902, 1051542205], [1363902850, 52079613, 1721268402], [2124568309, 323328202, 1426344655], [1775218167, 1821828429, 1704892958], [1784543283, 783698836, 1882907069], [1165130550, 1276086917, 957090966], [1623553701, 77158667, 420399405], [790514637, 1104383431, 1645303152], [879499287, 349457843, 1313813953], [367336866, 1207824094, 514125338], [767413913, 135340640, 756292967], [475442692, 2076098223, 1252936842], [964050497, 2006979633, 948353974], [1923834215, 1061136894, 1319606154], [1186538913, 1770176901, 715354628], [1470481551, 403222608, 252019996], [260033548, 1553379907, 1096456683], [2027881549, 1992616114, 382810564]], - } - self.req_bin_0 = b'\x64\x14\x3e\x00' b'\x83\x03\x00\x00' \ - b'\x79\xec\x2b\x58' b'\x1a\x31\x87\x1d' \ - b'\xda\xbe\x7a\x68' b'\xaa\x40\xea\x0a' \ - b'\x7e\xfa\x47\x31' b'\xe8\x28\x4f\x20' \ - b'\x76\xf7\xf6\x1e' b'\xf6\x0f\xfb\x50' \ - b'\xbd\x42\xad\x3e' b'\x82\x81\x4b\x51' \ - b'\xfd\xab\x1a\x03' b'\xb2\x78\x98\x66' \ - b'\xf5\x56\xa2\x7e' b'\xca\x98\x45\x13' \ - b'\xcf\x4a\x04\x55' b'\xf7\xad\xcf\x69' \ - b'\x4d\xe5\x96\x6c' b'\x1e\x9a\x9e\x65' \ - b'\x33\xf8\x5d\x6a' b'\x94\x4b\xb6\x2e' \ - b'\xbd\xe1\x3a\x70' b'\x36\x7b\x72\x45' \ - b'\x85\x8a\x0f\x4c' b'\x96\x0c\x0c\x39' \ - b'\xa5\x76\xc5\x60' b'\x0b\x59\x99\x04' \ - b'\x2d\xc9\x0e\x19' b'\xcd\x4b\x1e\x2f' \ - b'\xc7\x8d\xd3\x41' b'\x70\x55\x11\x62' \ - b'\x17\x18\x6c\x34' b'\xb3\x4d\xd4\x14' \ - b'\xc1\x35\x4f\x4e' b'\xa2\x1d\xe5\x15' \ - b'\xde\xee\xfd\x47' b'\x1a\xee\xa4\x1e' \ - b'\x99\xce\xbd\x2d' b'\x60\x22\x11\x08' \ - b'\x67\x1d\x14\x2d' b'\x04\xae\x56\x1c' \ - b'\xaf\xbe\xbe\x7b' b'\x8a\x4c\xae\x4a' \ - b'\x41\x3e\x76\x39' b'\x31\x14\xa0\x77' \ - b'\xb6\xbb\x86\x38' b'\x67\x61\xab\x72' \ - b'\xfe\xa9\x3f\x3f' b'\x8a\x97\xa7\x4e' \ - b'\xa1\x25\xb9\x46' b'\x85\xc1\x82\x69' \ - b'\x04\x72\xa3\x2a' b'\x8f\xc4\xa5\x57' \ - b'\x50\xb0\x08\x18' b'\x1c\x85\x05\x0f' \ - b'\x0c\xcc\x7f\x0f' b'\x43\xb2\x96\x5c' \ - b'\xeb\x99\x5a\x41' b'\x4d\x04\xdf\x78' \ - b'\xb2\xe8\xc4\x76' b'\xc4\x39\xd1\x16' + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) + + +class TestChangeKeyboardMapping(EndianTest): + def setUp(self): + self.req_args_0 = { + 'first_keycode': 209, + 'keysyms': [[1603668560, 931946639, 211405004], [1360963098, 1873849632, 952792434], [1490356148, 1940088399, 98764853], [1709705072, 630002501, 804965110], [312608755, 1140670982, 1215321258], [1701922610, 365037106, 169583241], [1870113797, 1330817882, 517178039], [1960285384, 307342963, 990311897], [545412183, 548309930, 20180830], [1727936374, 1935332499, 1455158296], [339250065, 948607486, 742096527], [1261800628, 1372110414, 911196506], [537081847, 1815276355, 427815247], [826122461, 1037681409, 509395365], [1228194629, 1234399220, 2131789930], [634003216, 2100119788, 1413537765], [589442127, 1215323309, 1472743195], [1599164158, 105321726, 1302248027], [1066713724, 1941658701, 614597260], [1715539042, 1303662156, 756603491]], + } + self.req_bin_0 = '\x64\x14\x3e\x00' '\xd1\x03\x00\x00' \ + '\x50\x0a\x96\x5f' '\x8f\x60\x8c\x37' \ + '\xcc\xc8\x99\x0c' '\x1a\xa6\x1e\x51' \ + '\x20\xad\xb0\x6f' '\x72\x75\xca\x38' \ + '\xb4\x07\xd5\x58' '\x4f\x66\xa3\x73' \ + '\x35\x08\xe3\x05' '\x70\x07\xe8\x65' \ + '\x45\x13\x8d\x25' '\xf6\xca\xfa\x2f' \ + '\xf3\x07\xa2\x12' '\x06\x42\xfd\x43' \ + '\xaa\x54\x70\x48' '\x32\x47\x71\x65' \ + '\x32\x06\xc2\x15' '\x89\xa2\x1b\x0a' \ + '\x05\xac\x77\x6f' '\x5a\xab\x52\x4f' \ + '\xb7\x82\xd3\x1e' '\xc8\x94\xd7\x74' \ + '\x73\xae\x51\x12' '\xd9\xf5\x06\x3b' \ + '\x57\x54\x82\x20' '\xaa\x8b\xae\x20' \ + '\x5e\xef\x33\x01' '\x76\x37\xfe\x66' \ + '\x93\xd4\x5a\x73' '\x18\xf4\xbb\x56' \ + '\x91\x8b\x38\x14' '\xfe\x99\x8a\x38' \ + '\x8f\x7e\x3b\x2c' '\xb4\x8c\x35\x4b' \ + '\x4e\xbe\xc8\x51' '\x5a\xc1\x4f\x36' \ + '\xf7\x37\x03\x20' '\x43\xeb\x32\x6c' \ + '\x4f\xf1\x7f\x19' '\xdd\xa0\x3d\x31' \ + '\x01\xc3\xd9\x3d' '\xa5\xc1\x5c\x1e' \ + '\x45\xc3\x34\x49' '\xf4\x6f\x93\x49' \ + '\x6a\x88\x10\x7f' '\x10\x1f\xca\x25' \ + '\xec\x48\x2d\x7d' '\xe5\xdf\x40\x54' \ + '\x4f\x2c\x22\x23' '\xad\x5c\x70\x48' \ + '\x1b\x47\xc8\x57' '\xfe\x4e\x51\x5f' \ + '\xfe\x14\x47\x06' '\x5b\xba\x9e\x4d' \ + '\x7c\xc2\x94\x3f' '\x4d\x5c\xbb\x73' \ + '\x8c\x02\xa2\x24' '\x62\x0c\x41\x66' \ + '\x4c\x4e\xb4\x4d' '\x63\xda\x18\x2d' def testPackRequest0(self): bin = request.ChangeKeyboardMapping._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGetKeyboardMapping(unittest.TestCase): +class TestGetKeyboardMapping(EndianTest): def setUp(self): self.req_args_0 = { - 'first_keycode': 174, - 'count': 233, + 'count': 214, + 'first_keycode': 207, } - self.req_bin_0 = b'\x65\x00\x02\x00' b'\xae\xe9\x00\x00' + self.req_bin_0 = '\x65\x00\x02\x00' '\xcf\xd6\x00\x00' self.reply_args_0 = { - 'keysyms': [[536700486, 90972970, 1834434734], [604690854, 1612992766, 1785113276], [1258017014, 814047417, 79874791], [1752913778, 2069894554, 1342993084], [691283205, 2002270597, 1552550365], [1427239047, 80222814, 380890249], [932130695, 1233544402, 1343201446], [850296480, 830996690, 1219102856], [1427529259, 1334110395, 1423305447], [925543758, 1154246092, 389857513], [782217983, 1673349321, 296773941], [904384636, 788791004, 1427343811], [578056967, 1628142600, 882651915], [1727003528, 1202959768, 59536638], [932784259, 453243643, 1846802632], [1527858524, 2055184942, 1534128611], [134086768, 909769847, 323736641], [2080620639, 1573387975, 566724688], [1393924270, 1408645244, 1610610798], [391612329, 341605408, 484634403]], - 'sequence_number': 27901, - } - self.reply_bin_0 = b'\x01\x03\xfd\x6c' b'\x3c\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x46\x66\xfd\x1f' b'\x2a\x23\x6c\x05' \ - b'\xae\x40\x57\x6d' b'\xa6\xd9\x0a\x24' \ - b'\xfe\x50\x24\x60' b'\xbc\xaa\x66\x6a' \ - b'\xf6\xd0\xfb\x4a' b'\xb9\x60\x85\x30' \ - b'\xe7\xca\xc2\x04' b'\x72\x57\x7b\x68' \ - b'\x9a\x15\x60\x7b' b'\xbc\x72\x0c\x50' \ - b'\x05\x25\x34\x29' b'\x85\x39\x58\x77' \ - b'\xdd\x09\x8a\x5c' b'\x87\xf0\x11\x55' \ - b'\x5e\x1a\xc8\x04' b'\x89\xec\xb3\x16' \ - b'\x87\x2f\x8f\x37' b'\xd2\x64\x86\x49' \ - b'\xa6\xa0\x0f\x50' b'\xa0\x7e\xae\x32' \ - b'\xd2\x00\x88\x31' b'\x88\x08\xaa\x48' \ - b'\x2b\x5e\x16\x55' b'\xbb\xe8\x84\x4f' \ - b'\xe7\xea\xd5\x54' b'\x4e\xad\x2a\x37' \ - b'\xcc\x65\xcc\x44' b'\xe9\xc0\x3c\x17' \ - b'\xff\xb2\x9f\x2e' b'\xc9\x48\xbd\x63' \ - b'\x35\x69\xb0\x11' b'\x7c\xd0\xe7\x35' \ - b'\xdc\xfe\x03\x2f' b'\xc3\x89\x13\x55' \ - b'\x07\x73\x74\x22' b'\x08\x7c\x0b\x61' \ - b'\x0b\x33\x9c\x34' b'\x88\xfb\xef\x66' \ - b'\x98\xb5\xb3\x47' b'\xfe\x74\x8c\x03' \ - b'\x83\x28\x99\x37' b'\xfb\xf2\x03\x1b' \ - b'\xc8\xf8\x13\x6e' b'\x5c\x45\x11\x5b' \ - b'\x2e\xa2\x7f\x7a' b'\xe3\xf1\x70\x5b' \ - b'\x70\x00\xfe\x07' b'\x77\xfc\x39\x36' \ - b'\x41\xd4\x4b\x13' b'\x5f\xc0\x03\x7c' \ - b'\xc7\xfe\xc7\x5d' b'\x50\x88\xc7\x21' \ - b'\xae\x98\x15\x53' b'\x7c\x38\xf6\x53' \ - b'\x6e\xf8\xff\x5f' b'\xa9\x87\x57\x17' \ - b'\x20\x7c\x5c\x14' b'\x23\xef\xe2\x1c' + 'keysyms': [[1548181899, 1415581578, 1800315249], [1349152528, 1940044681, 1388005887], [663428316, 946660592, 1244625269], [1572730625, 193559950, 633744868], [1605202933, 377184179, 283811004], [1158369341, 2086257988, 1139996791], [1961698339, 1783426369, 551839054], [1771007886, 1034760334, 1731920851], [1603223997, 727385468, 247325063], [2067797600, 302273387, 2075543394], [1847137865, 1555243546, 2104409941], [2077195964, 1727838808, 785495937], [1697976597, 29890084, 1152280257], [976645557, 1444887947, 1443840867], [1255333237, 1766127705, 2019261461], [232671482, 502128711, 53740025], [1898879870, 1205613172, 1965497096], [475382442, 135757562, 1769215894], [1952895082, 648948458, 876808673], [300168848, 2032081167, 653617967]], + 'sequence_number': 32414, + } + self.reply_bin_0 = '\x01\x03\x9e\x7e' '\x3c\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x8b\x61\x47\x5c' '\x8a\x0f\x60\x54' \ + '\x71\xa1\x4e\x6b' '\x10\x6f\x6a\x50' \ + '\x89\xbb\xa2\x73' '\xff\x49\xbb\x52' \ + '\xdc\x1c\x8b\x27' '\xf0\xe4\x6c\x38' \ + '\x75\x79\x2f\x4a' '\x01\xf7\xbd\x5d' \ + '\x8e\x7d\x89\x0b' '\xe4\x2d\xc6\x25' \ + '\xf5\x73\xad\x5f' '\xb3\x5f\x7b\x16' \ + '\xbc\x9c\xea\x10' '\x3d\x50\x0b\x45' \ + '\x44\xc5\x59\x7c' '\x77\xf8\xf2\x43' \ + '\x23\x24\xed\x74' '\x41\xed\x4c\x6a' \ + '\x4e\x65\xe4\x20' '\x8e\x6f\x8f\x69' \ + '\x8e\x30\xad\x3d' '\xd3\x03\x3b\x67' \ + '\xbd\x41\x8f\x5f' '\x7c\x05\x5b\x2b' \ + '\x87\xe1\xbd\x0e' '\x60\x16\x40\x7b' \ + '\x6b\x53\x04\x12' '\x62\x47\xb6\x7b' \ + '\x49\x16\x19\x6e' '\x1a\x22\xb3\x5c' \ + '\x55\xbf\x6e\x7d' '\xbc\x7e\xcf\x7b' \ + '\x58\xba\xfc\x66' '\x81\xb7\xd1\x2e' \ + '\x15\x11\x35\x65' '\x24\x16\xc8\x01' \ + '\xc1\x66\xae\x44' '\xb5\x6d\x36\x3a' \ + '\x8b\x3d\x1f\x56' '\x63\x43\x0f\x56' \ + '\x75\xdd\xd2\x4a' '\x59\xf8\x44\x69' \ + '\x15\x7c\x5b\x78' '\xfa\x48\xde\x0d' \ + '\x47\xe0\xed\x1d' '\xf9\x01\x34\x03' \ + '\x7e\x9b\x2e\x71' '\x74\x32\xdc\x47' \ + '\x08\x1b\x27\x75' '\xaa\xc2\x55\x1c' \ + '\xfa\x7e\x17\x08' '\x96\x17\x74\x69' \ + '\x6a\xd0\x66\x74' '\xea\x2a\xae\x26' \ + '\xe1\x09\x43\x34' '\x90\x36\xe4\x11' \ + '\x0f\x19\x1f\x79' '\x2f\x6b\xf5\x26' def testPackRequest0(self): bin = request.GetKeyboardMapping._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetKeyboardMapping._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetKeyboardMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestChangeKeyboardControl(unittest.TestCase): +class TestChangeKeyboardControl(EndianTest): def setUp(self): self.req_args_0 = { - 'attrs': {'led': 241, 'key': 193, 'bell_duration': -19485, 'auto_repeat_mode': 0, 'bell_pitch': -13220, 'key_click_percent': -3, 'bell_percent': -74, 'led_mode': 1}, + 'attrs': {'led': 213, 'auto_repeat_mode': 1, 'bell_pitch': -28323, 'bell_percent': -15, 'key_click_percent': -116, 'key': 249, 'bell_duration': -17904, 'led_mode': 1}, } - self.req_bin_0 = b'\x66\x00\x0a\x00' b'\xff\x00\x00\x00' \ - b'\xfd\x00\x00\x00' b'\xb6\x00\x00\x00' \ - b'\x5c\xcc\x00\x00' b'\xe3\xb3\x00\x00' \ - b'\xf1\x00\x00\x00' b'\x01\x00\x00\x00' \ - b'\xc1\x00\x00\x00' b'\x00\x00\x00\x00' + self.req_bin_0 = '\x66\x00\x0a\x00' '\xff\x00\x00\x00' \ + '\x8c\x00\x00\x00' '\xf1\x00\x00\x00' \ + '\x5d\x91\x00\x00' '\x10\xba\x00\x00' \ + '\xd5\x00\x00\x00' '\x01\x00\x00\x00' \ + '\xf9\x00\x00\x00' '\x01\x00\x00\x00' def testPackRequest0(self): bin = request.ChangeKeyboardControl._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGetKeyboardControl(unittest.TestCase): +class TestGetKeyboardControl(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = b'\x67\x00\x01\x00' + self.req_bin_0 = '\x67\x00\x01\x00' self.reply_args_0 = { - 'led_mask': 1389423883, - 'global_auto_repeat': 1, - 'auto_repeats': [129, 211, 180, 202, 218, 145, 129, 136, 137, 165, 210, 160, 229, 223, 226, 130, 197, 233, 187, 166, 211, 241, 173, 183, 184, 216, 216, 218, 182, 224, 175, 210], - 'bell_pitch': 27576, - 'bell_duration': 26314, - 'bell_percent': 130, - 'sequence_number': 62321, - 'key_click_percent': 140, - } - self.reply_bin_0 = b'\x01\x01\x71\xf3' b'\x05\x00\x00\x00' \ - b'\x0b\xed\xd0\x52' b'\x8c\x82\xb8\x6b' \ - b'\xca\x66\x00\x00' b'\x81\xd3\xb4\xca' \ - b'\xda\x91\x81\x88' b'\x89\xa5\xd2\xa0' \ - b'\xe5\xdf\xe2\x82' b'\xc5\xe9\xbb\xa6' \ - b'\xd3\xf1\xad\xb7' b'\xb8\xd8\xd8\xda' \ - b'\xb6\xe0\xaf\xd2' + 'auto_repeats': [223, 147, 181, 140, 190, 180, 249, 132, 175, 184, 249, 237, 140, 215, 197, 253, 173, 178, 152, 143, 236, 186, 212, 210, 204, 130, 228, 159, 144, 200, 136, 225], + 'bell_duration': 441, + 'bell_percent': 146, + 'bell_pitch': 59042, + 'global_auto_repeat': 0, + 'key_click_percent': 170, + 'led_mask': 1867665246, + 'sequence_number': 14353, + } + self.reply_bin_0 = '\x01\x00\x11\x38' '\x05\x00\x00\x00' \ + '\x5e\x4f\x52\x6f' '\xaa\x92\xa2\xe6' \ + '\xb9\x01\x00\x00' '\xdf\x93\xb5\x8c' \ + '\xbe\xb4\xf9\x84' '\xaf\xb8\xf9\xed' \ + '\x8c\xd7\xc5\xfd' '\xad\xb2\x98\x8f' \ + '\xec\xba\xd4\xd2' '\xcc\x82\xe4\x9f' \ + '\x90\xc8\x88\xe1' def testPackRequest0(self): bin = request.GetKeyboardControl._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetKeyboardControl._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetKeyboardControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestBell(unittest.TestCase): +class TestBell(EndianTest): def setUp(self): self.req_args_0 = { - 'percent': -14, + 'percent': -19, } - self.req_bin_0 = b'\x68\xf2\x01\x00' + self.req_bin_0 = '\x68\xed\x01\x00' def testPackRequest0(self): bin = request.Bell._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.Bell._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestChangePointerControl(unittest.TestCase): +class TestChangePointerControl(EndianTest): def setUp(self): self.req_args_0 = { - 'accel_num': -5554, - 'threshold': -10566, - 'do_accel': 1, - 'accel_denum': -24572, + 'accel_denum': -28542, + 'accel_num': -28064, + 'do_accel': 0, 'do_thresh': 1, + 'threshold': -24619, } - self.req_bin_0 = b'\x69\x00\x03\x00' b'\x4e\xea\x04\xa0' \ - b'\xba\xd6\x01\x01' + self.req_bin_0 = '\x69\x00\x03\x00' '\x60\x92\x82\x90' \ + '\xd5\x9f\x00\x01' def testPackRequest0(self): bin = request.ChangePointerControl._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangePointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGetPointerControl(unittest.TestCase): +class TestGetPointerControl(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = b'\x6a\x00\x01\x00' + self.req_bin_0 = '\x6a\x00\x01\x00' self.reply_args_0 = { - 'accel_num': 11888, - 'threshold': 36822, - 'sequence_number': 62480, - 'accel_denom': 46073, + 'accel_denom': 51826, + 'accel_num': 1226, + 'sequence_number': 1938, + 'threshold': 15788, } - self.reply_bin_0 = b'\x01\x00\x10\xf4' b'\x00\x00\x00\x00' \ - b'\x70\x2e\xf9\xb3' b'\xd6\x8f\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\x00\x92\x07' '\x00\x00\x00\x00' \ + '\xca\x04\x72\xca' '\xac\x3d\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetPointerControl._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetPointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetPointerControl._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetPointerControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestSetScreenSaver(unittest.TestCase): +class TestSetScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { - 'prefer_blank': 1, - 'interval': -19218, - 'timeout': -2423, 'allow_exposures': 2, + 'interval': -27103, + 'prefer_blank': 0, + 'timeout': -22242, } - self.req_bin_0 = b'\x6b\x00\x03\x00' b'\x89\xf6\xee\xb4' \ - b'\x01\x02\x00\x00' + self.req_bin_0 = '\x6b\x00\x03\x00' '\x1e\xa9\x21\x96' \ + '\x00\x02\x00\x00' def testPackRequest0(self): bin = request.SetScreenSaver._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestGetScreenSaver(unittest.TestCase): +class TestGetScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = b'\x6c\x00\x01\x00' + self.req_bin_0 = '\x6c\x00\x01\x00' self.reply_args_0 = { - 'interval': 51464, - 'prefer_blanking': 1, - 'timeout': 5207, - 'sequence_number': 45153, 'allow_exposures': 1, + 'interval': 31345, + 'prefer_blanking': 1, + 'sequence_number': 34598, + 'timeout': 48933, } - self.reply_bin_0 = b'\x01\x00\x61\xb0' b'\x00\x00\x00\x00' \ - b'\x57\x14\x08\xc9' b'\x01\x01\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\x00\x26\x87' '\x00\x00\x00\x00' \ + '\x25\xbf\x71\x7a' '\x01\x01\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetScreenSaver._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetScreenSaver._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetScreenSaver._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestChangeHosts(unittest.TestCase): +class TestChangeHosts(EndianTest): def setUp(self): self.req_args_0 = { - 'host': [150, 200, 205, 182], - 'mode': 0, - 'host_family': 0, + 'host': [141, 192, 249, 133], + 'host_family': 2, + 'mode': 1, } - self.req_bin_0 = b'\x6d\x00\x03\x00' b'\x00\x00\x04\x00' \ - b'\x96\xc8\xcd\xb6' + self.req_bin_0 = '\x6d\x01\x03\x00' '\x02\x00\x04\x00' \ + '\x8d\xc0\xf9\x85' def testPackRequest0(self): bin = request.ChangeHosts._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeHosts._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestListHosts(unittest.TestCase): +class TestListHosts(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = b'\x6e\x00\x01\x00' + self.req_bin_0 = '\x6e\x00\x01\x00' self.reply_args_0 = { 'hosts': [{'name': [34, 23, 178, 12], 'family': 0}, {'name': [130, 236, 254, 15], 'family': 0}], 'mode': 1, - 'sequence_number': 33455, + 'sequence_number': 30157, } - self.reply_bin_0 = b'\x01\x01\xaf\x82' b'\x04\x00\x00\x00' \ - b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x04\x00' b'\x22\x17\xb2\x0c' \ - b'\x00\x00\x04\x00' b'\x82\xec\xfe\x0f' + self.reply_bin_0 = '\x01\x01\xcd\x75' '\x04\x00\x00\x00' \ + '\x02\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x04\x00' '\x22\x17\xb2\x0c' \ + '\x00\x00\x04\x00' '\x82\xec\xfe\x0f' def testPackRequest0(self): bin = request.ListHosts._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListHosts._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListHosts._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListHosts._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestSetAccessControl(unittest.TestCase): +class TestSetAccessControl(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 1, } - self.req_bin_0 = b'\x6f\x01\x01\x00' + self.req_bin_0 = '\x6f\x01\x01\x00' def testPackRequest0(self): bin = request.SetAccessControl._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetAccessControl._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestSetCloseDownMode(unittest.TestCase): +class TestSetCloseDownMode(EndianTest): def setUp(self): self.req_args_0 = { - 'mode': 1, + 'mode': 0, } - self.req_bin_0 = b'\x70\x01\x01\x00' + self.req_bin_0 = '\x70\x00\x01\x00' def testPackRequest0(self): bin = request.SetCloseDownMode._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetCloseDownMode._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestKillClient(unittest.TestCase): +class TestKillClient(EndianTest): def setUp(self): self.req_args_0 = { - 'resource': 1900634441, + 'resource': 1028639966, } - self.req_bin_0 = b'\x71\x00\x02\x00' b'\x49\x61\x49\x71' + self.req_bin_0 = '\x71\x00\x02\x00' '\xde\xcc\x4f\x3d' def testPackRequest0(self): bin = request.KillClient._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.KillClient._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestRotateProperties(unittest.TestCase): +class TestRotateProperties(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1149115389, - 'properties': [194806244, 1444715269, 486779871, 1850032482, 1083061497, 786546027, 807635511, 1716883082, 80335197, 1654299, 1459844212, 850673646], - 'delta': -27029, + 'delta': -15519, + 'properties': [862505702, 1473403724, 1052877752, 1953573572, 157880830, 173556470, 1306334440, 141112753, 590639874, 1359545959, 1177616073, 698374646], + 'window': 2135947192, } - self.req_bin_0 = b'\x72\x00\x0f\x00' b'\xfd\x1b\x7e\x44' \ - b'\x0c\x00\x6b\x96' b'\xe4\x81\x9c\x0b' \ - b'\x05\x9b\x1c\x56' b'\xdf\xab\x03\x1d' \ - b'\x62\x41\x45\x6e' b'\xf9\x34\x8e\x40' \ - b'\x6b\xbd\xe1\x2e' b'\x37\x8a\x23\x30' \ - b'\x8a\x8e\x55\x66' b'\x5d\xd1\xc9\x04' \ - b'\x1b\x3e\x19\x00' b'\x74\x74\x03\x57' \ - b'\xee\x3f\xb4\x32' + self.req_bin_0 = '\x72\x00\x0f\x00' '\xb8\xf7\x4f\x7f' \ + '\x0c\x00\x61\xc3' '\xe6\xca\x68\x33' \ + '\x4c\x5b\xd2\x57' '\xb8\xa3\xc1\x3e' \ + '\xc4\x2a\x71\x74' '\xfe\x11\x69\x09' \ + '\xf6\x42\x58\x0a' '\xe8\x14\xdd\x4d' \ + '\xb1\x35\x69\x08' '\x02\x73\x34\x23' \ + '\x67\x06\x09\x51' '\xc9\xfe\x30\x46' \ + '\xf6\x59\xa0\x29' def testPackRequest0(self): bin = request.RotateProperties._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.RotateProperties._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestForceScreenSaver(unittest.TestCase): +class TestForceScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { - 'mode': 1, + 'mode': 0, } - self.req_bin_0 = b'\x73\x01\x01\x00' + self.req_bin_0 = '\x73\x00\x01\x00' def testPackRequest0(self): bin = request.ForceScreenSaver._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ForceScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) -class TestSetPointerMapping(unittest.TestCase): +class TestSetPointerMapping(EndianTest): def setUp(self): self.req_args_0 = { - 'map': [130, 178, 229, 218, 178], + 'map': [205, 140, 217, 237, 211], } - self.req_bin_0 = b'\x74\x05\x03\x00' b'\x82\xb2\xe5\xda' \ - b'\xb2\x00\x00\x00' + self.req_bin_0 = '\x74\x05\x03\x00' '\xcd\x8c\xd9\xed' \ + '\xd3\x00\x00\x00' self.reply_args_0 = { - 'status': 145, - 'sequence_number': 57045, + 'sequence_number': 47312, + 'status': 226, } - self.reply_bin_0 = b'\x01\x91\xd5\xde' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\xe2\xd0\xb8' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SetPointerMapping._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.SetPointerMapping._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.SetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestGetPointerMapping(unittest.TestCase): +class TestGetPointerMapping(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = b'\x75\x00\x01\x00' + self.req_bin_0 = '\x75\x00\x01\x00' self.reply_args_0 = { - 'map': [248, 185, 227, 157, 133], - 'sequence_number': 20072, + 'map': [155, 185, 157, 171, 186], + 'sequence_number': 27411, } - self.reply_bin_0 = b'\x01\x05\x68\x4e' b'\x02\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\xf8\xb9\xe3\x9d' b'\x85\x00\x00\x00' + self.reply_bin_0 = '\x01\x05\x13\x6b' '\x02\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x9b\xb9\x9d\xab' '\xba\x00\x00\x00' def testPackRequest0(self): bin = request.GetPointerMapping._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetPointerMapping._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestSetModifierMapping(unittest.TestCase): +class TestSetModifierMapping(EndianTest): def setUp(self): self.req_args_0 = { - 'keycodes': [[6, 191], [94, 123], [46, 94], [104, 116], [132, 158], [35, 75], [128, 63], [135, 221]], + 'keycodes': [[24, 109], [170, 95], [39, 236], [17, 212], [23, 24], [189, 207], [142, 150], [143, 84]], } - self.req_bin_0 = b'\x76\x02\x05\x00' b'\x06\xbf\x5e\x7b' \ - b'\x2e\x5e\x68\x74' b'\x84\x9e\x23\x4b' \ - b'\x80\x3f\x87\xdd' + self.req_bin_0 = '\x76\x02\x05\x00' '\x18\x6d\xaa\x5f' \ + '\x27\xec\x11\xd4' '\x17\x18\xbd\xcf' \ + '\x8e\x96\x8f\x54' self.reply_args_0 = { - 'status': 149, - 'sequence_number': 26757, + 'sequence_number': 23338, + 'status': 143, } - self.reply_bin_0 = b'\x01\x95\x85\x68' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = '\x01\x8f\x2a\x5b' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SetModifierMapping._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.SetModifierMapping._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.SetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestGetModifierMapping(unittest.TestCase): +class TestGetModifierMapping(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = b'\x77\x00\x01\x00' + self.req_bin_0 = '\x77\x00\x01\x00' self.reply_args_0 = { - 'keycodes': [[85, 162], [139, 194], [12, 107], [120, 193], [26, 40], [125, 221], [27, 0], [220, 78]], - 'sequence_number': 17677, + 'keycodes': [[170, 192], [222, 184], [247, 153], [90, 147], [54, 168], [57, 27], [216, 94], [195, 146]], + 'sequence_number': 52951, } - self.reply_bin_0 = b'\x01\x02\x0d\x45' b'\x04\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x55\xa2\x8b\xc2' b'\x0c\x6b\x78\xc1' \ - b'\x1a\x28\x7d\xdd' b'\x1b\x00\xdc\x4e' + self.reply_bin_0 = '\x01\x02\xd7\xce' '\x04\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ + '\xaa\xc0\xde\xb8' '\xf7\x99\x5a\x93' \ + '\x36\xa8\x39\x1b' '\xd8\x5e\xc3\x92' def testPackRequest0(self): bin = request.GetModifierMapping._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetModifierMapping._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) -class TestNoOperation(unittest.TestCase): +class TestNoOperation(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = b'\x7f\x00\x01\x00' + self.req_bin_0 = '\x7f\x00\x01\x00' def testPackRequest0(self): bin = request.NoOperation._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.NoOperation._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) if __name__ == "__main__": - check_endian() unittest.main() From 92da1cf8ee0b26087bb624688f8e8caecc4bcdf0 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 19:00:58 +0200 Subject: [PATCH 045/279] test: manually update big-endian tests --- test/test_events_be.py | 113 ++++----------- test/test_requests_be.py | 303 ++++++++++++++++----------------------- 2 files changed, 152 insertions(+), 264 deletions(-) diff --git a/test/test_events_be.py b/test/test_events_be.py index 0b425181..b032f6d5 100755 --- a/test/test_events_be.py +++ b/test/test_events_be.py @@ -1,76 +1,17 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 -import sys, os -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) +import sys, os, difflib +sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest from Xlib.protocol import request, rq, event -import Xlib.protocol.event +from . import BigEndianTest as EndianTest +from . import DummyDisplay -import struct -import array - -class CmpArray(object): - def __init__(self, *args, **kws): - self.array = array.array(*args, **kws) - - def __len__(self): - return len(self.array) - - def __getitem__(self, key): - if isinstance(key, slice): - x = key.start - y = key.stop - return list(self.array[x:y]) - else: - return self.array[key] - - def __getattr__(self, attr): - return getattr(self.array, attr) - - def __lt__(self, other): - return self.array.tolist() < other - - def __gt__(self, other): - return self.array.tolist() > other - - def __eq__(self, other): - return self.array.tolist() == other - -rq.array = CmpArray - -def tohex(bin): - bin = ''.join(map(lambda c: '\\x%02x' % ord(c), bin)) - - bins = [] - for i in range(0, len(bin), 16): - bins.append(bin[i:i+16]) - - bins2 = [] - for i in range(0, len(bins), 2): - try: - bins2.append("'%s' '%s'" % (bins[i], bins[i + 1])) - except IndexError: - bins2.append("'%s'" % bins[i]) - - return ' \\\n '.join(bins2) - -class DummyDisplay: - def get_resource_class(self, x): - return None - - event_classes = Xlib.protocol.event.event_class dummy_display = DummyDisplay() -def check_endian(): - if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 1: - sys.stderr.write('Big-endian tests, skipping on this system.\n') - sys.exit(0) - - - -class TestKeymapNotify(unittest.TestCase): +class TestKeymapNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'type': 154, @@ -101,7 +42,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestExpose(unittest.TestCase): +class TestExpose(EndianTest): def setUp(self): self.evt_args_0 = { 'height': 22214, @@ -138,7 +79,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestGraphicsExpose(unittest.TestCase): +class TestGraphicsExpose(EndianTest): def setUp(self): self.evt_args_0 = { 'height': 352, @@ -177,7 +118,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestNoExpose(unittest.TestCase): +class TestNoExpose(EndianTest): def setUp(self): self.evt_args_0 = { 'sequence_number': 46171, @@ -211,7 +152,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestVisibilityNotify(unittest.TestCase): +class TestVisibilityNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'state': 238, @@ -244,7 +185,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestCreateNotify(unittest.TestCase): +class TestCreateNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'height': 15506, @@ -283,7 +224,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestDestroyNotify(unittest.TestCase): +class TestDestroyNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'sequence_number': 49137, @@ -316,7 +257,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestUnmapNotify(unittest.TestCase): +class TestUnmapNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'from_configure': 0, @@ -350,7 +291,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestMapNotify(unittest.TestCase): +class TestMapNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'sequence_number': 65096, @@ -384,7 +325,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestMapRequest(unittest.TestCase): +class TestMapRequest(EndianTest): def setUp(self): self.evt_args_0 = { 'parent': 1664235152, @@ -417,7 +358,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestReparentNotify(unittest.TestCase): +class TestReparentNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'sequence_number': 9256, @@ -454,7 +395,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestConfigureNotify(unittest.TestCase): +class TestConfigureNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'height': 16243, @@ -494,7 +435,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestConfigureRequest(unittest.TestCase): +class TestConfigureRequest(EndianTest): def setUp(self): self.evt_args_0 = { 'sequence_number': 31377, @@ -535,7 +476,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestGravityNotify(unittest.TestCase): +class TestGravityNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'sequence_number': 43376, @@ -570,7 +511,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestResizeRequest(unittest.TestCase): +class TestResizeRequest(EndianTest): def setUp(self): self.evt_args_0 = { 'height': 59752, @@ -604,7 +545,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestPropertyNotify(unittest.TestCase): +class TestPropertyNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'atom': 762586168, @@ -639,7 +580,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestSelectionClear(unittest.TestCase): +class TestSelectionClear(EndianTest): def setUp(self): self.evt_args_0 = { 'time': 578079299, @@ -673,7 +614,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestSelectionRequest(unittest.TestCase): +class TestSelectionRequest(EndianTest): def setUp(self): self.evt_args_0 = { 'sequence_number': 13254, @@ -710,7 +651,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestSelectionNotify(unittest.TestCase): +class TestSelectionNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'sequence_number': 39736, @@ -746,7 +687,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestColormapNotify(unittest.TestCase): +class TestColormapNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'state': 209, @@ -781,7 +722,7 @@ def testUnpack0(self): raise AssertionError(args) -class TestClientMessage(unittest.TestCase): +class TestClientMessage(EndianTest): def setUp(self): self.evt_args_0 = { 'sequence_number': 48712, @@ -875,7 +816,7 @@ def testUnpack2(self): raise AssertionError(args) -class TestMappingNotify(unittest.TestCase): +class TestMappingNotify(EndianTest): def setUp(self): self.evt_args_0 = { 'sequence_number': 53541, diff --git a/test/test_requests_be.py b/test/test_requests_be.py index c67074b0..f02236cb 100644 --- a/test/test_requests_be.py +++ b/test/test_requests_be.py @@ -1,70 +1,17 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 -import sys, os -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) +import sys, os, difflib +sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest from Xlib.protocol import request, rq, event -import Xlib.protocol.event +from . import BigEndianTest as EndianTest +from . import DummyDisplay -import struct -import array - -class CmpArray(object): - def __init__(self, *args, **kws): - self.array = array.array(*args, **kws) - - def __len__(self): - return len(self.array) - - def __getitem__(self, key): - if isinstance(key, slice): - x = key.start - y = key.stop - return list(self.array[x:y]) - else: - return self.array[key] - - def __getattr__(self, attr): - return getattr(self.array, attr) - - def __cmp__(self, other): - return cmp(self.array.tolist(), other) - -rq.array = CmpArray - -def tohex(bin): - bin = ''.join(map(lambda c: '\\x%02x' % ord(c), bin)) - - bins = [] - for i in range(0, len(bin), 16): - bins.append(bin[i:i+16]) - - bins2 = [] - for i in range(0, len(bins), 2): - try: - bins2.append("'%s' '%s'" % (bins[i], bins[i + 1])) - except IndexError: - bins2.append("'%s'" % bins[i]) - - return ' \\\n '.join(bins2) - -class DummyDisplay: - def get_resource_class(self, x): - return None - - event_classes = Xlib.protocol.event.event_class dummy_display = DummyDisplay() -def check_endian(): - if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 1: - sys.stderr.write('Big-endian tests, skipping on this system.\n') - sys.exit(0) - - - -class TestCreateWindow(unittest.TestCase): +class TestCreateWindow(EndianTest): def setUp(self): self.req_args_0 = { 'height': 38608, @@ -112,7 +59,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestChangeWindowAttributes(unittest.TestCase): +class TestChangeWindowAttributes(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1813552124, @@ -148,7 +95,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGetWindowAttributes(unittest.TestCase): +class TestGetWindowAttributes(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1931593850, @@ -218,7 +165,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestDestroyWindow(unittest.TestCase): +class TestDestroyWindow(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1622184267, @@ -245,7 +192,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestDestroySubWindows(unittest.TestCase): +class TestDestroySubWindows(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1000376476, @@ -272,7 +219,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestChangeSaveSet(unittest.TestCase): +class TestChangeSaveSet(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1577523459, @@ -300,7 +247,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestReparentWindow(unittest.TestCase): +class TestReparentWindow(EndianTest): def setUp(self): self.req_args_0 = { 'parent': 72188776, @@ -331,7 +278,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestMapWindow(unittest.TestCase): +class TestMapWindow(EndianTest): def setUp(self): self.req_args_0 = { 'window': 61469476, @@ -358,7 +305,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestMapSubwindows(unittest.TestCase): +class TestMapSubwindows(EndianTest): def setUp(self): self.req_args_0 = { 'window': 818738118, @@ -385,7 +332,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestUnmapWindow(unittest.TestCase): +class TestUnmapWindow(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1923663468, @@ -412,7 +359,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestUnmapSubwindows(unittest.TestCase): +class TestUnmapSubwindows(EndianTest): def setUp(self): self.req_args_0 = { 'window': 999740194, @@ -439,7 +386,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestConfigureWindow(unittest.TestCase): +class TestConfigureWindow(EndianTest): def setUp(self): self.req_args_0 = { 'window': 190634459, @@ -471,7 +418,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestCirculateWindow(unittest.TestCase): +class TestCirculateWindow(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1712979067, @@ -499,7 +446,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGetGeometry(unittest.TestCase): +class TestGetGeometry(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 680179490, @@ -559,7 +506,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestQueryTree(unittest.TestCase): +class TestQueryTree(EndianTest): def setUp(self): self.req_args_0 = { 'window': 2052496265, @@ -619,7 +566,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestInternAtom(unittest.TestCase): +class TestInternAtom(EndianTest): def setUp(self): self.req_args_0 = { 'only_if_exists': 0, @@ -676,7 +623,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestGetAtomName(unittest.TestCase): +class TestGetAtomName(EndianTest): def setUp(self): self.req_args_0 = { 'atom': 1022286544, @@ -731,7 +678,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestChangeProperty(unittest.TestCase): +class TestChangeProperty(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 0, @@ -973,7 +920,7 @@ def testUnpackRequest7(self): raise AssertionError(args) -class TestDeleteProperty(unittest.TestCase): +class TestDeleteProperty(EndianTest): def setUp(self): self.req_args_0 = { 'property': 506897017, @@ -1002,7 +949,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGetProperty(unittest.TestCase): +class TestGetProperty(EndianTest): def setUp(self): self.req_args_0 = { 'delete': 0, @@ -1274,7 +1221,7 @@ def testUnpackReply7(self): raise AssertionError(args) -class TestListProperties(unittest.TestCase): +class TestListProperties(EndianTest): def setUp(self): self.req_args_0 = { 'window': 91262675, @@ -1340,7 +1287,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestSetSelectionOwner(unittest.TestCase): +class TestSetSelectionOwner(EndianTest): def setUp(self): self.req_args_0 = { 'selection': 2071258139, @@ -1370,7 +1317,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGetSelectionOwner(unittest.TestCase): +class TestGetSelectionOwner(EndianTest): def setUp(self): self.req_args_0 = { 'selection': 819576555, @@ -1424,7 +1371,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestConvertSelection(unittest.TestCase): +class TestConvertSelection(EndianTest): def setUp(self): self.req_args_0 = { 'property': 2137791927, @@ -1457,7 +1404,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestSendEvent(unittest.TestCase): +class TestSendEvent(EndianTest): def setUp(self): self.req_args_0 = { 'event': Xlib.protocol.event.Expose(height = 64784, sequence_number = 0, type = 12, x = 52546, y = 56316, window = 1322187412, width = 16612, count = 14164), @@ -1492,7 +1439,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGrabPointer(unittest.TestCase): +class TestGrabPointer(EndianTest): def setUp(self): self.req_args_0 = { 'owner_events': 1, @@ -1555,7 +1502,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestUngrabPointer(unittest.TestCase): +class TestUngrabPointer(EndianTest): def setUp(self): self.req_args_0 = { 'time': 209008422, @@ -1582,7 +1529,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGrabButton(unittest.TestCase): +class TestGrabButton(EndianTest): def setUp(self): self.req_args_0 = { 'owner_events': 1, @@ -1619,7 +1566,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestUngrabButton(unittest.TestCase): +class TestUngrabButton(EndianTest): def setUp(self): self.req_args_0 = { 'grab_window': 795414150, @@ -1649,7 +1596,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestChangeActivePointerGrab(unittest.TestCase): +class TestChangeActivePointerGrab(EndianTest): def setUp(self): self.req_args_0 = { 'time': 891337572, @@ -1679,7 +1626,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGrabKeyboard(unittest.TestCase): +class TestGrabKeyboard(EndianTest): def setUp(self): self.req_args_0 = { 'owner_events': 0, @@ -1738,7 +1685,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestUngrabKeyboard(unittest.TestCase): +class TestUngrabKeyboard(EndianTest): def setUp(self): self.req_args_0 = { 'time': 1352311886, @@ -1765,7 +1712,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGrabKey(unittest.TestCase): +class TestGrabKey(EndianTest): def setUp(self): self.req_args_0 = { 'owner_events': 1, @@ -1798,7 +1745,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestUngrabKey(unittest.TestCase): +class TestUngrabKey(EndianTest): def setUp(self): self.req_args_0 = { 'grab_window': 769929659, @@ -1828,7 +1775,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestAllowEvents(unittest.TestCase): +class TestAllowEvents(EndianTest): def setUp(self): self.req_args_0 = { 'time': 342147129, @@ -1856,7 +1803,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGrabServer(unittest.TestCase): +class TestGrabServer(EndianTest): def setUp(self): self.req_args_0 = { } @@ -1882,7 +1829,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestUngrabServer(unittest.TestCase): +class TestUngrabServer(EndianTest): def setUp(self): self.req_args_0 = { } @@ -1908,7 +1855,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestQueryPointer(unittest.TestCase): +class TestQueryPointer(EndianTest): def setUp(self): self.req_args_0 = { 'window': 561336799, @@ -1969,7 +1916,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestGetMotionEvents(unittest.TestCase): +class TestGetMotionEvents(EndianTest): def setUp(self): self.req_args_0 = { 'window': 843681780, @@ -2031,7 +1978,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestTranslateCoords(unittest.TestCase): +class TestTranslateCoords(EndianTest): def setUp(self): self.req_args_0 = { 'src_y': -27247, @@ -2092,7 +2039,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestWarpPointer(unittest.TestCase): +class TestWarpPointer(EndianTest): def setUp(self): self.req_args_0 = { 'src_height': 56634, @@ -2128,7 +2075,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestSetInputFocus(unittest.TestCase): +class TestSetInputFocus(EndianTest): def setUp(self): self.req_args_0 = { 'revert_to': 1, @@ -2158,7 +2105,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGetInputFocus(unittest.TestCase): +class TestGetInputFocus(EndianTest): def setUp(self): self.req_args_0 = { } @@ -2212,7 +2159,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestQueryKeymap(unittest.TestCase): +class TestQueryKeymap(EndianTest): def setUp(self): self.req_args_0 = { } @@ -2266,7 +2213,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestOpenFont(unittest.TestCase): +class TestOpenFont(EndianTest): def setUp(self): self.req_args_0 = { 'fid': 1728036313, @@ -2296,7 +2243,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestCloseFont(unittest.TestCase): +class TestCloseFont(EndianTest): def setUp(self): self.req_args_0 = { 'font': 1139770507, @@ -2323,7 +2270,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestQueryFont(unittest.TestCase): +class TestQueryFont(EndianTest): def setUp(self): self.req_args_0 = { 'font': 1867659050, @@ -2398,7 +2345,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestQueryTextExtents(unittest.TestCase): +class TestQueryTextExtents(EndianTest): def setUp(self): self.req_args_0 = { 'font': 1562125736, @@ -2461,7 +2408,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestListFonts(unittest.TestCase): +class TestListFonts(EndianTest): def setUp(self): self.req_args_0 = { 'max_names': 53961, @@ -2520,7 +2467,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestListFontsWithInfo(unittest.TestCase): +class TestListFontsWithInfo(EndianTest): def setUp(self): self.req_args_0 = { 'max_names': 46571, @@ -2595,7 +2542,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestSetFontPath(unittest.TestCase): +class TestSetFontPath(EndianTest): def setUp(self): self.req_args_0 = { 'path': ['foo', 'bar', 'gazonk'], @@ -2647,7 +2594,7 @@ def testUnpackRequest1(self): raise AssertionError(args) -class TestGetFontPath(unittest.TestCase): +class TestGetFontPath(EndianTest): def setUp(self): self.req_args_0 = { } @@ -2729,7 +2676,7 @@ def testUnpackReply1(self): raise AssertionError(args) -class TestCreatePixmap(unittest.TestCase): +class TestCreatePixmap(EndianTest): def setUp(self): self.req_args_0 = { 'height': 65515, @@ -2761,7 +2708,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestFreePixmap(unittest.TestCase): +class TestFreePixmap(EndianTest): def setUp(self): self.req_args_0 = { 'pixmap': 213012851, @@ -2788,7 +2735,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestCreateGC(unittest.TestCase): +class TestCreateGC(EndianTest): def setUp(self): self.req_args_0 = { 'cid': 1060658282, @@ -2830,7 +2777,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestChangeGC(unittest.TestCase): +class TestChangeGC(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'dashes': 249, 'fill_rule': 1, 'clip_mask': 496525721, 'plane_mask': 1467281901, 'line_style': 2, 'tile': 1713935374, 'arc_mode': 0, 'clip_y_origin': -24572, 'dash_offset': 46636, 'line_width': 61036, 'background': 1598773587, 'clip_x_origin': -19725, 'join_style': 1, 'graphics_exposures': 0, 'font': 429323306, 'tile_stipple_y_origin': -11767, 'stipple': 1365263649, 'fill_style': 2, 'cap_style': 1, 'subwindow_mode': 1, 'tile_stipple_x_origin': -23501, 'foreground': 1272378077, 'function': 11}, @@ -2870,7 +2817,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestCopyGC(unittest.TestCase): +class TestCopyGC(EndianTest): def setUp(self): self.req_args_0 = { 'mask': 1039948946, @@ -2900,7 +2847,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestSetDashes(unittest.TestCase): +class TestSetDashes(EndianTest): def setUp(self): self.req_args_0 = { 'dashes': [169, 241, 158, 238, 173, 159, 182, 139, 139], @@ -2931,7 +2878,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestSetClipRectangles(unittest.TestCase): +class TestSetClipRectangles(EndianTest): def setUp(self): self.req_args_0 = { 'rectangles': [{'height': 59391, 'x': -15430, 'width': 46673, 'y': -3009}, {'height': 9883, 'x': -14046, 'width': 7782, 'y': -24857}], @@ -2993,7 +2940,7 @@ def testUnpackRequest1(self): raise AssertionError(args) -class TestFreeGC(unittest.TestCase): +class TestFreeGC(EndianTest): def setUp(self): self.req_args_0 = { 'gc': 371787524, @@ -3020,7 +2967,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestClearArea(unittest.TestCase): +class TestClearArea(EndianTest): def setUp(self): self.req_args_0 = { 'exposures': 0, @@ -3053,7 +3000,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestCopyArea(unittest.TestCase): +class TestCopyArea(EndianTest): def setUp(self): self.req_args_0 = { 'src_drawable': 321720617, @@ -3091,7 +3038,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestCopyPlane(unittest.TestCase): +class TestCopyPlane(EndianTest): def setUp(self): self.req_args_0 = { 'src_drawable': 1988650265, @@ -3130,7 +3077,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestPolyPoint(unittest.TestCase): +class TestPolyPoint(EndianTest): def setUp(self): self.req_args_0 = { 'gc': 206266633, @@ -3162,7 +3109,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestPolyLine(unittest.TestCase): +class TestPolyLine(EndianTest): def setUp(self): self.req_args_0 = { 'gc': 1355594189, @@ -3195,7 +3142,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestPolySegment(unittest.TestCase): +class TestPolySegment(EndianTest): def setUp(self): self.req_args_0 = { 'segments': [{'y1': -24252, 'y2': -22523, 'x1': -12610, 'x2': -25770}], @@ -3226,7 +3173,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestPolyRectangle(unittest.TestCase): +class TestPolyRectangle(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 1927481661, @@ -3259,7 +3206,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestPolyArc(unittest.TestCase): +class TestPolyArc(EndianTest): def setUp(self): self.req_args_0 = { 'arcs': [{'height': 37549, 'angle1': -16979, 'x': -4943, 'angle2': -25650, 'width': 65448, 'y': -9205}, {'height': 9322, 'angle1': -20781, 'x': -13865, 'angle2': -8498, 'width': 62173, 'y': -22862}, {'height': 63266, 'angle1': -1231, 'x': -12693, 'angle2': -809, 'width': 63732, 'y': -7550}], @@ -3293,7 +3240,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestFillPoly(unittest.TestCase): +class TestFillPoly(EndianTest): def setUp(self): self.req_args_0 = { 'shape': 1, @@ -3327,7 +3274,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestPolyFillRectangle(unittest.TestCase): +class TestPolyFillRectangle(EndianTest): def setUp(self): self.req_args_0 = { 'drawable': 1708671692, @@ -3359,7 +3306,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestPolyFillArc(unittest.TestCase): +class TestPolyFillArc(EndianTest): def setUp(self): self.req_args_0 = { 'arcs': [{'height': 64114, 'angle1': -28360, 'x': -10754, 'angle2': -6712, 'width': 53819, 'y': -19555}], @@ -3390,7 +3337,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestPutImage(unittest.TestCase): +class TestPutImage(EndianTest): def setUp(self): self.req_args_0 = { 'height': 9883, @@ -3430,7 +3377,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGetImage(unittest.TestCase): +class TestGetImage(EndianTest): def setUp(self): self.req_args_0 = { 'height': 42657, @@ -3498,7 +3445,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestPolyText8(unittest.TestCase): +class TestPolyText8(EndianTest): def setUp(self): self.req_args_0 = { 'gc': 1481564777, @@ -3532,7 +3479,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestPolyText16(unittest.TestCase): +class TestPolyText16(EndianTest): def setUp(self): self.req_args_0 = { 'gc': 400697368, @@ -3566,7 +3513,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestImageText8(unittest.TestCase): +class TestImageText8(EndianTest): def setUp(self): self.req_args_0 = { 'string': 'showme', @@ -3599,7 +3546,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestImageText16(unittest.TestCase): +class TestImageText16(EndianTest): def setUp(self): self.req_args_0 = { 'string': (115, 104, 111, 119, 109, 111, 114, 101), @@ -3633,7 +3580,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestCreateColormap(unittest.TestCase): +class TestCreateColormap(EndianTest): def setUp(self): self.req_args_0 = { 'mid': 157536683, @@ -3664,7 +3611,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestFreeColormap(unittest.TestCase): +class TestFreeColormap(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 1296514923, @@ -3691,7 +3638,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestCopyColormapAndFree(unittest.TestCase): +class TestCopyColormapAndFree(EndianTest): def setUp(self): self.req_args_0 = { 'src_cmap': 1049336329, @@ -3720,7 +3667,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestInstallColormap(unittest.TestCase): +class TestInstallColormap(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 1539075582, @@ -3747,7 +3694,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestUninstallColormap(unittest.TestCase): +class TestUninstallColormap(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 959493342, @@ -3774,7 +3721,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestListInstalledColormaps(unittest.TestCase): +class TestListInstalledColormaps(EndianTest): def setUp(self): self.req_args_0 = { 'window': 1517864638, @@ -3829,7 +3776,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestAllocColor(unittest.TestCase): +class TestAllocColor(EndianTest): def setUp(self): self.req_args_0 = { 'red': 39725, @@ -3890,7 +3837,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestAllocNamedColor(unittest.TestCase): +class TestAllocNamedColor(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 128217824, @@ -3953,7 +3900,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestAllocColorCells(unittest.TestCase): +class TestAllocColorCells(EndianTest): def setUp(self): self.req_args_0 = { 'planes': 32867, @@ -4050,7 +3997,7 @@ def testUnpackReply1(self): raise AssertionError(args) -class TestAllocColorPlanes(unittest.TestCase): +class TestAllocColorPlanes(EndianTest): def setUp(self): self.req_args_0 = { 'red': 22876, @@ -4115,7 +4062,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestFreeColors(unittest.TestCase): +class TestFreeColors(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 727008216, @@ -4153,7 +4100,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestStoreColors(unittest.TestCase): +class TestStoreColors(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 501035281, @@ -4187,7 +4134,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestStoreNamedColor(unittest.TestCase): +class TestStoreNamedColor(EndianTest): def setUp(self): self.req_args_0 = { 'name': 'blue', @@ -4219,7 +4166,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestQueryColors(unittest.TestCase): +class TestQueryColors(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 596369797, @@ -4307,7 +4254,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestLookupColor(unittest.TestCase): +class TestLookupColor(EndianTest): def setUp(self): self.req_args_0 = { 'cmap': 789574750, @@ -4369,7 +4316,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestCreateCursor(unittest.TestCase): +class TestCreateCursor(EndianTest): def setUp(self): self.req_args_0 = { 'x': 14199, @@ -4409,7 +4356,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestCreateGlyphCursor(unittest.TestCase): +class TestCreateGlyphCursor(EndianTest): def setUp(self): self.req_args_0 = { 'fore_red': 56306, @@ -4449,7 +4396,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestFreeCursor(unittest.TestCase): +class TestFreeCursor(EndianTest): def setUp(self): self.req_args_0 = { 'cursor': 553262138, @@ -4476,7 +4423,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestRecolorCursor(unittest.TestCase): +class TestRecolorCursor(EndianTest): def setUp(self): self.req_args_0 = { 'fore_red': 44718, @@ -4511,7 +4458,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestQueryBestSize(unittest.TestCase): +class TestQueryBestSize(EndianTest): def setUp(self): self.req_args_0 = { 'height': 34743, @@ -4570,7 +4517,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestQueryExtension(unittest.TestCase): +class TestQueryExtension(EndianTest): def setUp(self): self.req_args_0 = { 'name': 'XTRA', @@ -4628,7 +4575,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestListExtensions(unittest.TestCase): +class TestListExtensions(EndianTest): def setUp(self): self.req_args_0 = { } @@ -4683,7 +4630,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestChangeKeyboardMapping(unittest.TestCase): +class TestChangeKeyboardMapping(EndianTest): def setUp(self): self.req_args_0 = { 'keysyms': [[707837223, 99294840, 1205405602], [67157514, 879853050, 2059131033], [1139736188, 578113249, 1525786315], [1335349176, 246731334, 277761436], [1386594542, 1676932187, 1862777168], [535892916, 342718655, 195574000], [5712156, 1820472637, 848853860], [1123197289, 1664064022, 94999154], [380150420, 402902535, 1061375041], [510686316, 502245882, 422893644], [1423643601, 194077695, 403885178], [1571826296, 529249772, 623556591], [720045879, 37553034, 955963792], [513407882, 861125615, 219940695], [184890179, 472466494, 1649347894], [1679171989, 1991748404, 1674460475], [1762342934, 276695222, 1941684480], [886658026, 1860690072, 577030090], [227169721, 1390318675, 321524615], [2144591365, 545119116, 404205206]], @@ -4741,7 +4688,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGetKeyboardMapping(unittest.TestCase): +class TestGetKeyboardMapping(EndianTest): def setUp(self): self.req_args_0 = { 'count': 131, @@ -4826,7 +4773,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestChangeKeyboardControl(unittest.TestCase): +class TestChangeKeyboardControl(EndianTest): def setUp(self): self.req_args_0 = { 'attrs': {'key_click_percent': -35, 'bell_percent': -53, 'led_mode': 1, 'bell_pitch': -17390, 'auto_repeat_mode': 2, 'bell_duration': -30281, 'key': 235, 'led': 192}, @@ -4857,7 +4804,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGetKeyboardControl(unittest.TestCase): +class TestGetKeyboardControl(EndianTest): def setUp(self): self.req_args_0 = { } @@ -4919,7 +4866,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestBell(unittest.TestCase): +class TestBell(EndianTest): def setUp(self): self.req_args_0 = { 'percent': -19, @@ -4946,7 +4893,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestChangePointerControl(unittest.TestCase): +class TestChangePointerControl(EndianTest): def setUp(self): self.req_args_0 = { 'accel_denum': -32484, @@ -4978,7 +4925,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGetPointerControl(unittest.TestCase): +class TestGetPointerControl(EndianTest): def setUp(self): self.req_args_0 = { } @@ -5033,7 +4980,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestSetScreenSaver(unittest.TestCase): +class TestSetScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { 'allow_exposures': 0, @@ -5064,7 +5011,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestGetScreenSaver(unittest.TestCase): +class TestGetScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { } @@ -5120,7 +5067,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestChangeHosts(unittest.TestCase): +class TestChangeHosts(EndianTest): def setUp(self): self.req_args_0 = { 'host': [188, 226, 135, 199], @@ -5150,7 +5097,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestListHosts(unittest.TestCase): +class TestListHosts(EndianTest): def setUp(self): self.req_args_0 = { } @@ -5206,7 +5153,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestSetAccessControl(unittest.TestCase): +class TestSetAccessControl(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 0, @@ -5233,7 +5180,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestSetCloseDownMode(unittest.TestCase): +class TestSetCloseDownMode(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 0, @@ -5260,7 +5207,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestKillClient(unittest.TestCase): +class TestKillClient(EndianTest): def setUp(self): self.req_args_0 = { 'resource': 1679944210, @@ -5287,7 +5234,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestRotateProperties(unittest.TestCase): +class TestRotateProperties(EndianTest): def setUp(self): self.req_args_0 = { 'delta': -27095, @@ -5323,7 +5270,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestForceScreenSaver(unittest.TestCase): +class TestForceScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 1, @@ -5350,7 +5297,7 @@ def testUnpackRequest0(self): raise AssertionError(args) -class TestSetPointerMapping(unittest.TestCase): +class TestSetPointerMapping(EndianTest): def setUp(self): self.req_args_0 = { 'map': [218, 142, 195, 250, 194], @@ -5405,7 +5352,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestGetPointerMapping(unittest.TestCase): +class TestGetPointerMapping(EndianTest): def setUp(self): self.req_args_0 = { } @@ -5459,7 +5406,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestSetModifierMapping(unittest.TestCase): +class TestSetModifierMapping(EndianTest): def setUp(self): self.req_args_0 = { 'keycodes': [[72, 169], [161, 154], [26, 10], [108, 187], [110, 198], [225, 88], [33, 66], [189, 147]], @@ -5515,7 +5462,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestGetModifierMapping(unittest.TestCase): +class TestGetModifierMapping(EndianTest): def setUp(self): self.req_args_0 = { } @@ -5570,7 +5517,7 @@ def testUnpackReply0(self): raise AssertionError(args) -class TestNoOperation(unittest.TestCase): +class TestNoOperation(EndianTest): def setUp(self): self.req_args_0 = { } From 4c7cb71a514cabb3ad4de98fbfbf3196603efaf2 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 19:03:29 +0200 Subject: [PATCH 046/279] test: no need for testall anymore --- .travis.yml | 2 +- test/testall.py | 53 ------------------------------------------------- 2 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 test/testall.py diff --git a/.travis.yml b/.travis.yml index 44488ec7..4b618a4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ before_script: # command to run tests script: - nosetests --with-xunit --with-coverage --cover-html --cover-html-dir=Coverage_report --verbosity=3 test/testall.py examples/run_examples.py + nosetests --with-xunit --with-coverage --cover-html --cover-html-dir=Coverage_report --verbosity=3 test/ examples/run_examples.py after_success: - codecov diff --git a/test/testall.py b/test/testall.py deleted file mode 100644 index c3cbffad..00000000 --- a/test/testall.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python - -from __future__ import print_function -import sys -import os -import unittest -import struct - -testfolder = os.path.abspath(os.path.dirname(__file__)) -package_root = os.path.abspath(os.path.join(testfolder, "..")) -sys.path.append(package_root) - -from Xlib.protocol import request, rq, event -import Xlib.protocol.event - -def is_big_endian(): - "Check endianess (return True on big-endian system)" - return struct.unpack('BB', struct.pack('H', 0x0100))[0] != 0 - - -def run_tests(): - "Run all suitable tests" - - if is_big_endian(): - excludes = ['test_events_le', 'test_requests_le', ] - else: - excludes = ['test_events_be', 'test_requests_be', ] - - suite = unittest.TestSuite() - - sys.path.append(testfolder) - - for root, dirs, files in os.walk(testfolder): - test_modules = [ - file.replace('.py', '') for file in files if - file.startswith('test_') and - file.endswith('.py')] - - test_modules = [mod for mod in test_modules if mod.lower() not in excludes] - print('test_modules:') - print(test_modules) - for mod in test_modules: - - imported_mod = __import__(mod, globals(), locals()) - - suite.addTests( - unittest.defaultTestLoader.loadTestsFromModule(imported_mod)) - - unittest.TextTestRunner(verbosity=3).run(suite) - - -if __name__ == '__main__': - run_tests() \ No newline at end of file From 9c0d63b09e5d32f9ca95eb66f2205bd616324a24 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 27 Jun 2016 12:36:23 +0200 Subject: [PATCH 047/279] fixup! test: update genprottest.py --- test/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/__init__.py b/test/__init__.py index 0f85c937..d6f7d286 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -45,22 +45,22 @@ def get_resource_class(self, x): class TestCase(unittest.TestCase): def assertBinaryEqual(self, bin1, bin2): - if bin1 == bin2: - return - self.fail('binary contents differ:\n' + bindiff(bin1, bin2)) + if bin1 != bin2: + self.fail('binary contents differ:\n' + bindiff(bin1, bin2)) def assertBinaryEmpty(self, bin): - if 0 == len(bin): - return - self.fail('binary content not empty:\n' + ''.join(tohex(bin))) + if len(bin) != 0: + self.fail('binary content not empty:\n' + ''.join(tohex(bin))) class BigEndianTest(TestCase): + @classmethod def setUpClass(cls): if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 1: raise unittest.SkipTest('big-endian tests, skipping on this system') class LittleEndianTest(TestCase): + @classmethod def setUpClass(cls): if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 0: From 4bd0b6d7df0cd5e6d5abe43ed04a3bc902c8524d Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 26 Jun 2016 22:09:37 +0200 Subject: [PATCH 048/279] test: fix test_xlib_display messing with pointer mapping --- test/test_xlib_display.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/test_xlib_display.py b/test/test_xlib_display.py index 35e4e63c..c79586df 100644 --- a/test/test_xlib_display.py +++ b/test/test_xlib_display.py @@ -40,9 +40,13 @@ def test_pointer_mapping_is_list(self): self.assertTrue(isinstance(self.display.get_pointer_mapping(), list)) def test_set_get_pointer_mapping(self): - length = len(self.display.get_pointer_mapping()) - self.display.set_pointer_mapping([0] * length) - self.assertEqual(self.display.get_pointer_mapping(), [0] * length) + orig_mapping = self.display.get_pointer_mapping() + length = len(orig_mapping) + try: + self.display.set_pointer_mapping([0] * length) + self.assertEqual(self.display.get_pointer_mapping(), [0] * length) + finally: + self.display.set_pointer_mapping(orig_mapping) def test_can_close_display(self): self.display.close() From bba6d2797a0180fd1c475515b7ba991fc3e7ddd5 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 27 Jun 2016 12:40:16 +0200 Subject: [PATCH 049/279] travis: drop Python 2.6 support --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4b618a4d..658931df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: python python: - - "2.6" - "2.7" - "3.3" - "3.4" From 585257e7cac512162c3e8931964ab353084c3d9c Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 2 Dec 2015 11:32:48 +0100 Subject: [PATCH 050/279] fix old-style class definitions --- examples/childwin.py | 2 +- examples/draw-proto.py | 6 +++--- examples/draw.py | 6 +++--- examples/shapewin.py | 2 +- examples/xinerama.py | 2 +- examples/xrandr.py | 2 +- utils/parsexbug.py | 8 ++++---- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/childwin.py b/examples/childwin.py index 1fad1f62..c308a2b6 100755 --- a/examples/childwin.py +++ b/examples/childwin.py @@ -29,7 +29,7 @@ from Xlib import X, display, Xutil # Application window -class Window: +class Window(object): def __init__(self, display): self.d = display diff --git a/examples/draw-proto.py b/examples/draw-proto.py index 21b26070..a4a16807 100755 --- a/examples/draw-proto.py +++ b/examples/draw-proto.py @@ -30,7 +30,7 @@ from Xlib.protocol.request import * # Application window (only one) -class Window: +class Window(object): def __init__(self, display): self.d = display self.objects = [] @@ -106,7 +106,7 @@ def loop(self): # A drawed objects, consisting of either a single # romboid, or two romboids connected by a winding line -class Movement: +class Movement(object): def __init__(self, win, ev): self.win = win @@ -204,7 +204,7 @@ def expose(self, ev): # A romboid, drawed around the Movement endpoints -class Romboid: +class Romboid(object): def __init__(self, win, ev): self.win = win self.x = ev.event_x diff --git a/examples/draw.py b/examples/draw.py index dba1ebf4..d075b1c7 100755 --- a/examples/draw.py +++ b/examples/draw.py @@ -28,7 +28,7 @@ from Xlib import X, display, Xutil # Application window (only one) -class Window: +class Window(object): def __init__(self, display): self.d = display self.objects = [] @@ -117,7 +117,7 @@ def loop(self): # A drawed objects, consisting of either a single # romboid, or two romboids connected by a winding line -class Movement: +class Movement(object): def __init__(self, win, ev): self.win = win @@ -205,7 +205,7 @@ def expose(self, ev): # A romboid, drawed around the Movement endpoints -class Romboid: +class Romboid(object): def __init__(self, win, ev): self.win = win self.x = ev.event_x diff --git a/examples/shapewin.py b/examples/shapewin.py index 5fa5a5c0..a01c5a03 100755 --- a/examples/shapewin.py +++ b/examples/shapewin.py @@ -29,7 +29,7 @@ from Xlib.ext import shape # Application window (only one) -class Window: +class Window(object): def __init__(self, display): self.d = display diff --git a/examples/xinerama.py b/examples/xinerama.py index d2aa8b51..124567ed 100755 --- a/examples/xinerama.py +++ b/examples/xinerama.py @@ -30,7 +30,7 @@ from Xlib.ext import xinerama # Application window (only one) -class Window: +class Window(object): def __init__(self, display): self.d = display diff --git a/examples/xrandr.py b/examples/xrandr.py index 8b83c0ea..6f283f11 100755 --- a/examples/xrandr.py +++ b/examples/xrandr.py @@ -30,7 +30,7 @@ from Xlib.ext import randr # Application window (only one) -class Window: +class Window(object): def __init__(self, display): self.d = display diff --git a/utils/parsexbug.py b/utils/parsexbug.py index 632d6666..92f38361 100644 --- a/utils/parsexbug.py +++ b/utils/parsexbug.py @@ -20,7 +20,7 @@ def dummy_buffer(str, x, y = sys.maxint): # We don't want any fancy dictwrapper, just plain mappings rq.DictWrapper = lambda x: x -class BugFile: +class BugFile(object): def __init__(self, file): self.file = file self.cbuf = self.sbuf = '' @@ -60,7 +60,7 @@ def read_next(self): raise ValueError('Bad control line: %s' % line) -class ParseString: +class ParseString(object): def __init__(self, datafunc): self.get_data = datafunc self.data = '' @@ -102,11 +102,11 @@ def __getitem__(self, key): return self.data[i:j] -class DummyDisplay: +class DummyDisplay(object): def get_resource_class(self, name): return None -class ParseXbug: +class ParseXbug(object): def __init__(self, infile = sys.stdin, outfile = sys.stdout): bf = BugFile(infile) self.cdata = ParseString(bf.read_client) From 437bef946abe3ac04c4983aa1c2758daf068300a Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Thu, 3 Dec 2015 16:57:31 +0100 Subject: [PATCH 051/279] protocol/rq: minor cleanup --- Xlib/protocol/rq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 093d1266..75fed75e 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -443,7 +443,7 @@ def pack_value(self, val): else: pad = b'' - return struct.pack(*('>' + 'H' * slen, ) + tuple(val)) + pad, slen, None + return struct.pack('>' + 'H' * slen, *val) + pad, slen, None def parse_binary_value(self, data, display, length, format): if length == 'odd': From cae10c7c5848ee3315a490b7a99112f0fc054e15 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 11 Dec 2015 12:06:53 +0100 Subject: [PATCH 052/279] remove uses of deprecated 'apply' builtin --- Xlib/ext/record.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/ext/record.py b/Xlib/ext/record.py index 424c672f..6b164537 100644 --- a/Xlib/ext/record.py +++ b/Xlib/ext/record.py @@ -214,7 +214,7 @@ class EnableContext(rq.ReplyRequest): def __init__(self, callback, *args, **keys): self._callback = callback - apply(rq.ReplyRequest.__init__, (self, ) + args, keys) + rq.ReplyRequest.__init__(self, *args, **keys) def _parse_response(self, data): r, d = self._reply.parse_binary(data, self._display) From b2fde4760bdc2d98df0dc386e34356222d9b33f2 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 12 Apr 2016 01:10:10 +0200 Subject: [PATCH 053/279] XK: fix relative import --- Xlib/XK.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/XK.py b/Xlib/XK.py index 56e3a334..bdd6cdef 100644 --- a/Xlib/XK.py +++ b/Xlib/XK.py @@ -20,7 +20,7 @@ # as a modular keysym definition and loading mechanism. See the keysym # definition modules in the Xlib/keysymdef directory. -from X import NoSymbol +from Xlib.X import NoSymbol def string_to_keysym(keysym): '''Return the (16 bit) numeric code of keysym. From 7e2724d381d9bd9855a2d67eb604d1dc9d622c76 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 17 May 2016 23:48:29 +0200 Subject: [PATCH 054/279] protocol/rq: use more pythonic isinstance for type checks --- Xlib/protocol/rq.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 75fed75e..d2445956 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -584,7 +584,7 @@ def pack_value(self, val): return self.type.pack_value(val) def check_value(self, val): - if type(val) is tuple: + if isinstance(val, tuple): vals = [] i = 0 for f in self.type.fields: @@ -600,7 +600,7 @@ def check_value(self, val): i = i + 1 return vals - if type(val) is dict: + if isinstance(val, dict): data = val elif isinstance(val, DictWrapper): data = val._data @@ -666,7 +666,7 @@ def pack_value(self, value): dlen = vlen // size else: - if type(val) is tuple: + if isinstance(val, tuple): val = list(val) size = fmt // 8 @@ -1057,7 +1057,7 @@ def pack_value(self, value): if type(value) is tuple: return self.to_binary(*value) - elif type(value) is dict: + elif isinstance(value, dict): return self.to_binary(**value) elif isinstance(value, DictWrapper): return self.to_binary(**value._data) @@ -1203,10 +1203,9 @@ def pack_value(self, value): # A tuple, it should be (delta, string) # Encode it as one or more textitems - if type(v) in (tuple, dict) or \ - isinstance(v, DictWrapper): + if isinstance(v, (tuple, dict, DictWrapper)): - if type(v) is tuple: + if isinstance(v, tuple): delta, str = v else: delta = v['delta'] From 65eefb599afb7163ff4664dbd6ecfa141501c120 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 18:13:15 +0200 Subject: [PATCH 055/279] xobjects: fix Python 3 support changes Rework so the API is backward compatible. --- Xlib/xobject/cursor.py | 5 +++-- Xlib/xobject/drawable.py | 7 +++---- Xlib/xobject/fontable.py | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Xlib/xobject/cursor.py b/Xlib/xobject/cursor.py index d693e694..6aebb001 100644 --- a/Xlib/xobject/cursor.py +++ b/Xlib/xobject/cursor.py @@ -29,8 +29,9 @@ def free(self, onerror = None): cursor = self.id) self.display.free_resource_id(self.id) - def recolor(self, fore_red, fore_green, fore_blue, - back_red, back_green, back_blue, onerror = None): + def recolor(self, foreground, background, onerror=None): + fore_red, fore_green, fore_blue = foreground + back_red, back_green, back_blue = background request.RecolorCursor(display = self.display, onerror = onerror, diff --git a/Xlib/xobject/drawable.py b/Xlib/xobject/drawable.py index c8117a5f..a1df88e9 100644 --- a/Xlib/xobject/drawable.py +++ b/Xlib/xobject/drawable.py @@ -797,10 +797,9 @@ def free(self, onerror = None): self.display.free_resource_id(self.id) - def create_cursor(self, mask, - fore_red, fore_green, fore_blue, - back_red, back_green, back_blue, - x, y): + def create_cursor(self, mask, foreground, background, x, y): + fore_red, fore_green, fore_blue = foreground + back_red, back_green, back_blue = background cid = self.display.allocate_resource_id() request.CreateCursor(display = self.display, cid = cid, diff --git a/Xlib/xobject/fontable.py b/Xlib/xobject/fontable.py index 8ce22229..3e73e88b 100644 --- a/Xlib/xobject/fontable.py +++ b/Xlib/xobject/fontable.py @@ -85,8 +85,9 @@ def close(self, onerror = None): self.display.free_resource_id(self.id) def create_glyph_cursor(self, mask, source_char, mask_char, - fore_red, fore_green, fore_blue, - back_red, back_green, back_blue): + foreground, background): + fore_red, fore_green, fore_blue = foreground + back_red, back_green, back_blue = background cid = self.display.allocate_resource_id() request.CreateGlyphCursor(display = self.display, From d6b7a078bc756c3c64f18b0c19eebb240389912c Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 18:32:00 +0200 Subject: [PATCH 056/279] test: fix binary data in generated tests --- test/gen/genprottest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/gen/genprottest.py b/test/gen/genprottest.py index b6993c08..7de43fea 100755 --- a/test/gen/genprottest.py +++ b/test/gen/genprottest.py @@ -898,9 +898,9 @@ def build_bin(bin): bins2 = [] for i in range(0, len(bins), 2): try: - bins2.append("'%s' '%s'" % (bins[i], bins[i + 1])) + bins2.append("b'%s' b'%s'" % (bins[i], bins[i + 1])) except IndexError: - bins2.append("'%s'" % bins[i]) + bins2.append("b'%s'" % bins[i]) return ' \\\n '.join(bins2) From 92bc7028c9f927354bfa730bd68889f7084b94f6 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 18:47:29 +0200 Subject: [PATCH 057/279] test: update little-endian tests --- test/test_events_le.py | 192 +++--- test/test_requests_le.py | 1374 +++++++++++++++++++------------------- 2 files changed, 783 insertions(+), 783 deletions(-) diff --git a/test/test_events_le.py b/test/test_events_le.py index b8ff9c07..0a624498 100755 --- a/test/test_events_le.py +++ b/test/test_events_le.py @@ -17,10 +17,10 @@ def setUp(self): 'data': [236, 252, 232, 206, 210, 131, 246, 234, 162, 151, 217, 167, 171, 128, 239, 200, 179, 146, 209, 131, 223, 155, 181, 171, 175, 220, 227, 200, 138, 134, 148], 'type': 207, } - self.evt_bin_0 = '\xcf\xec\xfc\xe8' '\xce\xd2\x83\xf6' \ - '\xea\xa2\x97\xd9' '\xa7\xab\x80\xef' \ - '\xc8\xb3\x92\xd1' '\x83\xdf\x9b\xb5' \ - '\xab\xaf\xdc\xe3' '\xc8\x8a\x86\x94' + self.evt_bin_0 = b'\xcf\xec\xfc\xe8' b'\xce\xd2\x83\xf6' \ + b'\xea\xa2\x97\xd9' b'\xa7\xab\x80\xef' \ + b'\xc8\xb3\x92\xd1' b'\x83\xdf\x9b\xb5' \ + b'\xab\xaf\xdc\xe3' b'\xc8\x8a\x86\x94' def testPack0(self): @@ -45,10 +45,10 @@ def setUp(self): 'x': 31959, 'y': 29112, } - self.evt_bin_0 = '\xd6\x00\x62\x46' '\xc1\xbe\xba\x54' \ - '\xd7\x7c\xb8\x71' '\xa8\x46\x82\xc1' \ - '\x06\x1e\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xd6\x00\x62\x46' b'\xc1\xbe\xba\x54' \ + b'\xd7\x7c\xb8\x71' b'\xa8\x46\x82\xc1' \ + b'\x06\x1e\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -75,10 +75,10 @@ def setUp(self): 'x': 32023, 'y': 43806, } - self.evt_bin_0 = '\xb7\x00\x3a\x49' '\x87\xf5\xd8\x56' \ - '\x17\x7d\x1e\xab' '\x94\x0c\xca\x65' \ - '\xd3\x99\xf5\x02' '\xa6\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xb7\x00\x3a\x49' b'\x87\xf5\xd8\x56' \ + b'\x17\x7d\x1e\xab' b'\x94\x0c\xca\x65' \ + b'\xd3\x99\xf5\x02' b'\xa6\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -100,10 +100,10 @@ def setUp(self): 'type': 155, 'window': 548772746, } - self.evt_bin_0 = '\x9b\x00\xfe\x23' '\x8a\x9b\xb5\x20' \ - '\xab\x54\x80\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\x9b\x00\xfe\x23' b'\x8a\x9b\xb5\x20' \ + b'\xab\x54\x80\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -124,10 +124,10 @@ def setUp(self): 'type': 223, 'window': 816529890, } - self.evt_bin_0 = '\xdf\x00\xcd\x2d' '\xe2\x41\xab\x30' \ - '\xda\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xdf\x00\xcd\x2d' b'\xe2\x41\xab\x30' \ + b'\xda\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -154,10 +154,10 @@ def setUp(self): 'x': -4750, 'y': -31393, } - self.evt_bin_0 = '\xc0\x00\x81\xd5' '\xf1\xc2\x31\x67' \ - '\xa2\xb2\x3a\x09' '\x72\xed\x5f\x85' \ - '\xc7\x05\xe5\xeb' '\xd6\xdc\x01\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xc0\x00\x81\xd5' b'\xf1\xc2\x31\x67' \ + b'\xa2\xb2\x3a\x09' b'\x72\xed\x5f\x85' \ + b'\xc7\x05\xe5\xeb' b'\xd6\xdc\x01\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -178,10 +178,10 @@ def setUp(self): 'type': 201, 'window': 247390922, } - self.evt_bin_0 = '\xc9\x00\xec\xb5' '\xf6\x93\x77\x35' \ - '\xca\xe2\xbe\x0e' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xc9\x00\xec\xb5' b'\xf6\x93\x77\x35' \ + b'\xca\xe2\xbe\x0e' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -203,10 +203,10 @@ def setUp(self): 'type': 130, 'window': 1327438921, } - self.evt_bin_0 = '\x82\x00\xd0\x53' '\x4a\xec\x91\x66' \ - '\x49\x1c\x1f\x4f' '\x01\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\x82\x00\xd0\x53' b'\x4a\xec\x91\x66' \ + b'\x49\x1c\x1f\x4f' b'\x01\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -228,10 +228,10 @@ def setUp(self): 'type': 245, 'window': 522567740, } - self.evt_bin_0 = '\xf5\x00\x79\x17' '\x10\x38\x18\x6c' \ - '\x3c\xc0\x25\x1f' '\x01\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xf5\x00\x79\x17' b'\x10\x38\x18\x6c' \ + b'\x3c\xc0\x25\x1f' b'\x01\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -252,10 +252,10 @@ def setUp(self): 'type': 195, 'window': 729142504, } - self.evt_bin_0 = '\xc3\x00\xeb\x65' '\x3d\xc4\xb7\x27' \ - '\xe8\xd4\x75\x2b' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xc3\x00\xeb\x65' b'\x3d\xc4\xb7\x27' \ + b'\xe8\xd4\x75\x2b' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -280,10 +280,10 @@ def setUp(self): 'x': -3314, 'y': -21409, } - self.evt_bin_0 = '\xaa\x00\xdf\x2b' '\x7a\x01\x58\x41' \ - '\x97\x4f\x99\x0e' '\x66\x99\x46\x41' \ - '\x0e\xf3\x5f\xac' '\x01\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xaa\x00\xdf\x2b' b'\x7a\x01\x58\x41' \ + b'\x97\x4f\x99\x0e' b'\x66\x99\x46\x41' \ + b'\x0e\xf3\x5f\xac' b'\x01\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -311,10 +311,10 @@ def setUp(self): 'x': -13183, 'y': -8052, } - self.evt_bin_0 = '\xe8\x00\xd5\xd0' '\x45\xd2\x3e\x1e' \ - '\xa6\x89\xbf\x12' '\x52\x01\x41\x19' \ - '\x81\xcc\x8c\xe0' '\x27\xa8\x2c\x2e' \ - '\x13\xc6\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xe8\x00\xd5\xd0' b'\x45\xd2\x3e\x1e' \ + b'\xa6\x89\xbf\x12' b'\x52\x01\x41\x19' \ + b'\x81\xcc\x8c\xe0' b'\x27\xa8\x2c\x2e' \ + b'\x13\xc6\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -343,10 +343,10 @@ def setUp(self): 'x': -12463, 'y': -4669, } - self.evt_bin_0 = '\xe0\xe1\x78\x73' '\x37\xc3\x4a\x76' \ - '\xc7\xb3\x41\x48' '\xec\xd1\x51\x51' \ - '\x51\xcf\xc3\xed' '\xf0\xa0\x7e\x27' \ - '\x69\x12\xc3\x71' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xe0\xe1\x78\x73' b'\x37\xc3\x4a\x76' \ + b'\xc7\xb3\x41\x48' b'\xec\xd1\x51\x51' \ + b'\x51\xcf\xc3\xed' b'\xf0\xa0\x7e\x27' \ + b'\x69\x12\xc3\x71' b'\x00\x00\x00\x00' def testPack0(self): @@ -369,10 +369,10 @@ def setUp(self): 'x': -22676, 'y': -18075, } - self.evt_bin_0 = '\xa6\x00\x0a\x47' '\x84\x97\x31\x07' \ - '\x5f\xe8\xf0\x40' '\x6c\xa7\x65\xb9' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xa6\x00\x0a\x47' b'\x84\x97\x31\x07' \ + b'\x5f\xe8\xf0\x40' b'\x6c\xa7\x65\xb9' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -394,10 +394,10 @@ def setUp(self): 'width': 56674, 'window': 164839077, } - self.evt_bin_0 = '\x87\x00\x15\xd5' '\xa5\x3e\xd3\x09' \ - '\x62\xdd\x19\xdb' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\x87\x00\x15\xd5' b'\xa5\x3e\xd3\x09' \ + b'\x62\xdd\x19\xdb' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -420,10 +420,10 @@ def setUp(self): 'type': 206, 'window': 993700932, } - self.evt_bin_0 = '\xce\x00\x4d\x82' '\x44\xac\x3a\x3b' \ - '\xd7\x48\xf4\x46' '\x66\x7e\x5a\x65' \ - '\xf2\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xce\x00\x4d\x82' b'\x44\xac\x3a\x3b' \ + b'\xd7\x48\xf4\x46' b'\x66\x7e\x5a\x65' \ + b'\xf2\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -445,10 +445,10 @@ def setUp(self): 'type': 185, 'window': 690517929, } - self.evt_bin_0 = '\xb9\x00\x80\xcf' '\x03\xc2\x6f\x53' \ - '\xa9\x77\x28\x29' '\xb4\xef\xe1\x3c' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xb9\x00\x80\xcf' b'\x03\xc2\x6f\x53' \ + b'\xa9\x77\x28\x29' b'\xb4\xef\xe1\x3c' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -473,10 +473,10 @@ def setUp(self): 'time': 222327341, 'type': 147, } - self.evt_bin_0 = '\x93\x00\xc7\x10' '\x2d\x72\x40\x0d' \ - '\x5f\xb0\x16\x73' '\xf3\x6c\xf6\x2b' \ - '\x43\xfa\x6e\x5b' '\x9f\x8e\x95\x40' \ - '\xe3\x3c\x17\x16' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\x93\x00\xc7\x10' b'\x2d\x72\x40\x0d' \ + b'\x5f\xb0\x16\x73' b'\xf3\x6c\xf6\x2b' \ + b'\x43\xfa\x6e\x5b' b'\x9f\x8e\x95\x40' \ + b'\xe3\x3c\x17\x16' b'\x00\x00\x00\x00' def testPack0(self): @@ -500,10 +500,10 @@ def setUp(self): 'time': 943687849, 'type': 159, } - self.evt_bin_0 = '\x9f\x00\xa0\x70' '\xa9\x88\x3f\x38' \ - '\x86\xe2\xe9\x42' '\x12\xa3\x52\x14' \ - '\xab\x3d\xba\x2f' '\xea\x92\x36\x24' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\x9f\x00\xa0\x70' b'\xa9\x88\x3f\x38' \ + b'\x86\xe2\xe9\x42' b'\x12\xa3\x52\x14' \ + b'\xab\x3d\xba\x2f' b'\xea\x92\x36\x24' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -526,10 +526,10 @@ def setUp(self): 'type': 180, 'window': 1283976465, } - self.evt_bin_0 = '\xb4\x00\x48\x57' '\x11\xed\x87\x4c' \ - '\x4e\x99\x05\x65' '\x01\x88\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xb4\x00\x48\x57' b'\x11\xed\x87\x4c' \ + b'\x4e\x99\x05\x65' b'\x01\x88\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -551,10 +551,10 @@ def setUp(self): 'type': 140, 'window': 610247893, } - self.evt_bin_0 = '\x8c\x08\xfc\xad' '\xd5\xa4\x5f\x24' \ - '\xa6\x94\xa3\x5c' '\x30\x31\x32\x33' \ - '\x34\x35\x36\x37' '\x38\x39\x30\x31' \ - '\x32\x33\x34\x35' '\x36\x37\x38\x39' + self.evt_bin_0 = b'\x8c\x08\xfc\xad' b'\xd5\xa4\x5f\x24' \ + b'\xa6\x94\xa3\x5c' b'\x30\x31\x32\x33' \ + b'\x34\x35\x36\x37' b'\x38\x39\x30\x31' \ + b'\x32\x33\x34\x35' b'\x36\x37\x38\x39' self.evt_args_1 = { 'client_type': 715933209, @@ -563,10 +563,10 @@ def setUp(self): 'type': 212, 'window': 1875362098, } - self.evt_bin_1 = '\xd4\x10\x1e\xe8' '\x32\xc1\xc7\x6f' \ - '\x19\x46\xac\x2a' '\x01\x00\x02\x00' \ - '\x03\x00\x04\x00' '\x05\x00\x06\x00' \ - '\x07\x00\x08\x00' '\x09\x00\x0a\x00' + self.evt_bin_1 = b'\xd4\x10\x1e\xe8' b'\x32\xc1\xc7\x6f' \ + b'\x19\x46\xac\x2a' b'\x01\x00\x02\x00' \ + b'\x03\x00\x04\x00' b'\x05\x00\x06\x00' \ + b'\x07\x00\x08\x00' b'\x09\x00\x0a\x00' self.evt_args_2 = { 'client_type': 2078114542, @@ -575,10 +575,10 @@ def setUp(self): 'type': 202, 'window': 751277030, } - self.evt_bin_2 = '\xca\x20\x10\x25' '\xe6\x93\xc7\x2c' \ - '\xee\x82\xdd\x7b' '\x01\x00\x00\x00' \ - '\x02\x00\x00\x00' '\x03\x00\x00\x00' \ - '\x04\x00\x00\x00' '\x05\x00\x00\x00' + self.evt_bin_2 = b'\xca\x20\x10\x25' b'\xe6\x93\xc7\x2c' \ + b'\xee\x82\xdd\x7b' b'\x01\x00\x00\x00' \ + b'\x02\x00\x00\x00' b'\x03\x00\x00\x00' \ + b'\x04\x00\x00\x00' b'\x05\x00\x00\x00' def testPack0(self): @@ -618,10 +618,10 @@ def setUp(self): 'sequence_number': 25843, 'type': 217, } - self.evt_bin_0 = '\xd9\x00\xf3\x64' '\xcc\xf8\xa7\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xd9\x00\xf3\x64' b'\xcc\xf8\xa7\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): diff --git a/test/test_requests_le.py b/test/test_requests_le.py index e79db09d..87baa47c 100755 --- a/test/test_requests_le.py +++ b/test/test_requests_le.py @@ -26,18 +26,18 @@ def setUp(self): 'x': -6451, 'y': -32557, } - self.req_bin_0 = '\x01\xc5\x17\x00' '\x88\x2d\x38\x1c' \ - '\xf9\x77\x6d\x4b' '\xcd\xe6\xd3\x80' \ - '\x7b\xce\x06\xb3' '\xc3\x57\x00\x00' \ - '\x2f\x00\x86\x7a' '\xff\x7f\x00\x00' \ - '\x0f\x19\xd9\x51' '\x04\x87\x34\x03' \ - '\xbb\xe2\x34\x23' '\x3d\xf2\x92\x1c' \ - '\x07\x00\x00\x00' '\x06\x00\x00\x00' \ - '\x02\x00\x00\x00' '\x87\xb9\x21\x0b' \ - '\xbd\x1c\x02\x36' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x0a\xfa\xaf\x40' \ - '\x0d\x81\x66\x03' '\x34\x50\x74\x19' \ - '\x6b\xc3\x2f\x53' + self.req_bin_0 = b'\x01\xc5\x17\x00' b'\x88\x2d\x38\x1c' \ + b'\xf9\x77\x6d\x4b' b'\xcd\xe6\xd3\x80' \ + b'\x7b\xce\x06\xb3' b'\xc3\x57\x00\x00' \ + b'\x2f\x00\x86\x7a' b'\xff\x7f\x00\x00' \ + b'\x0f\x19\xd9\x51' b'\x04\x87\x34\x03' \ + b'\xbb\xe2\x34\x23' b'\x3d\xf2\x92\x1c' \ + b'\x07\x00\x00\x00' b'\x06\x00\x00\x00' \ + b'\x02\x00\x00\x00' b'\x87\xb9\x21\x0b' \ + b'\xbd\x1c\x02\x36' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x0a\xfa\xaf\x40' \ + b'\x0d\x81\x66\x03' b'\x34\x50\x74\x19' \ + b'\x6b\xc3\x2f\x53' def testPackRequest0(self): @@ -56,15 +56,15 @@ def setUp(self): 'attrs': {'cursor': 1239881989, 'override_redirect': 0, 'bit_gravity': 5, 'event_mask': 1781144133, 'border_pixel': 1819990287, 'background_pixel': 199229639, 'save_under': 1, 'colormap': 1850510540, 'do_not_propagate_mask': 1328286054, 'backing_store': 2, 'win_gravity': 7, 'backing_planes': 1151571451, 'border_pixmap': 207756035, 'backing_pixel': 2089751951, 'background_pixmap': 722874758}, 'window': 1513075857, } - self.req_bin_0 = '\x02\x00\x12\x00' '\x91\xb4\x2f\x5a' \ - '\xff\x7f\x00\x00' '\x86\x31\x16\x2b' \ - '\xc7\x00\xe0\x0b' '\x03\x1b\x62\x0c' \ - '\x0f\xd9\x7a\x6c' '\x05\x00\x00\x00' \ - '\x07\x00\x00\x00' '\x02\x00\x00\x00' \ - '\xfb\x95\xa3\x44' '\x8f\x15\x8f\x7c' \ - '\x00\x00\x00\x00' '\x01\x00\x00\x00' \ - '\x45\x1a\x2a\x6a' '\x66\x09\x2c\x4f' \ - '\xcc\x8c\x4c\x6e' '\x05\x19\xe7\x49' + self.req_bin_0 = b'\x02\x00\x12\x00' b'\x91\xb4\x2f\x5a' \ + b'\xff\x7f\x00\x00' b'\x86\x31\x16\x2b' \ + b'\xc7\x00\xe0\x0b' b'\x03\x1b\x62\x0c' \ + b'\x0f\xd9\x7a\x6c' b'\x05\x00\x00\x00' \ + b'\x07\x00\x00\x00' b'\x02\x00\x00\x00' \ + b'\xfb\x95\xa3\x44' b'\x8f\x15\x8f\x7c' \ + b'\x00\x00\x00\x00' b'\x01\x00\x00\x00' \ + b'\x45\x1a\x2a\x6a' b'\x66\x09\x2c\x4f' \ + b'\xcc\x8c\x4c\x6e' b'\x05\x19\xe7\x49' def testPackRequest0(self): @@ -82,7 +82,7 @@ def setUp(self): self.req_args_0 = { 'window': 98469647, } - self.req_bin_0 = '\x03\x00\x02\x00' '\x0f\x87\xde\x05' + self.req_bin_0 = b'\x03\x00\x02\x00' b'\x0f\x87\xde\x05' self.reply_args_0 = { 'all_event_masks': 1308124489, @@ -102,12 +102,12 @@ def setUp(self): 'win_gravity': 163, 'your_event_mask': 367571768, } - self.reply_bin_0 = '\x01\x9d\xcb\x4a' '\x03\x00\x00\x00' \ - '\x30\x8b\x37\x0a' '\x5c\x3c\x8c\xa3' \ - '\xe0\x78\x5e\x51' '\xbc\x74\xb3\x2e' \ - '\x00\x00\xa2\x01' '\xea\x2c\xf3\x52' \ - '\x49\x65\xf8\x4d' '\x38\xb3\xe8\x15' \ - '\xed\xba\x00\x00' + self.reply_bin_0 = b'\x01\x9d\xcb\x4a' b'\x03\x00\x00\x00' \ + b'\x30\x8b\x37\x0a' b'\x5c\x3c\x8c\xa3' \ + b'\xe0\x78\x5e\x51' b'\xbc\x74\xb3\x2e' \ + b'\x00\x00\xa2\x01' b'\xea\x2c\xf3\x52' \ + b'\x49\x65\xf8\x4d' b'\x38\xb3\xe8\x15' \ + b'\xed\xba\x00\x00' def testPackRequest0(self): @@ -134,7 +134,7 @@ def setUp(self): self.req_args_0 = { 'window': 350959010, } - self.req_bin_0 = '\x04\x00\x02\x00' '\xa2\x35\xeb\x14' + self.req_bin_0 = b'\x04\x00\x02\x00' b'\xa2\x35\xeb\x14' def testPackRequest0(self): @@ -152,7 +152,7 @@ def setUp(self): self.req_args_0 = { 'window': 814915023, } - self.req_bin_0 = '\x05\x00\x02\x00' '\xcf\x9d\x92\x30' + self.req_bin_0 = b'\x05\x00\x02\x00' b'\xcf\x9d\x92\x30' def testPackRequest0(self): @@ -171,7 +171,7 @@ def setUp(self): 'mode': 1, 'window': 1374412611, } - self.req_bin_0 = '\x06\x01\x02\x00' '\x43\xdf\xeb\x51' + self.req_bin_0 = b'\x06\x01\x02\x00' b'\x43\xdf\xeb\x51' def testPackRequest0(self): @@ -192,8 +192,8 @@ def setUp(self): 'x': -5365, 'y': -7538, } - self.req_bin_0 = '\x07\x00\x04\x00' '\x7e\x92\x4a\x47' \ - '\x51\xc1\xa1\x57' '\x0b\xeb\x8e\xe2' + self.req_bin_0 = b'\x07\x00\x04\x00' b'\x7e\x92\x4a\x47' \ + b'\x51\xc1\xa1\x57' b'\x0b\xeb\x8e\xe2' def testPackRequest0(self): @@ -211,7 +211,7 @@ def setUp(self): self.req_args_0 = { 'window': 491927514, } - self.req_bin_0 = '\x08\x00\x02\x00' '\xda\x37\x52\x1d' + self.req_bin_0 = b'\x08\x00\x02\x00' b'\xda\x37\x52\x1d' def testPackRequest0(self): @@ -229,7 +229,7 @@ def setUp(self): self.req_args_0 = { 'window': 68998181, } - self.req_bin_0 = '\x09\x00\x02\x00' '\x25\xd4\x1c\x04' + self.req_bin_0 = b'\x09\x00\x02\x00' b'\x25\xd4\x1c\x04' def testPackRequest0(self): @@ -247,7 +247,7 @@ def setUp(self): self.req_args_0 = { 'window': 677475124, } - self.req_bin_0 = '\x0a\x00\x02\x00' '\x34\x73\x61\x28' + self.req_bin_0 = b'\x0a\x00\x02\x00' b'\x34\x73\x61\x28' def testPackRequest0(self): @@ -265,7 +265,7 @@ def setUp(self): self.req_args_0 = { 'window': 575017142, } - self.req_bin_0 = '\x0b\x00\x02\x00' '\xb6\x10\x46\x22' + self.req_bin_0 = b'\x0b\x00\x02\x00' b'\xb6\x10\x46\x22' def testPackRequest0(self): @@ -284,11 +284,11 @@ def setUp(self): 'attrs': {'width': 61485, 'stack_mode': 4, 'height': 43079, 'sibling': 849652645, 'y': -1871, 'x': -25855, 'border_width': -11291}, 'window': 985412314, } - self.req_bin_0 = '\x0c\x00\x0a\x00' '\xda\x32\xbc\x3a' \ - '\x7f\x00\x00\x00' '\x01\x9b\x00\x00' \ - '\xb1\xf8\x00\x00' '\x2d\xf0\x00\x00' \ - '\x47\xa8\x00\x00' '\xe5\xd3\x00\x00' \ - '\xa5\xab\xa4\x32' '\x04\x00\x00\x00' + self.req_bin_0 = b'\x0c\x00\x0a\x00' b'\xda\x32\xbc\x3a' \ + b'\x7f\x00\x00\x00' b'\x01\x9b\x00\x00' \ + b'\xb1\xf8\x00\x00' b'\x2d\xf0\x00\x00' \ + b'\x47\xa8\x00\x00' b'\xe5\xd3\x00\x00' \ + b'\xa5\xab\xa4\x32' b'\x04\x00\x00\x00' def testPackRequest0(self): @@ -307,7 +307,7 @@ def setUp(self): 'direction': 0, 'window': 529677912, } - self.req_bin_0 = '\x0d\x00\x02\x00' '\x58\x3e\x92\x1f' + self.req_bin_0 = b'\x0d\x00\x02\x00' b'\x58\x3e\x92\x1f' def testPackRequest0(self): @@ -325,7 +325,7 @@ def setUp(self): self.req_args_0 = { 'drawable': 1205557634, } - self.req_bin_0 = '\x0e\x00\x02\x00' '\x82\x59\xdb\x47' + self.req_bin_0 = b'\x0e\x00\x02\x00' b'\x82\x59\xdb\x47' self.reply_args_0 = { 'border_width': 6190, @@ -337,10 +337,10 @@ def setUp(self): 'x': -19783, 'y': -25638, } - self.reply_bin_0 = '\x01\xa1\x11\x96' '\x00\x00\x00\x00' \ - '\x60\xf6\xeb\x72' '\xb9\xb2\xda\x9b' \ - '\x5f\xff\xed\x82' '\x2e\x18\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\xa1\x11\x96' b'\x00\x00\x00\x00' \ + b'\x60\xf6\xeb\x72' b'\xb9\xb2\xda\x9b' \ + b'\x5f\xff\xed\x82' b'\x2e\x18\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -367,7 +367,7 @@ def setUp(self): self.req_args_0 = { 'window': 101244093, } - self.req_bin_0 = '\x0f\x00\x02\x00' '\xbd\xdc\x08\x06' + self.req_bin_0 = b'\x0f\x00\x02\x00' b'\xbd\xdc\x08\x06' self.reply_args_0 = { 'children': [235528064, 1347454529, 1700991108, 906619494, 136486082, 819561703, 2139154628], @@ -375,14 +375,14 @@ def setUp(self): 'root': 2085376831, 'sequence_number': 34796, } - self.reply_bin_0 = '\x01\x00\xec\x87' '\x07\x00\x00\x00' \ - '\x3f\x53\x4c\x7c' '\x22\x2b\x2e\x6e' \ - '\x07\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x80\xdf\x09\x0e' '\x41\x86\x50\x50' \ - '\x84\x10\x63\x65' '\x66\xea\x09\x36' \ - '\xc2\x9c\x22\x08' '\xe7\x84\xd9\x30' \ - '\xc4\xe8\x80\x7f' + self.reply_bin_0 = b'\x01\x00\xec\x87' b'\x07\x00\x00\x00' \ + b'\x3f\x53\x4c\x7c' b'\x22\x2b\x2e\x6e' \ + b'\x07\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x80\xdf\x09\x0e' b'\x41\x86\x50\x50' \ + b'\x84\x10\x63\x65' b'\x66\xea\x09\x36' \ + b'\xc2\x9c\x22\x08' b'\xe7\x84\xd9\x30' \ + b'\xc4\xe8\x80\x7f' def testPackRequest0(self): @@ -410,18 +410,18 @@ def setUp(self): 'name': 'fuzzy_prop', 'only_if_exists': 0, } - self.req_bin_0 = '\x10\x00\x05\x00' '\x0a\x00\x00\x00' \ - '\x66\x75\x7a\x7a' '\x79\x5f\x70\x72' \ - '\x6f\x70\x00\x00' + self.req_bin_0 = b'\x10\x00\x05\x00' b'\x0a\x00\x00\x00' \ + b'\x66\x75\x7a\x7a' b'\x79\x5f\x70\x72' \ + b'\x6f\x70\x00\x00' self.reply_args_0 = { 'atom': 1463982728, 'sequence_number': 47304, } - self.reply_bin_0 = '\x01\x00\xc8\xb8' '\x00\x00\x00\x00' \ - '\x88\x9a\x42\x57' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\xc8\xb8' b'\x00\x00\x00\x00' \ + b'\x88\x9a\x42\x57' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -448,17 +448,17 @@ def setUp(self): self.req_args_0 = { 'atom': 1153165348, } - self.req_bin_0 = '\x11\x00\x02\x00' '\x24\xe8\xbb\x44' + self.req_bin_0 = b'\x11\x00\x02\x00' b'\x24\xe8\xbb\x44' self.reply_args_0 = { 'name': 'WM_CLASS', 'sequence_number': 17674, } - self.reply_bin_0 = '\x01\x00\x0a\x45' '\x02\x00\x00\x00' \ - '\x08\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x57\x4d\x5f\x43' '\x4c\x41\x53\x53' + self.reply_bin_0 = b'\x01\x00\x0a\x45' b'\x02\x00\x00\x00' \ + b'\x08\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x57\x4d\x5f\x43' b'\x4c\x41\x53\x53' def testPackRequest0(self): @@ -489,9 +489,9 @@ def setUp(self): 'type': 974400040, 'window': 239614693, } - self.req_bin_0 = '\x12\x01\x06\x00' '\xe5\x3a\x48\x0e' \ - '\xf5\xf3\xa6\x37' '\x28\x2a\x14\x3a' \ - '\x08\x00\x00\x00' '\x00\x00\x00\x00' + self.req_bin_0 = b'\x12\x01\x06\x00' b'\xe5\x3a\x48\x0e' \ + b'\xf5\xf3\xa6\x37' b'\x28\x2a\x14\x3a' \ + b'\x08\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_1 = { 'data': (8, 'foo'), @@ -500,10 +500,10 @@ def setUp(self): 'type': 1075033221, 'window': 1880888002, } - self.req_bin_1 = '\x12\x02\x07\x00' '\xc2\x12\x1c\x70' \ - '\x11\x78\xb7\x21' '\x85\xb4\x13\x40' \ - '\x08\x00\x00\x00' '\x03\x00\x00\x00' \ - '\x66\x6f\x6f\x00' + self.req_bin_1 = b'\x12\x02\x07\x00' b'\xc2\x12\x1c\x70' \ + b'\x11\x78\xb7\x21' b'\x85\xb4\x13\x40' \ + b'\x08\x00\x00\x00' b'\x03\x00\x00\x00' \ + b'\x66\x6f\x6f\x00' self.req_args_2 = { 'data': (8, 'zoom'), @@ -512,10 +512,10 @@ def setUp(self): 'type': 640951286, 'window': 1959859086, } - self.req_bin_2 = '\x12\x00\x07\x00' '\x8e\x13\xd1\x74' \ - '\x2e\x48\x6d\x6f' '\xf6\x23\x34\x26' \ - '\x08\x00\x00\x00' '\x04\x00\x00\x00' \ - '\x7a\x6f\x6f\x6d' + self.req_bin_2 = b'\x12\x00\x07\x00' b'\x8e\x13\xd1\x74' \ + b'\x2e\x48\x6d\x6f' b'\xf6\x23\x34\x26' \ + b'\x08\x00\x00\x00' b'\x04\x00\x00\x00' \ + b'\x7a\x6f\x6f\x6d' self.req_args_3 = { 'data': (16, []), @@ -524,9 +524,9 @@ def setUp(self): 'type': 1637495037, 'window': 1307779197, } - self.req_bin_3 = '\x12\x01\x06\x00' '\x7d\x20\xf3\x4d' \ - '\x95\x15\x91\x13' '\xfd\x30\x9a\x61' \ - '\x10\x00\x00\x00' '\x00\x00\x00\x00' + self.req_bin_3 = b'\x12\x01\x06\x00' b'\x7d\x20\xf3\x4d' \ + b'\x95\x15\x91\x13' b'\xfd\x30\x9a\x61' \ + b'\x10\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_4 = { 'data': (16, [1, 2, 3]), @@ -535,10 +535,10 @@ def setUp(self): 'type': 1293636, 'window': 1672102137, } - self.req_bin_4 = '\x12\x01\x08\x00' '\xf9\x40\xaa\x63' \ - '\x48\x19\xe3\x43' '\x44\xbd\x13\x00' \ - '\x10\x00\x00\x00' '\x03\x00\x00\x00' \ - '\x01\x00\x02\x00' '\x03\x00\x00\x00' + self.req_bin_4 = b'\x12\x01\x08\x00' b'\xf9\x40\xaa\x63' \ + b'\x48\x19\xe3\x43' b'\x44\xbd\x13\x00' \ + b'\x10\x00\x00\x00' b'\x03\x00\x00\x00' \ + b'\x01\x00\x02\x00' b'\x03\x00\x00\x00' self.req_args_5 = { 'data': (16, [1, 2, 3, 4]), @@ -547,10 +547,10 @@ def setUp(self): 'type': 1887048810, 'window': 41890245, } - self.req_bin_5 = '\x12\x00\x08\x00' '\xc5\x31\x7f\x02' \ - '\x3b\xc6\xec\x76' '\x6a\x14\x7a\x70' \ - '\x10\x00\x00\x00' '\x04\x00\x00\x00' \ - '\x01\x00\x02\x00' '\x03\x00\x04\x00' + self.req_bin_5 = b'\x12\x00\x08\x00' b'\xc5\x31\x7f\x02' \ + b'\x3b\xc6\xec\x76' b'\x6a\x14\x7a\x70' \ + b'\x10\x00\x00\x00' b'\x04\x00\x00\x00' \ + b'\x01\x00\x02\x00' b'\x03\x00\x04\x00' self.req_args_6 = { 'data': (32, []), @@ -559,9 +559,9 @@ def setUp(self): 'type': 1885519250, 'window': 660426938, } - self.req_bin_6 = '\x12\x02\x06\x00' '\xba\x50\x5d\x27' \ - '\xaf\x08\x6b\x07' '\x92\xbd\x62\x70' \ - '\x20\x00\x00\x00' '\x00\x00\x00\x00' + self.req_bin_6 = b'\x12\x02\x06\x00' b'\xba\x50\x5d\x27' \ + b'\xaf\x08\x6b\x07' b'\x92\xbd\x62\x70' \ + b'\x20\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_7 = { 'data': (32, [1, 2, 3]), @@ -570,11 +570,11 @@ def setUp(self): 'type': 148693751, 'window': 183999310, } - self.req_bin_7 = '\x12\x02\x09\x00' '\x4e\x9b\xf7\x0a' \ - '\x12\x73\x35\x3e' '\xf7\xe2\xdc\x08' \ - '\x20\x00\x00\x00' '\x03\x00\x00\x00' \ - '\x01\x00\x00\x00' '\x02\x00\x00\x00' \ - '\x03\x00\x00\x00' + self.req_bin_7 = b'\x12\x02\x09\x00' b'\x4e\x9b\xf7\x0a' \ + b'\x12\x73\x35\x3e' b'\xf7\xe2\xdc\x08' \ + b'\x20\x00\x00\x00' b'\x03\x00\x00\x00' \ + b'\x01\x00\x00\x00' b'\x02\x00\x00\x00' \ + b'\x03\x00\x00\x00' def testPackRequest0(self): @@ -656,8 +656,8 @@ def setUp(self): 'property': 1644632259, 'window': 1633396400, } - self.req_bin_0 = '\x13\x00\x03\x00' '\xb0\xa6\x5b\x61' \ - '\xc3\x18\x07\x62' + self.req_bin_0 = b'\x13\x00\x03\x00' b'\xb0\xa6\x5b\x61' \ + b'\xc3\x18\x07\x62' def testPackRequest0(self): @@ -680,9 +680,9 @@ def setUp(self): 'type': 569252941, 'window': 1020695522, } - self.req_bin_0 = '\x14\x00\x06\x00' '\xe2\x93\xd6\x3c' \ - '\x12\x6a\x60\x46' '\x4d\x1c\xee\x21' \ - '\x71\x03\xac\x6f' '\xfc\xf5\x29\x36' + self.req_bin_0 = b'\x14\x00\x06\x00' b'\xe2\x93\xd6\x3c' \ + b'\x12\x6a\x60\x46' b'\x4d\x1c\xee\x21' \ + b'\x71\x03\xac\x6f' b'\xfc\xf5\x29\x36' self.reply_args_0 = { 'bytes_after': 1567532733, @@ -690,10 +690,10 @@ def setUp(self): 'sequence_number': 14082, 'value': (8, ''), } - self.reply_bin_0 = '\x01\x08\x02\x37' '\x00\x00\x00\x00' \ - '\x6c\x1d\x08\x45' '\xbd\xa6\x6e\x5d' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x08\x02\x37' b'\x00\x00\x00\x00' \ + b'\x6c\x1d\x08\x45' b'\xbd\xa6\x6e\x5d' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_1 = { 'bytes_after': 2137067287, @@ -701,11 +701,11 @@ def setUp(self): 'sequence_number': 13387, 'value': (8, 'foo'), } - self.reply_bin_1 = '\x01\x08\x4b\x34' '\x01\x00\x00\x00' \ - '\xf9\x01\xe7\x27' '\x17\x0f\x61\x7f' \ - '\x03\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x66\x6f\x6f\x00' + self.reply_bin_1 = b'\x01\x08\x4b\x34' b'\x01\x00\x00\x00' \ + b'\xf9\x01\xe7\x27' b'\x17\x0f\x61\x7f' \ + b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x66\x6f\x6f\x00' self.reply_args_2 = { 'bytes_after': 1111517270, @@ -713,11 +713,11 @@ def setUp(self): 'sequence_number': 42680, 'value': (8, 'zoom'), } - self.reply_bin_2 = '\x01\x08\xb8\xa6' '\x01\x00\x00\x00' \ - '\xb6\x39\x14\x38' '\x56\x68\x40\x42' \ - '\x04\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x7a\x6f\x6f\x6d' + self.reply_bin_2 = b'\x01\x08\xb8\xa6' b'\x01\x00\x00\x00' \ + b'\xb6\x39\x14\x38' b'\x56\x68\x40\x42' \ + b'\x04\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x7a\x6f\x6f\x6d' self.reply_args_3 = { 'bytes_after': 726076595, @@ -725,10 +725,10 @@ def setUp(self): 'sequence_number': 8155, 'value': (16, []), } - self.reply_bin_3 = '\x01\x10\xdb\x1f' '\x00\x00\x00\x00' \ - '\x5b\xa8\xc3\x1c' '\xb3\x0c\x47\x2b' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_3 = b'\x01\x10\xdb\x1f' b'\x00\x00\x00\x00' \ + b'\x5b\xa8\xc3\x1c' b'\xb3\x0c\x47\x2b' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_4 = { 'bytes_after': 472964335, @@ -736,11 +736,11 @@ def setUp(self): 'sequence_number': 38660, 'value': (16, [1, 2, 3]), } - self.reply_bin_4 = '\x01\x10\x04\x97' '\x02\x00\x00\x00' \ - '\x60\x2b\x75\x1d' '\xef\xdc\x30\x1c' \ - '\x03\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x01\x00\x02\x00' '\x03\x00\x00\x00' + self.reply_bin_4 = b'\x01\x10\x04\x97' b'\x02\x00\x00\x00' \ + b'\x60\x2b\x75\x1d' b'\xef\xdc\x30\x1c' \ + b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x01\x00\x02\x00' b'\x03\x00\x00\x00' self.reply_args_5 = { 'bytes_after': 491699268, @@ -748,11 +748,11 @@ def setUp(self): 'sequence_number': 4890, 'value': (16, [1, 2, 3, 4]), } - self.reply_bin_5 = '\x01\x10\x1a\x13' '\x02\x00\x00\x00' \ - '\xc0\x59\xc8\x50' '\x44\xbc\x4e\x1d' \ - '\x04\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x01\x00\x02\x00' '\x03\x00\x04\x00' + self.reply_bin_5 = b'\x01\x10\x1a\x13' b'\x02\x00\x00\x00' \ + b'\xc0\x59\xc8\x50' b'\x44\xbc\x4e\x1d' \ + b'\x04\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x01\x00\x02\x00' b'\x03\x00\x04\x00' self.reply_args_6 = { 'bytes_after': 152225892, @@ -760,10 +760,10 @@ def setUp(self): 'sequence_number': 59361, 'value': (32, []), } - self.reply_bin_6 = '\x01\x20\xe1\xe7' '\x00\x00\x00\x00' \ - '\x53\xac\x08\x6e' '\x64\xc8\x12\x09' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_6 = b'\x01\x20\xe1\xe7' b'\x00\x00\x00\x00' \ + b'\x53\xac\x08\x6e' b'\x64\xc8\x12\x09' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_7 = { 'bytes_after': 460121536, @@ -771,12 +771,12 @@ def setUp(self): 'sequence_number': 15792, 'value': (32, [1, 2, 3]), } - self.reply_bin_7 = '\x01\x20\xb0\x3d' '\x03\x00\x00\x00' \ - '\x14\x65\xa1\x55' '\xc0\xe5\x6c\x1b' \ - '\x03\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x01\x00\x00\x00' '\x02\x00\x00\x00' \ - '\x03\x00\x00\x00' + self.reply_bin_7 = b'\x01\x20\xb0\x3d' b'\x03\x00\x00\x00' \ + b'\x14\x65\xa1\x55' b'\xc0\xe5\x6c\x1b' \ + b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x01\x00\x00\x00' b'\x02\x00\x00\x00' \ + b'\x03\x00\x00\x00' def testPackRequest0(self): @@ -866,28 +866,28 @@ def setUp(self): self.req_args_0 = { 'window': 284194396, } - self.req_bin_0 = '\x15\x00\x02\x00' '\x5c\x76\xf0\x10' + self.req_bin_0 = b'\x15\x00\x02\x00' b'\x5c\x76\xf0\x10' self.reply_args_0 = { 'atoms': [2009005759, 1226333816, 1015087858, 1684971497, 1734099213, 408955234, 208216521, 925712651, 909665942, 1002962766, 1565696219, 1446060760, 2113479735, 211409854, 864661769, 728690095, 1850436746, 534034650, 408523590, 963426393, 906021810, 598218424, 536504426], 'sequence_number': 60526, } - self.reply_bin_0 = '\x01\x00\x6e\xec' '\x17\x00\x00\x00' \ - '\x17\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\xbf\xfe\xbe\x77' '\x78\x5e\x18\x49' \ - '\xf2\x02\x81\x3c' '\xe9\x9f\x6e\x64' \ - '\x0d\x41\x5c\x67' '\x62\x29\x60\x18' \ - '\xc9\x21\x69\x0c' '\x0b\x41\x2d\x37' \ - '\x96\x66\x38\x36' '\x4e\xff\xc7\x3b' \ - '\xdb\xa0\x52\x5d' '\xd8\x22\x31\x56' \ - '\x37\x24\xf9\x7d' '\xbe\xdb\x99\x0c' \ - '\x09\xb1\x89\x33' '\xaf\xed\x6e\x2b' \ - '\x8a\x6c\x4b\x6e' '\xda\xb8\xd4\x1f' \ - '\x46\x93\x59\x18' '\x59\xb8\x6c\x39' \ - '\xb2\xcb\x00\x36' '\xb8\x16\xa8\x23' \ - '\x6a\x68\xfa\x1f' + self.reply_bin_0 = b'\x01\x00\x6e\xec' b'\x17\x00\x00\x00' \ + b'\x17\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\xbf\xfe\xbe\x77' b'\x78\x5e\x18\x49' \ + b'\xf2\x02\x81\x3c' b'\xe9\x9f\x6e\x64' \ + b'\x0d\x41\x5c\x67' b'\x62\x29\x60\x18' \ + b'\xc9\x21\x69\x0c' b'\x0b\x41\x2d\x37' \ + b'\x96\x66\x38\x36' b'\x4e\xff\xc7\x3b' \ + b'\xdb\xa0\x52\x5d' b'\xd8\x22\x31\x56' \ + b'\x37\x24\xf9\x7d' b'\xbe\xdb\x99\x0c' \ + b'\x09\xb1\x89\x33' b'\xaf\xed\x6e\x2b' \ + b'\x8a\x6c\x4b\x6e' b'\xda\xb8\xd4\x1f' \ + b'\x46\x93\x59\x18' b'\x59\xb8\x6c\x39' \ + b'\xb2\xcb\x00\x36' b'\xb8\x16\xa8\x23' \ + b'\x6a\x68\xfa\x1f' def testPackRequest0(self): @@ -916,8 +916,8 @@ def setUp(self): 'time': 1181844078, 'window': 951652523, } - self.req_bin_0 = '\x16\x00\x04\x00' '\xab\x10\xb9\x38' \ - '\x7b\xd3\x40\x6e' '\x6e\x82\x71\x46' + self.req_bin_0 = b'\x16\x00\x04\x00' b'\xab\x10\xb9\x38' \ + b'\x7b\xd3\x40\x6e' b'\x6e\x82\x71\x46' def testPackRequest0(self): @@ -935,16 +935,16 @@ def setUp(self): self.req_args_0 = { 'selection': 108699831, } - self.req_bin_0 = '\x17\x00\x02\x00' '\xb7\xa0\x7a\x06' + self.req_bin_0 = b'\x17\x00\x02\x00' b'\xb7\xa0\x7a\x06' self.reply_args_0 = { 'owner': 1795366313, 'sequence_number': 65489, } - self.reply_bin_0 = '\x01\x00\xd1\xff' '\x00\x00\x00\x00' \ - '\xa9\x1d\x03\x6b' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\xd1\xff' b'\x00\x00\x00\x00' \ + b'\xa9\x1d\x03\x6b' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -975,9 +975,9 @@ def setUp(self): 'target': 1822570126, 'time': 1042940084, } - self.req_bin_0 = '\x18\x00\x06\x00' '\xb0\x19\x08\x7c' \ - '\x54\x44\x93\x76' '\x8e\x36\xa2\x6c' \ - '\x22\x84\x4a\x15' '\xb4\x00\x2a\x3e' + self.req_bin_0 = b'\x18\x00\x06\x00' b'\xb0\x19\x08\x7c' \ + b'\x54\x44\x93\x76' b'\x8e\x36\xa2\x6c' \ + b'\x22\x84\x4a\x15' b'\xb4\x00\x2a\x3e' def testPackRequest0(self): @@ -998,12 +998,12 @@ def setUp(self): 'event_mask': 908439472, 'propagate': 1, } - self.req_bin_0 = '\x19\x01\x0b\x00' '\x58\x42\x3e\x3a' \ - '\xb0\xaf\x25\x36' '\x0c\x00\x00\x00' \ - '\x95\xdb\x5c\x1b' '\x43\x67\xf3\x0f' \ - '\xa3\x61\x40\xfc' '\xa0\x44\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' + self.req_bin_0 = b'\x19\x01\x0b\x00' b'\x58\x42\x3e\x3a' \ + b'\xb0\xaf\x25\x36' b'\x0c\x00\x00\x00' \ + b'\x95\xdb\x5c\x1b' b'\x43\x67\xf3\x0f' \ + b'\xa3\x61\x40\xfc' b'\xa0\x44\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1028,18 +1028,18 @@ def setUp(self): 'pointer_mode': 1, 'time': 1243807782, } - self.req_bin_0 = '\x1a\x01\x06\x00' '\xe7\x03\x6a\x7f' \ - '\xb8\x8e\x01\x00' '\xae\x39\xfb\x25' \ - '\x22\xb3\xfe\x7b' '\x26\x00\x23\x4a' + self.req_bin_0 = b'\x1a\x01\x06\x00' b'\xe7\x03\x6a\x7f' \ + b'\xb8\x8e\x01\x00' b'\xae\x39\xfb\x25' \ + b'\x22\xb3\xfe\x7b' b'\x26\x00\x23\x4a' self.reply_args_0 = { 'sequence_number': 49083, 'status': 197, } - self.reply_bin_0 = '\x01\xc5\xbb\xbf' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\xc5\xbb\xbf' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1066,7 +1066,7 @@ def setUp(self): self.req_args_0 = { 'time': 122823278, } - self.req_bin_0 = '\x1b\x00\x02\x00' '\x6e\x22\x52\x07' + self.req_bin_0 = b'\x1b\x00\x02\x00' b'\x6e\x22\x52\x07' def testPackRequest0(self): @@ -1092,9 +1092,9 @@ def setUp(self): 'owner_events': 1, 'pointer_mode': 0, } - self.req_bin_0 = '\x1c\x01\x06\x00' '\x03\xe6\x5d\x40' \ - '\x71\xda\x00\x01' '\x2b\x03\x42\x0a' \ - '\x2e\xed\xc9\x17' '\xcc\x00\x2d\xad' + self.req_bin_0 = b'\x1c\x01\x06\x00' b'\x03\xe6\x5d\x40' \ + b'\x71\xda\x00\x01' b'\x2b\x03\x42\x0a' \ + b'\x2e\xed\xc9\x17' b'\xcc\x00\x2d\xad' def testPackRequest0(self): @@ -1114,8 +1114,8 @@ def setUp(self): 'grab_window': 257512222, 'modifiers': 58373, } - self.req_bin_0 = '\x1d\x9e\x03\x00' '\x1e\x53\x59\x0f' \ - '\x05\xe4\x00\x00' + self.req_bin_0 = b'\x1d\x9e\x03\x00' b'\x1e\x53\x59\x0f' \ + b'\x05\xe4\x00\x00' def testPackRequest0(self): @@ -1135,8 +1135,8 @@ def setUp(self): 'event_mask': 40689, 'time': 1276746733, } - self.req_bin_0 = '\x1e\x00\x04\x00' '\x01\xbd\x84\x1f' \ - '\xed\x9b\x19\x4c' '\xf1\x9e\x00\x00' + self.req_bin_0 = b'\x1e\x00\x04\x00' b'\x01\xbd\x84\x1f' \ + b'\xed\x9b\x19\x4c' b'\xf1\x9e\x00\x00' def testPackRequest0(self): @@ -1158,17 +1158,17 @@ def setUp(self): 'pointer_mode': 1, 'time': 1122698607, } - self.req_bin_0 = '\x1f\x00\x04\x00' '\x9c\x30\xb6\x4a' \ - '\x6f\x05\xeb\x42' '\x01\x00\x00\x00' + self.req_bin_0 = b'\x1f\x00\x04\x00' b'\x9c\x30\xb6\x4a' \ + b'\x6f\x05\xeb\x42' b'\x01\x00\x00\x00' self.reply_args_0 = { 'sequence_number': 15837, 'status': 219, } - self.reply_bin_0 = '\x01\xdb\xdd\x3d' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\xdb\xdd\x3d' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1195,7 +1195,7 @@ def setUp(self): self.req_args_0 = { 'time': 849983231, } - self.req_bin_0 = '\x20\x00\x02\x00' '\xff\xb6\xa9\x32' + self.req_bin_0 = b'\x20\x00\x02\x00' b'\xff\xb6\xa9\x32' def testPackRequest0(self): @@ -1218,8 +1218,8 @@ def setUp(self): 'owner_events': 1, 'pointer_mode': 0, } - self.req_bin_0 = '\x21\x01\x04\x00' '\x1a\x01\x67\x26' \ - '\xa0\x51\xe0\x00' '\x00\x00\x00\x00' + self.req_bin_0 = b'\x21\x01\x04\x00' b'\x1a\x01\x67\x26' \ + b'\xa0\x51\xe0\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1239,8 +1239,8 @@ def setUp(self): 'key': 255, 'modifiers': 5038, } - self.req_bin_0 = '\x22\xff\x03\x00' '\xa0\x17\x80\x7f' \ - '\xae\x13\x00\x00' + self.req_bin_0 = b'\x22\xff\x03\x00' b'\xa0\x17\x80\x7f' \ + b'\xae\x13\x00\x00' def testPackRequest0(self): @@ -1259,7 +1259,7 @@ def setUp(self): 'mode': 1, 'time': 569561709, } - self.req_bin_0 = '\x23\x01\x02\x00' '\x6d\xd2\xf2\x21' + self.req_bin_0 = b'\x23\x01\x02\x00' b'\x6d\xd2\xf2\x21' def testPackRequest0(self): @@ -1276,7 +1276,7 @@ class TestGrabServer(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x24\x00\x01\x00' + self.req_bin_0 = b'\x24\x00\x01\x00' def testPackRequest0(self): @@ -1293,7 +1293,7 @@ class TestUngrabServer(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x25\x00\x01\x00' + self.req_bin_0 = b'\x25\x00\x01\x00' def testPackRequest0(self): @@ -1311,7 +1311,7 @@ def setUp(self): self.req_args_0 = { 'window': 2004163626, } - self.req_bin_0 = '\x26\x00\x02\x00' '\x2a\x1c\x75\x77' + self.req_bin_0 = b'\x26\x00\x02\x00' b'\x2a\x1c\x75\x77' self.reply_args_0 = { 'child': 338813940, @@ -1324,10 +1324,10 @@ def setUp(self): 'win_x': -12881, 'win_y': -671, } - self.reply_bin_0 = '\x01\x01\x36\xe1' '\x00\x00\x00\x00' \ - '\x4a\x4b\x4d\x2f' '\xf4\xe3\x31\x14' \ - '\xe3\xe9\x5a\xd9' '\xaf\xcd\x61\xfd' \ - '\xc3\xa7\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x01\x36\xe1' b'\x00\x00\x00\x00' \ + b'\x4a\x4b\x4d\x2f' b'\xf4\xe3\x31\x14' \ + b'\xe3\xe9\x5a\xd9' b'\xaf\xcd\x61\xfd' \ + b'\xc3\xa7\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1356,22 +1356,22 @@ def setUp(self): 'stop': 642956890, 'window': 16865017, } - self.req_bin_0 = '\x27\x00\x04\x00' '\xf9\x56\x01\x01' \ - '\x1a\x0d\x97\x68' '\x5a\xbe\x52\x26' + self.req_bin_0 = b'\x27\x00\x04\x00' b'\xf9\x56\x01\x01' \ + b'\x1a\x0d\x97\x68' b'\x5a\xbe\x52\x26' self.reply_args_0 = { 'events': [{'y': -28402, 'x': -2241, 'time': 1424638477}, {'y': -14782, 'x': -29288, 'time': 247939153}, {'y': -9437, 'x': -13104, 'time': 584911019}, {'y': -24186, 'x': -12148, 'time': 437274091}, {'y': -5259, 'x': -3333, 'time': 1049147683}], 'sequence_number': 6281, } - self.reply_bin_0 = '\x01\x00\x89\x18' '\x0a\x00\x00\x00' \ - '\x05\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x0d\x42\xea\x54' '\x3f\xf7\x0e\x91' \ - '\x51\x40\xc7\x0e' '\x98\x8d\x42\xc6' \ - '\xab\x08\xdd\x22' '\xd0\xcc\x23\xdb' \ - '\xeb\x45\x10\x1a' '\x8c\xd0\x86\xa1' \ - '\x23\xb9\x88\x3e' '\xfb\xf2\x75\xeb' + self.reply_bin_0 = b'\x01\x00\x89\x18' b'\x0a\x00\x00\x00' \ + b'\x05\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x0d\x42\xea\x54' b'\x3f\xf7\x0e\x91' \ + b'\x51\x40\xc7\x0e' b'\x98\x8d\x42\xc6' \ + b'\xab\x08\xdd\x22' b'\xd0\xcc\x23\xdb' \ + b'\xeb\x45\x10\x1a' b'\x8c\xd0\x86\xa1' \ + b'\x23\xb9\x88\x3e' b'\xfb\xf2\x75\xeb' def testPackRequest0(self): @@ -1401,8 +1401,8 @@ def setUp(self): 'src_x': -32653, 'src_y': -7697, } - self.req_bin_0 = '\x28\x00\x04\x00' '\xad\x4e\x38\x36' \ - '\x1b\xfb\x6a\x23' '\x73\x80\xef\xe1' + self.req_bin_0 = b'\x28\x00\x04\x00' b'\xad\x4e\x38\x36' \ + b'\x1b\xfb\x6a\x23' b'\x73\x80\xef\xe1' self.reply_args_0 = { 'child': 1591798213, @@ -1411,10 +1411,10 @@ def setUp(self): 'x': -14832, 'y': -18863, } - self.reply_bin_0 = '\x01\x01\xcc\x43' '\x00\x00\x00\x00' \ - '\xc5\xe9\xe0\x5e' '\x10\xc6\x51\xb6' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x01\xcc\x43' b'\x00\x00\x00\x00' \ + b'\xc5\xe9\xe0\x5e' b'\x10\xc6\x51\xb6' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1448,9 +1448,9 @@ def setUp(self): 'src_x': -4056, 'src_y': -3379, } - self.req_bin_0 = '\x29\x00\x06\x00' '\xd8\xd8\x3d\x01' \ - '\xfb\x83\xa2\x09' '\x28\xf0\xcd\xf2' \ - '\x20\x8c\xd2\xd5' '\xfb\xc9\xce\x92' + self.req_bin_0 = b'\x29\x00\x06\x00' b'\xd8\xd8\x3d\x01' \ + b'\xfb\x83\xa2\x09' b'\x28\xf0\xcd\xf2' \ + b'\x20\x8c\xd2\xd5' b'\xfb\xc9\xce\x92' def testPackRequest0(self): @@ -1470,8 +1470,8 @@ def setUp(self): 'revert_to': 0, 'time': 1930554666, } - self.req_bin_0 = '\x2a\x00\x03\x00' '\x8b\xb3\x75\x27' \ - '\x2a\xed\x11\x73' + self.req_bin_0 = b'\x2a\x00\x03\x00' b'\x8b\xb3\x75\x27' \ + b'\x2a\xed\x11\x73' def testPackRequest0(self): @@ -1488,17 +1488,17 @@ class TestGetInputFocus(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x2b\x00\x01\x00' + self.req_bin_0 = b'\x2b\x00\x01\x00' self.reply_args_0 = { 'focus': 1930432580, 'revert_to': 229, 'sequence_number': 56442, } - self.reply_bin_0 = '\x01\xe5\x7a\xdc' '\x00\x00\x00\x00' \ - '\x44\x10\x10\x73' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\xe5\x7a\xdc' b'\x00\x00\x00\x00' \ + b'\x44\x10\x10\x73' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1524,17 +1524,17 @@ class TestQueryKeymap(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x2c\x00\x01\x00' + self.req_bin_0 = b'\x2c\x00\x01\x00' self.reply_args_0 = { 'map': [154, 159, 141, 227, 241, 180, 207, 147, 247, 238, 252, 231, 240, 131, 222, 170, 247, 230, 238, 231, 162, 228, 141, 239, 237, 156, 232, 186, 167, 229, 157, 131], 'sequence_number': 12863, } - self.reply_bin_0 = '\x01\x00\x3f\x32' '\x02\x00\x00\x00' \ - '\x9a\x9f\x8d\xe3' '\xf1\xb4\xcf\x93' \ - '\xf7\xee\xfc\xe7' '\xf0\x83\xde\xaa' \ - '\xf7\xe6\xee\xe7' '\xa2\xe4\x8d\xef' \ - '\xed\x9c\xe8\xba' '\xa7\xe5\x9d\x83' + self.reply_bin_0 = b'\x01\x00\x3f\x32' b'\x02\x00\x00\x00' \ + b'\x9a\x9f\x8d\xe3' b'\xf1\xb4\xcf\x93' \ + b'\xf7\xee\xfc\xe7' b'\xf0\x83\xde\xaa' \ + b'\xf7\xe6\xee\xe7' b'\xa2\xe4\x8d\xef' \ + b'\xed\x9c\xe8\xba' b'\xa7\xe5\x9d\x83' def testPackRequest0(self): @@ -1562,9 +1562,9 @@ def setUp(self): 'fid': 704981195, 'name': 'foofont', } - self.req_bin_0 = '\x2d\x00\x05\x00' '\xcb\x28\x05\x2a' \ - '\x07\x00\x00\x00' '\x66\x6f\x6f\x66' \ - '\x6f\x6e\x74\x00' + self.req_bin_0 = b'\x2d\x00\x05\x00' b'\xcb\x28\x05\x2a' \ + b'\x07\x00\x00\x00' b'\x66\x6f\x6f\x66' \ + b'\x6f\x6e\x74\x00' def testPackRequest0(self): @@ -1582,7 +1582,7 @@ def setUp(self): self.req_args_0 = { 'font': 1856192698, } - self.req_bin_0 = '\x2e\x00\x02\x00' '\xba\x40\xa3\x6e' + self.req_bin_0 = b'\x2e\x00\x02\x00' b'\xba\x40\xa3\x6e' def testPackRequest0(self): @@ -1600,7 +1600,7 @@ def setUp(self): self.req_args_0 = { 'font': 2076380709, } - self.req_bin_0 = '\x2f\x00\x02\x00' '\x25\x0e\xc3\x7b' + self.req_bin_0 = b'\x2f\x00\x02\x00' b'\x25\x0e\xc3\x7b' self.reply_args_0 = { 'all_chars_exist': 0, @@ -1618,19 +1618,19 @@ def setUp(self): 'properties': [{'name': 599463600, 'value': 1377595039}], 'sequence_number': 46525, } - self.reply_bin_0 = '\x01\x00\xbd\xb5' '\x12\x00\x00\x00' \ - '\x36\x80\x8d\xf5' '\x62\xc4\x5e\xdb' \ - '\x3b\xde\x02\xac' '\x00\x00\x00\x00' \ - '\x41\xae\xe3\x88' '\x5c\xd4\xef\xa9' \ - '\xde\xa7\x3e\xd9' '\x00\x00\x00\x00' \ - '\x89\xb8\x95\x4d' '\xde\x4f\x01\x00' \ - '\xb4\xb3\xa5\x00' '\x65\xb5\x6e\xf7' \ - '\x03\x00\x00\x00' '\xb0\x16\xbb\x23' \ - '\x9f\x6e\x1c\x52' '\xc2\xb2\x9c\xfc' \ - '\x19\xc4\x49\xf7' '\xa6\x8e\x73\xf8' \ - '\xad\x96\x3e\xfa' '\xb7\xa1\xc4\x8d' \ - '\x30\xb7\xc7\xba' '\xd6\xa7\xfd\xcc' \ - '\xf3\xc0\xeb\xb0' '\x3a\xc9\xf4\x41' + self.reply_bin_0 = b'\x01\x00\xbd\xb5' b'\x12\x00\x00\x00' \ + b'\x36\x80\x8d\xf5' b'\x62\xc4\x5e\xdb' \ + b'\x3b\xde\x02\xac' b'\x00\x00\x00\x00' \ + b'\x41\xae\xe3\x88' b'\x5c\xd4\xef\xa9' \ + b'\xde\xa7\x3e\xd9' b'\x00\x00\x00\x00' \ + b'\x89\xb8\x95\x4d' b'\xde\x4f\x01\x00' \ + b'\xb4\xb3\xa5\x00' b'\x65\xb5\x6e\xf7' \ + b'\x03\x00\x00\x00' b'\xb0\x16\xbb\x23' \ + b'\x9f\x6e\x1c\x52' b'\xc2\xb2\x9c\xfc' \ + b'\x19\xc4\x49\xf7' b'\xa6\x8e\x73\xf8' \ + b'\xad\x96\x3e\xfa' b'\xb7\xa1\xc4\x8d' \ + b'\x30\xb7\xc7\xba' b'\xd6\xa7\xfd\xcc' \ + b'\xf3\xc0\xeb\xb0' b'\x3a\xc9\xf4\x41' def testPackRequest0(self): @@ -1658,8 +1658,8 @@ def setUp(self): 'font': 1454550358, 'string': (102, 111, 111), } - self.req_bin_0 = '\x30\x01\x04\x00' '\x56\xad\xb2\x56' \ - '\x00\x66\x00\x6f' '\x00\x6f\x00\x00' + self.req_bin_0 = b'\x30\x01\x04\x00' b'\x56\xad\xb2\x56' \ + b'\x00\x66\x00\x6f' b'\x00\x6f\x00\x00' self.reply_args_0 = { 'draw_direction': 243, @@ -1672,10 +1672,10 @@ def setUp(self): 'overall_width': -1224334048, 'sequence_number': 40436, } - self.reply_bin_0 = '\x01\xf3\xf4\x9d' '\x00\x00\x00\x00' \ - '\x38\xa6\x97\xc5' '\x0d\x80\x70\xa4' \ - '\x20\x25\x06\xb7' '\x80\x5c\x3c\xca' \ - '\x3b\xbd\xcc\xd3' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\xf3\xf4\x9d' b'\x00\x00\x00\x00' \ + b'\x38\xa6\x97\xc5' b'\x0d\x80\x70\xa4' \ + b'\x20\x25\x06\xb7' b'\x80\x5c\x3c\xca' \ + b'\x3b\xbd\xcc\xd3' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1703,20 +1703,20 @@ def setUp(self): 'max_names': 30610, 'pattern': 'bhazr', } - self.req_bin_0 = '\x31\x00\x04\x00' '\x92\x77\x05\x00' \ - '\x62\x68\x61\x7a' '\x72\x00\x00\x00' + self.req_bin_0 = b'\x31\x00\x04\x00' b'\x92\x77\x05\x00' \ + b'\x62\x68\x61\x7a' b'\x72\x00\x00\x00' self.reply_args_0 = { 'fonts': ['fie', 'fuzzy', 'foozooom'], 'sequence_number': 29120, } - self.reply_bin_0 = '\x01\x00\xc0\x71' '\x05\x00\x00\x00' \ - '\x03\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x03\x66\x69\x65' '\x05\x66\x75\x7a' \ - '\x7a\x79\x08\x66' '\x6f\x6f\x7a\x6f' \ - '\x6f\x6f\x6d\x00' + self.reply_bin_0 = b'\x01\x00\xc0\x71' b'\x05\x00\x00\x00' \ + b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x03\x66\x69\x65' b'\x05\x66\x75\x7a' \ + b'\x7a\x79\x08\x66' b'\x6f\x6f\x7a\x6f' \ + b'\x6f\x6f\x6d\x00' def testPackRequest0(self): @@ -1744,8 +1744,8 @@ def setUp(self): 'max_names': 14206, 'pattern': 'bhazr2', } - self.req_bin_0 = '\x32\x00\x04\x00' '\x7e\x37\x06\x00' \ - '\x62\x68\x61\x7a' '\x72\x32\x00\x00' + self.req_bin_0 = b'\x32\x00\x04\x00' b'\x7e\x37\x06\x00' \ + b'\x62\x68\x61\x7a' b'\x72\x32\x00\x00' self.reply_args_0 = { 'all_chars_exist': 1, @@ -1764,16 +1764,16 @@ def setUp(self): 'replies_hint': 1408896390, 'sequence_number': 52220, } - self.reply_bin_0 = '\x01\x08\xfc\xcb' '\x0b\x00\x00\x00' \ - '\x8d\x95\xc4\x8a' '\x76\xc1\x62\xd0' \ - '\x91\xaa\xb2\xd1' '\x00\x00\x00\x00' \ - '\x65\xdf\x72\xd5' '\x87\x9c\x4a\x99' \ - '\x1a\x83\x6f\x3f' '\x00\x00\x00\x00' \ - '\x28\x7a\xae\xd9' '\x92\x13\x01\x00' \ - '\xb5\xd0\x98\x01' '\xc9\xbe\xfc\x9e' \ - '\x86\x0d\xfa\x53' '\x49\xe4\x91\x3c' \ - '\xfa\xfd\x59\x73' '\x66\x6f\x6e\x74' \ - '\x66\x6f\x6e\x74' + self.reply_bin_0 = b'\x01\x08\xfc\xcb' b'\x0b\x00\x00\x00' \ + b'\x8d\x95\xc4\x8a' b'\x76\xc1\x62\xd0' \ + b'\x91\xaa\xb2\xd1' b'\x00\x00\x00\x00' \ + b'\x65\xdf\x72\xd5' b'\x87\x9c\x4a\x99' \ + b'\x1a\x83\x6f\x3f' b'\x00\x00\x00\x00' \ + b'\x28\x7a\xae\xd9' b'\x92\x13\x01\x00' \ + b'\xb5\xd0\x98\x01' b'\xc9\xbe\xfc\x9e' \ + b'\x86\x0d\xfa\x53' b'\x49\xe4\x91\x3c' \ + b'\xfa\xfd\x59\x73' b'\x66\x6f\x6e\x74' \ + b'\x66\x6f\x6e\x74' def testPackRequest0(self): @@ -1800,14 +1800,14 @@ def setUp(self): self.req_args_0 = { 'path': ['foo', 'bar', 'gazonk'], } - self.req_bin_0 = '\x33\x00\x06\x00' '\x03\x00\x00\x00' \ - '\x03\x66\x6f\x6f' '\x03\x62\x61\x72' \ - '\x06\x67\x61\x7a' '\x6f\x6e\x6b\x00' + self.req_bin_0 = b'\x33\x00\x06\x00' b'\x03\x00\x00\x00' \ + b'\x03\x66\x6f\x6f' b'\x03\x62\x61\x72' \ + b'\x06\x67\x61\x7a' b'\x6f\x6e\x6b\x00' self.req_args_1 = { 'path': [], } - self.req_bin_1 = '\x33\x00\x02\x00' '\x00\x00\x00\x00' + self.req_bin_1 = b'\x33\x00\x02\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1833,27 +1833,27 @@ class TestGetFontPath(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x34\x00\x01\x00' + self.req_bin_0 = b'\x34\x00\x01\x00' self.reply_args_0 = { 'paths': ['path1', 'path2232'], 'sequence_number': 617, } - self.reply_bin_0 = '\x01\x00\x69\x02' '\x04\x00\x00\x00' \ - '\x02\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x05\x70\x61\x74' '\x68\x31\x08\x70' \ - '\x61\x74\x68\x32' '\x32\x33\x32\x00' + self.reply_bin_0 = b'\x01\x00\x69\x02' b'\x04\x00\x00\x00' \ + b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x05\x70\x61\x74' b'\x68\x31\x08\x70' \ + b'\x61\x74\x68\x32' b'\x32\x33\x32\x00' self.reply_args_1 = { 'paths': [], 'sequence_number': 49278, } - self.reply_bin_1 = '\x01\x00\x7e\xc0' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_1 = b'\x01\x00\x7e\xc0' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1893,8 +1893,8 @@ def setUp(self): 'pid': 228953027, 'width': 11737, } - self.req_bin_0 = '\x35\xe2\x04\x00' '\xc3\x8b\xa5\x0d' \ - '\xec\xc3\x6b\x36' '\xd9\x2d\x48\xf5' + self.req_bin_0 = b'\x35\xe2\x04\x00' b'\xc3\x8b\xa5\x0d' \ + b'\xec\xc3\x6b\x36' b'\xd9\x2d\x48\xf5' def testPackRequest0(self): @@ -1912,7 +1912,7 @@ def setUp(self): self.req_args_0 = { 'pixmap': 1112337390, } - self.req_bin_0 = '\x36\x00\x02\x00' '\xee\xeb\x4c\x42' + self.req_bin_0 = b'\x36\x00\x02\x00' b'\xee\xeb\x4c\x42' def testPackRequest0(self): @@ -1932,20 +1932,20 @@ def setUp(self): 'cid': 1345956480, 'drawable': 589741066, } - self.req_bin_0 = '\x37\x00\x1b\x00' '\x80\xaa\x39\x50' \ - '\x0a\xbc\x26\x23' '\xff\xff\x7f\x00' \ - '\x00\x00\x00\x00' '\xe2\x7a\xe6\x1f' \ - '\xe4\x6f\x96\x6c' '\x76\xe2\x6d\x3a' \ - '\x95\xe6\x00\x00' '\x02\x00\x00\x00' \ - '\x03\x00\x00\x00' '\x01\x00\x00\x00' \ - '\x03\x00\x00\x00' '\x01\x00\x00\x00' \ - '\x55\xc7\x6b\x4e' '\x2b\x73\x11\x5c' \ - '\x9c\xc0\x00\x00' '\x50\xea\x00\x00' \ - '\xc5\x1e\x21\x46' '\x01\x00\x00\x00' \ - '\x01\x00\x00\x00' '\xc2\xbc\x00\x00' \ - '\x2d\xa1\x00\x00' '\xf2\x4d\xa6\x1f' \ - '\x9f\xd1\x00\x00' '\xe2\x00\x00\x00' \ - '\x01\x00\x00\x00' + self.req_bin_0 = b'\x37\x00\x1b\x00' b'\x80\xaa\x39\x50' \ + b'\x0a\xbc\x26\x23' b'\xff\xff\x7f\x00' \ + b'\x00\x00\x00\x00' b'\xe2\x7a\xe6\x1f' \ + b'\xe4\x6f\x96\x6c' b'\x76\xe2\x6d\x3a' \ + b'\x95\xe6\x00\x00' b'\x02\x00\x00\x00' \ + b'\x03\x00\x00\x00' b'\x01\x00\x00\x00' \ + b'\x03\x00\x00\x00' b'\x01\x00\x00\x00' \ + b'\x55\xc7\x6b\x4e' b'\x2b\x73\x11\x5c' \ + b'\x9c\xc0\x00\x00' b'\x50\xea\x00\x00' \ + b'\xc5\x1e\x21\x46' b'\x01\x00\x00\x00' \ + b'\x01\x00\x00\x00' b'\xc2\xbc\x00\x00' \ + b'\x2d\xa1\x00\x00' b'\xf2\x4d\xa6\x1f' \ + b'\x9f\xd1\x00\x00' b'\xe2\x00\x00\x00' \ + b'\x01\x00\x00\x00' def testPackRequest0(self): @@ -1964,19 +1964,19 @@ def setUp(self): 'attrs': {'stipple': 1165278526, 'background': 686615653, 'subwindow_mode': 1, 'fill_style': 2, 'font': 902289335, 'graphics_exposures': 1, 'tile': 875351804, 'tile_stipple_x_origin': -19144, 'dashes': 128, 'function': 1, 'foreground': 583551477, 'clip_x_origin': -9978, 'cap_style': 0, 'tile_stipple_y_origin': -25991, 'join_style': 2, 'line_width': 50468, 'dash_offset': 45232, 'clip_y_origin': -4695, 'arc_mode': 0, 'line_style': 0, 'plane_mask': 613643341, 'clip_mask': 1644117194, 'fill_rule': 0}, 'gc': 1618091665, } - self.req_bin_0 = '\x38\x00\x1a\x00' '\x91\x1e\x72\x60' \ - '\xff\xff\x7f\x00' '\x01\x00\x00\x00' \ - '\x4d\x74\x93\x24' '\xf5\x49\xc8\x22' \ - '\x65\xec\xec\x28' '\x24\xc5\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x02\x00\x00\x00' '\x02\x00\x00\x00' \ - '\x00\x00\x00\x00' '\xfc\xce\x2c\x34' \ - '\x3e\xbd\x74\x45' '\x38\xb5\x00\x00' \ - '\x79\x9a\x00\x00' '\xb7\xd7\xc7\x35' \ - '\x01\x00\x00\x00' '\x01\x00\x00\x00' \ - '\x06\xd9\x00\x00' '\xa9\xed\x00\x00' \ - '\xca\x3c\xff\x61' '\xb0\xb0\x00\x00' \ - '\x80\x00\x00\x00' '\x00\x00\x00\x00' + self.req_bin_0 = b'\x38\x00\x1a\x00' b'\x91\x1e\x72\x60' \ + b'\xff\xff\x7f\x00' b'\x01\x00\x00\x00' \ + b'\x4d\x74\x93\x24' b'\xf5\x49\xc8\x22' \ + b'\x65\xec\xec\x28' b'\x24\xc5\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x02\x00\x00\x00' b'\x02\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\xfc\xce\x2c\x34' \ + b'\x3e\xbd\x74\x45' b'\x38\xb5\x00\x00' \ + b'\x79\x9a\x00\x00' b'\xb7\xd7\xc7\x35' \ + b'\x01\x00\x00\x00' b'\x01\x00\x00\x00' \ + b'\x06\xd9\x00\x00' b'\xa9\xed\x00\x00' \ + b'\xca\x3c\xff\x61' b'\xb0\xb0\x00\x00' \ + b'\x80\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1996,8 +1996,8 @@ def setUp(self): 'mask': 899879427, 'src_gc': 1832775121, } - self.req_bin_0 = '\x39\x00\x04\x00' '\xd1\xed\x3d\x6d' \ - '\x48\x0d\x0a\x7a' '\x03\x12\xa3\x35' + self.req_bin_0 = b'\x39\x00\x04\x00' b'\xd1\xed\x3d\x6d' \ + b'\x48\x0d\x0a\x7a' b'\x03\x12\xa3\x35' def testPackRequest0(self): @@ -2017,9 +2017,9 @@ def setUp(self): 'dashes': [223, 197, 205, 156, 156, 183, 131, 171, 214], 'gc': 868302473, } - self.req_bin_0 = '\x3a\x00\x06\x00' '\x89\x3e\xc1\x33' \ - '\x16\x2b\x09\x00' '\xdf\xc5\xcd\x9c' \ - '\x9c\xb7\x83\xab' '\xd6\x00\x00\x00' + self.req_bin_0 = b'\x3a\x00\x06\x00' b'\x89\x3e\xc1\x33' \ + b'\x16\x2b\x09\x00' b'\xdf\xc5\xcd\x9c' \ + b'\x9c\xb7\x83\xab' b'\xd6\x00\x00\x00' def testPackRequest0(self): @@ -2041,10 +2041,10 @@ def setUp(self): 'x_origin': -31134, 'y_origin': -20443, } - self.req_bin_0 = '\x3b\x00\x07\x00' '\x10\x79\x19\x3b' \ - '\x62\x86\x25\xb0' '\x5c\xbb\x35\x90' \ - '\xac\x9f\xe0\x07' '\x0a\xb2\xae\xc7' \ - '\xe9\x07\xe6\xa4' + self.req_bin_0 = b'\x3b\x00\x07\x00' b'\x10\x79\x19\x3b' \ + b'\x62\x86\x25\xb0' b'\x5c\xbb\x35\x90' \ + b'\xac\x9f\xe0\x07' b'\x0a\xb2\xae\xc7' \ + b'\xe9\x07\xe6\xa4' self.req_args_1 = { 'gc': 701940136, @@ -2053,8 +2053,8 @@ def setUp(self): 'x_origin': -8019, 'y_origin': -20442, } - self.req_bin_1 = '\x3b\x00\x03\x00' '\xa8\xc1\xd6\x29' \ - '\xad\xe0\x26\xb0' + self.req_bin_1 = b'\x3b\x00\x03\x00' b'\xa8\xc1\xd6\x29' \ + b'\xad\xe0\x26\xb0' def testPackRequest0(self): @@ -2081,7 +2081,7 @@ def setUp(self): self.req_args_0 = { 'gc': 1614945050, } - self.req_bin_0 = '\x3c\x00\x02\x00' '\x1a\x1b\x42\x60' + self.req_bin_0 = b'\x3c\x00\x02\x00' b'\x1a\x1b\x42\x60' def testPackRequest0(self): @@ -2104,8 +2104,8 @@ def setUp(self): 'x': -30105, 'y': -32138, } - self.req_bin_0 = '\x3d\x01\x04\x00' '\x68\x2e\x4b\x20' \ - '\x67\x8a\x76\x82' '\x8d\x8a\xf9\xff' + self.req_bin_0 = b'\x3d\x01\x04\x00' b'\x68\x2e\x4b\x20' \ + b'\x67\x8a\x76\x82' b'\x8d\x8a\xf9\xff' def testPackRequest0(self): @@ -2131,10 +2131,10 @@ def setUp(self): 'src_y': -8246, 'width': 1586, } - self.req_bin_0 = '\x3e\x00\x07\x00' '\x8c\x26\xcc\x2c' \ - '\x80\x45\x38\x53' '\xcf\xa9\xff\x63' \ - '\xc6\xd2\xca\xdf' '\x9a\xf8\x51\x99' \ - '\x32\x06\xdb\x27' + self.req_bin_0 = b'\x3e\x00\x07\x00' b'\x8c\x26\xcc\x2c' \ + b'\x80\x45\x38\x53' b'\xcf\xa9\xff\x63' \ + b'\xc6\xd2\xca\xdf' b'\x9a\xf8\x51\x99' \ + b'\x32\x06\xdb\x27' def testPackRequest0(self): @@ -2161,10 +2161,10 @@ def setUp(self): 'src_y': -10027, 'width': 39897, } - self.req_bin_0 = '\x3f\x00\x08\x00' '\xf7\xe1\x28\x10' \ - '\x6f\x28\xb1\x55' '\x5e\x97\x30\x48' \ - '\xae\x9b\xd5\xd8' '\x66\xe1\x4f\x95' \ - '\xd9\x9b\xb8\xbf' '\x0a\xe6\xa9\x0e' + self.req_bin_0 = b'\x3f\x00\x08\x00' b'\xf7\xe1\x28\x10' \ + b'\x6f\x28\xb1\x55' b'\x5e\x97\x30\x48' \ + b'\xae\x9b\xd5\xd8' b'\x66\xe1\x4f\x95' \ + b'\xd9\x9b\xb8\xbf' b'\x0a\xe6\xa9\x0e' def testPackRequest0(self): @@ -2185,9 +2185,9 @@ def setUp(self): 'gc': 1535501063, 'points': [{'y': -1403, 'x': -6131}, {'y': -31934, 'x': -29254}, {'y': -10746, 'x': -22626}], } - self.req_bin_0 = '\x40\x01\x06\x00' '\x13\x2d\xc6\x32' \ - '\x07\xe3\x85\x5b' '\x0d\xe8\x85\xfa' \ - '\xba\x8d\x42\x83' '\x9e\xa7\x06\xd6' + self.req_bin_0 = b'\x40\x01\x06\x00' b'\x13\x2d\xc6\x32' \ + b'\x07\xe3\x85\x5b' b'\x0d\xe8\x85\xfa' \ + b'\xba\x8d\x42\x83' b'\x9e\xa7\x06\xd6' def testPackRequest0(self): @@ -2208,10 +2208,10 @@ def setUp(self): 'gc': 795836146, 'points': [{'y': -10315, 'x': -30298}, {'y': -29455, 'x': -12375}, {'y': -5123, 'x': -7653}, {'y': -28833, 'x': -13247}, {'y': -7323, 'x': -781}], } - self.req_bin_0 = '\x41\x00\x08\x00' '\x8f\xa9\xd5\x36' \ - '\xf2\x7e\x6f\x2f' '\xa6\x89\xb5\xd7' \ - '\xa9\xcf\xf1\x8c' '\x1b\xe2\xfd\xeb' \ - '\x41\xcc\x5f\x8f' '\xf3\xfc\x65\xe3' + self.req_bin_0 = b'\x41\x00\x08\x00' b'\x8f\xa9\xd5\x36' \ + b'\xf2\x7e\x6f\x2f' b'\xa6\x89\xb5\xd7' \ + b'\xa9\xcf\xf1\x8c' b'\x1b\xe2\xfd\xeb' \ + b'\x41\xcc\x5f\x8f' b'\xf3\xfc\x65\xe3' def testPackRequest0(self): @@ -2231,9 +2231,9 @@ def setUp(self): 'gc': 2063278158, 'segments': [{'y1': -21674, 'x2': -5146, 'x1': -16318, 'y2': -6032}], } - self.req_bin_0 = '\x42\x00\x05\x00' '\x32\x31\x83\x0d' \ - '\x4e\x20\xfb\x7a' '\x42\xc0\x56\xab' \ - '\xe6\xeb\x70\xe8' + self.req_bin_0 = b'\x42\x00\x05\x00' b'\x32\x31\x83\x0d' \ + b'\x4e\x20\xfb\x7a' b'\x42\xc0\x56\xab' \ + b'\xe6\xeb\x70\xe8' def testPackRequest0(self): @@ -2253,11 +2253,11 @@ def setUp(self): 'gc': 1829049801, 'rectangles': [{'y': -5825, 'x': -12104, 'height': 28684, 'width': 46429}, {'y': -1378, 'x': -8911, 'height': 53015, 'width': 17886}, {'y': -17049, 'x': -15271, 'height': 47977, 'width': 28690}], } - self.req_bin_0 = '\x43\x00\x09\x00' '\x3f\x84\x5b\x22' \ - '\xc9\x15\x05\x6d' '\xb8\xd0\x3f\xe9' \ - '\x5d\xb5\x0c\x70' '\x31\xdd\x9e\xfa' \ - '\xde\x45\x17\xcf' '\x59\xc4\x67\xbd' \ - '\x12\x70\x69\xbb' + self.req_bin_0 = b'\x43\x00\x09\x00' b'\x3f\x84\x5b\x22' \ + b'\xc9\x15\x05\x6d' b'\xb8\xd0\x3f\xe9' \ + b'\x5d\xb5\x0c\x70' b'\x31\xdd\x9e\xfa' \ + b'\xde\x45\x17\xcf' b'\x59\xc4\x67\xbd' \ + b'\x12\x70\x69\xbb' def testPackRequest0(self): @@ -2277,12 +2277,12 @@ def setUp(self): 'drawable': 183912361, 'gc': 1546366910, } - self.req_bin_0 = '\x44\x00\x0c\x00' '\xa9\x47\xf6\x0a' \ - '\xbe\xaf\x2b\x5c' '\x81\xe9\x01\x8b' \ - '\xd0\xe1\x2f\x3f' '\x05\xbb\x83\xcd' \ - '\x22\xb0\xa5\x83' '\xfe\xd9\x5e\x2f' \ - '\xf0\x9a\x53\xe5' '\x39\xab\xcd\xef' \ - '\xcd\xb3\x72\x47' '\x4a\x81\x68\xf8' + self.req_bin_0 = b'\x44\x00\x0c\x00' b'\xa9\x47\xf6\x0a' \ + b'\xbe\xaf\x2b\x5c' b'\x81\xe9\x01\x8b' \ + b'\xd0\xe1\x2f\x3f' b'\x05\xbb\x83\xcd' \ + b'\x22\xb0\xa5\x83' b'\xfe\xd9\x5e\x2f' \ + b'\xf0\x9a\x53\xe5' b'\x39\xab\xcd\xef' \ + b'\xcd\xb3\x72\x47' b'\x4a\x81\x68\xf8' def testPackRequest0(self): @@ -2304,10 +2304,10 @@ def setUp(self): 'points': [{'y': -8118, 'x': -16883}, {'y': -11768, 'x': -10315}, {'y': -6988, 'x': -16810}], 'shape': 2, } - self.req_bin_0 = '\x45\x00\x07\x00' '\x42\x14\xea\x0b' \ - '\x9b\x0c\x5e\x1c' '\x02\x00\x00\x00' \ - '\x0d\xbe\x4a\xe0' '\xb5\xd7\x08\xd2' \ - '\x56\xbe\xb4\xe4' + self.req_bin_0 = b'\x45\x00\x07\x00' b'\x42\x14\xea\x0b' \ + b'\x9b\x0c\x5e\x1c' b'\x02\x00\x00\x00' \ + b'\x0d\xbe\x4a\xe0' b'\xb5\xd7\x08\xd2' \ + b'\x56\xbe\xb4\xe4' def testPackRequest0(self): @@ -2327,10 +2327,10 @@ def setUp(self): 'gc': 259164168, 'rectangles': [{'y': -17381, 'x': -13860, 'height': 28032, 'width': 34914}, {'y': -22013, 'x': -8516, 'height': 17941, 'width': 46138}], } - self.req_bin_0 = '\x46\x00\x07\x00' '\x87\xbe\x2e\x20' \ - '\x08\x88\x72\x0f' '\xdc\xc9\x1b\xbc' \ - '\x62\x88\x80\x6d' '\xbc\xde\x03\xaa' \ - '\x3a\xb4\x15\x46' + self.req_bin_0 = b'\x46\x00\x07\x00' b'\x87\xbe\x2e\x20' \ + b'\x08\x88\x72\x0f' b'\xdc\xc9\x1b\xbc' \ + b'\x62\x88\x80\x6d' b'\xbc\xde\x03\xaa' \ + b'\x3a\xb4\x15\x46' def testPackRequest0(self): @@ -2350,9 +2350,9 @@ def setUp(self): 'drawable': 1039842351, 'gc': 1556052490, } - self.req_bin_0 = '\x47\x00\x06\x00' '\x2f\xbc\xfa\x3d' \ - '\x0a\x7a\xbf\x5c' '\x75\x98\x2f\x8f' \ - '\xa5\x89\x5b\xc3' '\x83\x97\x7b\x9b' + self.req_bin_0 = b'\x47\x00\x06\x00' b'\x2f\xbc\xfa\x3d' \ + b'\x0a\x7a\xbf\x5c' b'\x75\x98\x2f\x8f' \ + b'\xa5\x89\x5b\xc3' b'\x83\x97\x7b\x9b' def testPackRequest0(self): @@ -2379,11 +2379,11 @@ def setUp(self): 'left_pad': 129, 'width': 6818, } - self.req_bin_0 = '\x48\x02\x09\x00' '\xba\xc6\x27\x43' \ - '\xbc\x04\x3a\x24' '\xa2\x1a\x7f\x32' \ - '\xe4\x9c\xca\x96' '\x81\xc4\x00\x00' \ - '\x62\x69\x74\x20' '\x6d\x61\x70\x20' \ - '\x64\x61\x74\x61' + self.req_bin_0 = b'\x48\x02\x09\x00' b'\xba\xc6\x27\x43' \ + b'\xbc\x04\x3a\x24' b'\xa2\x1a\x7f\x32' \ + b'\xe4\x9c\xca\x96' b'\x81\xc4\x00\x00' \ + b'\x62\x69\x74\x20' b'\x6d\x61\x70\x20' \ + b'\x64\x61\x74\x61' def testPackRequest0(self): @@ -2407,9 +2407,9 @@ def setUp(self): 'x': -14777, 'y': -10093, } - self.req_bin_0 = '\x49\x01\x05\x00' '\xd4\xb8\xb5\x7c' \ - '\x47\xc6\x93\xd8' '\x33\x21\x75\xde' \ - '\x46\x9f\xd5\x3e' + self.req_bin_0 = b'\x49\x01\x05\x00' b'\xd4\xb8\xb5\x7c' \ + b'\x47\xc6\x93\xd8' b'\x33\x21\x75\xde' \ + b'\x46\x9f\xd5\x3e' self.reply_args_0 = { 'data': 'this is real ly imag e b-map', @@ -2417,14 +2417,14 @@ def setUp(self): 'sequence_number': 37730, 'visual': 1008057036, } - self.reply_bin_0 = '\x01\xef\x62\x93' '\x07\x00\x00\x00' \ - '\xcc\xba\x15\x3c' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x74\x68\x69\x73' '\x20\x69\x73\x20' \ - '\x72\x65\x61\x6c' '\x20\x6c\x79\x20' \ - '\x69\x6d\x61\x67' '\x20\x65\x20\x62' \ - '\x2d\x6d\x61\x70' + self.reply_bin_0 = b'\x01\xef\x62\x93' b'\x07\x00\x00\x00' \ + b'\xcc\xba\x15\x3c' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x74\x68\x69\x73' b'\x20\x69\x73\x20' \ + b'\x72\x65\x61\x6c' b'\x20\x6c\x79\x20' \ + b'\x69\x6d\x61\x67' b'\x20\x65\x20\x62' \ + b'\x2d\x6d\x61\x70' def testPackRequest0(self): @@ -2455,10 +2455,10 @@ def setUp(self): 'x': -31098, 'y': -2172, } - self.req_bin_0 = '\x4a\x00\x08\x00' '\x52\xd7\x61\x38' \ - '\x5c\x0b\x9a\x17' '\x86\x86\x84\xf7' \ - '\x03\x02\x7a\x6f' '\x6f\xff\x01\x02' \ - '\x03\x04\x02\x00' '\x69\x65\x00\x00' + self.req_bin_0 = b'\x4a\x00\x08\x00' b'\x52\xd7\x61\x38' \ + b'\x5c\x0b\x9a\x17' b'\x86\x86\x84\xf7' \ + b'\x03\x02\x7a\x6f' b'\x6f\xff\x01\x02' \ + b'\x03\x04\x02\x00' b'\x69\x65\x00\x00' def testPackRequest0(self): @@ -2480,10 +2480,10 @@ def setUp(self): 'x': -19740, 'y': -30360, } - self.req_bin_0 = '\x4b\x00\x07\x00' '\x94\xc0\x26\x3d' \ - '\x6a\x43\x3b\x69' '\xe4\xb2\x68\x89' \ - '\x02\x02\x10\x23' '\x00\x12\xff\x01' \ - '\x02\x03\x04\x00' + self.req_bin_0 = b'\x4b\x00\x07\x00' b'\x94\xc0\x26\x3d' \ + b'\x6a\x43\x3b\x69' b'\xe4\xb2\x68\x89' \ + b'\x02\x02\x10\x23' b'\x00\x12\xff\x01' \ + b'\x02\x03\x04\x00' def testPackRequest0(self): @@ -2505,9 +2505,9 @@ def setUp(self): 'x': -27918, 'y': -14469, } - self.req_bin_0 = '\x4c\x06\x06\x00' '\x26\x0c\x92\x50' \ - '\xc9\x9b\xdd\x06' '\xf2\x92\x7b\xc7' \ - '\x73\x68\x6f\x77' '\x6d\x65\x00\x00' + self.req_bin_0 = b'\x4c\x06\x06\x00' b'\x26\x0c\x92\x50' \ + b'\xc9\x9b\xdd\x06' b'\xf2\x92\x7b\xc7' \ + b'\x73\x68\x6f\x77' b'\x6d\x65\x00\x00' def testPackRequest0(self): @@ -2529,10 +2529,10 @@ def setUp(self): 'x': -28917, 'y': -7914, } - self.req_bin_0 = '\x4d\x08\x08\x00' '\x38\xc7\xe4\x26' \ - '\x11\xb7\x38\x7f' '\x0b\x8f\x16\xe1' \ - '\x00\x73\x00\x68' '\x00\x6f\x00\x77' \ - '\x00\x6d\x00\x6f' '\x00\x72\x00\x65' + self.req_bin_0 = b'\x4d\x08\x08\x00' b'\x38\xc7\xe4\x26' \ + b'\x11\xb7\x38\x7f' b'\x0b\x8f\x16\xe1' \ + b'\x00\x73\x00\x68' b'\x00\x6f\x00\x77' \ + b'\x00\x6d\x00\x6f' b'\x00\x72\x00\x65' def testPackRequest0(self): @@ -2553,8 +2553,8 @@ def setUp(self): 'visual': 1122247262, 'window': 484710181, } - self.req_bin_0 = '\x4e\x01\x04\x00' '\x6b\x34\x37\x65' \ - '\x25\x17\xe4\x1c' '\x5e\x22\xe4\x42' + self.req_bin_0 = b'\x4e\x01\x04\x00' b'\x6b\x34\x37\x65' \ + b'\x25\x17\xe4\x1c' b'\x5e\x22\xe4\x42' def testPackRequest0(self): @@ -2572,7 +2572,7 @@ def setUp(self): self.req_args_0 = { 'cmap': 967508457, } - self.req_bin_0 = '\x4f\x00\x02\x00' '\xe9\x01\xab\x39' + self.req_bin_0 = b'\x4f\x00\x02\x00' b'\xe9\x01\xab\x39' def testPackRequest0(self): @@ -2591,8 +2591,8 @@ def setUp(self): 'mid': 950772638, 'src_cmap': 1847203012, } - self.req_bin_0 = '\x50\x00\x03\x00' '\x9e\xa3\xab\x38' \ - '\xc4\x14\x1a\x6e' + self.req_bin_0 = b'\x50\x00\x03\x00' b'\x9e\xa3\xab\x38' \ + b'\xc4\x14\x1a\x6e' def testPackRequest0(self): @@ -2610,7 +2610,7 @@ def setUp(self): self.req_args_0 = { 'cmap': 2126076595, } - self.req_bin_0 = '\x51\x00\x02\x00' '\xb3\x5a\xb9\x7e' + self.req_bin_0 = b'\x51\x00\x02\x00' b'\xb3\x5a\xb9\x7e' def testPackRequest0(self): @@ -2628,7 +2628,7 @@ def setUp(self): self.req_args_0 = { 'cmap': 655844603, } - self.req_bin_0 = '\x52\x00\x02\x00' '\xfb\x64\x17\x27' + self.req_bin_0 = b'\x52\x00\x02\x00' b'\xfb\x64\x17\x27' def testPackRequest0(self): @@ -2646,17 +2646,17 @@ def setUp(self): self.req_args_0 = { 'window': 1333670852, } - self.req_bin_0 = '\x53\x00\x02\x00' '\xc4\x33\x7e\x4f' + self.req_bin_0 = b'\x53\x00\x02\x00' b'\xc4\x33\x7e\x4f' self.reply_args_0 = { 'cmaps': [1309197997, 1589346714], 'sequence_number': 62114, } - self.reply_bin_0 = '\x01\x00\xa2\xf2' '\x02\x00\x00\x00' \ - '\x02\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\xad\xc6\x08\x4e' '\x9a\x81\xbb\x5e' + self.reply_bin_0 = b'\x01\x00\xa2\xf2' b'\x02\x00\x00\x00' \ + b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\xad\xc6\x08\x4e' b'\x9a\x81\xbb\x5e' def testPackRequest0(self): @@ -2686,8 +2686,8 @@ def setUp(self): 'green': 43368, 'red': 14031, } - self.req_bin_0 = '\x54\x00\x04\x00' '\x18\x96\x99\x1a' \ - '\xcf\x36\x68\xa9' '\x0c\x29\x00\x00' + self.req_bin_0 = b'\x54\x00\x04\x00' b'\x18\x96\x99\x1a' \ + b'\xcf\x36\x68\xa9' b'\x0c\x29\x00\x00' self.reply_args_0 = { 'blue': 29664, @@ -2696,10 +2696,10 @@ def setUp(self): 'red': 5156, 'sequence_number': 11602, } - self.reply_bin_0 = '\x01\x00\x52\x2d' '\x00\x00\x00\x00' \ - '\x24\x14\xae\x01' '\xe0\x73\x00\x00' \ - '\x52\x69\x02\x4c' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\x52\x2d' b'\x00\x00\x00\x00' \ + b'\x24\x14\xae\x01' b'\xe0\x73\x00\x00' \ + b'\x52\x69\x02\x4c' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -2727,9 +2727,9 @@ def setUp(self): 'cmap': 625521008, 'name': 'octarin', } - self.req_bin_0 = '\x55\x00\x05\x00' '\x70\xb1\x48\x25' \ - '\x07\x00\x00\x00' '\x6f\x63\x74\x61' \ - '\x72\x69\x6e\x00' + self.req_bin_0 = b'\x55\x00\x05\x00' b'\x70\xb1\x48\x25' \ + b'\x07\x00\x00\x00' b'\x6f\x63\x74\x61' \ + b'\x72\x69\x6e\x00' self.reply_args_0 = { 'exact_blue': 45128, @@ -2741,10 +2741,10 @@ def setUp(self): 'screen_red': 60568, 'sequence_number': 15366, } - self.reply_bin_0 = '\x01\x00\x06\x3c' '\x00\x00\x00\x00' \ - '\x58\xd2\x7d\x5a' '\x43\xb4\xc7\x74' \ - '\x48\xb0\x98\xec' '\xe5\xc9\x63\xa0' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\x06\x3c' b'\x00\x00\x00\x00' \ + b'\x58\xd2\x7d\x5a' b'\x43\xb4\xc7\x74' \ + b'\x48\xb0\x98\xec' b'\xe5\xc9\x63\xa0' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -2774,38 +2774,38 @@ def setUp(self): 'contiguous': 1, 'planes': 35805, } - self.req_bin_0 = '\x56\x01\x03\x00' '\xad\x83\x82\x77' \ - '\x69\x6d\xdd\x8b' + self.req_bin_0 = b'\x56\x01\x03\x00' b'\xad\x83\x82\x77' \ + b'\x69\x6d\xdd\x8b' self.reply_args_0 = { 'masks': [927811713, 692224741, 537710104], 'pixels': [1390808070, 1950804725, 1775188259, 153412312, 356371138, 660636713, 1608390912, 1222391062, 619833140, 267104833, 1478945126, 1502686323, 2024385568, 1074788553, 1060450333, 172807825, 85663305], 'sequence_number': 6217, } - self.reply_bin_0 = '\x01\x00\x49\x18' '\x14\x00\x00\x00' \ - '\x11\x00\x03\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x06\x0c\xe6\x52' '\xf5\xea\x46\x74' \ - '\x23\x39\xcf\x69' '\xd8\xe2\x24\x09' \ - '\xc2\xca\x3d\x15' '\x29\x84\x60\x27' \ - '\x00\x19\xde\x5f' '\x16\x35\xdc\x48' \ - '\x34\xe7\xf1\x24' '\x41\xb2\xeb\x0f' \ - '\x66\xe9\x26\x58' '\x73\x2c\x91\x59' \ - '\x20\xac\xa9\x78' '\xc9\xf8\x0f\x40' \ - '\x1d\x30\x35\x3f' '\x91\xd6\x4c\x0a' \ - '\x49\x1e\x1b\x05' '\x81\x48\x4d\x37' \ - '\xe5\x82\x42\x29' '\x18\xce\x0c\x20' + self.reply_bin_0 = b'\x01\x00\x49\x18' b'\x14\x00\x00\x00' \ + b'\x11\x00\x03\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x06\x0c\xe6\x52' b'\xf5\xea\x46\x74' \ + b'\x23\x39\xcf\x69' b'\xd8\xe2\x24\x09' \ + b'\xc2\xca\x3d\x15' b'\x29\x84\x60\x27' \ + b'\x00\x19\xde\x5f' b'\x16\x35\xdc\x48' \ + b'\x34\xe7\xf1\x24' b'\x41\xb2\xeb\x0f' \ + b'\x66\xe9\x26\x58' b'\x73\x2c\x91\x59' \ + b'\x20\xac\xa9\x78' b'\xc9\xf8\x0f\x40' \ + b'\x1d\x30\x35\x3f' b'\x91\xd6\x4c\x0a' \ + b'\x49\x1e\x1b\x05' b'\x81\x48\x4d\x37' \ + b'\xe5\x82\x42\x29' b'\x18\xce\x0c\x20' self.reply_args_1 = { 'masks': [], 'pixels': [], 'sequence_number': 63049, } - self.reply_bin_1 = '\x01\x00\x49\xf6' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_1 = b'\x01\x00\x49\xf6' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -2846,8 +2846,8 @@ def setUp(self): 'green': 44142, 'red': 65508, } - self.req_bin_0 = '\x57\x01\x04\x00' '\x98\x8c\xa0\x49' \ - '\x73\xf3\xe4\xff' '\x6e\xac\xb9\x45' + self.req_bin_0 = b'\x57\x01\x04\x00' b'\x98\x8c\xa0\x49' \ + b'\x73\xf3\xe4\xff' b'\x6e\xac\xb9\x45' self.reply_args_0 = { 'blue_mask': 1363213739, @@ -2856,12 +2856,12 @@ def setUp(self): 'red_mask': 389798617, 'sequence_number': 60057, } - self.reply_bin_0 = '\x01\x00\x99\xea' '\x04\x00\x00\x00' \ - '\x04\x00\x00\x00' '\xd9\xda\x3b\x17' \ - '\xee\x7e\xec\x4a' '\xab\xfd\x40\x51' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x6f\x45\x27\x05' '\x27\xa9\xcd\x60' \ - '\x85\xe6\x39\x3c' '\xed\x02\x65\x53' + self.reply_bin_0 = b'\x01\x00\x99\xea' b'\x04\x00\x00\x00' \ + b'\x04\x00\x00\x00' b'\xd9\xda\x3b\x17' \ + b'\xee\x7e\xec\x4a' b'\xab\xfd\x40\x51' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x6f\x45\x27\x05' b'\x27\xa9\xcd\x60' \ + b'\x85\xe6\x39\x3c' b'\xed\x02\x65\x53' def testPackRequest0(self): @@ -2890,16 +2890,16 @@ def setUp(self): 'pixels': [1056006429, 196001131, 747283410, 715818017, 1439122371, 1841977117, 708291896, 1489672946, 618989649, 2029791261, 1747131973, 1181352956, 976766929, 675465375, 694269519, 2083457789, 867998373], 'plane_mask': 2121970633, } - self.req_bin_0 = '\x58\x00\x14\x00' '\x80\xc6\xde\x41' \ - '\xc9\xb3\x7a\x7e' '\x1d\x61\xf1\x3e' \ - '\x6b\xbd\xae\x0b' '\xd2\xa3\x8a\x2c' \ - '\x21\x84\xaa\x2a' '\xc3\x43\xc7\x55' \ - '\x1d\x57\xca\x6d' '\x38\xad\x37\x2a' \ - '\xf2\x9a\xca\x58' '\x51\x08\xe5\x24' \ - '\x1d\x28\xfc\x78' '\x45\x1e\x23\x68' \ - '\xfc\x03\x6a\x46' '\xd1\x47\x38\x3a' \ - '\x9f\xc8\x42\x28' '\x4f\xb6\x61\x29' \ - '\xfd\x0a\x2f\x7c' '\xa5\x9a\xbc\x33' + self.req_bin_0 = b'\x58\x00\x14\x00' b'\x80\xc6\xde\x41' \ + b'\xc9\xb3\x7a\x7e' b'\x1d\x61\xf1\x3e' \ + b'\x6b\xbd\xae\x0b' b'\xd2\xa3\x8a\x2c' \ + b'\x21\x84\xaa\x2a' b'\xc3\x43\xc7\x55' \ + b'\x1d\x57\xca\x6d' b'\x38\xad\x37\x2a' \ + b'\xf2\x9a\xca\x58' b'\x51\x08\xe5\x24' \ + b'\x1d\x28\xfc\x78' b'\x45\x1e\x23\x68' \ + b'\xfc\x03\x6a\x46' b'\xd1\x47\x38\x3a' \ + b'\x9f\xc8\x42\x28' b'\x4f\xb6\x61\x29' \ + b'\xfd\x0a\x2f\x7c' b'\xa5\x9a\xbc\x33' def testPackRequest0(self): @@ -2918,13 +2918,13 @@ def setUp(self): 'cmap': 200224662, 'items': [{'blue': 12501, 'flags': 174, 'green': 27232, 'pixel': 1412337360, 'red': 35676}, {'blue': 13544, 'flags': 198, 'green': 49868, 'pixel': 1624465264, 'red': 41082}, {'blue': 8182, 'flags': 252, 'green': 45837, 'pixel': 1992166823, 'red': 28856}, {'blue': 36214, 'flags': 198, 'green': 10594, 'pixel': 1307567581, 'red': 15877}], } - self.req_bin_0 = '\x59\x00\x0e\x00' '\x96\x2f\xef\x0b' \ - '\xd0\x8e\x2e\x54' '\x5c\x8b\x60\x6a' \ - '\xd5\x30\xae\x00' '\x70\x5f\xd3\x60' \ - '\x7a\xa0\xcc\xc2' '\xe8\x34\xc6\x00' \ - '\xa7\x0d\xbe\x76' '\xb8\x70\x0d\xb3' \ - '\xf6\x1f\xfc\x00' '\xdd\xe5\xef\x4d' \ - '\x05\x3e\x62\x29' '\x76\x8d\xc6\x00' + self.req_bin_0 = b'\x59\x00\x0e\x00' b'\x96\x2f\xef\x0b' \ + b'\xd0\x8e\x2e\x54' b'\x5c\x8b\x60\x6a' \ + b'\xd5\x30\xae\x00' b'\x70\x5f\xd3\x60' \ + b'\x7a\xa0\xcc\xc2' b'\xe8\x34\xc6\x00' \ + b'\xa7\x0d\xbe\x76' b'\xb8\x70\x0d\xb3' \ + b'\xf6\x1f\xfc\x00' b'\xdd\xe5\xef\x4d' \ + b'\x05\x3e\x62\x29' b'\x76\x8d\xc6\x00' def testPackRequest0(self): @@ -2945,9 +2945,9 @@ def setUp(self): 'name': 'blue', 'pixel': 990987101, } - self.req_bin_0 = '\x5a\xff\x05\x00' '\x2b\xf9\xda\x74' \ - '\x5d\x43\x11\x3b' '\x04\x00\x00\x00' \ - '\x62\x6c\x75\x65' + self.req_bin_0 = b'\x5a\xff\x05\x00' b'\x2b\xf9\xda\x74' \ + b'\x5d\x43\x11\x3b' b'\x04\x00\x00\x00' \ + b'\x62\x6c\x75\x65' def testPackRequest0(self): @@ -2966,31 +2966,31 @@ def setUp(self): 'cmap': 523457697, 'pixels': [252314471, 1787024858, 1070286120, 1538912496, 1092826517, 587223111, 1792566854, 2105060613], } - self.req_bin_0 = '\x5b\x00\x0a\x00' '\xa1\x54\x33\x1f' \ - '\x67\x03\x0a\x0f' '\xda\xd5\x83\x6a' \ - '\x28\x45\xcb\x3f' '\xf0\xf0\xb9\x5b' \ - '\x95\x35\x23\x41' '\x47\x50\x00\x23' \ - '\x46\x66\xd8\x6a' '\x05\xad\x78\x7d' + self.req_bin_0 = b'\x5b\x00\x0a\x00' b'\xa1\x54\x33\x1f' \ + b'\x67\x03\x0a\x0f' b'\xda\xd5\x83\x6a' \ + b'\x28\x45\xcb\x3f' b'\xf0\xf0\xb9\x5b' \ + b'\x95\x35\x23\x41' b'\x47\x50\x00\x23' \ + b'\x46\x66\xd8\x6a' b'\x05\xad\x78\x7d' self.reply_args_0 = { 'colors': [{'blue': 33433, 'green': 60435, 'red': 25296}, {'blue': 18289, 'green': 56659, 'red': 57658}, {'blue': 61243, 'green': 27343, 'red': 51827}, {'blue': 18719, 'green': 53821, 'red': 33401}, {'blue': 65464, 'green': 38571, 'red': 19745}], 'sequence_number': 32219, } - self.reply_bin_0 = '\x01\x00\xdb\x7d' '\x0a\x00\x00\x00' \ - '\x05\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\xd0\x62\x13\xec' '\x99\x82\x00\x00' \ - '\x3a\xe1\x53\xdd' '\x71\x47\x00\x00' \ - '\x73\xca\xcf\x6a' '\x3b\xef\x00\x00' \ - '\x79\x82\x3d\xd2' '\x1f\x49\x00\x00' \ - '\x21\x4d\xab\x96' '\xb8\xff\x00\x00' + self.reply_bin_0 = b'\x01\x00\xdb\x7d' b'\x0a\x00\x00\x00' \ + b'\x05\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\xd0\x62\x13\xec' b'\x99\x82\x00\x00' \ + b'\x3a\xe1\x53\xdd' b'\x71\x47\x00\x00' \ + b'\x73\xca\xcf\x6a' b'\x3b\xef\x00\x00' \ + b'\x79\x82\x3d\xd2' b'\x1f\x49\x00\x00' \ + b'\x21\x4d\xab\x96' b'\xb8\xff\x00\x00' self.req_args_1 = { 'cmap': 1183862146, 'pixels': [], } - self.req_bin_1 = '\x5b\x00\x02\x00' '\x82\x4d\x90\x46' + self.req_bin_1 = b'\x5b\x00\x02\x00' b'\x82\x4d\x90\x46' def testPackRequest0(self): @@ -3027,9 +3027,9 @@ def setUp(self): 'cmap': 319162028, 'name': 'octarin', } - self.req_bin_0 = '\x5c\x00\x05\x00' '\xac\x06\x06\x13' \ - '\x07\x00\x00\x00' '\x6f\x63\x74\x61' \ - '\x72\x69\x6e\x00' + self.req_bin_0 = b'\x5c\x00\x05\x00' b'\xac\x06\x06\x13' \ + b'\x07\x00\x00\x00' b'\x6f\x63\x74\x61' \ + b'\x72\x69\x6e\x00' self.reply_args_0 = { 'exact_blue': 35731, @@ -3040,10 +3040,10 @@ def setUp(self): 'screen_red': 29980, 'sequence_number': 35414, } - self.reply_bin_0 = '\x01\x00\x56\x8a' '\x00\x00\x00\x00' \ - '\x01\x59\xbd\x8d' '\x93\x8b\x1c\x75' \ - '\x0d\x53\x1b\x31' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\x56\x8a' b'\x00\x00\x00\x00' \ + b'\x01\x59\xbd\x8d' b'\x93\x8b\x1c\x75' \ + b'\x0d\x53\x1b\x31' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -3080,10 +3080,10 @@ def setUp(self): 'x': 43581, 'y': 53834, } - self.req_bin_0 = '\x5d\x00\x08\x00' '\x53\xee\x47\x59' \ - '\xe4\x17\x31\x49' '\x02\x24\xe6\x1d' \ - '\xc3\xc6\x21\x0c' '\xe6\xbe\xd5\xb4' \ - '\xe8\xcf\x73\x63' '\x3d\xaa\x4a\xd2' + self.req_bin_0 = b'\x5d\x00\x08\x00' b'\x53\xee\x47\x59' \ + b'\xe4\x17\x31\x49' b'\x02\x24\xe6\x1d' \ + b'\xc3\xc6\x21\x0c' b'\xe6\xbe\xd5\xb4' \ + b'\xe8\xcf\x73\x63' b'\x3d\xaa\x4a\xd2' def testPackRequest0(self): @@ -3111,10 +3111,10 @@ def setUp(self): 'source': 1063743249, 'source_char': 33045, } - self.req_bin_0 = '\x5e\x00\x08\x00' '\xca\x77\x8b\x7d' \ - '\x11\x6f\x67\x3f' '\x87\x05\xbe\x04' \ - '\x15\x81\x7e\x97' '\xc6\xde\xeb\xdf' \ - '\x47\x71\x1e\x87' '\x84\x75\x39\xb9' + self.req_bin_0 = b'\x5e\x00\x08\x00' b'\xca\x77\x8b\x7d' \ + b'\x11\x6f\x67\x3f' b'\x87\x05\xbe\x04' \ + b'\x15\x81\x7e\x97' b'\xc6\xde\xeb\xdf' \ + b'\x47\x71\x1e\x87' b'\x84\x75\x39\xb9' def testPackRequest0(self): @@ -3132,7 +3132,7 @@ def setUp(self): self.req_args_0 = { 'cursor': 880461049, } - self.req_bin_0 = '\x5f\x00\x02\x00' '\xf9\xc4\x7a\x34' + self.req_bin_0 = b'\x5f\x00\x02\x00' b'\xf9\xc4\x7a\x34' def testPackRequest0(self): @@ -3156,9 +3156,9 @@ def setUp(self): 'fore_green': 30904, 'fore_red': 10332, } - self.req_bin_0 = '\x60\x00\x05\x00' '\x3f\x38\xd0\x53' \ - '\x5c\x28\xb8\x78' '\x25\xf8\x55\x57' \ - '\xa3\xb1\xb5\xa6' + self.req_bin_0 = b'\x60\x00\x05\x00' b'\x3f\x38\xd0\x53' \ + b'\x5c\x28\xb8\x78' b'\x25\xf8\x55\x57' \ + b'\xa3\xb1\xb5\xa6' def testPackRequest0(self): @@ -3179,18 +3179,18 @@ def setUp(self): 'item_class': 2, 'width': 56353, } - self.req_bin_0 = '\x61\x02\x03\x00' '\x26\xab\x19\x6d' \ - '\x21\xdc\xe7\x61' + self.req_bin_0 = b'\x61\x02\x03\x00' b'\x26\xab\x19\x6d' \ + b'\x21\xdc\xe7\x61' self.reply_args_0 = { 'height': 49829, 'sequence_number': 20927, 'width': 47173, } - self.reply_bin_0 = '\x01\x00\xbf\x51' '\x00\x00\x00\x00' \ - '\x45\xb8\xa5\xc2' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\xbf\x51' b'\x00\x00\x00\x00' \ + b'\x45\xb8\xa5\xc2' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -3217,8 +3217,8 @@ def setUp(self): self.req_args_0 = { 'name': 'XTRA', } - self.req_bin_0 = '\x62\x00\x03\x00' '\x04\x00\x00\x00' \ - '\x58\x54\x52\x41' + self.req_bin_0 = b'\x62\x00\x03\x00' b'\x04\x00\x00\x00' \ + b'\x58\x54\x52\x41' self.reply_args_0 = { 'first_error': 245, @@ -3227,10 +3227,10 @@ def setUp(self): 'present': 0, 'sequence_number': 57205, } - self.reply_bin_0 = '\x01\x00\x75\xdf' '\x00\x00\x00\x00' \ - '\x00\x88\xd0\xf5' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\x75\xdf' b'\x00\x00\x00\x00' \ + b'\x00\x88\xd0\xf5' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -3256,18 +3256,18 @@ class TestListExtensions(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x63\x00\x01\x00' + self.req_bin_0 = b'\x63\x00\x01\x00' self.reply_args_0 = { 'names': ['XTRA', 'XTRA-II'], 'sequence_number': 65367, } - self.reply_bin_0 = '\x01\x02\x57\xff' '\x04\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x04\x58\x54\x52' '\x41\x07\x58\x54' \ - '\x52\x41\x2d\x49' '\x49\x00\x00\x00' + self.reply_bin_0 = b'\x01\x02\x57\xff' b'\x04\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x04\x58\x54\x52' b'\x41\x07\x58\x54' \ + b'\x52\x41\x2d\x49' b'\x49\x00\x00\x00' def testPackRequest0(self): @@ -3295,37 +3295,37 @@ def setUp(self): 'first_keycode': 209, 'keysyms': [[1603668560, 931946639, 211405004], [1360963098, 1873849632, 952792434], [1490356148, 1940088399, 98764853], [1709705072, 630002501, 804965110], [312608755, 1140670982, 1215321258], [1701922610, 365037106, 169583241], [1870113797, 1330817882, 517178039], [1960285384, 307342963, 990311897], [545412183, 548309930, 20180830], [1727936374, 1935332499, 1455158296], [339250065, 948607486, 742096527], [1261800628, 1372110414, 911196506], [537081847, 1815276355, 427815247], [826122461, 1037681409, 509395365], [1228194629, 1234399220, 2131789930], [634003216, 2100119788, 1413537765], [589442127, 1215323309, 1472743195], [1599164158, 105321726, 1302248027], [1066713724, 1941658701, 614597260], [1715539042, 1303662156, 756603491]], } - self.req_bin_0 = '\x64\x14\x3e\x00' '\xd1\x03\x00\x00' \ - '\x50\x0a\x96\x5f' '\x8f\x60\x8c\x37' \ - '\xcc\xc8\x99\x0c' '\x1a\xa6\x1e\x51' \ - '\x20\xad\xb0\x6f' '\x72\x75\xca\x38' \ - '\xb4\x07\xd5\x58' '\x4f\x66\xa3\x73' \ - '\x35\x08\xe3\x05' '\x70\x07\xe8\x65' \ - '\x45\x13\x8d\x25' '\xf6\xca\xfa\x2f' \ - '\xf3\x07\xa2\x12' '\x06\x42\xfd\x43' \ - '\xaa\x54\x70\x48' '\x32\x47\x71\x65' \ - '\x32\x06\xc2\x15' '\x89\xa2\x1b\x0a' \ - '\x05\xac\x77\x6f' '\x5a\xab\x52\x4f' \ - '\xb7\x82\xd3\x1e' '\xc8\x94\xd7\x74' \ - '\x73\xae\x51\x12' '\xd9\xf5\x06\x3b' \ - '\x57\x54\x82\x20' '\xaa\x8b\xae\x20' \ - '\x5e\xef\x33\x01' '\x76\x37\xfe\x66' \ - '\x93\xd4\x5a\x73' '\x18\xf4\xbb\x56' \ - '\x91\x8b\x38\x14' '\xfe\x99\x8a\x38' \ - '\x8f\x7e\x3b\x2c' '\xb4\x8c\x35\x4b' \ - '\x4e\xbe\xc8\x51' '\x5a\xc1\x4f\x36' \ - '\xf7\x37\x03\x20' '\x43\xeb\x32\x6c' \ - '\x4f\xf1\x7f\x19' '\xdd\xa0\x3d\x31' \ - '\x01\xc3\xd9\x3d' '\xa5\xc1\x5c\x1e' \ - '\x45\xc3\x34\x49' '\xf4\x6f\x93\x49' \ - '\x6a\x88\x10\x7f' '\x10\x1f\xca\x25' \ - '\xec\x48\x2d\x7d' '\xe5\xdf\x40\x54' \ - '\x4f\x2c\x22\x23' '\xad\x5c\x70\x48' \ - '\x1b\x47\xc8\x57' '\xfe\x4e\x51\x5f' \ - '\xfe\x14\x47\x06' '\x5b\xba\x9e\x4d' \ - '\x7c\xc2\x94\x3f' '\x4d\x5c\xbb\x73' \ - '\x8c\x02\xa2\x24' '\x62\x0c\x41\x66' \ - '\x4c\x4e\xb4\x4d' '\x63\xda\x18\x2d' + self.req_bin_0 = b'\x64\x14\x3e\x00' b'\xd1\x03\x00\x00' \ + b'\x50\x0a\x96\x5f' b'\x8f\x60\x8c\x37' \ + b'\xcc\xc8\x99\x0c' b'\x1a\xa6\x1e\x51' \ + b'\x20\xad\xb0\x6f' b'\x72\x75\xca\x38' \ + b'\xb4\x07\xd5\x58' b'\x4f\x66\xa3\x73' \ + b'\x35\x08\xe3\x05' b'\x70\x07\xe8\x65' \ + b'\x45\x13\x8d\x25' b'\xf6\xca\xfa\x2f' \ + b'\xf3\x07\xa2\x12' b'\x06\x42\xfd\x43' \ + b'\xaa\x54\x70\x48' b'\x32\x47\x71\x65' \ + b'\x32\x06\xc2\x15' b'\x89\xa2\x1b\x0a' \ + b'\x05\xac\x77\x6f' b'\x5a\xab\x52\x4f' \ + b'\xb7\x82\xd3\x1e' b'\xc8\x94\xd7\x74' \ + b'\x73\xae\x51\x12' b'\xd9\xf5\x06\x3b' \ + b'\x57\x54\x82\x20' b'\xaa\x8b\xae\x20' \ + b'\x5e\xef\x33\x01' b'\x76\x37\xfe\x66' \ + b'\x93\xd4\x5a\x73' b'\x18\xf4\xbb\x56' \ + b'\x91\x8b\x38\x14' b'\xfe\x99\x8a\x38' \ + b'\x8f\x7e\x3b\x2c' b'\xb4\x8c\x35\x4b' \ + b'\x4e\xbe\xc8\x51' b'\x5a\xc1\x4f\x36' \ + b'\xf7\x37\x03\x20' b'\x43\xeb\x32\x6c' \ + b'\x4f\xf1\x7f\x19' b'\xdd\xa0\x3d\x31' \ + b'\x01\xc3\xd9\x3d' b'\xa5\xc1\x5c\x1e' \ + b'\x45\xc3\x34\x49' b'\xf4\x6f\x93\x49' \ + b'\x6a\x88\x10\x7f' b'\x10\x1f\xca\x25' \ + b'\xec\x48\x2d\x7d' b'\xe5\xdf\x40\x54' \ + b'\x4f\x2c\x22\x23' b'\xad\x5c\x70\x48' \ + b'\x1b\x47\xc8\x57' b'\xfe\x4e\x51\x5f' \ + b'\xfe\x14\x47\x06' b'\x5b\xba\x9e\x4d' \ + b'\x7c\xc2\x94\x3f' b'\x4d\x5c\xbb\x73' \ + b'\x8c\x02\xa2\x24' b'\x62\x0c\x41\x66' \ + b'\x4c\x4e\xb4\x4d' b'\x63\xda\x18\x2d' def testPackRequest0(self): @@ -3344,46 +3344,46 @@ def setUp(self): 'count': 214, 'first_keycode': 207, } - self.req_bin_0 = '\x65\x00\x02\x00' '\xcf\xd6\x00\x00' + self.req_bin_0 = b'\x65\x00\x02\x00' b'\xcf\xd6\x00\x00' self.reply_args_0 = { 'keysyms': [[1548181899, 1415581578, 1800315249], [1349152528, 1940044681, 1388005887], [663428316, 946660592, 1244625269], [1572730625, 193559950, 633744868], [1605202933, 377184179, 283811004], [1158369341, 2086257988, 1139996791], [1961698339, 1783426369, 551839054], [1771007886, 1034760334, 1731920851], [1603223997, 727385468, 247325063], [2067797600, 302273387, 2075543394], [1847137865, 1555243546, 2104409941], [2077195964, 1727838808, 785495937], [1697976597, 29890084, 1152280257], [976645557, 1444887947, 1443840867], [1255333237, 1766127705, 2019261461], [232671482, 502128711, 53740025], [1898879870, 1205613172, 1965497096], [475382442, 135757562, 1769215894], [1952895082, 648948458, 876808673], [300168848, 2032081167, 653617967]], 'sequence_number': 32414, } - self.reply_bin_0 = '\x01\x03\x9e\x7e' '\x3c\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x8b\x61\x47\x5c' '\x8a\x0f\x60\x54' \ - '\x71\xa1\x4e\x6b' '\x10\x6f\x6a\x50' \ - '\x89\xbb\xa2\x73' '\xff\x49\xbb\x52' \ - '\xdc\x1c\x8b\x27' '\xf0\xe4\x6c\x38' \ - '\x75\x79\x2f\x4a' '\x01\xf7\xbd\x5d' \ - '\x8e\x7d\x89\x0b' '\xe4\x2d\xc6\x25' \ - '\xf5\x73\xad\x5f' '\xb3\x5f\x7b\x16' \ - '\xbc\x9c\xea\x10' '\x3d\x50\x0b\x45' \ - '\x44\xc5\x59\x7c' '\x77\xf8\xf2\x43' \ - '\x23\x24\xed\x74' '\x41\xed\x4c\x6a' \ - '\x4e\x65\xe4\x20' '\x8e\x6f\x8f\x69' \ - '\x8e\x30\xad\x3d' '\xd3\x03\x3b\x67' \ - '\xbd\x41\x8f\x5f' '\x7c\x05\x5b\x2b' \ - '\x87\xe1\xbd\x0e' '\x60\x16\x40\x7b' \ - '\x6b\x53\x04\x12' '\x62\x47\xb6\x7b' \ - '\x49\x16\x19\x6e' '\x1a\x22\xb3\x5c' \ - '\x55\xbf\x6e\x7d' '\xbc\x7e\xcf\x7b' \ - '\x58\xba\xfc\x66' '\x81\xb7\xd1\x2e' \ - '\x15\x11\x35\x65' '\x24\x16\xc8\x01' \ - '\xc1\x66\xae\x44' '\xb5\x6d\x36\x3a' \ - '\x8b\x3d\x1f\x56' '\x63\x43\x0f\x56' \ - '\x75\xdd\xd2\x4a' '\x59\xf8\x44\x69' \ - '\x15\x7c\x5b\x78' '\xfa\x48\xde\x0d' \ - '\x47\xe0\xed\x1d' '\xf9\x01\x34\x03' \ - '\x7e\x9b\x2e\x71' '\x74\x32\xdc\x47' \ - '\x08\x1b\x27\x75' '\xaa\xc2\x55\x1c' \ - '\xfa\x7e\x17\x08' '\x96\x17\x74\x69' \ - '\x6a\xd0\x66\x74' '\xea\x2a\xae\x26' \ - '\xe1\x09\x43\x34' '\x90\x36\xe4\x11' \ - '\x0f\x19\x1f\x79' '\x2f\x6b\xf5\x26' + self.reply_bin_0 = b'\x01\x03\x9e\x7e' b'\x3c\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x8b\x61\x47\x5c' b'\x8a\x0f\x60\x54' \ + b'\x71\xa1\x4e\x6b' b'\x10\x6f\x6a\x50' \ + b'\x89\xbb\xa2\x73' b'\xff\x49\xbb\x52' \ + b'\xdc\x1c\x8b\x27' b'\xf0\xe4\x6c\x38' \ + b'\x75\x79\x2f\x4a' b'\x01\xf7\xbd\x5d' \ + b'\x8e\x7d\x89\x0b' b'\xe4\x2d\xc6\x25' \ + b'\xf5\x73\xad\x5f' b'\xb3\x5f\x7b\x16' \ + b'\xbc\x9c\xea\x10' b'\x3d\x50\x0b\x45' \ + b'\x44\xc5\x59\x7c' b'\x77\xf8\xf2\x43' \ + b'\x23\x24\xed\x74' b'\x41\xed\x4c\x6a' \ + b'\x4e\x65\xe4\x20' b'\x8e\x6f\x8f\x69' \ + b'\x8e\x30\xad\x3d' b'\xd3\x03\x3b\x67' \ + b'\xbd\x41\x8f\x5f' b'\x7c\x05\x5b\x2b' \ + b'\x87\xe1\xbd\x0e' b'\x60\x16\x40\x7b' \ + b'\x6b\x53\x04\x12' b'\x62\x47\xb6\x7b' \ + b'\x49\x16\x19\x6e' b'\x1a\x22\xb3\x5c' \ + b'\x55\xbf\x6e\x7d' b'\xbc\x7e\xcf\x7b' \ + b'\x58\xba\xfc\x66' b'\x81\xb7\xd1\x2e' \ + b'\x15\x11\x35\x65' b'\x24\x16\xc8\x01' \ + b'\xc1\x66\xae\x44' b'\xb5\x6d\x36\x3a' \ + b'\x8b\x3d\x1f\x56' b'\x63\x43\x0f\x56' \ + b'\x75\xdd\xd2\x4a' b'\x59\xf8\x44\x69' \ + b'\x15\x7c\x5b\x78' b'\xfa\x48\xde\x0d' \ + b'\x47\xe0\xed\x1d' b'\xf9\x01\x34\x03' \ + b'\x7e\x9b\x2e\x71' b'\x74\x32\xdc\x47' \ + b'\x08\x1b\x27\x75' b'\xaa\xc2\x55\x1c' \ + b'\xfa\x7e\x17\x08' b'\x96\x17\x74\x69' \ + b'\x6a\xd0\x66\x74' b'\xea\x2a\xae\x26' \ + b'\xe1\x09\x43\x34' b'\x90\x36\xe4\x11' \ + b'\x0f\x19\x1f\x79' b'\x2f\x6b\xf5\x26' def testPackRequest0(self): @@ -3410,11 +3410,11 @@ def setUp(self): self.req_args_0 = { 'attrs': {'led': 213, 'auto_repeat_mode': 1, 'bell_pitch': -28323, 'bell_percent': -15, 'key_click_percent': -116, 'key': 249, 'bell_duration': -17904, 'led_mode': 1}, } - self.req_bin_0 = '\x66\x00\x0a\x00' '\xff\x00\x00\x00' \ - '\x8c\x00\x00\x00' '\xf1\x00\x00\x00' \ - '\x5d\x91\x00\x00' '\x10\xba\x00\x00' \ - '\xd5\x00\x00\x00' '\x01\x00\x00\x00' \ - '\xf9\x00\x00\x00' '\x01\x00\x00\x00' + self.req_bin_0 = b'\x66\x00\x0a\x00' b'\xff\x00\x00\x00' \ + b'\x8c\x00\x00\x00' b'\xf1\x00\x00\x00' \ + b'\x5d\x91\x00\x00' b'\x10\xba\x00\x00' \ + b'\xd5\x00\x00\x00' b'\x01\x00\x00\x00' \ + b'\xf9\x00\x00\x00' b'\x01\x00\x00\x00' def testPackRequest0(self): @@ -3431,7 +3431,7 @@ class TestGetKeyboardControl(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x67\x00\x01\x00' + self.req_bin_0 = b'\x67\x00\x01\x00' self.reply_args_0 = { 'auto_repeats': [223, 147, 181, 140, 190, 180, 249, 132, 175, 184, 249, 237, 140, 215, 197, 253, 173, 178, 152, 143, 236, 186, 212, 210, 204, 130, 228, 159, 144, 200, 136, 225], @@ -3443,13 +3443,13 @@ def setUp(self): 'led_mask': 1867665246, 'sequence_number': 14353, } - self.reply_bin_0 = '\x01\x00\x11\x38' '\x05\x00\x00\x00' \ - '\x5e\x4f\x52\x6f' '\xaa\x92\xa2\xe6' \ - '\xb9\x01\x00\x00' '\xdf\x93\xb5\x8c' \ - '\xbe\xb4\xf9\x84' '\xaf\xb8\xf9\xed' \ - '\x8c\xd7\xc5\xfd' '\xad\xb2\x98\x8f' \ - '\xec\xba\xd4\xd2' '\xcc\x82\xe4\x9f' \ - '\x90\xc8\x88\xe1' + self.reply_bin_0 = b'\x01\x00\x11\x38' b'\x05\x00\x00\x00' \ + b'\x5e\x4f\x52\x6f' b'\xaa\x92\xa2\xe6' \ + b'\xb9\x01\x00\x00' b'\xdf\x93\xb5\x8c' \ + b'\xbe\xb4\xf9\x84' b'\xaf\xb8\xf9\xed' \ + b'\x8c\xd7\xc5\xfd' b'\xad\xb2\x98\x8f' \ + b'\xec\xba\xd4\xd2' b'\xcc\x82\xe4\x9f' \ + b'\x90\xc8\x88\xe1' def testPackRequest0(self): @@ -3476,7 +3476,7 @@ def setUp(self): self.req_args_0 = { 'percent': -19, } - self.req_bin_0 = '\x68\xed\x01\x00' + self.req_bin_0 = b'\x68\xed\x01\x00' def testPackRequest0(self): @@ -3498,8 +3498,8 @@ def setUp(self): 'do_thresh': 1, 'threshold': -24619, } - self.req_bin_0 = '\x69\x00\x03\x00' '\x60\x92\x82\x90' \ - '\xd5\x9f\x00\x01' + self.req_bin_0 = b'\x69\x00\x03\x00' b'\x60\x92\x82\x90' \ + b'\xd5\x9f\x00\x01' def testPackRequest0(self): @@ -3516,7 +3516,7 @@ class TestGetPointerControl(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x6a\x00\x01\x00' + self.req_bin_0 = b'\x6a\x00\x01\x00' self.reply_args_0 = { 'accel_denom': 51826, @@ -3524,10 +3524,10 @@ def setUp(self): 'sequence_number': 1938, 'threshold': 15788, } - self.reply_bin_0 = '\x01\x00\x92\x07' '\x00\x00\x00\x00' \ - '\xca\x04\x72\xca' '\xac\x3d\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\x92\x07' b'\x00\x00\x00\x00' \ + b'\xca\x04\x72\xca' b'\xac\x3d\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -3557,8 +3557,8 @@ def setUp(self): 'prefer_blank': 0, 'timeout': -22242, } - self.req_bin_0 = '\x6b\x00\x03\x00' '\x1e\xa9\x21\x96' \ - '\x00\x02\x00\x00' + self.req_bin_0 = b'\x6b\x00\x03\x00' b'\x1e\xa9\x21\x96' \ + b'\x00\x02\x00\x00' def testPackRequest0(self): @@ -3575,7 +3575,7 @@ class TestGetScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x6c\x00\x01\x00' + self.req_bin_0 = b'\x6c\x00\x01\x00' self.reply_args_0 = { 'allow_exposures': 1, @@ -3584,10 +3584,10 @@ def setUp(self): 'sequence_number': 34598, 'timeout': 48933, } - self.reply_bin_0 = '\x01\x00\x26\x87' '\x00\x00\x00\x00' \ - '\x25\xbf\x71\x7a' '\x01\x01\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\x26\x87' b'\x00\x00\x00\x00' \ + b'\x25\xbf\x71\x7a' b'\x01\x01\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -3616,8 +3616,8 @@ def setUp(self): 'host_family': 2, 'mode': 1, } - self.req_bin_0 = '\x6d\x01\x03\x00' '\x02\x00\x04\x00' \ - '\x8d\xc0\xf9\x85' + self.req_bin_0 = b'\x6d\x01\x03\x00' b'\x02\x00\x04\x00' \ + b'\x8d\xc0\xf9\x85' def testPackRequest0(self): @@ -3634,19 +3634,19 @@ class TestListHosts(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x6e\x00\x01\x00' + self.req_bin_0 = b'\x6e\x00\x01\x00' self.reply_args_0 = { 'hosts': [{'name': [34, 23, 178, 12], 'family': 0}, {'name': [130, 236, 254, 15], 'family': 0}], 'mode': 1, 'sequence_number': 30157, } - self.reply_bin_0 = '\x01\x01\xcd\x75' '\x04\x00\x00\x00' \ - '\x02\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x04\x00' '\x22\x17\xb2\x0c' \ - '\x00\x00\x04\x00' '\x82\xec\xfe\x0f' + self.reply_bin_0 = b'\x01\x01\xcd\x75' b'\x04\x00\x00\x00' \ + b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x04\x00' b'\x22\x17\xb2\x0c' \ + b'\x00\x00\x04\x00' b'\x82\xec\xfe\x0f' def testPackRequest0(self): @@ -3673,7 +3673,7 @@ def setUp(self): self.req_args_0 = { 'mode': 1, } - self.req_bin_0 = '\x6f\x01\x01\x00' + self.req_bin_0 = b'\x6f\x01\x01\x00' def testPackRequest0(self): @@ -3691,7 +3691,7 @@ def setUp(self): self.req_args_0 = { 'mode': 0, } - self.req_bin_0 = '\x70\x00\x01\x00' + self.req_bin_0 = b'\x70\x00\x01\x00' def testPackRequest0(self): @@ -3709,7 +3709,7 @@ def setUp(self): self.req_args_0 = { 'resource': 1028639966, } - self.req_bin_0 = '\x71\x00\x02\x00' '\xde\xcc\x4f\x3d' + self.req_bin_0 = b'\x71\x00\x02\x00' b'\xde\xcc\x4f\x3d' def testPackRequest0(self): @@ -3729,14 +3729,14 @@ def setUp(self): 'properties': [862505702, 1473403724, 1052877752, 1953573572, 157880830, 173556470, 1306334440, 141112753, 590639874, 1359545959, 1177616073, 698374646], 'window': 2135947192, } - self.req_bin_0 = '\x72\x00\x0f\x00' '\xb8\xf7\x4f\x7f' \ - '\x0c\x00\x61\xc3' '\xe6\xca\x68\x33' \ - '\x4c\x5b\xd2\x57' '\xb8\xa3\xc1\x3e' \ - '\xc4\x2a\x71\x74' '\xfe\x11\x69\x09' \ - '\xf6\x42\x58\x0a' '\xe8\x14\xdd\x4d' \ - '\xb1\x35\x69\x08' '\x02\x73\x34\x23' \ - '\x67\x06\x09\x51' '\xc9\xfe\x30\x46' \ - '\xf6\x59\xa0\x29' + self.req_bin_0 = b'\x72\x00\x0f\x00' b'\xb8\xf7\x4f\x7f' \ + b'\x0c\x00\x61\xc3' b'\xe6\xca\x68\x33' \ + b'\x4c\x5b\xd2\x57' b'\xb8\xa3\xc1\x3e' \ + b'\xc4\x2a\x71\x74' b'\xfe\x11\x69\x09' \ + b'\xf6\x42\x58\x0a' b'\xe8\x14\xdd\x4d' \ + b'\xb1\x35\x69\x08' b'\x02\x73\x34\x23' \ + b'\x67\x06\x09\x51' b'\xc9\xfe\x30\x46' \ + b'\xf6\x59\xa0\x29' def testPackRequest0(self): @@ -3754,7 +3754,7 @@ def setUp(self): self.req_args_0 = { 'mode': 0, } - self.req_bin_0 = '\x73\x00\x01\x00' + self.req_bin_0 = b'\x73\x00\x01\x00' def testPackRequest0(self): @@ -3772,17 +3772,17 @@ def setUp(self): self.req_args_0 = { 'map': [205, 140, 217, 237, 211], } - self.req_bin_0 = '\x74\x05\x03\x00' '\xcd\x8c\xd9\xed' \ - '\xd3\x00\x00\x00' + self.req_bin_0 = b'\x74\x05\x03\x00' b'\xcd\x8c\xd9\xed' \ + b'\xd3\x00\x00\x00' self.reply_args_0 = { 'sequence_number': 47312, 'status': 226, } - self.reply_bin_0 = '\x01\xe2\xd0\xb8' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\xe2\xd0\xb8' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -3808,17 +3808,17 @@ class TestGetPointerMapping(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x75\x00\x01\x00' + self.req_bin_0 = b'\x75\x00\x01\x00' self.reply_args_0 = { 'map': [155, 185, 157, 171, 186], 'sequence_number': 27411, } - self.reply_bin_0 = '\x01\x05\x13\x6b' '\x02\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x9b\xb9\x9d\xab' '\xba\x00\x00\x00' + self.reply_bin_0 = b'\x01\x05\x13\x6b' b'\x02\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x9b\xb9\x9d\xab' b'\xba\x00\x00\x00' def testPackRequest0(self): @@ -3845,18 +3845,18 @@ def setUp(self): self.req_args_0 = { 'keycodes': [[24, 109], [170, 95], [39, 236], [17, 212], [23, 24], [189, 207], [142, 150], [143, 84]], } - self.req_bin_0 = '\x76\x02\x05\x00' '\x18\x6d\xaa\x5f' \ - '\x27\xec\x11\xd4' '\x17\x18\xbd\xcf' \ - '\x8e\x96\x8f\x54' + self.req_bin_0 = b'\x76\x02\x05\x00' b'\x18\x6d\xaa\x5f' \ + b'\x27\xec\x11\xd4' b'\x17\x18\xbd\xcf' \ + b'\x8e\x96\x8f\x54' self.reply_args_0 = { 'sequence_number': 23338, 'status': 143, } - self.reply_bin_0 = '\x01\x8f\x2a\x5b' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x8f\x2a\x5b' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -3882,18 +3882,18 @@ class TestGetModifierMapping(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x77\x00\x01\x00' + self.req_bin_0 = b'\x77\x00\x01\x00' self.reply_args_0 = { 'keycodes': [[170, 192], [222, 184], [247, 153], [90, 147], [54, 168], [57, 27], [216, 94], [195, 146]], 'sequence_number': 52951, } - self.reply_bin_0 = '\x01\x02\xd7\xce' '\x04\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\xaa\xc0\xde\xb8' '\xf7\x99\x5a\x93' \ - '\x36\xa8\x39\x1b' '\xd8\x5e\xc3\x92' + self.reply_bin_0 = b'\x01\x02\xd7\xce' b'\x04\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\xaa\xc0\xde\xb8' b'\xf7\x99\x5a\x93' \ + b'\x36\xa8\x39\x1b' b'\xd8\x5e\xc3\x92' def testPackRequest0(self): @@ -3919,7 +3919,7 @@ class TestNoOperation(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x7f\x00\x01\x00' + self.req_bin_0 = b'\x7f\x00\x01\x00' def testPackRequest0(self): From cdec88f26b345c76ecd007a7bdcd79d6e855cd2c Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 20:10:48 +0200 Subject: [PATCH 058/279] support: improve fix for combined Python 2 and 3 support --- Xlib/support/connect.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Xlib/support/connect.py b/Xlib/support/connect.py index a9ae2669..597335a3 100644 --- a/Xlib/support/connect.py +++ b/Xlib/support/connect.py @@ -17,8 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys -import os -import imp +import importlib # List the modules which contain the corresponding functions @@ -49,6 +48,10 @@ del _parts +def _relative_import(modname): + return importlib.import_module('..' + modname, __name__) + + def get_display(display): """dname, host, dno, screen = get_display(display) @@ -62,8 +65,7 @@ def get_display(display): """ modname = _display_mods.get(platform, _default_display_mod) - mod = imp.load_source(modname, os.path.join(os.path.dirname(__file__), modname + ".py")) - # mod = __import__(modname, globals()) + mod = _relative_import(modname) return mod.get_display(display) @@ -77,8 +79,7 @@ def get_socket(dname, host, dno): """ modname = _socket_mods.get(platform, _default_socket_mod) - mod = imp.load_source(modname, os.path.join(os.path.dirname(__file__), modname + ".py")) - #mod = __import__(modname, globals()) + mod = _relative_import(modname) return mod.get_socket(dname, host, dno) @@ -93,6 +94,5 @@ def get_auth(sock, dname, host, dno): """ modname = _auth_mods.get(platform, _default_auth_mod) - mod = imp.load_source(modname, os.path.join(os.path.dirname(__file__), modname + ".py")) - #mod = __import__(modname, globals()) + mod = _relative_import(modname) return mod.get_auth(sock, dname, host, dno) From 1f8f9e5bd7f6e66bf7cca1b6e4af8a2735a40774 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 21:04:56 +0200 Subject: [PATCH 059/279] setup: switch to setuptools --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 28eacf8a..f45315f3 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ # Distutils script for python-xlib -from distutils.core import setup +from setuptools import setup import sys if sys.version < '2.3.3': From ebb70c30c18605f4e891547616ca82213c405cec Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 21:05:04 +0200 Subject: [PATCH 060/279] setup: add 'six' requirements --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index f45315f3..e9344267 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,8 @@ author='Peter Liljenberg', author_email='petli@ctrl-c.liu.se', + install_requires=['six>=1.10.0'], + packages=[ 'Xlib', 'Xlib.ext', From 5355c452dd315c24196e644affd422204acd34bc Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 21:13:23 +0200 Subject: [PATCH 061/279] xauth: Python 3 support --- Xlib/xauth.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/xauth.py b/Xlib/xauth.py index dc58bcd7..4637e535 100644 --- a/Xlib/xauth.py +++ b/Xlib/xauth.py @@ -96,7 +96,7 @@ def __getitem__(self, i): return self.entries[i] def get_best_auth(self, family, address, dispno, - types = ( "MIT-MAGIC-COOKIE-1", )): + types = ( b"MIT-MAGIC-COOKIE-1", )): """Find an authentication entry matching FAMILY, ADDRESS and DISPNO. @@ -109,7 +109,7 @@ def get_best_auth(self, family, address, dispno, otherwise XNoAuthError is raised. """ - num = str(dispno) + num = str(dispno).encode() matches = {} From 8be5c0cd3c64e70f498021306f231e89d3414ef9 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 21:13:39 +0200 Subject: [PATCH 062/279] support/unix_connect: Python 3 support --- Xlib/support/unix_connect.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index c178e151..d2b6b610 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -106,10 +106,10 @@ def new_get_auth(sock, dname, host, dno): # Convert the prettyprinted IP number into 4-octet string. # Sometimes these modules are too damn smart... octets = sock.getpeername()[0].split('.') - addr = ''.join(map(lambda x: chr(int(x)), octets)) + addr = bytes(int(x) for x in octets) else: family = xauth.FamilyLocal - addr = socket.gethostname() + addr = socket.gethostname().encode() au = xauth.Xauthority() while 1: @@ -126,12 +126,12 @@ def new_get_auth(sock, dname, host, dno): family = xauth.FamilyLocal addr = socket.gethostname() else: - return '', '' + return b'', b'' def old_get_auth(sock, dname, host, dno): # Find authorization cookie - auth_name = auth_data = '' + auth_name = auth_data = b'' try: # We could parse .Xauthority, but xauth is simpler @@ -148,7 +148,7 @@ def old_get_auth(sock, dname, host, dno): if len(parts) == 3: auth_name = parts[1] hexauth = parts[2] - auth = '' + auth = b'' # Translate hexcode into binary for i in range(0, len(hexauth), 2): From b4a94dc897a3435bfecdc9408f9fea348ebab0de Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 21:14:08 +0200 Subject: [PATCH 063/279] protocol: Python 3 support --- Xlib/protocol/display.py | 22 +++++++++++++++++----- Xlib/protocol/rq.py | 22 +++++++++++++--------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index a4a6a6cf..c2a304d8 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -25,6 +25,9 @@ import errno import socket +# Python 2/3 compatibility. +from six import PY3, byte2int, indexbytes + # Xlib modules from .. import error from ..ext import ge @@ -35,6 +38,15 @@ from . import rq from . import event +if PY3: + def buffer(object, offset=None, size=None): + if offset is None: + offset = 0 + if size is None: + size = len(object)-offset + return memoryview(object)[offset:offset+size] + + class Display(object): resource_classes = {} extension_major_opcodes = {} @@ -84,8 +96,8 @@ def __init__(self, display = None): # Data used by the send-and-recieve loop self.sent_requests = [] self.recv_packet_len = 0 - self.data_send = '' - self.data_recv = '' + self.data_send = b'' + self.data_recv = b'' self.data_sent_bytes = 0 # Resource ID structures @@ -557,7 +569,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) self.close_internal('server') raise self.socket_error - self.data_recv = self.data_recv + bytes_recv + self.data_recv = bytes(self.data_recv) + bytes_recv gotreq = self.parse_response(request) # Otherwise return, allowing the calling thread to figure @@ -642,7 +654,7 @@ def parse_response(self, request): while 1: if self.data_recv: # Check the first byte to find out what kind of response it is - rtype = ord(self.data_recv[0]) + rtype = byte2int(self.data_recv) # Are we're waiting for additional data for the current packet? if self.recv_packet_len: @@ -681,7 +693,7 @@ def parse_response(self, request): def parse_error_response(self, request): # Code is second byte - code = ord(self.data_recv[1]) + code = indexbytes(self.data_recv, 1) # Fetch error class estruct = self.error_classes.get(code, error.XError) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index d2445956..51bd9efb 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -23,6 +23,9 @@ from array import array import types +# Python 2/3 compatibility. +from six import byte2int, indexbytes, string_types + # Xlib modules from .. import X from ..support import lock @@ -654,14 +657,15 @@ def pack_value(self, value): if fmt not in (8, 16, 32): raise BadDataError('Invalid property data format {0}'.format(fmt)) - if type(val) in [bytes, str]: + if isinstance(val, string_types): + val = val.encode() size = fmt // 8 vlen = len(val) if vlen % size: vlen = vlen - vlen % size - data = val[:vlen].encode() + data = val[:vlen] else: - data = val.encode() + data = val dlen = vlen // size @@ -836,10 +840,10 @@ def pack_value(self, value): def parse_binary_value(self, data, display, length, format): from . import event - estruct = display.event_classes.get(_to_ord(data[0]) & 0x7f, event.AnyEvent) + estruct = display.event_classes.get(byte2int(data) & 0x7f, event.AnyEvent) if type(estruct) == dict: # this etype refers to a set of sub-events with individual subcodes - estruct = estruct[_to_ord(data[1])] + estruct = estruct[indexbytes(data, 1)] return estruct(display = display, binarydata = data[:32]), data[32:] @@ -887,7 +891,7 @@ def pack_value(self, val): return (chr(len(val)) + val).encode() def parse_binary(self, data, display): - slen = _to_ord(data[0]) + 1 + slen = byte2int(data) + 1 return data[1:slen].decode(), data[slen:] Str = StrClass() @@ -1239,12 +1243,12 @@ def parse_binary_value(self, data, display, length, format): break # font change - if _to_ord(data[0]) == 255: - values.append(struct.unpack('>L', data[1:5].decode().encode())[0]) + if byte2int(data) == 255: + values.append(struct.unpack('>L', bytes(data[1:5]))[0]) data = data[5:] # skip null strings - elif _to_ord(data[0]) == 0 and _to_ord(data[1]) == 0: + elif byte2int(data) == 0 and indexbytes(data, 1) == 0: data = data[2:] # string with delta From 2d3cba9334a6427ccbdf616d9054a37c2df56e48 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 21:14:25 +0200 Subject: [PATCH 064/279] display: Python 3 support --- Xlib/display.py | 52 ++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/Xlib/display.py b/Xlib/display.py index 71a49d24..b6ce0702 100644 --- a/Xlib/display.py +++ b/Xlib/display.py @@ -19,6 +19,9 @@ # Python modules import types +# Python 2/3 compatibility. +from six import create_unbound_method + # Xlib modules from . import error from . import ext @@ -62,7 +65,7 @@ class _BaseDisplay(protocol_display.Display): # dealing with some ICCCM properties not defined in Xlib.Xatom def __init__(self, *args, **keys): - protocol_display.Display.__init__(*(self, ) + args, **keys) + protocol_display.Display.__init__(self, *args, **keys) self._atom_cache = {} def get_atom(self, atomname, only_if_exists=0): @@ -124,16 +127,11 @@ def __init__(self, display = None): # Finalize extensions by creating new classes - for type, dict in self.class_extension_dicts.items(): - origcls = self.display.resource_classes[type] - if hasattr(types, 'ClassType'): - self.display.resource_classes[type] = types.ClassType(origcls.__name__, - (origcls,), - dict) - else: - self.display.resource_classes[type] = types.new_class(origcls.__name__, - (origcls,), - dict) + for class_name, dictionary in self.class_extension_dicts.items(): + origcls = self.display.resource_classes[class_name] + self.display.resource_classes[class_name] = type(origcls.__name__, + (origcls,), + dictionary) # Problem: we have already created some objects without the # extensions: the screen roots and default colormaps. @@ -221,7 +219,7 @@ class directly, since any X extensions dynamically added by the def __getattr__(self, attr): try: function = self.display_extension_methods[attr] - return types.MethodType(function, self, self.__class__) + return types.MethodType(function, self) except KeyError: raise AttributeError(attr) @@ -276,19 +274,19 @@ def extension_add_method(self, object, name, function): self.display_extension_methods[name] = function else: - types_ = (object, ) + _resource_hierarchy.get(object, ()) - for type in types_: - cls = _resource_baseclasses[type] + class_list = (object, ) + _resource_hierarchy.get(object, ()) + for class_name in class_list: + cls = _resource_baseclasses[class_name] if hasattr(cls, name): - raise AssertionError('attempting to replace %s method: %s' % (type, name)) + raise AssertionError('attempting to replace %s method: %s' % (class_name, name)) - method = types.MethodType(function, None, cls) + method = create_unbound_method(function, cls) # Maybe should check extension overrides too try: - self.class_extension_dicts[type][name] = method + self.class_extension_dicts[class_name][name] = method except KeyError: - self.class_extension_dicts[type] = { name: method } + self.class_extension_dicts[class_name] = { name: method } def extension_add_event(self, code, evt, name = None): """extension_add_event(code, evt, [name]) @@ -302,12 +300,8 @@ def extension_add_event(self, code, evt, name = None): extension_event. """ - if hasattr(types, 'ClassType'): - newevt = types.ClassType(evt.__name__, evt.__bases__, - evt.__dict__.copy()) - else: - newevt = types.new_class(evt.__name__, evt.__bases__, - evt.__dict__.copy()) + newevt = type(evt.__name__, evt.__bases__, + evt.__dict__.copy()) newevt._code = code self.display.add_extension_event(code, newevt) @@ -330,12 +324,8 @@ def extension_add_subevent(self, code, subcode, evt, name = None): extension_event. """ - if hasattr(types, 'ClassType'): - newevt = types.ClassType(evt.__name__, evt.__bases__, - evt.__dict__.copy()) - else: - newevt = types.new_class(evt.__name__, evt.__bases__, - evt.__dict__.copy()) + newevt = type(evt.__name__, evt.__bases__, + evt.__dict__.copy()) newevt._code = code self.display.add_extension_event(code, newevt, subcode) From b4de67123dcd0323a8ba256664018bdd53744504 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 21:14:44 +0200 Subject: [PATCH 065/279] threaded: Python 3 support --- Xlib/threaded.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/threaded.py b/Xlib/threaded.py index 6e51d27b..4a84b55f 100644 --- a/Xlib/threaded.py +++ b/Xlib/threaded.py @@ -16,10 +16,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -import thread +from six.moves import _thread # We change the allocate_lock function in Xlib.support.lock to # return a basic Python lock, instead of the default dummy lock from Xlib.support import lock -lock.allocate_lock = thread.allocate_lock +lock.allocate_lock = _thread.allocate_lock From c805f235f4feaaf0632ed3ad5e601b9b806b220f Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 21:17:59 +0200 Subject: [PATCH 066/279] travis: fix build; six needs to be installed --- .travis.yml | 4 +++- requirements.txt | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 requirements.txt diff --git a/.travis.yml b/.travis.yml index 658931df..fe3a4055 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,9 @@ python: - "3.5" # command to install dependencies -install: pip install -r dev-requirements.txt +install: + - pip install -r requirements.txt + - pip install -r dev-requirements.txt before_script: - "export DISPLAY=:99.0" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..dde39334 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +six>=1.10.0 From 7a2dfb26aed58dc019ce62e8700e11712ccd2a55 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 21:29:41 +0200 Subject: [PATCH 067/279] examples: Python 3 support --- examples/childwin.py | 4 +++- examples/eventthread.py | 7 +++++-- examples/profilex.py | 9 +++++--- examples/record_demo.py | 19 ++++++++++------- examples/run_examples.py | 3 +++ examples/security.py | 11 ++++++---- examples/shapewin.py | 9 +++++--- examples/threadtest.py | 5 ++++- examples/xfixes.py | 13 +++++++----- examples/xinerama.py | 19 ++++++++++------- examples/xinput.py | 17 ++++++++------- examples/xlsatoms.py | 5 ++++- examples/xrandr.py | 45 +++++++++++++++++++++------------------- 13 files changed, 102 insertions(+), 64 deletions(-) diff --git a/examples/childwin.py b/examples/childwin.py index c308a2b6..75e49fcf 100755 --- a/examples/childwin.py +++ b/examples/childwin.py @@ -19,6 +19,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Python 2/3 compatibility. +from __future__ import print_function import sys import os @@ -127,7 +129,7 @@ def loop(self): # Button released, add or subtract elif e.type == X.ButtonRelease: if e.detail == 1: - print "Moving child window." + print("Moving child window.") self.childWindow.configure( x=e.event_x - self.childWidth // 2, y=e.event_y - self.childHeight // 2 diff --git a/examples/eventthread.py b/examples/eventthread.py index 7b92cd3a..2638354c 100755 --- a/examples/eventthread.py +++ b/examples/eventthread.py @@ -19,6 +19,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Python 2/3 compatibility. +from __future__ import print_function + import sys import os @@ -44,7 +47,7 @@ def __init__(self, display): def run(self): while True: event = self.display.next_event() - print 'event: %r' % event + print('event: %r' % event) def main(argv): @@ -60,7 +63,7 @@ def main(argv): # call in the thread. atom = display.intern_atom('_XROOTPMAP_ID', True) response = screen.root.get_property(atom, Xatom.PIXMAP, 0, 1) - print 'get_property response: %r' % response + print('get_property response: %r' % response) display.close() diff --git a/examples/profilex.py b/examples/profilex.py index 999e2f4d..e8361fd0 100755 --- a/examples/profilex.py +++ b/examples/profilex.py @@ -4,6 +4,9 @@ # the profile stats file to generate. +# Python 2/3 compatibility. +from __future__ import print_function + import sys import os @@ -19,9 +22,9 @@ def dostuff(): r = d.screen().root cm = d.screen().default_colormap - for i in xrange(0, 1000): + for i in range(0, 1000): if i % 50 == 0: - print 'Iteration', i + print('Iteration', i) r.delete_property(Xatom.WM_NORMAL_HINTS) r.delete_property(Xatom.WM_NORMAL_HINTS) @@ -40,4 +43,4 @@ def main(filename): if len(sys.argv) == 2: main(sys.argv[1]) else: - print sys.argv[0], "" + print(sys.argv[0], "") diff --git a/examples/record_demo.py b/examples/record_demo.py index 928a0706..55e13080 100755 --- a/examples/record_demo.py +++ b/examples/record_demo.py @@ -22,6 +22,9 @@ # Not very much unlike the xmacrorec2 program in the xmacro package. +# Python 2/3 compatibility. +from __future__ import print_function + import sys import os @@ -45,7 +48,7 @@ def record_callback(reply): if reply.category != record.FromServer: return if reply.client_swapped: - print "* received swapped protocol data, cowardly ignored" + print("* received swapped protocol data, cowardly ignored") return if not len(reply.data) or ord(reply.data[0]) < 2: # not an event @@ -60,28 +63,28 @@ def record_callback(reply): keysym = local_dpy.keycode_to_keysym(event.detail, 0) if not keysym: - print "KeyCode%s" % pr, event.detail + print("KeyCode%s" % pr, event.detail) else: - print "KeyStr%s" % pr, lookup_keysym(keysym) + print("KeyStr%s" % pr, lookup_keysym(keysym)) if event.type == X.KeyPress and keysym == XK.XK_Escape: local_dpy.record_disable_context(ctx) local_dpy.flush() return elif event.type == X.ButtonPress: - print "ButtonPress", event.detail + print("ButtonPress", event.detail) elif event.type == X.ButtonRelease: - print "ButtonRelease", event.detail + print("ButtonRelease", event.detail) elif event.type == X.MotionNotify: - print "MotionNotify", event.root_x, event.root_y + print("MotionNotify", event.root_x, event.root_y) # Check if the extension is present if not record_dpy.has_extension("RECORD"): - print "RECORD extension not found" + print("RECORD extension not found") sys.exit(1) r = record_dpy.record_get_version(0, 0) -print "RECORD extension version %d.%d" % (r.major_version, r.minor_version) +print("RECORD extension version %d.%d" % (r.major_version, r.minor_version)) # Create a recording context; we only want key and mouse events ctx = record_dpy.record_create_context( diff --git a/examples/run_examples.py b/examples/run_examples.py index 8de4d7d7..16a06883 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -24,6 +24,9 @@ # Suite 330, # Boston, MA 02111-1307 USA +# Python 2/3 compatibility. +from __future__ import print_function + import sys import os import subprocess diff --git a/examples/security.py b/examples/security.py index 2a2f8aec..34042258 100755 --- a/examples/security.py +++ b/examples/security.py @@ -19,6 +19,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Python 2/3 compatibility. +from __future__ import print_function + import sys, os from optparse import OptionParser @@ -51,14 +54,14 @@ def main(argv): if not display.has_extension('SECURITY'): if display.query_extension('SECURITY') is None: - print >>sys.stderr, 'SECURITY extension not supported' + print('SECURITY extension not supported', file=sys.stderr) return 1 security_version = display.security_query_version() - print >>sys.stderr, 'Found SECURITY version %s.%s' % ( + print('SECURITY version %s.%s' % ( security_version.major_version, security_version.minor_version, - ) + ), file=sys.stderr) if opts.generate: kwargs = {} @@ -67,7 +70,7 @@ def main(argv): elif opts.untrusted: kwargs['trust_level'] = security.SecurityClientUntrusted reply = display.security_generate_authorization(opts.proto, **kwargs) - print reply.authid + print(reply.authid) elif opts.revoke: for arg in args: diff --git a/examples/shapewin.py b/examples/shapewin.py index a01c5a03..d5507ff7 100755 --- a/examples/shapewin.py +++ b/examples/shapewin.py @@ -19,6 +19,9 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Python 2/3 compatibility. +from __future__ import print_function + import sys import os @@ -39,9 +42,9 @@ def __init__(self, display): % sys.argv[1]) sys.exit(1) - # print version + # print(version) r = self.d.shape_query_version() - print 'SHAPE version %d.%d' % (r.major_version, r.minor_version) + print('SHAPE version %d.%d' % (r.major_version, r.minor_version)) # Find which screen to open the window on @@ -163,7 +166,7 @@ def loop(self): # Shape has changed elif e.type == self.d.extension_event.ShapeNotify: - print 'Shape change' + print('Shape change') # Somebody wants to tell us something elif e.type == X.ClientMessage: diff --git a/examples/threadtest.py b/examples/threadtest.py index 7a174f7d..9732f575 100755 --- a/examples/threadtest.py +++ b/examples/threadtest.py @@ -1,5 +1,8 @@ #!/usr/bin/python +# Python 2/3 compatibility. +from __future__ import print_function + import sys import os @@ -17,7 +20,7 @@ def redraw(win, gc): def blink(display, win, gc, cols): while 1: time.sleep(2) - print 'Changing color', cols[0] + print('Changing color', cols[0]) gc.change(foreground = cols[0]) cols = (cols[1], cols[0]) redraw(win, gc) diff --git a/examples/xfixes.py b/examples/xfixes.py index 93fae8a5..2a004964 100755 --- a/examples/xfixes.py +++ b/examples/xfixes.py @@ -19,6 +19,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Python 2/3 compatibility. +from __future__ import print_function + import sys import os import time @@ -34,24 +37,24 @@ def main(argv): if not display.has_extension('XFIXES'): if display.query_extension('XFIXES') is None: - print >>sys.stderr, 'XFIXES extension not supported' + print('XFIXES extension not supported', file=sys.stderr) return 1 xfixes_version = display.xfixes_query_version() - print >>sys.stderr, 'Found XFIXES version %s.%s' % ( + print('Found XFIXES version %s.%s' % ( xfixes_version.major_version, xfixes_version.minor_version, - ) + ), file=sys.stderr) screen = display.screen() - print >>sys.stderr, 'Hiding cursor ...' + print('Hiding cursor ...', file=sys.stderr) screen.root.xfixes_hide_cursor() display.sync() time.sleep(5) - print >>sys.stderr, 'Showing cursor ...' + print('Showing cursor ...', file=sys.stderr) screen.root.xfixes_hide_cursor() display.sync() diff --git a/examples/xinerama.py b/examples/xinerama.py index 124567ed..67abf2fc 100755 --- a/examples/xinerama.py +++ b/examples/xinerama.py @@ -19,6 +19,9 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Python 2/3 compatibility. +from __future__ import print_function + import sys import os import pprint @@ -38,14 +41,14 @@ def __init__(self, display): if not self.d.has_extension('XINERAMA'): sys.stderr.write('%s: server does not have the XINERAMA extension\n' % sys.argv[0]) - print self.d.query_extension('XINERAMA') + print(self.d.query_extension('XINERAMA')) sys.stderr.write("\n".join(self.d.list_extensions())) if self.d.query_extension('XINERAMA') is None: sys.exit(1) # print version r = self.d.xinerama_query_version() - print 'XINERAMA version %d.%d' % (r.major_version, r.minor_version) + print('XINERAMA version %d.%d' % (r.major_version, r.minor_version)) # Grab the current screen @@ -95,23 +98,23 @@ def __init__(self, display): self.pp = pprint.PrettyPrinter(indent=4) - print "Xinerama active:", bool(self.d.xinerama_is_active()) + print("Xinerama active:", bool(self.d.xinerama_is_active())) - print "Screen info:" + print("Screen info:") self.pp.pprint(self.d.xinerama_query_screens()._data) # FIXME: This doesn't work! - #print "Xinerama info:" + #print("Xinerama info:") #self.pp.pprint(self.d.xinerama_get_info(self.d.screen().root_visual)._data) - print "Xinerama state:" + print("Xinerama state:") self.pp.pprint(self.window.xinerama_get_state()._data) - print "Screen count:" + print("Screen count:") self.pp.pprint(self.window.xinerama_get_screen_count()._data) for screennum in range(self.window.xinerama_get_screen_count().screen_count): - print "Screen %d size:" % (screennum, ) + print("Screen %d size:" % (screennum, )) self.pp.pprint(self.window.xinerama_get_screen_size(screennum)._data) def parseModes(self, mode_names, modes): diff --git a/examples/xinput.py b/examples/xinput.py index 294f39f6..5066d81d 100755 --- a/examples/xinput.py +++ b/examples/xinput.py @@ -19,6 +19,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Python 2/3 compatibility. +from __future__ import print_function + import sys import os @@ -30,24 +33,24 @@ def print_hierarchy_changed_event(event): - print '' + print('}>') def print_info(info): - print ' ' % ( + print(' ' % ( info.deviceid, info.attachment, info.type, info.enabled, info.flags, - ) + )) def main(argv): @@ -57,10 +60,10 @@ def main(argv): xinput_major = extension_info.major_opcode version_info = display.xinput_query_version() - print 'Found XInput version %u.%u' % ( + print('Found XInput version %u.%u' % ( version_info.major_version, version_info.minor_version, - ) + )) screen = display.screen() screen.root.xinput_select_events([ diff --git a/examples/xlsatoms.py b/examples/xlsatoms.py index 17644ca7..7899dbf6 100755 --- a/examples/xlsatoms.py +++ b/examples/xlsatoms.py @@ -23,6 +23,9 @@ ''' +# Python 2/3 compatibility. +from __future__ import print_function + import sys import os @@ -48,7 +51,7 @@ d = display.Display(options.display) def print_atom(print_format,atom,value): - print print_format%(atom,value) + print(print_format%(atom,value)) def list_atoms(d,re_obj,low,high): while(low <= high): diff --git a/examples/xrandr.py b/examples/xrandr.py index 6f283f11..6be10e85 100755 --- a/examples/xrandr.py +++ b/examples/xrandr.py @@ -19,6 +19,9 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# Python 2/3 compatibility. +from __future__ import print_function + import sys import os import pprint @@ -38,14 +41,14 @@ def __init__(self, display): if not self.d.has_extension('RANDR'): sys.stderr.write('%s: server does not have the RANDR extension\n' % sys.argv[0]) - print self.d.query_extension('RANDR') + print(self.d.query_extension('RANDR')) sys.stderr.write("\n".join(self.d.list_extensions())) if self.d.query_extension('RANDR') is None: sys.exit(1) - # print version + # print(version) r = self.d.xrandr_query_version() - print 'RANDR version %d.%d' % (r.major_version, r.minor_version) + print('RANDR version %d.%d' % (r.major_version, r.minor_version)) # Grab the current screen @@ -103,30 +106,30 @@ def __init__(self, display): self.pp = pprint.PrettyPrinter(indent=4) - print "Screen info:" + print("Screen info:") self.pp.pprint(self.window.xrandr_get_screen_info()._data) - print "Screen size range:" + print("Screen size range:") self.pp.pprint(self.window.xrandr_get_screen_size_range()._data) - print "Primary output:" + print("Primary output:") self.pp.pprint(self.window.xrandr_get_output_primary()._data) resources = self.window.xrandr_get_screen_resources()._data - print "Modes:" - for mode_id, mode in self.parseModes(resources['mode_names'], resources['modes']).iteritems(): - print " %d: %s" % (mode_id, mode['name']) + print("Modes:") + for mode_id, mode in self.parseModes(resources['mode_names'], resources['modes']).items(): + print(" %d: %s" % (mode_id, mode['name'])) for output in resources['outputs']: - print "Output %d info:" % (output, ) + print("Output %d info:" % (output, )) self.pp.pprint(self.d.xrandr_get_output_info(output, resources['config_timestamp'])._data) for crtc in resources['crtcs']: - print "CRTC %d info:" % (crtc, ) + print("CRTC %d info:" % (crtc, )) self.pp.pprint(self.d.xrandr_get_crtc_info(crtc, resources['config_timestamp'])._data) - print "Raw screen resources:" + print("Raw screen resources:") self.pp.pprint(resources) def parseModes(self, mode_names, modes): @@ -151,8 +154,8 @@ def loop(self): # Screen information has changed elif e.__class__.__name__ == randr.ScreenChangeNotify.__name__: - print 'Screen change' - print self.pp.pprint(e._data) + print('Screen change') + print(self.pp.pprint(e._data)) # check if we're getting one of the RandR event types with subcodes elif e.type == self.d.extension_event.CrtcChangeNotify[0]: @@ -160,23 +163,23 @@ def loop(self): # CRTC information has changed if (e.type, e.sub_code) == self.d.extension_event.CrtcChangeNotify: - print 'CRTC change' + print('CRTC change') #e = randr.CrtcChangeNotify(display=display.display, binarydata = e._binary) - print self.pp.pprint(e._data) + print(self.pp.pprint(e._data)) # Output information has changed elif (e.type, e.sub_code) == self.d.extension_event.OutputChangeNotify: - print 'Output change' + print('Output change') #e = randr.OutputChangeNotify(display=display.display, binarydata = e._binary) - print self.pp.pprint(e._data) + print(self.pp.pprint(e._data)) # Output property information has changed elif (e.type, e.sub_code) == self.d.extension_event.OutputPropertyNotify: - print 'Output property change' + print('Output property change') #e = randr.OutputPropertyNotify(display=display.display, binarydata = e._binary) - print self.pp.pprint(e._data) + print(self.pp.pprint(e._data)) else: - print "Unrecognised subcode", e.sub_code + print("Unrecognised subcode", e.sub_code) # Somebody wants to tell us something elif e.type == X.ClientMessage: From 1316a7ac9e31f8a19a62fbb839439c19bbb3b74f Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 21:42:37 +0200 Subject: [PATCH 068/279] protocol/rq: add Bytes field (for binary strings) --- Xlib/protocol/rq.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 51bd9efb..71e0028a 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -391,6 +391,39 @@ def __init__(self, name, size): self.structcode = '{0}s'.format(size) +class Bytes(ValueField): + structcode = None + + def __init__(self, name, pad = 1): + ValueField.__init__(self, name) + self.pad = pad + + def pack_value(self, val): + if isinstance(val, bytes): + val_bytes = val + else: + val_bytes = val.encode() + slen = len(val_bytes) + + if self.pad: + return val_bytes + b'\0' * ((4 - slen % 4) % 4), slen, None + else: + return val_bytes, slen, None + + def parse_binary_value(self, data, display, length, format): + if length is None: + return data, b'' + + if self.pad: + slen = length + ((4 - length % 4) % 4) + else: + slen = length + + data_bytes = data[:length] + + return data_bytes, data[slen:] + + class String8(ValueField): structcode = None From 44f37e1008dab01a14aef38186fb20bc5e66275e Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 21:43:07 +0200 Subject: [PATCH 069/279] ext/security: Python 3 support --- Xlib/ext/security.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/ext/security.py b/Xlib/ext/security.py index d0be663d..c9afceed 100644 --- a/Xlib/ext/security.py +++ b/Xlib/ext/security.py @@ -72,7 +72,7 @@ class SecurityGenerateAuthorization(rq.ReplyRequest): rq.LengthOf('auth_data', 2), rq.Card32('value_mask'), rq.String8('auth_proto'), - rq.String8('auth_data'), + rq.Bytes('auth_data'), rq.List('values', rq.Card32Obj) ) _reply = rq.Struct(rq.ReplyCode(), @@ -82,7 +82,7 @@ class SecurityGenerateAuthorization(rq.ReplyRequest): AUTHID('authid'), rq.LengthOf('auth_data_return', 2), rq.Pad(18), - rq.String8('auth_data_return') + rq.Bytes('auth_data_return') ) From 736e7c86d48f31ab9830de07126a9c19888374e3 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 21:43:51 +0200 Subject: [PATCH 070/279] xobject/resource: fix object comparison --- Xlib/xobject/resource.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Xlib/xobject/resource.py b/Xlib/xobject/resource.py index 4c08483c..b7a5ad63 100644 --- a/Xlib/xobject/resource.py +++ b/Xlib/xobject/resource.py @@ -27,14 +27,17 @@ def __init__(self, display, rid, owner = 0): def __resource__(self): return self.id - def __cmp__(self, obj): + def __eq__(self, obj): if isinstance(obj, Resource): if self.display == obj.display: - return cmp(self.id, obj.id) + return self.id == obj.id else: - return cmp(self.display, obj.display) + return False else: - return cmp(id(self), id(obj)) + return id(self) == id(obj) + + def __ne__(self, obj): + return not self == obj def __hash__(self): return int(self.id) From 53cf81b7e89c78f5f106f3812917210e50506179 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 27 Jun 2016 14:12:24 +0200 Subject: [PATCH 071/279] test: remove unused imports --- test/gen/genprottest.py | 7 +++---- test/test_events_be.py | 4 ++-- test/test_events_le.py | 4 ++-- test/test_requests_be.py | 4 ++-- test/test_requests_le.py | 4 ++-- test/test_xlib_display.py | 1 - 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/test/gen/genprottest.py b/test/gen/genprottest.py index 7de43fea..18f4c76f 100755 --- a/test/gen/genprottest.py +++ b/test/gen/genprottest.py @@ -5,12 +5,11 @@ sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../../..'))) -import types import struct from random import randint, choice, seed from Xlib.protocol import request, structs, rq, event -from Xlib import X, XK +from Xlib import X @@ -1021,11 +1020,11 @@ def build_bin(bin): PY_HEADER = r'''#!/usr/bin/env python2 -import sys, os, difflib +import sys, os sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest -from Xlib.protocol import request, rq, event +from Xlib.protocol import request, event from . import %(endname)sTest as EndianTest from . import DummyDisplay diff --git a/test/test_events_be.py b/test/test_events_be.py index b032f6d5..96778ea2 100755 --- a/test/test_events_be.py +++ b/test/test_events_be.py @@ -1,10 +1,10 @@ #!/usr/bin/env python2 -import sys, os, difflib +import sys, os sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest -from Xlib.protocol import request, rq, event +from Xlib.protocol import request, event from . import BigEndianTest as EndianTest from . import DummyDisplay diff --git a/test/test_events_le.py b/test/test_events_le.py index 0a624498..e34871ff 100755 --- a/test/test_events_le.py +++ b/test/test_events_le.py @@ -1,10 +1,10 @@ #!/usr/bin/env python2 -import sys, os, difflib +import sys, os sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest -from Xlib.protocol import request, rq, event +from Xlib.protocol import request, event from . import LittleEndianTest as EndianTest from . import DummyDisplay diff --git a/test/test_requests_be.py b/test/test_requests_be.py index f02236cb..ec6d2b6f 100644 --- a/test/test_requests_be.py +++ b/test/test_requests_be.py @@ -1,10 +1,10 @@ #!/usr/bin/env python2 -import sys, os, difflib +import sys, os sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest -from Xlib.protocol import request, rq, event +from Xlib.protocol import request, event from . import BigEndianTest as EndianTest from . import DummyDisplay diff --git a/test/test_requests_le.py b/test/test_requests_le.py index 87baa47c..6cc5c94c 100755 --- a/test/test_requests_le.py +++ b/test/test_requests_le.py @@ -1,10 +1,10 @@ #!/usr/bin/env python2 -import sys, os, difflib +import sys, os sys.path.insert(0, os.path.normpath(os.path.join(__file__, '../..'))) import unittest -from Xlib.protocol import request, rq, event +from Xlib.protocol import request, event from . import LittleEndianTest as EndianTest from . import DummyDisplay diff --git a/test/test_xlib_display.py b/test/test_xlib_display.py index c79586df..fb617a3a 100644 --- a/test/test_xlib_display.py +++ b/test/test_xlib_display.py @@ -3,7 +3,6 @@ import sys import os import unittest -import subprocess sys.path.append(os.path.join(os.path.dirname(__file__), '..')) From 6ca39b63c0d0e5d7f996517ec5e727c0c694ab1d Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 20 Aug 2014 02:43:09 +0200 Subject: [PATCH 072/279] xinput: add grab_device/ungrab_device support --- Xlib/ext/xinput.py | 84 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 119334a8..67a1a478 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -24,6 +24,7 @@ import sys, array from Xlib.protocol import rq +from Xlib import X extname = 'XInputExtension' @@ -138,6 +139,10 @@ RawButtonReleaseMask = (1 << RawButtonRelease) RawMotionMask = (1 << RawMotion) +GrabModeSync = 0 +GrabModeAsync = 1 +GrabModeTouch = 2 + DEVICEID = rq.Card16 DEVICE = rq.Card16 DEVICEUSE = rq.Card8 @@ -232,6 +237,66 @@ def select_events(self, event_masks): masks=masks, ) +class XIGrabDevice(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(51), + rq.RequestLength(), + rq.Window('grab_window'), + rq.Card32('time'), + rq.Cursor('cursor', (X.NONE, )), + rq.Card16('deviceid'), + rq.Set('grab_mode', 1, (GrabModeSync, GrabModeAsync)), + rq.Set('paired_device_mode', 1, (GrabModeSync, GrabModeAsync)), + rq.Bool('owner_events'), + rq.Pad(1), + rq.LengthOf('masks', 2), + rq.List('masks', EventMask), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card8('status'), + rq.Pad(23), + ) + +def grab_device(self, deviceid, time, grab_mode, paired_device_mode, owner_events, event_mask): + masks = [] + mask_seq = array.array(rq.struct_to_array_codes['L']) + mask_seq.append(event_mask) + return XIGrabDevice( + display=self.display, + opcode=self.display.get_extension_major(extname), + deviceid=deviceid, + grab_window=self, + time=time, + cursor=X.NONE, + grab_mode=grab_mode, + paired_device_mode=paired_device_mode, + owner_events=owner_events, + masks=masks, + ) + +class XIUngrabDevice(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(52), + rq.RequestLength(), + rq.Card32('time'), + rq.Card16('deviceid'), + rq.Pad(2), + ) + +def ungrab_device(self, deviceid, time): + return XIUngrabDevice( + display=self.display, + opcode=self.display.get_extension_major(extname), + time=time, + deviceid=deviceid, + ) HierarchyInfo = rq.Struct( DEVICEID('deviceid'), @@ -252,9 +317,26 @@ def select_events(self, event_masks): rq.List('info', HierarchyInfo), ) +DeviceEventData = rq.Struct( + DEVICEID('deviceid'), + rq.Card32('time'), + rq.Card32('detail'), + rq.Window('root'), + rq.Window('event'), + rq.Window('child'), + rq.LengthOf('info', 2), + rq.Pad(8 + 8 + 4), + rq.Pad(16), + rq.Pad(4), + ) + def init(disp, info): disp.extension_add_method('display', 'xinput_query_version', query_version) disp.extension_add_method('window', 'xinput_select_events', select_events) + disp.extension_add_method('window', 'xinput_grab_device', grab_device) + disp.extension_add_method('display', 'xinput_ungrab_device', ungrab_device) - disp.ge_add_event_data(info.major_opcode, 11, HierarchyEventData) + disp.ge_add_event_data(info.major_opcode, KeyPress, DeviceEventData) + disp.ge_add_event_data(info.major_opcode, KeyRelease, DeviceEventData) + disp.ge_add_event_data(info.major_opcode, HierarchyChanged, HierarchyEventData) From 40901f98b0c0a7cee93bf86ae7e32528025192d7 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 30 Oct 2015 22:37:08 +0100 Subject: [PATCH 073/279] xinput: improve DeviceEvent support --- Xlib/ext/xinput.py | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 67a1a478..4a4bd426 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -317,18 +317,36 @@ def ungrab_device(self, deviceid, time): rq.List('info', HierarchyInfo), ) +ModifierInfo = rq.Struct( + rq.Card32('base_mods'), + rq.Card32('latched_mods'), + rq.Card32('locked_mods'), + rq.Card32('effective_mods'), +) + +GroupInfo = rq.Struct( + rq.Card8('base_group'), + rq.Card8('latched_group'), + rq.Card8('locked_group'), + rq.Card8('effective_group'), +) + DeviceEventData = rq.Struct( - DEVICEID('deviceid'), - rq.Card32('time'), - rq.Card32('detail'), - rq.Window('root'), - rq.Window('event'), - rq.Window('child'), - rq.LengthOf('info', 2), - rq.Pad(8 + 8 + 4), - rq.Pad(16), - rq.Pad(4), - ) + DEVICEID('deviceid'), + rq.Card32('time'), + rq.Card32('detail'), + rq.Window('root'), + rq.Window('event'), + rq.Window('child'), + rq.Pad(4 * 4), # 4*FP1616 (root_x, root_y, event_x, event_y) + rq.Card16('buttons_len'), + rq.Card16('valulators_len'), + DEVICEID('sourceid'), + rq.Pad(2), + rq.Card32('flags'), + rq.Object('mods', ModifierInfo), + rq.Object('groups', GroupInfo), +) def init(disp, info): From 459c94950390f4142358f1012b31b41755ec206d Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 30 Oct 2015 23:17:19 +0100 Subject: [PATCH 074/279] xinput: further improve DeviceEvent support --- Xlib/ext/xinput.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 4a4bd426..3210e2d2 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -331,6 +331,14 @@ def ungrab_device(self, deviceid, time): rq.Card8('effective_group'), ) +class FP1616(rq.Int32): + + def check_value(self, value): + return int(value * 65536.0) + + def parse_value(self, value, display): + return float(value) / float(1 << 16) + DeviceEventData = rq.Struct( DEVICEID('deviceid'), rq.Card32('time'), @@ -338,7 +346,10 @@ def ungrab_device(self, deviceid, time): rq.Window('root'), rq.Window('event'), rq.Window('child'), - rq.Pad(4 * 4), # 4*FP1616 (root_x, root_y, event_x, event_y) + FP1616('root_x'), + FP1616('root_y'), + FP1616('event_x'), + FP1616('event_y'), rq.Card16('buttons_len'), rq.Card16('valulators_len'), DEVICEID('sourceid'), From 9653220aa59e4d3f34970b112e8ae39fcebfff48 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 31 Oct 2015 02:23:19 +0100 Subject: [PATCH 075/279] xinput: small cleanup --- Xlib/ext/xinput.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 3210e2d2..080f2e7e 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -245,7 +245,7 @@ class XIGrabDevice(rq.ReplyRequest): rq.Window('grab_window'), rq.Card32('time'), rq.Cursor('cursor', (X.NONE, )), - rq.Card16('deviceid'), + DEVICEID('deviceid'), rq.Set('grab_mode', 1, (GrabModeSync, GrabModeAsync)), rq.Set('paired_device_mode', 1, (GrabModeSync, GrabModeAsync)), rq.Bool('owner_events'), @@ -286,7 +286,7 @@ class XIUngrabDevice(rq.Request): rq.Opcode(52), rq.RequestLength(), rq.Card32('time'), - rq.Card16('deviceid'), + DEVICEID('deviceid'), rq.Pad(2), ) From 703253166920b655d2fac2787dbbda20a34d4758 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 31 Oct 2015 02:23:52 +0100 Subject: [PATCH 076/279] xinput: fix event_mask handling for grab_device --- Xlib/ext/xinput.py | 59 ++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 080f2e7e..741981d2 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -194,6 +194,29 @@ class XISelectEvents(rq.Request): rq.List('masks', EventMask), ) +def pack_event_mask(deviceid, mask): + mask_seq = array.array(rq.struct_to_array_codes['L']) + + if isinstance(mask, (int, long)): + # We need to build a "binary mask" that (as far as I can tell) is + # encoded in native byte order from end to end. The simple case is + # with a single unsigned 32-bit value, for which we construct an + # array with just one item. For values too big to fit inside 4 + # bytes we build a longer array, being careful to maintain native + # byte order across the entire set of values. + if sys.byteorder == 'little': + f = lambda v: mask_seq.insert(0, v) + elif sys.byteorder == 'big': + f = mask_seq.append + else: + raise AssertionError(sys.byteorder) + while mask: + f(mask & 0xFFFFFFFF) + mask = mask >> 32 + else: + mask_seq.extend(mask) + + return {'deviceid': deviceid, 'mask': mask_seq} def select_events(self, event_masks): ''' @@ -205,31 +228,7 @@ def select_events(self, event_masks): integer or sequence of 32 byte unsigned values ''' - masks = [] - for deviceid, mask in event_masks: - mask_seq = array.array(rq.struct_to_array_codes['L']) - - if isinstance(mask, (int, long)): - # We need to build a "binary mask" that (as far as I can tell) is - # encoded in native byte order from end to end. The simple case is - # with a single unsigned 32-bit value, for which we construct an - # array with just one item. For values too big to fit inside 4 - # bytes we build a longer array, being careful to maintain native - # byte order across the entire set of values. - if sys.byteorder == 'little': - f = lambda v: mask_seq.insert(0, v) - elif sys.byteorder == 'big': - f = mask_seq.append - else: - raise AssertionError(sys.byteorder) - while mask: - f(mask & 0xFFFFFFFF) - mask = mask >> 32 - else: - mask_seq.extend(mask) - - masks.append({'deviceid': deviceid, 'mask': mask_seq}) - + masks = [pack_event_mask(deviceid, mask) for deviceid, mask in event_masks] return XISelectEvents( display=self.display, opcode=self.display.get_extension_major(extname), @@ -250,8 +249,8 @@ class XIGrabDevice(rq.ReplyRequest): rq.Set('paired_device_mode', 1, (GrabModeSync, GrabModeAsync)), rq.Bool('owner_events'), rq.Pad(1), - rq.LengthOf('masks', 2), - rq.List('masks', EventMask), + rq.LengthOf('mask', 2), + rq.List('mask', rq.Card32), ) _reply = rq.Struct( @@ -264,9 +263,7 @@ class XIGrabDevice(rq.ReplyRequest): ) def grab_device(self, deviceid, time, grab_mode, paired_device_mode, owner_events, event_mask): - masks = [] - mask_seq = array.array(rq.struct_to_array_codes['L']) - mask_seq.append(event_mask) + mask = pack_event_mask(deviceid, event_mask) return XIGrabDevice( display=self.display, opcode=self.display.get_extension_major(extname), @@ -277,7 +274,7 @@ def grab_device(self, deviceid, time, grab_mode, paired_device_mode, owner_event grab_mode=grab_mode, paired_device_mode=paired_device_mode, owner_events=owner_events, - masks=masks, + mask=mask['mask'], ) class XIUngrabDevice(rq.Request): From 33aff14140b5459cc71919accb3961949a3101d3 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 31 Oct 2015 02:24:19 +0100 Subject: [PATCH 077/279] xinput: add missing GrabtypeTouchBegin --- Xlib/ext/xinput.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 741981d2..fed5e4e4 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -53,6 +53,7 @@ GrabtypeKeycode = 1 GrabtypeEnter = 2 GrabtypeFocusIn = 3 +GrabtypeTouchBegin = 4 AnyModifier = (1 << 31) AnyButton = 0 From 35fe44dcd1c69df3b6f10e37fef23ff2821047ca Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 31 Oct 2015 04:30:41 +0100 Subject: [PATCH 078/279] xinput: add grab_keycode/ungrab_keycode support --- Xlib/ext/xinput.py | 94 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index fed5e4e4..f6f87abc 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -296,6 +296,98 @@ def ungrab_device(self, deviceid, time): deviceid=deviceid, ) +class XIPassiveGrabDevice(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(54), + rq.RequestLength(), + rq.Card32('time'), + rq.Window('grab_window'), + rq.Cursor('cursor', (X.NONE, )), + rq.Card32('detail'), + DEVICEID('deviceid'), + rq.LengthOf('modifiers', 2), + rq.LengthOf('mask', 2), + rq.Set('grab_type', 1, (GrabtypeButton, GrabtypeKeycode, GrabtypeEnter, + GrabtypeFocusIn, GrabtypeTouchBegin)), + rq.Set('grab_mode', 1, (GrabModeSync, GrabModeAsync)), + rq.Set('paired_device_mode', 1, (GrabModeSync, GrabModeAsync)), + rq.Bool('owner_events'), + rq.Pad(2), + rq.List('mask', rq.Card32), + rq.List('modifiers', rq.Card32), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.LengthOf('modifiers', 2), + rq.Pad(22), + rq.List('modifiers', rq.Card32), + ) + +def passive_grab_device(self, deviceid, time, detail, + grab_type, grab_mode, paired_device_mode, + owner_events, event_mask, modifiers): + mask = pack_event_mask(deviceid, event_mask) + return XIPassiveGrabDevice( + display=self.display, + opcode=self.display.get_extension_major(extname), + deviceid=deviceid, + grab_window=self, + time=time, + cursor=X.NONE, + detail=detail, + grab_type=grab_type, + grab_mode=grab_mode, + paired_device_mode=paired_device_mode, + owner_events=owner_events, + mask=mask['mask'], + modifiers=modifiers, + ) + +def grab_keycode(self, deviceid, time, keycode, + grab_mode, paired_device_mode, + owner_events, event_mask, modifiers): + return passive_grab_device(self, deviceid, time, keycode, + GrabtypeKeycode, + grab_mode, paired_device_mode, + owner_events, event_mask, modifiers) + +class XIPassiveUngrabDevice(rq.Request): + + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(55), + rq.RequestLength(), + rq.Window('grab_window'), + rq.Card32('detail'), + DEVICEID('deviceid'), + rq.LengthOf('modifiers', 2), + rq.Set('grab_type', 1, (GrabtypeButton, GrabtypeKeycode, + GrabtypeEnter, GrabtypeFocusIn, + GrabtypeTouchBegin)), + rq.Pad(3), + rq.List('modifiers', rq.Card32), + ) + +def passive_ungrab_device(self, deviceid, detail, grab_type, modifiers): + return XIPassiveUngrabDevice( + display=self.display, + opcode=self.display.get_extension_major(extname), + deviceid=deviceid, + grab_window=self, + detail=detail, + grab_type=grab_type, + modifiers=modifiers, + ) + +def ungrab_keycode(self, deviceid, keycode, modifiers): + return passive_ungrab_device(self, deviceid, keycode, + GrabtypeKeycode, modifiers) + HierarchyInfo = rq.Struct( DEVICEID('deviceid'), DEVICEID('attachment'), @@ -363,6 +455,8 @@ def init(disp, info): disp.extension_add_method('window', 'xinput_select_events', select_events) disp.extension_add_method('window', 'xinput_grab_device', grab_device) disp.extension_add_method('display', 'xinput_ungrab_device', ungrab_device) + disp.extension_add_method('window', 'xinput_grab_keycode', grab_keycode) + disp.extension_add_method('window', 'xinput_ungrab_keycode', ungrab_keycode) disp.ge_add_event_data(info.major_opcode, KeyPress, DeviceEventData) disp.ge_add_event_data(info.major_opcode, KeyRelease, DeviceEventData) From e73cbed4175cf25c0ad6e928782d021fa5947644 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 31 Oct 2015 11:18:12 +0100 Subject: [PATCH 079/279] xinput: add query_device support --- Xlib/ext/xinput.py | 154 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 153 insertions(+), 1 deletion(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index f6f87abc..f8f1e97e 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -21,7 +21,7 @@ A very incomplete implementation of the XInput extension. ''' -import sys, array +import sys, array, struct from Xlib.protocol import rq from Xlib import X @@ -98,6 +98,8 @@ KeyClass = 0 ButtonClass = 1 ValuatorClass = 2 +ScrollClass = 3 +TouchClass = 8 KeyRepeat = (1 << 16) @@ -237,6 +239,155 @@ def select_events(self, event_masks): masks=masks, ) +DeviceInfo = rq.Struct( + DEVICEID('deviceid'), + rq.Card16('use'), + rq.Card16('attachment'), + rq.Card16('num_classes'), + rq.LengthOf('name', 2), + rq.Bool('enabled'), + rq.Pad(1), + rq.String8('name', 4), + # classes follow. +) + +AnyInfo = rq.Struct( + rq.Card16('type'), + rq.Card16('length'), + rq.Card16('sourceid'), + rq.Pad(2), +) + +ButtonInfo = rq.Struct( + rq.Card16('type'), + rq.Card16('length'), + rq.Card16('sourceid'), + rq.Card16('num_buttons'), + # state mask and label atoms follow. +) + +KeyInfo = rq.Struct( + rq.Card16('type'), + rq.Card16('length'), + rq.Card16('sourceid'), + rq.LengthOf('keycodes', 2), + rq.List('keycodes', rq.Card32), +) + +class FP3232(rq.ValueField): + structcode = 'lL' + structvalues = 2 + + def check_value(self, value): + return value + + def parse_value(self, value, display): + integral, frac = value + ret = float(integral) + # optimised math.ldexp(float(frac), -32) + ret += float(frac) * (1.0 / (1 << 32)) + return ret + +ValuatorInfo = rq.Struct( + rq.Card16('type'), + rq.Card16('length'), + rq.Card16('sourceid'), + rq.Card16('number'), + rq.Card32('label'), + FP3232('min'), + FP3232('max'), + FP3232('value'), + rq.Card32('resolution'), + rq.Card8('mode'), + rq.Pad(3), +) + +ScrollInfo = rq.Struct( + rq.Card16('type'), + rq.Card16('length'), + rq.Card16('sourceid'), + rq.Card16('number'), + rq.Card16('scroll_type'), + rq.Pad(2), + rq.Card32('flags'), + FP3232('increment'), +) + +TouchInfo = rq.Struct( + rq.Card16('type'), + rq.Card16('length'), + rq.Card16('sourceid'), + rq.Card8('mode'), + rq.Card8('num_touches'), +) + +INFO_CLASSES = { + KeyClass: KeyInfo, + ButtonClass: ButtonInfo, + ValuatorClass: ValuatorInfo, + ScrollClass: ScrollInfo, + TouchClass: TouchInfo, +} + +class XIQueryDevice(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(48), + rq.RequestLength(), + DEVICEID('deviceid'), + rq.Pad(2), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card16('num_devices'), + rq.Pad(22), + ) + + def _parse_response(self, data): + self._response_lock.acquire() + self._data, d = self._reply.parse_binary(data, self._display) + self._data.devices = devices = [] + for _ in range(self._data.num_devices): + devinfo, d = DeviceInfo.parse_binary(d, self._display) + devinfo.classes = classes = [] + for _ in range(devinfo.num_classes): + class_type, length = struct.unpack('=HH', d[:4]) + class_struct = INFO_CLASSES.get(class_type, None) + if class_struct is not None: + class_data, _ = class_struct.parse_binary(d, self._display) + classes.append(class_data) + # Parse ButtonInfo state mask and label atoms. + if ButtonClass == class_type: + # Mask: bitfield of size a multiple of 4. + mask_offset = ButtonInfo.static_size + mask_len = 4 * ((((class_data.num_buttons + 7) >> 3) + 3) >> 2) + mask_data = d[mask_offset:mask_offset+mask_len] + mask = 0 + for b in reversed(struct.unpack('=%uB' % mask_len, mask_data)): + mask <<= 8 + mask |= b + class_data.state = mask + # Labels: a list of atoms. + labels_offset = mask_offset + mask_len + labels_len = class_data.num_buttons * 4 + labels_data = d[labels_offset:labels_offset+labels_len] + labels = struct.unpack('=%uL' % class_data.num_buttons, labels_data) + class_data.labels = labels + d = buffer(d, length * 4) + devices.append(devinfo) + self._response_lock.release() + +def query_device(self, deviceid): + return XIQueryDevice( + display=self.display, + opcode=self.display.get_extension_major(extname), + deviceid=deviceid, + ) + class XIGrabDevice(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), @@ -453,6 +604,7 @@ def parse_value(self, value, display): def init(disp, info): disp.extension_add_method('display', 'xinput_query_version', query_version) disp.extension_add_method('window', 'xinput_select_events', select_events) + disp.extension_add_method('display', 'xinput_query_device', query_device) disp.extension_add_method('window', 'xinput_grab_device', grab_device) disp.extension_add_method('display', 'xinput_ungrab_device', ungrab_device) disp.extension_add_method('window', 'xinput_grab_keycode', grab_keycode) From 89ce2190e6df85328e388c03095a313e80c1946b Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 1 Nov 2015 01:28:33 +0100 Subject: [PATCH 080/279] xinput: clean up parsing of device info --- Xlib/ext/xinput.py | 159 +++++++++++++++++++++++++-------------------- 1 file changed, 88 insertions(+), 71 deletions(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index f8f1e97e..01c1261f 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -150,6 +150,27 @@ DEVICE = rq.Card16 DEVICEUSE = rq.Card8 +class FP1616(rq.Int32): + + def check_value(self, value): + return int(value * 65536.0) + + def parse_value(self, value, display): + return float(value) / float(1 << 16) + +class FP3232(rq.ValueField): + structcode = 'lL' + structvalues = 2 + + def check_value(self, value): + return value + + def parse_value(self, value, display): + integral, frac = value + ret = float(integral) + # optimised math.ldexp(float(frac), -32) + ret += float(frac) * (1.0 / (1 << 32)) + return ret class XIQueryVersion(rq.ReplyRequest): _request = rq.Struct( @@ -239,18 +260,6 @@ def select_events(self, event_masks): masks=masks, ) -DeviceInfo = rq.Struct( - DEVICEID('deviceid'), - rq.Card16('use'), - rq.Card16('attachment'), - rq.Card16('num_classes'), - rq.LengthOf('name', 2), - rq.Bool('enabled'), - rq.Pad(1), - rq.String8('name', 4), - # classes follow. -) - AnyInfo = rq.Struct( rq.Card16('type'), rq.Card16('length'), @@ -258,12 +267,50 @@ def select_events(self, event_masks): rq.Pad(2), ) +class Mask(object): + + def __init__(self, value, length): + self._value = value + self._length = length + + def __len__(self): + return self._length + + def __getitem__(self, key): + return self._value & (1 << key) + + def __str__(self): + return ('{0:0%ub}' % self._length).format(self._value) + + def __repr__(self): + return '%#0*x' % ((self._length + 3) / 8, self._value) + +class ButtonState(rq.ValueField): + + structcode = None + + def __init__(self, name): + rq.ValueField.__init__(self, name) + + def parse_binary_value(self, data, display, length, format): + # Mask: bitfield of button states. + mask_len = 4 * ((((length + 7) >> 3) + 3) >> 2) + mask_data = data[:mask_len] + mask_value = 0 + for b in reversed(struct.unpack('=%uB' % mask_len, mask_data)): + mask_value <<= 8 + mask_value |= b + data = buffer(data, mask_len) + assert 0 == (mask_value & 1) + return Mask(mask_value >> 1, length), data + ButtonInfo = rq.Struct( rq.Card16('type'), rq.Card16('length'), rq.Card16('sourceid'), - rq.Card16('num_buttons'), - # state mask and label atoms follow. + rq.LengthOf(('state', 'labels'), 2), + ButtonState('state'), + rq.List('labels', rq.Card32), ) KeyInfo = rq.Struct( @@ -274,20 +321,6 @@ def select_events(self, event_masks): rq.List('keycodes', rq.Card32), ) -class FP3232(rq.ValueField): - structcode = 'lL' - structvalues = 2 - - def check_value(self, value): - return value - - def parse_value(self, value, display): - integral, frac = value - ret = float(integral) - # optimised math.ldexp(float(frac), -32) - ret += float(frac) * (1.0 / (1 << 32)) - return ret - ValuatorInfo = rq.Struct( rq.Card16('type'), rq.Card16('length'), @@ -329,6 +362,31 @@ def parse_value(self, value, display): TouchClass: TouchInfo, } +class ClassInfoClass: + + structcode = None + + def parse_binary(self, data, display): + class_type, length = struct.unpack('=HH', data[:4]) + class_struct = INFO_CLASSES.get(class_type, AnyInfo) + class_data, _ = class_struct.parse_binary(data, display) + data = buffer(data, length * 4) + return class_data, data + +ClassInfo = ClassInfoClass() + +DeviceInfo = rq.Struct( + DEVICEID('deviceid'), + rq.Card16('use'), + rq.Card16('attachment'), + rq.LengthOf('classes', 2), + rq.LengthOf('name', 2), + rq.Bool('enabled'), + rq.Pad(1), + rq.String8('name', 4), + rq.List('classes', ClassInfo), +) + class XIQueryDevice(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), @@ -343,44 +401,11 @@ class XIQueryDevice(rq.ReplyRequest): rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), - rq.Card16('num_devices'), + rq.LengthOf('devices', 2), rq.Pad(22), + rq.List('devices', DeviceInfo), ) - def _parse_response(self, data): - self._response_lock.acquire() - self._data, d = self._reply.parse_binary(data, self._display) - self._data.devices = devices = [] - for _ in range(self._data.num_devices): - devinfo, d = DeviceInfo.parse_binary(d, self._display) - devinfo.classes = classes = [] - for _ in range(devinfo.num_classes): - class_type, length = struct.unpack('=HH', d[:4]) - class_struct = INFO_CLASSES.get(class_type, None) - if class_struct is not None: - class_data, _ = class_struct.parse_binary(d, self._display) - classes.append(class_data) - # Parse ButtonInfo state mask and label atoms. - if ButtonClass == class_type: - # Mask: bitfield of size a multiple of 4. - mask_offset = ButtonInfo.static_size - mask_len = 4 * ((((class_data.num_buttons + 7) >> 3) + 3) >> 2) - mask_data = d[mask_offset:mask_offset+mask_len] - mask = 0 - for b in reversed(struct.unpack('=%uB' % mask_len, mask_data)): - mask <<= 8 - mask |= b - class_data.state = mask - # Labels: a list of atoms. - labels_offset = mask_offset + mask_len - labels_len = class_data.num_buttons * 4 - labels_data = d[labels_offset:labels_offset+labels_len] - labels = struct.unpack('=%uL' % class_data.num_buttons, labels_data) - class_data.labels = labels - d = buffer(d, length * 4) - devices.append(devinfo) - self._response_lock.release() - def query_device(self, deviceid): return XIQueryDevice( display=self.display, @@ -572,14 +597,6 @@ def ungrab_keycode(self, deviceid, keycode, modifiers): rq.Card8('effective_group'), ) -class FP1616(rq.Int32): - - def check_value(self, value): - return int(value * 65536.0) - - def parse_value(self, value, display): - return float(value) / float(1 << 16) - DeviceEventData = rq.Struct( DEVICEID('deviceid'), rq.Card32('time'), From a1f18f0b7b7e57923c9441778abce6bebdfb2922 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 1 Nov 2015 03:04:46 +0100 Subject: [PATCH 081/279] xinput: more DeviceEvent improvements - add DeviceEvent buttons state mask parsing - map pointer events (ButtonPress, ButtonRelease, and Motion) --- Xlib/ext/xinput.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 01c1261f..33d3239b 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -608,13 +608,14 @@ def ungrab_keycode(self, deviceid, keycode, modifiers): FP1616('root_y'), FP1616('event_x'), FP1616('event_y'), - rq.Card16('buttons_len'), + rq.LengthOf('buttons', 2), rq.Card16('valulators_len'), DEVICEID('sourceid'), rq.Pad(2), rq.Card32('flags'), rq.Object('mods', ModifierInfo), rq.Object('groups', GroupInfo), + ButtonState('buttons'), ) @@ -627,6 +628,6 @@ def init(disp, info): disp.extension_add_method('window', 'xinput_grab_keycode', grab_keycode) disp.extension_add_method('window', 'xinput_ungrab_keycode', ungrab_keycode) - disp.ge_add_event_data(info.major_opcode, KeyPress, DeviceEventData) - disp.ge_add_event_data(info.major_opcode, KeyRelease, DeviceEventData) + for device_event in (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion): + disp.ge_add_event_data(info.major_opcode, device_event, DeviceEventData) disp.ge_add_event_data(info.major_opcode, HierarchyChanged, HierarchyEventData) From a4e362089d5a725de759a5aa2b8a58990af81109 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 1 Nov 2015 16:45:43 +0100 Subject: [PATCH 082/279] xinput: add DeviceChangedEvent support --- Xlib/ext/xinput.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 33d3239b..7a706e45 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -618,6 +618,15 @@ def ungrab_keycode(self, deviceid, keycode, modifiers): ButtonState('buttons'), ) +DeviceChangedEventData = rq.Struct( + DEVICEID('deviceid'), + rq.Card32('time'), + rq.LengthOf('classes', 2), + DEVICEID('sourceid'), + rq.Card8('reason'), + rq.Pad(11), + rq.List('classes', ClassInfo), +) def init(disp, info): disp.extension_add_method('display', 'xinput_query_version', query_version) @@ -630,4 +639,5 @@ def init(disp, info): for device_event in (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion): disp.ge_add_event_data(info.major_opcode, device_event, DeviceEventData) + disp.ge_add_event_data(info.major_opcode, DeviceChanged, DeviceEventData) disp.ge_add_event_data(info.major_opcode, HierarchyChanged, HierarchyEventData) From a2c82daf97d02ca310850411518737b58b7d1463 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 6 Nov 2015 12:07:17 +0100 Subject: [PATCH 083/279] xinput: fix XIQueryVersion reply --- Xlib/ext/xinput.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 7a706e45..7dec0002 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -185,9 +185,9 @@ class XIQueryVersion(rq.ReplyRequest): rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), - rq.Card32('major_version'), - rq.Card32('minor_version'), - rq.Pad(16), + rq.Card16('major_version'), + rq.Card16('minor_version'), + rq.Pad(20), ) From 6e84230388ae43ad3c65995f07bd5749b5d863a5 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 6 Nov 2015 12:31:33 +0100 Subject: [PATCH 084/279] xinput: improve handling of event masks --- Xlib/ext/xinput.py | 75 +++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 7dec0002..5eddb173 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -199,11 +199,40 @@ def query_version(self): minor_version=0, ) +class Mask(rq.List): + + def __init__(self, name): + rq.List.__init__(self, name, rq.Card32, pad = 0) + + def pack_value(self, val): + + mask_seq = array.array(rq.struct_to_array_codes['L']) + + if isinstance(val, (int, long)): + # We need to build a "binary mask" that (as far as I can tell) is + # encoded in native byte order from end to end. The simple case is + # with a single unsigned 32-bit value, for which we construct an + # array with just one item. For values too big to fit inside 4 + # bytes we build a longer array, being careful to maintain native + # byte order across the entire set of values. + if sys.byteorder == 'little': + f = lambda v: mask_seq.insert(0, v) + elif sys.byteorder == 'big': + f = mask_seq.append + else: + raise AssertionError(sys.byteorder) + while val: + f(val & 0xFFFFFFFF) + val = val >> 32 + else: + mask_seq.extend(val) + + return mask_seq.tostring(), len(mask_seq), None EventMask = rq.Struct( DEVICE('deviceid'), rq.LengthOf('mask', 2), - rq.List('mask', rq.Card32), + Mask('mask'), ) @@ -218,30 +247,6 @@ class XISelectEvents(rq.Request): rq.List('masks', EventMask), ) -def pack_event_mask(deviceid, mask): - mask_seq = array.array(rq.struct_to_array_codes['L']) - - if isinstance(mask, (int, long)): - # We need to build a "binary mask" that (as far as I can tell) is - # encoded in native byte order from end to end. The simple case is - # with a single unsigned 32-bit value, for which we construct an - # array with just one item. For values too big to fit inside 4 - # bytes we build a longer array, being careful to maintain native - # byte order across the entire set of values. - if sys.byteorder == 'little': - f = lambda v: mask_seq.insert(0, v) - elif sys.byteorder == 'big': - f = mask_seq.append - else: - raise AssertionError(sys.byteorder) - while mask: - f(mask & 0xFFFFFFFF) - mask = mask >> 32 - else: - mask_seq.extend(mask) - - return {'deviceid': deviceid, 'mask': mask_seq} - def select_events(self, event_masks): ''' select_events(event_masks) @@ -249,15 +254,13 @@ def select_events(self, event_masks): event_masks: Sequence of (deviceid, mask) pairs, where deviceid is a numerical device ID, or AllDevices or AllMasterDevices, and mask is either an unsigned - integer or sequence of 32 byte unsigned values + integer or sequence of 32 bits unsigned values ''' - - masks = [pack_event_mask(deviceid, mask) for deviceid, mask in event_masks] return XISelectEvents( display=self.display, opcode=self.display.get_extension_major(extname), window=self, - masks=masks, + masks=event_masks, ) AnyInfo = rq.Struct( @@ -267,7 +270,7 @@ def select_events(self, event_masks): rq.Pad(2), ) -class Mask(object): +class ButtonMask(object): def __init__(self, value, length): self._value = value @@ -302,7 +305,7 @@ def parse_binary_value(self, data, display, length, format): mask_value |= b data = buffer(data, mask_len) assert 0 == (mask_value & 1) - return Mask(mask_value >> 1, length), data + return ButtonMask(mask_value >> 1, length), data ButtonInfo = rq.Struct( rq.Card16('type'), @@ -427,7 +430,7 @@ class XIGrabDevice(rq.ReplyRequest): rq.Bool('owner_events'), rq.Pad(1), rq.LengthOf('mask', 2), - rq.List('mask', rq.Card32), + Mask('mask'), ) _reply = rq.Struct( @@ -440,7 +443,6 @@ class XIGrabDevice(rq.ReplyRequest): ) def grab_device(self, deviceid, time, grab_mode, paired_device_mode, owner_events, event_mask): - mask = pack_event_mask(deviceid, event_mask) return XIGrabDevice( display=self.display, opcode=self.display.get_extension_major(extname), @@ -451,7 +453,7 @@ def grab_device(self, deviceid, time, grab_mode, paired_device_mode, owner_event grab_mode=grab_mode, paired_device_mode=paired_device_mode, owner_events=owner_events, - mask=mask['mask'], + mask=event_mask, ) class XIUngrabDevice(rq.Request): @@ -490,7 +492,7 @@ class XIPassiveGrabDevice(rq.ReplyRequest): rq.Set('paired_device_mode', 1, (GrabModeSync, GrabModeAsync)), rq.Bool('owner_events'), rq.Pad(2), - rq.List('mask', rq.Card32), + Mask('mask'), rq.List('modifiers', rq.Card32), ) @@ -507,7 +509,6 @@ class XIPassiveGrabDevice(rq.ReplyRequest): def passive_grab_device(self, deviceid, time, detail, grab_type, grab_mode, paired_device_mode, owner_events, event_mask, modifiers): - mask = pack_event_mask(deviceid, event_mask) return XIPassiveGrabDevice( display=self.display, opcode=self.display.get_extension_major(extname), @@ -520,7 +521,7 @@ def passive_grab_device(self, deviceid, time, detail, grab_mode=grab_mode, paired_device_mode=paired_device_mode, owner_events=owner_events, - mask=mask['mask'], + mask=event_mask, modifiers=modifiers, ) From 5af17b493e8c59f97a03e6a56ecbaa1cb7956a17 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 25 Jun 2016 22:37:14 +0200 Subject: [PATCH 085/279] xinput: Python 3 support --- Xlib/ext/xinput.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 5eddb173..6a8c0b09 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -23,6 +23,9 @@ import sys, array, struct +# Python 2/3 compatibility. +from six import integer_types + from Xlib.protocol import rq from Xlib import X @@ -208,7 +211,7 @@ def pack_value(self, val): mask_seq = array.array(rq.struct_to_array_codes['L']) - if isinstance(val, (int, long)): + if isinstance(val, integer_types): # We need to build a "binary mask" that (as far as I can tell) is # encoded in native byte order from end to end. The simple case is # with a single unsigned 32-bit value, for which we construct an @@ -303,7 +306,7 @@ def parse_binary_value(self, data, display, length, format): for b in reversed(struct.unpack('=%uB' % mask_len, mask_data)): mask_value <<= 8 mask_value |= b - data = buffer(data, mask_len) + data = data[mask_len:] assert 0 == (mask_value & 1) return ButtonMask(mask_value >> 1, length), data @@ -365,7 +368,7 @@ def parse_binary_value(self, data, display, length, format): TouchClass: TouchInfo, } -class ClassInfoClass: +class ClassInfoClass(object): structcode = None @@ -373,7 +376,7 @@ def parse_binary(self, data, display): class_type, length = struct.unpack('=HH', data[:4]) class_struct = INFO_CLASSES.get(class_type, AnyInfo) class_data, _ = class_struct.parse_binary(data, display) - data = buffer(data, length * 4) + data = data[length * 4:] return class_data, data ClassInfo = ClassInfoClass() From aed02985e9ab8fd2f1e86ac30215631df02fac64 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Mon, 27 Jun 2016 15:43:47 +0300 Subject: [PATCH 086/279] Create default YAML file for codecov.io service --- codecov.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..3d26ddea --- /dev/null +++ b/codecov.yml @@ -0,0 +1,7 @@ +comment: + layout: header, changes, diff +coverage: + ignore: + - test/.* + status: + patch: false From 3eacd9b3024f2a4049d93db63b69d2b115d17e8b Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 27 Jun 2016 14:57:16 +0200 Subject: [PATCH 087/279] xinput: small PEP8 cleanups --- Xlib/ext/xinput.py | 74 ++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 6a8c0b09..21fb1933 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -21,7 +21,9 @@ A very incomplete implementation of the XInput extension. ''' -import sys, array, struct +import sys +import array +import struct # Python 2/3 compatibility. from six import integer_types @@ -205,7 +207,7 @@ def query_version(self): class Mask(rq.List): def __init__(self, name): - rq.List.__init__(self, name, rq.Card32, pad = 0) + rq.List.__init__(self, name, rq.Card32, pad=0) def pack_value(self, val): @@ -219,13 +221,14 @@ def pack_value(self, val): # bytes we build a longer array, being careful to maintain native # byte order across the entire set of values. if sys.byteorder == 'little': - f = lambda v: mask_seq.insert(0, v) + def fun(val): + mask_seq.insert(0, val) elif sys.byteorder == 'big': - f = mask_seq.append + fun = mask_seq.append else: raise AssertionError(sys.byteorder) while val: - f(val & 0xFFFFFFFF) + fun(val & 0xFFFFFFFF) val = val >> 32 else: mask_seq.extend(val) @@ -233,10 +236,10 @@ def pack_value(self, val): return mask_seq.tostring(), len(mask_seq), None EventMask = rq.Struct( - DEVICE('deviceid'), - rq.LengthOf('mask', 2), - Mask('mask'), - ) + DEVICE('deviceid'), + rq.LengthOf('mask', 2), + Mask('mask'), +) class XISelectEvents(rq.Request): @@ -248,7 +251,7 @@ class XISelectEvents(rq.Request): rq.LengthOf('masks', 2), rq.Pad(2), rq.List('masks', EventMask), - ) + ) def select_events(self, event_masks): ''' @@ -264,13 +267,13 @@ def select_events(self, event_masks): opcode=self.display.get_extension_major(extname), window=self, masks=event_masks, - ) + ) AnyInfo = rq.Struct( - rq.Card16('type'), - rq.Card16('length'), - rq.Card16('sourceid'), - rq.Pad(2), + rq.Card16('type'), + rq.Card16('length'), + rq.Card16('sourceid'), + rq.Pad(2), ) class ButtonMask(object): @@ -286,10 +289,11 @@ def __getitem__(self, key): return self._value & (1 << key) def __str__(self): - return ('{0:0%ub}' % self._length).format(self._value) + return repr(self) def __repr__(self): - return '%#0*x' % ((self._length + 3) / 8, self._value) + return '0b{value:0{width}b}'.format(value=self._value, + width=self._length) class ButtonState(rq.ValueField): @@ -298,16 +302,16 @@ class ButtonState(rq.ValueField): def __init__(self, name): rq.ValueField.__init__(self, name) - def parse_binary_value(self, data, display, length, format): + def parse_binary_value(self, data, display, length, fmt): # Mask: bitfield of button states. mask_len = 4 * ((((length + 7) >> 3) + 3) >> 2) mask_data = data[:mask_len] mask_value = 0 - for b in reversed(struct.unpack('=%uB' % mask_len, mask_data)): + for byte in reversed(struct.unpack('={0:d}B'.format(mask_len), mask_data)): mask_value <<= 8 - mask_value |= b + mask_value |= byte data = data[mask_len:] - assert 0 == (mask_value & 1) + assert (mask_value & 1) == 0 return ButtonMask(mask_value >> 1, length), data ButtonInfo = rq.Struct( @@ -569,23 +573,23 @@ def ungrab_keycode(self, deviceid, keycode, modifiers): GrabtypeKeycode, modifiers) HierarchyInfo = rq.Struct( - DEVICEID('deviceid'), - DEVICEID('attachment'), - DEVICEUSE('type'), - rq.Bool('enabled'), - rq.Pad(2), - rq.Card32('flags'), - ) + DEVICEID('deviceid'), + DEVICEID('attachment'), + DEVICEUSE('type'), + rq.Bool('enabled'), + rq.Pad(2), + rq.Card32('flags'), +) HierarchyEventData = rq.Struct( - DEVICEID('deviceid'), - rq.Card32('time'), - rq.Card32('flags'), - rq.LengthOf('info', 2), - rq.Pad(10), - rq.List('info', HierarchyInfo), - ) + DEVICEID('deviceid'), + rq.Card32('time'), + rq.Card32('flags'), + rq.LengthOf('info', 2), + rq.Pad(10), + rq.List('info', HierarchyInfo), +) ModifierInfo = rq.Struct( rq.Card32('base_mods'), From 54fdf9abbc382ba17593b1be5d3ba23b04ad8d2d Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 27 Jun 2016 17:31:59 +0200 Subject: [PATCH 088/279] setup: update download/project URLs --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index e9344267..f8c723c7 100644 --- a/setup.py +++ b/setup.py @@ -13,8 +13,8 @@ version=Xlib.__version_string__, description='Python X Library', - download_url='http://sourceforge.net/projects/python-xlib/files/', - url='http://python-xlib.sourceforge.net/', + download_url='https://github.com/python-xlib/python-xlib/releases', + url='https://github.com/python-xlib/python-xlib', license='GPL', author='Peter Liljenberg', From a82e5f41c1ec1353edf9b7bd75895827bc57a2ba Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 27 Jun 2016 17:33:00 +0200 Subject: [PATCH 089/279] setup: remove code for Python <2.3.3 support --- setup.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/setup.py b/setup.py index f8c723c7..ad941970 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,10 @@ # Distutils script for python-xlib from setuptools import setup -import sys - -if sys.version < '2.3.3': - from distutils.dist import DistributionMetadata - DistributionMetadata.download_url = None import Xlib + setup(name='python-xlib', version=Xlib.__version_string__, From d1cd755fd0b8cdc33df9bf027ed461428a38d3d1 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 27 Jun 2016 17:45:47 +0200 Subject: [PATCH 090/279] protocol/rq: remove dead code --- Xlib/protocol/rq.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 71e0028a..a9c15483 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -60,25 +60,6 @@ class BadDataError(Exception): pass # print array_unsigned_codes, struct_to_array_codes -def _method(func, instance): - """Dynamically create a new method. - - Exposes a common interface for types.MethodType across Python 3 and 2 - """ - if sys.version_info[0] >= 3: - return types.MethodType(func, instance) - else: - return types.MethodType(func, instance, type(instance)) - -def _to_ord(ch): - """Get char code in a cross-Python way""" - if isinstance(ch, int): - # Python 3: bytes char is already an integer, no need to call ord() - return ch - else: - # Python 2: string char required to call ord() - return ord(ch) - class Field(object): """Field objects represent the data fields of a Struct. From 05d74e8c446c96a9fade1f42738fdcedfd6bc579 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 27 Jun 2016 20:53:38 +0200 Subject: [PATCH 091/279] support/vms_connect: fix invalid Python 3 syntax --- Xlib/support/vms_connect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/support/vms_connect.py b/Xlib/support/vms_connect.py index 106eba11..73be0824 100644 --- a/Xlib/support/vms_connect.py +++ b/Xlib/support/vms_connect.py @@ -60,7 +60,7 @@ def get_socket(dname, host, dno): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, 6000 + dno)) - except socket.error, val: + except socket.error as val: raise error.DisplayConnectionError(dname, str(val)) return s From 34c770ec211fa3b9ddc0bcf63601c41813ae64d4 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 28 Jun 2016 12:31:48 +0200 Subject: [PATCH 092/279] update readme --- README.md | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 69fa4e5c..daca7d68 100644 --- a/README.md +++ b/README.md @@ -10,34 +10,29 @@ The main part of the code is Copyright (C) 2000-2002 Peter Liljenberg -Some contributed code is copyrighted by [the contributors](https://github.com/python-xlib/python-xlib/graphs/contributors), in these cases that is indicated in the source files in question. +Some contributed code is copyrighted by [the contributors](https://github.com/python-xlib/python-xlib/graphs/contributors), +in these cases that is indicated in the source files in question. The Python X Library is released under LGPL v2.1 or later (since 2016), see the file LICENSE for details. 0.15rc1 and before were released under GPL v2. ### Requirements -The Python X Library requires Python 1.5.2 or newer. It has been -tested to various extents with Python 1.5.2 and 2.0 through 2.7. +The Python X Library requires Python 2.7 or newer. It has been +tested to various extents with Python 2.7 and 3.3 through 3.5. ### Installation -The Python Xlib uses the standard distutils to make installation -easy. Distutils is shipped with Python 1.6 and newer. Python 1.5.2 -users must download and install distutils before Python Xlib can be -installed. Distutils can be downloaded from -http://www.python.org/sigs/distutils-sig/. - -Install Python Xlib by running this command: +The Python Xlib uses the standard setuptools package, to install run this +command: ``` python setup.py install ``` -Installation can be modified with the normal install options, see the -documentation of distutils for details. +See the command help for details: `python setup.py install -h`. Alternatively, you can run programs from the distribution directory, -or changing the module path in programs. +or change the module path in programs. There's a simple example program, implemented twice using both the high-level interface and the low-level protocol. @@ -101,7 +96,10 @@ Author email: Peter Liljenberg Mailing list: http://sourceforge.net/mail/?group_id=10350 -The Python X Library is a SourceForged project (currently migrating to GitHub). The project page is http://sourceforge.net/projects/python-xlib/. Source is available from that page as zip archive and from the [releases list](https://github.com/python-xlib/python-xlib/releases). +The Python X Library is a SourceForged project (currently migrating to GitHub). +The project page is http://sourceforge.net/projects/python-xlib/. Source is +available from that page as zip archive and from the [releases +list](https://github.com/python-xlib/python-xlib/releases). There isn't any real web page yet, only a derivative of this file. It is located at http://python-xlib.sourceforge.net/. It now also From b86d84b470eb0b89c1898c1c49bcb1abdbc68c7f Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 28 Jun 2016 13:31:04 +0200 Subject: [PATCH 093/279] setup: cosmetic --- setup.py | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/setup.py b/setup.py index ad941970..d46b0e75 100644 --- a/setup.py +++ b/setup.py @@ -5,26 +5,26 @@ import Xlib -setup(name='python-xlib', - version=Xlib.__version_string__, - - description='Python X Library', - download_url='https://github.com/python-xlib/python-xlib/releases', - url='https://github.com/python-xlib/python-xlib', - license='GPL', - - author='Peter Liljenberg', - author_email='petli@ctrl-c.liu.se', - - install_requires=['six>=1.10.0'], - - packages=[ - 'Xlib', - 'Xlib.ext', - 'Xlib.keysymdef', - 'Xlib.protocol', - 'Xlib.support', - 'Xlib.xobject' - ], - ) - +setup( + name='python-xlib', + version=Xlib.__version_string__, + + description='Python X Library', + download_url='https://github.com/python-xlib/python-xlib/releases', + url='https://github.com/python-xlib/python-xlib', + license='GPL', + + author='Peter Liljenberg', + author_email='petli@ctrl-c.liu.se', + + install_requires=['six>=1.10.0'], + + packages=[ + 'Xlib', + 'Xlib.ext', + 'Xlib.keysymdef', + 'Xlib.protocol', + 'Xlib.support', + 'Xlib.xobject' + ], +) From f438fe0f8c12d78870d4d2e80e494ea3de46d794 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 28 Jun 2016 13:32:43 +0200 Subject: [PATCH 094/279] setup: rely on VCS plugin to keep track of distribution files --- MANIFEST.in | 18 ------------------ dev-requirements.txt | 3 ++- setup.py | 1 + 3 files changed, 3 insertions(+), 19 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 8a7138c3..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,18 +0,0 @@ -include MANIFEST.in -include README COPYING NEWS TODO - -global-include .cvsignore - -recursive-include doc Makefile -include doc/src/*.texi -include doc/info/python-xlib.info doc/info/python-xlib.info-*[0-9] -include doc/html/index.html doc/html/python-xlib_toc.html -include doc/html/python-xlib_*.html doc/html/texi2html -include doc/ps/python-xlib.ps - -include utils/tcpbug.py utils/parsexbug.py - -include examples/draw.py examples/draw-proto.py examples/profilex.py -include examples/shapewin.py -include examples/threadtest.py - diff --git a/dev-requirements.txt b/dev-requirements.txt index 403b034e..abadd128 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,2 +1,3 @@ coverage -codecov \ No newline at end of file +codecov +setuptools-scm diff --git a/setup.py b/setup.py index d46b0e75..929e3b26 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,7 @@ author_email='petli@ctrl-c.liu.se', install_requires=['six>=1.10.0'], + setup_requires=['setuptools-scm'], packages=[ 'Xlib', From ebabd38b94a37507e8b2410013a3a39cbee0c986 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 28 Jun 2016 15:32:00 +0200 Subject: [PATCH 095/279] fix readme to make 'python setup.py sdist' happy --- README.md | 106 ---------------------------------------------- README.rst | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 106 deletions(-) delete mode 100644 README.md create mode 100644 README.rst diff --git a/README.md b/README.md deleted file mode 100644 index daca7d68..00000000 --- a/README.md +++ /dev/null @@ -1,106 +0,0 @@ -[![Build Status](https://travis-ci.org/python-xlib/python-xlib.svg?branch=master)](https://travis-ci.org/python-xlib/python-xlib) -[![codecov.io](https://codecov.io/github/python-xlib/python-xlib/coverage.svg?branch=master)](https://codecov.io/github/python-xlib/python-xlib?branch=master) -[![Code Health](https://landscape.io/github/python-xlib/python-xlib/master/landscape.svg?style=flat)](https://landscape.io/github/python-xlib/python-xlib/master) - -# The Python X Library - -### Copyright - -The main part of the code is - - Copyright (C) 2000-2002 Peter Liljenberg - -Some contributed code is copyrighted by [the contributors](https://github.com/python-xlib/python-xlib/graphs/contributors), -in these cases that is indicated in the source files in question. - -The Python X Library is released under LGPL v2.1 or later (since 2016), see the file LICENSE for details. -0.15rc1 and before were released under GPL v2. - -### Requirements - -The Python X Library requires Python 2.7 or newer. It has been -tested to various extents with Python 2.7 and 3.3 through 3.5. - - -### Installation - -The Python Xlib uses the standard setuptools package, to install run this -command: -``` -python setup.py install -``` -See the command help for details: `python setup.py install -h`. - -Alternatively, you can run programs from the distribution directory, -or change the module path in programs. - -There's a simple example program, implemented twice using both the -high-level interface and the low-level protocol. - - -### Introduction - -The Python X Library is intended to be a fully functional X client -library for Python programs. It is written entirely in Python, in -contrast to earlier X libraries for Python (the ancient X extension -and the newer plxlib) which were interfaces to the C Xlib. - -This is possible to do since X client programs communicate with the X -server via the X protocol. The communication takes place over TCP/IP, -Unix sockets, DECnet or any other streaming network protocol. The C -Xlib is merely an interface to this protocol, providing functions -suitable for a C environment. - -There are three advantages of implementing a pure Python library: - - * Integration: The library can make use of the wonderful object - system in Python, providing an easy-to-use class hierarchy. - - * Portability: The library will be usable on (almost) any computer - which have Python installed. A C interface could be problematic to - port to non-Unix systems, such as MS Windows or OpenVMS. - - * Maintainability: It is much easier to develop and debug native - Python modules than modules written in C. - - -### Project status - -The low-level protocol is complete, implementing client-side X11R6. -The high-level object oriented interface is also fully functional. -It is possible to write client applications with the library. -Currently, the only real application using Python Xlib is the window -manager PLWM, starting with version 2.0. - -There is a resource database implementation, ICCCM support and a -framework for adding X extension code. Several extensions have been -implemented; (RECORD, SHAPE, Xinerama, Composite, RANDR, and XTEST) -patches for additions are very welcome. - -There are most likely still bugs, but the library is at least stable -enough to run PLWM. A continuously bigger part of the library is -covered by regression tests, improving stability. - -The documentation is still quite rudimentary, but should be of some -help for people programming with the Xlib. X beginners should first -find some general texts on X. A very good starting point is -http://www.rahul.net/kenton/xsites.html - -See the file TODO for a detailed list of what is missing, -approximately ordered by importance. - - -### Contact information - -Author email: Peter Liljenberg - -Mailing list: http://sourceforge.net/mail/?group_id=10350 - -The Python X Library is a SourceForged project (currently migrating to GitHub). -The project page is http://sourceforge.net/projects/python-xlib/. Source is -available from that page as zip archive and from the [releases -list](https://github.com/python-xlib/python-xlib/releases). - -There isn't any real web page yet, only a derivative of this file. It -is located at http://python-xlib.sourceforge.net/. It now also -features the documentation for downloading or browsing. diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..893bd79e --- /dev/null +++ b/README.rst @@ -0,0 +1,121 @@ +|Build Status| |codecov.io| |Code Health| + +The Python X Library +==================== + +Copyright +~~~~~~~~~ + +The main part of the code is + +:: + + Copyright (C) 2000-2002 Peter Liljenberg + +Some contributed code is copyrighted by `the +contributors `__, +in these cases that is indicated in the source files in question. + +The Python X Library is released under LGPL v2.1 or later (since 2016), +see the file LICENSE for details. 0.15rc1 and before were released under +GPL v2. + +Requirements +~~~~~~~~~~~~ + +The Python X Library requires Python 2.7 or newer. It has been tested to +various extents with Python 2.7 and 3.3 through 3.5. + +Installation +~~~~~~~~~~~~ + +The Python Xlib uses the standard setuptools package, to install run +this command: + +:: + + python setup.py install + +See the command help for details: ``python setup.py install -h``. + +Alternatively, you can run programs from the distribution directory, or +change the module path in programs. + +There's a simple example program, implemented twice using both the +high-level interface and the low-level protocol. + +Introduction +~~~~~~~~~~~~ + +The Python X Library is intended to be a fully functional X client +library for Python programs. It is written entirely in Python, in +contrast to earlier X libraries for Python (the ancient X extension and +the newer plxlib) which were interfaces to the C Xlib. + +This is possible to do since X client programs communicate with the X +server via the X protocol. The communication takes place over TCP/IP, +Unix sockets, DECnet or any other streaming network protocol. The C Xlib +is merely an interface to this protocol, providing functions suitable +for a C environment. + +There are three advantages of implementing a pure Python library: + +- Integration: The library can make use of the wonderful object system + in Python, providing an easy-to-use class hierarchy. + +- Portability: The library will be usable on (almost) any computer + which have Python installed. A C interface could be problematic to + port to non-Unix systems, such as MS Windows or OpenVMS. + +- Maintainability: It is much easier to develop and debug native Python + modules than modules written in C. + +Project status +~~~~~~~~~~~~~~ + +The low-level protocol is complete, implementing client-side X11R6. The +high-level object oriented interface is also fully functional. It is +possible to write client applications with the library. Currently, the +only real application using Python Xlib is the window manager PLWM, +starting with version 2.0. + +There is a resource database implementation, ICCCM support and a +framework for adding X extension code. Several extensions have been +implemented; (RECORD, SHAPE, Xinerama, Composite, RANDR, and XTEST) +patches for additions are very welcome. + +There are most likely still bugs, but the library is at least stable +enough to run PLWM. A continuously bigger part of the library is covered +by regression tests, improving stability. + +The documentation is still quite rudimentary, but should be of some help +for people programming with the Xlib. X beginners should first find some +general texts on X. A very good starting point is +http://www.rahul.net/kenton/xsites.html + +See the file TODO for a detailed list of what is missing, approximately +ordered by importance. + +Contact information +~~~~~~~~~~~~~~~~~~~ + +Author email: Peter Liljenberg petli@ctrl-c.liu.se + +Mailing list: http://sourceforge.net/mail/?group\_id=10350 + +The Python X Library is a SourceForged project (currently migrating to +GitHub). The project page is +http://sourceforge.net/projects/python-xlib/. Source is available from +that page as zip archive and from the `releases +list `__. + +There isn't any real web page yet, only a derivative of this file. It is +located at http://python-xlib.sourceforge.net/. It now also features the +documentation for downloading or browsing. + +.. |Build Status| image:: https://travis-ci.org/python-xlib/python-xlib.svg?branch=master + :target: https://travis-ci.org/python-xlib/python-xlib +.. |codecov.io| image:: https://codecov.io/github/python-xlib/python-xlib/coverage.svg?branch=master + :target: https://codecov.io/github/python-xlib/python-xlib?branch=master +.. |Code Health| image:: https://landscape.io/github/python-xlib/python-xlib/master/landscape.svg?style=flat + :target: https://landscape.io/github/python-xlib/python-xlib/master From d1db58f8c0f84e39f051308ecab8cf85fa9ed08c Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 28 Jun 2016 15:57:46 +0200 Subject: [PATCH 096/279] setup: add PyPi keywords/classifiers --- setup.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/setup.py b/setup.py index 929e3b26..a68d2ef9 100644 --- a/setup.py +++ b/setup.py @@ -28,4 +28,22 @@ 'Xlib.support', 'Xlib.xobject' ], + + keywords='xlib x11 x windows', + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: X11 Applications', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: GNU General Public License (GPL)', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: Implementation :: CPython', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Software Development :: Libraries', + 'Topic :: Software Development :: User Interfaces', + ], ) From e4c9a2d95391a38a63c905f52ececdc4e64e2efe Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 28 Jun 2016 18:14:30 +0200 Subject: [PATCH 097/279] setup: fix license --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index a68d2ef9..b425618f 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ description='Python X Library', download_url='https://github.com/python-xlib/python-xlib/releases', url='https://github.com/python-xlib/python-xlib', - license='GPL', + license='LGPLv2+', author='Peter Liljenberg', author_email='petli@ctrl-c.liu.se', @@ -34,7 +34,7 @@ 'Development Status :: 5 - Production/Stable', 'Environment :: X11 Applications', 'Intended Audience :: Developers', - 'License :: OSI Approved :: GNU General Public License (GPL)', + 'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)', 'Operating System :: OS Independent', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', From 529a4bd46c722fb65f88e6cdab8765c2aaa72798 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 28 Jun 2016 23:13:57 +0200 Subject: [PATCH 098/279] travis: fix command to run tests Make sure nosetest pick up all our tests in test/, including those present in executable files. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fe3a4055..d6321643 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ before_script: # command to run tests script: - nosetests --with-xunit --with-coverage --cover-html --cover-html-dir=Coverage_report --verbosity=3 test/ examples/run_examples.py + nosetests --exe --with-xunit --with-coverage --cover-html --cover-html-dir=Coverage_report --verbosity=3 test/ examples/run_examples.py after_success: - codecov From 55597878d641aade2f0bcd2f9550a269af06a688 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 29 Jun 2016 16:46:26 +0200 Subject: [PATCH 099/279] landscape: add configuration - enable Python 3 support - disable support for the mccabe tool to prevent decoding errors when parsing Xlib/protocol/display.py --- .landscape.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .landscape.yml diff --git a/.landscape.yml b/.landscape.yml new file mode 100644 index 00000000..2c3de431 --- /dev/null +++ b/.landscape.yml @@ -0,0 +1,4 @@ +python-targets: [2, 3] + +mccabe: + run: false From 7069b07919b0b135ab7a2489f186c7a808e1326b Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 29 Jun 2016 01:26:33 +0200 Subject: [PATCH 100/279] protocol: improve support for binary strings Rename rq.Bytes to rq.Binary and rq.FixedString to rq.FixedBinary so it's clear what those fields are used for. --- Xlib/ext/security.py | 6 +++--- Xlib/protocol/event.py | 2 +- Xlib/protocol/rq.py | 13 ++++--------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Xlib/ext/security.py b/Xlib/ext/security.py index c9afceed..ad3e77ab 100644 --- a/Xlib/ext/security.py +++ b/Xlib/ext/security.py @@ -72,7 +72,7 @@ class SecurityGenerateAuthorization(rq.ReplyRequest): rq.LengthOf('auth_data', 2), rq.Card32('value_mask'), rq.String8('auth_proto'), - rq.Bytes('auth_data'), + rq.Binary('auth_data'), rq.List('values', rq.Card32Obj) ) _reply = rq.Struct(rq.ReplyCode(), @@ -82,11 +82,11 @@ class SecurityGenerateAuthorization(rq.ReplyRequest): AUTHID('authid'), rq.LengthOf('auth_data_return', 2), rq.Pad(18), - rq.Bytes('auth_data_return') + rq.Binary('auth_data_return') ) -def generate_authorization(self, auth_proto, auth_data='', timeout=None, +def generate_authorization(self, auth_proto, auth_data=b'', timeout=None, trust_level=None, group=None, event_mask=None): value_mask = 0 values = [] diff --git a/Xlib/protocol/event.py b/Xlib/protocol/event.py index ff2cf766..db04247c 100644 --- a/Xlib/protocol/event.py +++ b/Xlib/protocol/event.py @@ -29,7 +29,7 @@ class AnyEvent(rq.Event): _fields = rq.Struct( rq.Card8('type'), rq.Card8('detail'), rq.Card16('sequence_number'), - rq.FixedString('data', 28), + rq.FixedBinary('data', 28), ) class KeyButtonPointer(rq.Event): diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index a9c15483..46782809 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -364,7 +364,7 @@ def __init__(self, name): X.SouthEastGravity)) -class FixedString(ValueField): +class FixedBinary(ValueField): structvalues = 1 def __init__(self, name, size): @@ -372,7 +372,7 @@ def __init__(self, name, size): self.structcode = '{0}s'.format(size) -class Bytes(ValueField): +class Binary(ValueField): structcode = None def __init__(self, name, pad = 1): @@ -380,10 +380,7 @@ def __init__(self, name, pad = 1): self.pad = pad def pack_value(self, val): - if isinstance(val, bytes): - val_bytes = val - else: - val_bytes = val.encode() + val_bytes = val slen = len(val_bytes) if self.pad: @@ -400,9 +397,7 @@ def parse_binary_value(self, data, display, length, format): else: slen = length - data_bytes = data[:length] - - return data_bytes, data[slen:] + return data[:length], data[slen:] class String8(ValueField): From 2b544833b0801e1519acae3dcabc7f99227349ae Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 29 Jun 2016 02:02:11 +0200 Subject: [PATCH 101/279] test: fix tohex helper --- test/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/__init__.py b/test/__init__.py index d6f7d286..7b73e96c 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -70,7 +70,7 @@ def setUpClass(cls): def tohex(bin): hex = [] for i in range(0, len(bin), 16): - hex.append(binascii.hexlify(bin[i:i+16]) + '\n') + hex.append(str(binascii.hexlify(bin[i:i+16])) + '\n') return hex def bindiff(bin1, bin2): From 1a69abeb5afc526e896d717f2b7515ee79b35fa1 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 29 Jun 2016 01:29:57 +0200 Subject: [PATCH 102/279] test: add struct tests --- test/test_struct.py | 174 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100755 test/test_struct.py diff --git a/test/test_struct.py b/test/test_struct.py new file mode 100755 index 00000000..c2ce4bb2 --- /dev/null +++ b/test/test_struct.py @@ -0,0 +1,174 @@ + +from collections import OrderedDict +from functools import partial +import struct +import types +import re + +from six import binary_type + +from Xlib.protocol import rq +from . import DummyDisplay, TestCase + + +dummy_display = DummyDisplay() + +def pack(format, *args): + return struct.pack('=' + format, *args) + +def packstr(s, padding=0): + return s.encode() + (b'\0' * padding) + + +class StructTest(object): + """ Test class helper for rq.Struct packing/unpacking support. """ + + struct = None + values = None + binary = None + + def test_pack_value_dict(self): + self.assertBinaryEqual(self.struct.pack_value(dict(self.values)), self.binary) + + def test_pack_value_tuple(self): + self.assertBinaryEqual(self.struct.pack_value(tuple(self.values.values())), self.binary) + + def test_to_binary_args(self): + self.assertBinaryEqual(self.struct.to_binary(*self.values.values()), self.binary) + + def test_to_binary_kwargs(self): + self.assertBinaryEqual(self.struct.to_binary(**dict(self.values)), self.binary) + + def test_parse_binary(self): + values, remain = self.struct.parse_binary(self.binary, dummy_display) + self.assertEqual(values, rq.DictWrapper(dict(self.values))) + self.assertBinaryEmpty(remain) + + +def _struct_test(name, fields): + """ Generate a new Struct packing/unpacking test. + + is a list of (field_name, field_type, field_value, field_binary): + - field_name: + name of the field, None if it's not a named field (e.g. LengthOf) + - field_type: + factory for the field type, taking one parameter only, the name of + the field and returning a rq.Field subclass instance + - field_value: + the raw value passed in when packing and expected output on unpacking + - field_binary: + the binary representation of the field value or a function to + convert it to binary for creating the expected result of packing + the struct + """ + + class_name = ''.join([part.capitalize() for part in re.sub(r'[^\w]+', ' ', name).split()]) + class_name += 'StructTest' + struct_layout = [] + values = OrderedDict() + binary = b'' + for field_name, field_type, field_value, field_binary in fields: + struct_layout.append(field_type(field_name)) + if field_name is not None and field_value is not None: + values[field_name] = field_value + if isinstance(field_binary, binary_type): + binary += field_binary + elif isinstance(field_binary, (types.FunctionType, types.LambdaType, partial)): + binary += field_binary(field_value) + else: + raise ValueError('unsupported type for binary: {data} [{type}]'.format( + data=str(field_binary), type=type(field_binary)) + ) + class_dict = { + 'struct': rq.Struct(*struct_layout), + 'values': values, + 'binary': binary, + } + globals()[class_name] = type(class_name, (StructTest, TestCase), class_dict) + + +_struct_test('card', ( + ('c8' , rq.Card8 , 0x42 , partial(pack, 'B')), + ('c16', rq.Card16, 0x666 , partial(pack, 'H')), + ('c32', rq.Card32, 0xdeadbeef, partial(pack, 'L')), +)) + +_struct_test('int', ( + ('i8' , rq.Int8 , -42 , partial(pack, 'b')), + ('i16', rq.Int16, -666 , partial(pack, 'h')), + ('i32', rq.Int32, -2147483648, partial(pack, 'l')), +)) + +_struct_test('list', ( + (None , lambda name: rq.LengthOf('lc8', 1) , None , pack('B', 2) ), + (None , lambda name: rq.LengthOf('lc16', 2) , None , pack('H', 3) ), + (None , lambda name: rq.LengthOf('lc32', 4) , None , pack('L', 5) ), + ('lc8' , lambda name: rq.List(name, rq.Card8 , pad=0), [0x42, 0xc3] , lambda v: pack('2B' , *v)), + ('lc16' , lambda name: rq.List(name, rq.Card16, pad=0), [666, 1, 60143] , lambda v: pack('3H' , *v)), + ('lc32' , lambda name: rq.List(name, rq.Card32, pad=0), [0xf02facb, 666, 1, 0x1043, 0xdeadbeef], lambda v: pack('5L' , *v)), +)) + +_struct_test('list pad', ( + (None , lambda name: rq.LengthOf('lc8', 1) , None , pack('B', 2) ), + (None , lambda name: rq.LengthOf('lc16', 2) , None , pack('H', 3) ), + (None , lambda name: rq.LengthOf('lc32', 4) , None , pack('L', 5) ), + ('lc8' , lambda name: rq.List(name, rq.Card8 , pad=1), [0x42, 0xc3] , lambda v: pack('2B2x', *v)), + ('lc16' , lambda name: rq.List(name, rq.Card16, pad=1), [666, 1, 60143] , lambda v: pack('3H2x', *v)), + ('lc32' , lambda name: rq.List(name, rq.Card32, pad=1), [0xf02facb, 666, 1, 0x1043, 0xdeadbeef], lambda v: pack('5L' , *v)), +)) + +_struct_test('fixed list', ( + ('lc8' , lambda name: rq.FixedList(name, 2, rq.Card8 , pad=0), [0x42, 0xc3] , lambda v: pack('2B' , *v)), + ('lc16' , lambda name: rq.FixedList(name, 3, rq.Card16, pad=0), [666, 1, 60143] , lambda v: pack('3H' , *v)), + ('lc32' , lambda name: rq.FixedList(name, 5, rq.Card32, pad=0), [0xf02facb, 666, 1, 0x1043, 0xdeadbeef], lambda v: pack('5L' , *v)), +)) + +_struct_test('fixed list pad', ( + ('lc8p' , lambda name: rq.FixedList(name, 2, rq.Card8 , pad=1), [0x42, 0xc3] , lambda v: pack('2B2x', *v)), + ('lc16p', lambda name: rq.FixedList(name, 3, rq.Card16, pad=1), [666, 1, 60143] , lambda v: pack('3H2x', *v)), + ('lc32p', lambda name: rq.FixedList(name, 5, rq.Card32, pad=1), [0xf02facb, 666, 1, 0x1043, 0xdeadbeef], lambda v: pack('5L' , *v)), +)) + +_struct_test('string8', ( + (None, lambda name: rq.LengthOf('s1', 1) , None , pack('B', 7) ), + (None, lambda name: rq.LengthOf('s2', 2) , None , pack('H', 13)), + (None, lambda name: rq.LengthOf('s3', 4) , None , pack('L', 34)), + ('s1', lambda name: rq.String8(name, pad=0), "testing" , packstr ), + ('s2', lambda name: rq.String8(name, pad=0), "one two three" , packstr ), + ('s3', lambda name: rq.String8(name, pad=0), "supercalifragilisticexpialidocious", packstr ), +)) + +_struct_test('string8 pad', ( + (None, lambda name: rq.LengthOf('s1', 1) , None , pack('B', 7) ), + (None, lambda name: rq.LengthOf('s2', 2) , None , pack('H', 13) ), + (None, lambda name: rq.LengthOf('s3', 4) , None , pack('L', 34) ), + ('s1', lambda name: rq.String8(name, pad=1), "testing" , partial(packstr, padding=1)), + ('s2', lambda name: rq.String8(name, pad=1), "one two three" , partial(packstr, padding=3)), + ('s3', lambda name: rq.String8(name, pad=1), "supercalifragilisticexpialidocious", partial(packstr, padding=2)), +)) + +_struct_test('binary', ( + (None, lambda name: rq.LengthOf('s1', 1) , None , pack('B', 7) ), + (None, lambda name: rq.LengthOf('s2', 2) , None , pack('H', 13)), + (None, lambda name: rq.LengthOf('s3', 4) , None , pack('L', 34)), + ('s1', lambda name: rq.Binary(name, pad=0), b"testing" , lambda v: v), + ('s2', lambda name: rq.Binary(name, pad=0), b"one two three" , lambda v: v), + ('s3', lambda name: rq.Binary(name, pad=0), b"supercalifragilisticexpialidocious", lambda v: v), +)) + +_struct_test('binary pad', ( + (None, lambda name: rq.LengthOf('s1', 1) , None , pack('B', 7) ), + (None, lambda name: rq.LengthOf('s2', 2) , None , pack('H', 13)), + (None, lambda name: rq.LengthOf('s3', 4) , None , pack('L', 34)), + ('s1', lambda name: rq.Binary(name, pad=1), b"testing" , lambda v: v + b'\0' * 1), + ('s2', lambda name: rq.Binary(name, pad=1), b"one two three" , lambda v: v + b'\0' * 3), + ('s3', lambda name: rq.Binary(name, pad=1), b"supercalifragilisticexpialidocious", lambda v: v + b'\0' * 2), +)) + +_struct_test('fixed binary', ( + ('s1', lambda name: rq.FixedBinary(name, 7 ), b"testing" , lambda v: v), + ('s2', lambda name: rq.FixedBinary(name, 13), b"one two three" , lambda v: v), + ('s3', lambda name: rq.FixedBinary(name, 34), b"supercalifragilisticexpialidocious", lambda v: v), + # Make sure fixed binary fields are handled as static fields. + ('c8', rq.Card8, 0x42, partial(pack, 'B')), +)) From 5796c74a18175afb481f5f883b9cd7ee329bfb87 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 28 Jun 2016 16:02:40 +0200 Subject: [PATCH 103/279] travis: add GitHub deployment --- .travis.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.travis.yml b/.travis.yml index d6321643..c25584bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,3 +23,27 @@ script: after_success: - codecov + +before_deploy: + # Generate source distribution. + # Note: only do this with Python 3.5 so we get support for tar.xz, and + # because the contents of the distribution are the same for all versions. + - case "$TRAVIS_PYTHON_VERSION" in 3.5) python setup.py sdist --formats=xztar;; esac + # Generate egg distribution. + - python setup.py bdist_egg + # Generate wheel distribution. + # Note: only do this once for each major Python version, as the minor version + # number is not encoded in the resulting filename (and contents are the same). + - case "$TRAVIS_PYTHON_VERSION" in 2.7|3.5) python setup.py bdist_wheel;; esac + +deploy: + - provider: releases + api_key: + secure: "lBEbXUeBQyDspP0XBGM/NgfzO2AhW3sMRqCKvOxWQNw4VrC+nfXCkF3OyuRkqQbw+25TKHJadjg+NxX/FtCxdKAJo2MeRrCxNmLqVhq3PnRyBSkVROxYfDFZFL12hmeFA0CrZp45uuSWdruU7a0xh9SkFVBdHSYt55jIzbHKZBdqy1fnL/ot+hnafmsUWc+EiP0s6BgLeqihfevxq87imKyzMKpyH8ofwKKWx6LTgq9khJdQt5x4LUm+Kq8HDcdDeJtz2eLFziDGA7ds+aIpbrk0bG8tmT4SaM06EmJCZoegifGWWnkf5xEe5CVmQXS8Xl3R2bgeII5O4eXUWUXk1tT2nuPLPPv4iTSsZkEd1UH/eHupIID/IKuVqo2GrhvzLBcIzDCFaZg/U8ufARmsx1FGfuzqWwzpqXb+tvDBp6Xz6xSpjrUwwJ41oDRWnDzGLN3uvH06VeMcy6pVFftRLbiMVpOEd76tNvGEEEj4ropb7VyvRL+IHGwbb0Ns62toJYDbgzHyBhisN43tFmaT8fpqLvZP7yuRCMIqs8mtH9Iw4YpOJUG8scsFtX445C4xEGw1j/E6TZkjBrfG0O1FVP1Q6wHYCyutCNjvGKnWvyd+4pg1Nzx/HC/O+ioNefVm+jOTjKtKla/kY6P3ctDWGjXgHGqRe6gn0MtwmR/T+mY=" + file_glob: true + file: + - dist/*.tar.* + - dist/*.egg + - dist/*.whl + on: + tags: true From b73b17d6d3f0d30da36490d3b59bc2a98309f2a6 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Fri, 1 Jul 2016 14:37:22 +0300 Subject: [PATCH 104/279] Replace license text in all files except shape.py (we have no confirmation from Jeffrey about the license change) --- Xlib/X.py | 25 ++++++++++++++----------- Xlib/XK.py | 25 ++++++++++++++----------- Xlib/Xatom.py | 25 ++++++++++++++----------- Xlib/Xcursorfont.py | 25 ++++++++++++++----------- Xlib/Xutil.py | 25 ++++++++++++++----------- Xlib/__init__.py | 27 +++++++++++++++------------ Xlib/display.py | 25 ++++++++++++++----------- Xlib/error.py | 25 ++++++++++++++----------- Xlib/ext/__init__.py | 25 ++++++++++++++----------- Xlib/ext/composite.py | 29 ++++++++++++++++------------- Xlib/ext/ge.py | 25 ++++++++++++++----------- Xlib/ext/randr.py | 26 ++++++++++++++------------ Xlib/ext/record.py | 25 ++++++++++++++----------- Xlib/ext/security.py | 25 ++++++++++++++----------- Xlib/ext/xfixes.py | 25 ++++++++++++++----------- Xlib/ext/xinerama.py | 26 ++++++++++++++------------ Xlib/ext/xinput.py | 25 ++++++++++++++----------- Xlib/ext/xtest.py | 25 ++++++++++++++----------- Xlib/keysymdef/__init__.py | 25 ++++++++++++++----------- Xlib/protocol/__init__.py | 25 ++++++++++++++----------- Xlib/protocol/display.py | 27 +++++++++++++++------------ Xlib/protocol/event.py | 25 ++++++++++++++----------- Xlib/protocol/request.py | 25 ++++++++++++++----------- Xlib/protocol/rq.py | 25 ++++++++++++++----------- Xlib/protocol/structs.py | 25 ++++++++++++++----------- Xlib/rdb.py | 25 ++++++++++++++----------- Xlib/support/__init__.py | 25 ++++++++++++++----------- Xlib/support/connect.py | 25 ++++++++++++++----------- Xlib/support/lock.py | 25 ++++++++++++++----------- Xlib/support/unix_connect.py | 25 ++++++++++++++----------- Xlib/support/vms_connect.py | 25 ++++++++++++++----------- Xlib/threaded.py | 25 ++++++++++++++----------- Xlib/xauth.py | 25 ++++++++++++++----------- Xlib/xobject/__init__.py | 25 ++++++++++++++----------- Xlib/xobject/colormap.py | 25 ++++++++++++++----------- Xlib/xobject/cursor.py | 25 ++++++++++++++----------- Xlib/xobject/drawable.py | 25 ++++++++++++++----------- Xlib/xobject/fontable.py | 25 ++++++++++++++----------- Xlib/xobject/icccm.py | 25 ++++++++++++++----------- Xlib/xobject/resource.py | 25 ++++++++++++++----------- examples/childwin.py | 25 ++++++++++++++----------- examples/draw-proto.py | 25 ++++++++++++++----------- examples/draw.py | 25 ++++++++++++++----------- examples/eventthread.py | 25 ++++++++++++++----------- examples/get_selection.py | 31 +++++++++++++++++-------------- examples/put_selection.py | 35 +++++++++++++++++++---------------- examples/record_demo.py | 34 ++++++++++++++++++++-------------- examples/run_examples.py | 5 +---- examples/security.py | 25 ++++++++++++++----------- examples/shapewin.py | 25 ++++++++++++++----------- examples/xfixes.py | 25 ++++++++++++++----------- examples/xinerama.py | 26 ++++++++++++++------------ examples/xinput.py | 25 ++++++++++++++----------- examples/xlsatoms.py | 29 ++++++++++++++++------------- examples/xrandr.py | 26 ++++++++++++++------------ test/gen/genprottest.py | 0 test/test_events_be.py | 0 test/test_events_le.py | 0 test/test_manual.py | 0 test/test_rdb.py | 0 test/test_requests_le.py | 0 test/test_struct.py | 0 62 files changed, 777 insertions(+), 619 deletions(-) mode change 100755 => 100644 test/gen/genprottest.py mode change 100755 => 100644 test/test_events_be.py mode change 100755 => 100644 test/test_events_le.py mode change 100755 => 100644 test/test_manual.py mode change 100755 => 100644 test/test_rdb.py mode change 100755 => 100644 test/test_requests_le.py mode change 100755 => 100644 test/test_struct.py diff --git a/Xlib/X.py b/Xlib/X.py index 27ea3ec3..3105e798 100644 --- a/Xlib/X.py +++ b/Xlib/X.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Avoid overwriting None if doing "from Xlib.X import *" NONE = 0 diff --git a/Xlib/XK.py b/Xlib/XK.py index bdd6cdef..7603ccd0 100644 --- a/Xlib/XK.py +++ b/Xlib/XK.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # # This module defines some functions for working with X keysyms as well # as a modular keysym definition and loading mechanism. See the keysym diff --git a/Xlib/Xatom.py b/Xlib/Xatom.py index a8f0b3c2..b0137779 100644 --- a/Xlib/Xatom.py +++ b/Xlib/Xatom.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA PRIMARY = 1 SECONDARY = 2 diff --git a/Xlib/Xcursorfont.py b/Xlib/Xcursorfont.py index c0dadef4..19919438 100644 --- a/Xlib/Xcursorfont.py +++ b/Xlib/Xcursorfont.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA num_glyphs = 154 X_cursor = 0 diff --git a/Xlib/Xutil.py b/Xlib/Xutil.py index 33cf099d..768c5e2f 100644 --- a/Xlib/Xutil.py +++ b/Xlib/Xutil.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA NoValue = 0x0000 diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 68f81232..167cde9d 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -2,23 +2,26 @@ # # Copyright (C) 2000-2002 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA __version__ = (0, 15) -__version_extra__ = 'rc1' +__version_extra__ = '' __version_string__ = '.'.join(map(str, __version__)) + __version_extra__ diff --git a/Xlib/display.py b/Xlib/display.py index b6ce0702..d5fd3faa 100644 --- a/Xlib/display.py +++ b/Xlib/display.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Python modules import types diff --git a/Xlib/error.py b/Xlib/error.py index 92ac60cb..cb6d0d07 100644 --- a/Xlib/error.py +++ b/Xlib/error.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Xlib modules from . import X diff --git a/Xlib/ext/__init__.py b/Xlib/ext/__init__.py index cd0de782..4ba62f8e 100644 --- a/Xlib/ext/__init__.py +++ b/Xlib/ext/__init__.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # __extensions__ is a list of tuples: (extname, extmod) # extname is the name of the extension according to the X diff --git a/Xlib/ext/composite.py b/Xlib/ext/composite.py index bdc37db2..95ff2445 100644 --- a/Xlib/ext/composite.py +++ b/Xlib/ext/composite.py @@ -4,19 +4,22 @@ # # Copyright (C) 2007 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA """Composite extension, allowing windows to be rendered to off-screen storage. @@ -160,7 +163,7 @@ def create_region_from_border_clip(self): """Create a region of the border clip of the window, i.e. the area that is not clipped by the parent and any sibling windows. """ - + rid = self.display.allocate_resource_id() CreateRegionFromBorderClip( display = self.display, @@ -202,7 +205,7 @@ def name_window_pixmap(self): cls = self.display.get_resource_class('pixmap', drawable.Pixmap) return cls(self.display, pid, owner = 1) - + def init(disp, info): disp.extension_add_method('display', diff --git a/Xlib/ext/ge.py b/Xlib/ext/ge.py index 749ace60..291ffa9a 100644 --- a/Xlib/ext/ge.py +++ b/Xlib/ext/ge.py @@ -3,19 +3,22 @@ # Copyright (C) 2012 Outpost Embedded, LLC # Forest Bond # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA ''' ge - Generic Event Extension diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index 168b90f6..0a1dfb9c 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -2,20 +2,22 @@ # # Copyright (C) 2006 Mike Meyer # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA """RandR - provide access to the RandR extension information. diff --git a/Xlib/ext/record.py b/Xlib/ext/record.py index 6b164537..28be9433 100644 --- a/Xlib/ext/record.py +++ b/Xlib/ext/record.py @@ -2,19 +2,22 @@ # # Copyright (C) 2006 Alex Badea # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA from Xlib import X from Xlib.protocol import rq diff --git a/Xlib/ext/security.py b/Xlib/ext/security.py index ad3e77ab..a8210171 100644 --- a/Xlib/ext/security.py +++ b/Xlib/ext/security.py @@ -3,19 +3,22 @@ # Copyright (C) 2010-2013 Outpost Embedded, LLC # Forest Bond # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA ''' A partial implementation of the SECURITY extension. Support for the diff --git a/Xlib/ext/xfixes.py b/Xlib/ext/xfixes.py index 671bcafa..72feb6d4 100644 --- a/Xlib/ext/xfixes.py +++ b/Xlib/ext/xfixes.py @@ -3,19 +3,22 @@ # Copyright (C) 2010-2011 Outpost Embedded, LLC # Forest Bond # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA ''' A partial implementation of the XFIXES extension. Only the HideCursor and diff --git a/Xlib/ext/xinerama.py b/Xlib/ext/xinerama.py index 65d7bd41..12d2f0e0 100644 --- a/Xlib/ext/xinerama.py +++ b/Xlib/ext/xinerama.py @@ -2,20 +2,22 @@ # # Copyright (C) 2006 Mike Meyer # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA """Xinerama - provide access to the Xinerama extension information. diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 21fb1933..1c95b54b 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -3,19 +3,22 @@ # Copyright (C) 2012 Outpost Embedded, LLC # Forest Bond # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA ''' A very incomplete implementation of the XInput extension. diff --git a/Xlib/ext/xtest.py b/Xlib/ext/xtest.py index e69b25cd..602df2ae 100644 --- a/Xlib/ext/xtest.py +++ b/Xlib/ext/xtest.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA from Xlib import X from Xlib.protocol import rq diff --git a/Xlib/keysymdef/__init__.py b/Xlib/keysymdef/__init__.py index adbe499d..4ff14416 100644 --- a/Xlib/keysymdef/__init__.py +++ b/Xlib/keysymdef/__init__.py @@ -2,19 +2,22 @@ # # Copyright (C) 2001 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA __all__ = [ 'apl', diff --git a/Xlib/protocol/__init__.py b/Xlib/protocol/__init__.py index b1239b4b..4e2840a1 100644 --- a/Xlib/protocol/__init__.py +++ b/Xlib/protocol/__init__.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA __all__ = [ 'display', diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index c2a304d8..db93f795 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -4,19 +4,22 @@ # # Copyright (C) 2000-2002 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Standard modules import sys @@ -797,7 +800,7 @@ def parse_event_response(self, etype): # Decrement it by one, so that we don't remove the request # that generated these events, if there is such a one. - # Bug reported by Ilpo Nyyssönen + # Bug reported by Ilpo Nyyss�nen self.get_waiting_request((e.sequence_number - 1) % 65536) # print 'recv Event:', e diff --git a/Xlib/protocol/event.py b/Xlib/protocol/event.py index db04247c..04743c6d 100644 --- a/Xlib/protocol/event.py +++ b/Xlib/protocol/event.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000-2002 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Xlib modules diff --git a/Xlib/protocol/request.py b/Xlib/protocol/request.py index e58a9bd2..578f4a68 100644 --- a/Xlib/protocol/request.py +++ b/Xlib/protocol/request.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000-2002 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Xlib modules diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 46782809..1a899d45 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000-2002 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Standard modules import sys diff --git a/Xlib/protocol/structs.py b/Xlib/protocol/structs.py index 826a6940..1661440d 100644 --- a/Xlib/protocol/structs.py +++ b/Xlib/protocol/structs.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Xlib modules from .. import X diff --git a/Xlib/rdb.py b/Xlib/rdb.py index 9b7c5544..21ef5622 100644 --- a/Xlib/rdb.py +++ b/Xlib/rdb.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # See end of file for an explanation of the algorithm and diff --git a/Xlib/support/__init__.py b/Xlib/support/__init__.py index a7c049cf..4c0d622b 100644 --- a/Xlib/support/__init__.py +++ b/Xlib/support/__init__.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA __all__ = [ 'lock', diff --git a/Xlib/support/connect.py b/Xlib/support/connect.py index 597335a3..af42d620 100644 --- a/Xlib/support/connect.py +++ b/Xlib/support/connect.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA import sys import importlib diff --git a/Xlib/support/lock.py b/Xlib/support/lock.py index dca874f6..6eee31f4 100644 --- a/Xlib/support/lock.py +++ b/Xlib/support/lock.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA class _DummyLock(object): def __init__(self): diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index fab1d5a0..5da37950 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000,2002 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA import re import os diff --git a/Xlib/support/vms_connect.py b/Xlib/support/vms_connect.py index 73be0824..394077b7 100644 --- a/Xlib/support/vms_connect.py +++ b/Xlib/support/vms_connect.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA import re import socket diff --git a/Xlib/threaded.py b/Xlib/threaded.py index 4a84b55f..44fcafeb 100644 --- a/Xlib/threaded.py +++ b/Xlib/threaded.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA from six.moves import _thread diff --git a/Xlib/xauth.py b/Xlib/xauth.py index 4637e535..f5c12b11 100644 --- a/Xlib/xauth.py +++ b/Xlib/xauth.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA import os import struct diff --git a/Xlib/xobject/__init__.py b/Xlib/xobject/__init__.py index 06da3453..67d32549 100644 --- a/Xlib/xobject/__init__.py +++ b/Xlib/xobject/__init__.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA __all__ = [ 'colormap', diff --git a/Xlib/xobject/colormap.py b/Xlib/xobject/colormap.py index d6ad23ea..033fb493 100644 --- a/Xlib/xobject/colormap.py +++ b/Xlib/xobject/colormap.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA from Xlib import error from Xlib.protocol import request diff --git a/Xlib/xobject/cursor.py b/Xlib/xobject/cursor.py index 6aebb001..432e4fd9 100644 --- a/Xlib/xobject/cursor.py +++ b/Xlib/xobject/cursor.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA from Xlib.protocol import request diff --git a/Xlib/xobject/drawable.py b/Xlib/xobject/drawable.py index a1df88e9..b8f7b9a1 100644 --- a/Xlib/xobject/drawable.py +++ b/Xlib/xobject/drawable.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA from Xlib import X, Xatom, Xutil from Xlib.protocol import request, rq diff --git a/Xlib/xobject/fontable.py b/Xlib/xobject/fontable.py index 3e73e88b..892f2665 100644 --- a/Xlib/xobject/fontable.py +++ b/Xlib/xobject/fontable.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA from Xlib.protocol import request diff --git a/Xlib/xobject/icccm.py b/Xlib/xobject/icccm.py index a6a1eb4e..d445e6df 100644 --- a/Xlib/xobject/icccm.py +++ b/Xlib/xobject/icccm.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA from Xlib import X, Xutil from Xlib.protocol import rq diff --git a/Xlib/xobject/resource.py b/Xlib/xobject/resource.py index b7a5ad63..0492ffec 100644 --- a/Xlib/xobject/resource.py +++ b/Xlib/xobject/resource.py @@ -2,19 +2,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA from Xlib.protocol import request diff --git a/examples/childwin.py b/examples/childwin.py index 75e49fcf..9a0cf6b3 100755 --- a/examples/childwin.py +++ b/examples/childwin.py @@ -5,19 +5,22 @@ # Copyright (C) 2008 David Bronke # Copyright (C) 2002 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function diff --git a/examples/draw-proto.py b/examples/draw-proto.py index a4a16807..3db1b994 100755 --- a/examples/draw-proto.py +++ b/examples/draw-proto.py @@ -4,19 +4,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA import sys diff --git a/examples/draw.py b/examples/draw.py index d075b1c7..8832a50f 100755 --- a/examples/draw.py +++ b/examples/draw.py @@ -4,19 +4,22 @@ # # Copyright (C) 2000 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA import sys diff --git a/examples/eventthread.py b/examples/eventthread.py index 2638354c..da8cb505 100755 --- a/examples/eventthread.py +++ b/examples/eventthread.py @@ -5,19 +5,22 @@ # Copyright (C) 2010-2011 Outpost Embedded, LLC # Forest Bond # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function diff --git a/examples/get_selection.py b/examples/get_selection.py index 6a02a0b2..0cbd6683 100755 --- a/examples/get_selection.py +++ b/examples/get_selection.py @@ -5,19 +5,22 @@ # # Copyright (C) 2013 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA import sys import os @@ -78,7 +81,7 @@ def main(): # Ask for the selection. We shouldn't use X.CurrentTime, but # since we don't have an event here we have to. w.convert_selection(sel_atom, target_atom, data_atom, X.CurrentTime) - + # Wait for the notificiaton that we got the selection while True: e = d.next_event() @@ -112,7 +115,7 @@ def main(): # Tell selection owner that we're done w.delete_property(data_atom) - + def handle_incr(d, w, data_atom, target_name): # This works by us removing the data property, the selection owner @@ -140,7 +143,7 @@ def handle_incr(d, w, data_atom, target_name): # End of data if len(r.value) == 0: return - + output_data(d, r, target_name) # loop around diff --git a/examples/put_selection.py b/examples/put_selection.py index b0df239f..ac488621 100755 --- a/examples/put_selection.py +++ b/examples/put_selection.py @@ -5,19 +5,22 @@ # # Copyright (C) 2013 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA import sys import os @@ -88,7 +91,7 @@ def main(): # We must have a window to own a selection w = d.screen().root.create_window( 0, 0, 10, 10, 0, X.CopyFromParent) - + # And to grab the selection we must have a timestamp, get one with # a property notify when we're anyway setting wm_name w.change_attributes(event_mask = X.PropertyChangeMask) @@ -97,7 +100,7 @@ def main(): e = d.next_event() sel_time = e.time w.change_attributes(event_mask = 0) - + # Grab the selection and make sure we actually got it w.set_selection_owner(sel_atom, sel_time) if d.get_selection_owner(sel_atom) != w: @@ -105,7 +108,7 @@ def main(): return log('took ownership of selection {0}', sel_name) - + # The event loop, waiting for and processing requests while True: e = d.next_event() @@ -123,7 +126,7 @@ def main(): client_prop = e.property target_name = d.get_atom_name(e.target) - + log('got request for {0}, dest {1} on 0x{2:08x} {3}', target_name, d.get_atom_name(client_prop), client.id, client.get_wm_name()) @@ -162,7 +165,7 @@ def main(): client.send_event(ev) # Done! - + elif (e.type == X.SelectionClear and e.window == w and e.atom == sel_atom): diff --git a/examples/record_demo.py b/examples/record_demo.py index 55e13080..62b88fe0 100755 --- a/examples/record_demo.py +++ b/examples/record_demo.py @@ -4,22 +4,28 @@ # # Copyright (C) 2006 Alex Badea # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# Simple demo for the RECORD extension -# Not very much unlike the xmacrorec2 program in the xmacro package. +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA + +''' +Simple demo for the RECORD extension + +Not very much unlike the xmacrorec2 program in the xmacro package. +''' # Python 2/3 compatibility. diff --git a/examples/run_examples.py b/examples/run_examples.py index 16a06883..48e05ef7 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -2,10 +2,7 @@ # # examples/run_examples.py -- run some examples. # -# GUI Application automation and testing library -# Copyright (C) 2016 Intel Corporation -# Copyright (C) 2012 Michael Herrmann -# Copyright (C) 2010 Mark Mc Mahon +# Copyright (C) 2016 Svetlana Filicheva # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License diff --git a/examples/security.py b/examples/security.py index 34042258..f95047ed 100755 --- a/examples/security.py +++ b/examples/security.py @@ -5,19 +5,22 @@ # Copyright (C) 2011 Outpost Embedded, LLC # Forest Bond # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function diff --git a/examples/shapewin.py b/examples/shapewin.py index d5507ff7..8c13344c 100755 --- a/examples/shapewin.py +++ b/examples/shapewin.py @@ -4,19 +4,22 @@ # # Copyright (C) 2002 Peter Liljenberg # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Python 2/3 compatibility. diff --git a/examples/xfixes.py b/examples/xfixes.py index 2a004964..a7fc06ba 100755 --- a/examples/xfixes.py +++ b/examples/xfixes.py @@ -5,19 +5,22 @@ # Copyright (C) 2011 Outpost Embedded, LLC # Forest Bond # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function diff --git a/examples/xinerama.py b/examples/xinerama.py index 67abf2fc..d635cfd9 100755 --- a/examples/xinerama.py +++ b/examples/xinerama.py @@ -4,19 +4,22 @@ # # Copyright (C) 2009 David H. Bronke # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Python 2/3 compatibility. @@ -147,4 +150,3 @@ def loop(self): if __name__ == '__main__': Window(display.Display()).loop() - diff --git a/examples/xinput.py b/examples/xinput.py index 5066d81d..ccfb27a3 100755 --- a/examples/xinput.py +++ b/examples/xinput.py @@ -5,19 +5,22 @@ # Copyright (C) 2012 Outpost Embedded, LLC # Forest Bond # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Python 2/3 compatibility. from __future__ import print_function diff --git a/examples/xlsatoms.py b/examples/xlsatoms.py index 7899dbf6..5e0a2890 100755 --- a/examples/xlsatoms.py +++ b/examples/xlsatoms.py @@ -1,24 +1,27 @@ #!/usr/bin/python # Copyright (C) 2011 Arun Balasubramanian # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA ''' xlsatoms - list atoms on X server (see man xlsatoms) -sample program using python Xlib that mimics the standard xlsatoms utility +sample program using python Xlib that mimics the standard xlsatoms utility additional capability is to match against regular expressions for atoms ''' @@ -59,7 +62,7 @@ def list_atoms(d,re_obj,low,high): val = d.get_atom_name(low) if (re_obj == None) : print_atom(options.format,low,val) - elif re_obj.match(val) != None: + elif re_obj.match(val) != None: print_atom(options.format,low,val) low += 1 except: diff --git a/examples/xrandr.py b/examples/xrandr.py index 6be10e85..30176b47 100755 --- a/examples/xrandr.py +++ b/examples/xrandr.py @@ -4,19 +4,22 @@ # # Copyright (C) 2009 David H. Bronke # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA # Python 2/3 compatibility. @@ -191,4 +194,3 @@ def loop(self): if __name__ == '__main__': Window(display.Display()).loop() - diff --git a/test/gen/genprottest.py b/test/gen/genprottest.py old mode 100755 new mode 100644 diff --git a/test/test_events_be.py b/test/test_events_be.py old mode 100755 new mode 100644 diff --git a/test/test_events_le.py b/test/test_events_le.py old mode 100755 new mode 100644 diff --git a/test/test_manual.py b/test/test_manual.py old mode 100755 new mode 100644 diff --git a/test/test_rdb.py b/test/test_rdb.py old mode 100755 new mode 100644 diff --git a/test/test_requests_le.py b/test/test_requests_le.py old mode 100755 new mode 100644 diff --git a/test/test_struct.py b/test/test_struct.py old mode 100755 new mode 100644 From 1066a80424512ec688792924a7c0edb7fe531d8a Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 1 Jul 2016 14:05:57 +0200 Subject: [PATCH 105/279] shape: rewrite extension Replace with a version generated form xcb-proto. --- Xlib/ext/shape.py | 545 ++++++++++++++++++++----------------------- examples/shapewin.py | 10 +- 2 files changed, 259 insertions(+), 296 deletions(-) diff --git a/Xlib/ext/shape.py b/Xlib/ext/shape.py index fd0d157c..6cb81afd 100644 --- a/Xlib/ext/shape.py +++ b/Xlib/ext/shape.py @@ -1,334 +1,297 @@ -# Xlib.ext.shape -- SHAPE extension module -# -# Copyright (C) 2002 Jeffrey Boser -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -# Constants to use -# -# Regions of a window -ShapeBounding = 0 # the 'edge' of a shaped window -ShapeClip = 1 # the clipping region -# Shape Operations -ShapeSet = 0 # Set the region unmodified (dest=src) -ShapeUnion = 1 # Add the new region to the old (dest=src|dest) -ShapeIntersect = 2 # Use the intersection (dest=src&dest) -ShapeSubtract = 3 # remove region (dest = dest - intersect) -ShapeInvert = 4 # opposite of subtract (dest = src - intersect) -# Events -ShapeNotifyMask = (1<<0) #a keypress mask? -ShapeNotify = 0 #still unsure of these values - -# How to Use -# The basic functions that change the shapes of things are: -# shape_rectangles (uses a set of rectangles as the source) -# operation, region, ordering, rects -# shape_mask (uses a bitmap as the source) -# operation, region, x_offset, y_offset, bitmap -# shape_combine (uses a window as the source) -# operation, src_region, dest_region, x_offset, y_offset, src_window -# shape_offset (moves the region) -# region, x_offset, y_offset -# The functions to find stuff out (these three return mappings of field/values): -# shape_query_version (shape extension version) -# major_version, minor_version -# shape_query_extents (rectangle boundaries of a window's regions) -# clip_shaped, clip_x, clip_y, clip_width, clip_height, -# bounding_shaped, bounding_x, bounding_y, bounding_width, bounding_height -# shape_input_selected (if the window products shapenotify events) -# enabled -# shape_get_rectangles (the rectangles set by shape_rectangles) -# ordering, rects -# And to turn on shape notify events: -# shape_select_input -# enable - - - -from Xlib import X +# Automatically generated file; DO NOT EDIT. +# Generated from: /usr/share/xcb/shape.xml + from Xlib.protocol import rq, structs + extname = 'SHAPE' -class QueryVersion(rq.ReplyRequest): - _request = rq.Struct( - rq.Card8('opcode'), - rq.Opcode(0), - rq.RequestLength(), - ) - _reply = rq.Struct( - rq.ReplyCode(), - rq.Pad(1), - rq.Card16('sequence_number'), - rq.ReplyLength(), - rq.Card16('major_version'), - rq.Card16('minor_version'), - rq.Pad(20), - ) - -def query_version(self): - return QueryVersion( - display = self.display, - opcode = self.display.get_extension_major(extname), - ) +OP = rq.Card8 +class SO: + Set = 0 + Union = 1 + Intersect = 2 + Subtract = 3 + Invert = 4 +class SK: + Bounding = 0 + Clip = 1 + Input = 2 -class Rectangles(rq.Request): - _request = rq.Struct( - rq.Card8('opcode'), - rq.Opcode(1), - rq.RequestLength(), - rq.Card8('operation'), - rq.Set('region', 1, (ShapeBounding, ShapeClip)), - rq.Card8('ordering'), - rq.Pad(1), - rq.Window('window'), - rq.Int16('x'), - rq.Int16('y'), - rq.List('rectangles', structs.Rectangle), - ) - -def rectangles(self, region, operation, ordering, x, y, rectangles): - Rectangles( - display = self.display, - opcode = self.display.get_extension_major(extname), - operation = operation, - region = region, - ordering = ordering, - window = self.id, - x = x, - y = y, - rectangles = rectangles, - ) +class KIND(rq.Set): + def __init__(self, name): + super(KIND, self).__init__(name, 1, + values=(SK.Bounding, + SK.Clip, + SK.Input)) +class NotifyEventData(rq.Event): + _code = None + _fields = rq.Struct( + rq.Card8('response_type'), + KIND('shape_kind'), + rq.Card16('sequence'), + rq.Window('affected_window'), + rq.Int16('extents_x'), + rq.Int16('extents_y'), + rq.Card16('extents_width'), + rq.Card16('extents_height'), + rq.Card32('server_time'), + rq.Card8('shaped'), + rq.Pad(11), + ) + +class QueryVersion(rq.ReplyRequest): -class Mask(rq.Request): _request = rq.Struct( - rq.Card8('opcode'), - rq.Opcode(2), - rq.RequestLength(), - rq.Card8('operation'), - rq.Set('region', 1, (ShapeBounding, ShapeClip)), - rq.Pad(2), - rq.Window('window'), - rq.Int16('x'), - rq.Int16('y'), - rq.Pixmap('source', (X.NONE, )), - ) - -def mask(self, operation, region, x, y, source): - Mask(display = self.display, - opcode = self.display.get_extension_major(extname), - window = self.id, - operation = operation, - region = region, - x = x, - y = y, - source = source, - ) + rq.Card8('opcode'), + rq.Opcode(0), + rq.RequestLength(), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card16('major_version'), + rq.Card16('minor_version'), + ) +class Rectangles(rq.Request): -class Combine(rq.Request): _request = rq.Struct( - rq.Card8('opcode'), - rq.Opcode(3), - rq.RequestLength(), - rq.Card8('operation'), - rq.Set('dest_region', 1, (ShapeBounding, ShapeClip)), - rq.Set('source_region', 1, (ShapeBounding, ShapeClip)), - rq.Pad(1), - rq.Window('dest'), - rq.Int16('x'), - rq.Int16('y'), - rq.Window('source'), - ) - -def combine(self, operation, region, source, source_region, x, y): - Combine( - display = self.display, - opcode = self.display.get_extension_major(extname), - operation = operation, - dest_region = region, - source_region = source_region, - dest = self.id, - x = x, - y = y, - source = source, - ) + rq.Card8('opcode'), + rq.Opcode(1), + rq.RequestLength(), + OP('operation'), + KIND('destination_kind'), + rq.Card8('ordering'), + rq.Pad(1), + rq.Window('destination_window'), + rq.Int16('x_offset'), + rq.Int16('y_offset'), + rq.List('rectangles', structs.Rectangle, pad=0), + ) +class Mask(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(2), + rq.RequestLength(), + OP('operation'), + KIND('destination_kind'), + rq.Pad(2), + rq.Window('destination_window'), + rq.Int16('x_offset'), + rq.Int16('y_offset'), + rq.Pixmap('source_bitmap'), + ) + +class Combine(rq.Request): -class Offset(rq.Request): _request = rq.Struct( - rq.Card8('opcode'), - rq.Opcode(4), - rq.RequestLength(), - rq.Set('region', 1, (ShapeBounding, ShapeClip)), - rq.Pad(3), - rq.Window('window'), - rq.Int16('x'), - rq.Int16('y'), - ) - -def offset(self, region, x, y): - Offset( - display = self.display, - opcode = self.display.get_extension_major(extname), - region = region, - window = self.id, - x = x, - y = y, - ) + rq.Card8('opcode'), + rq.Opcode(3), + rq.RequestLength(), + OP('operation'), + KIND('destination_kind'), + KIND('source_kind'), + rq.Pad(1), + rq.Window('destination_window'), + rq.Int16('x_offset'), + rq.Int16('y_offset'), + rq.Window('source_window'), + ) +class Offset(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(4), + rq.RequestLength(), + KIND('destination_kind'), + rq.Pad(3), + rq.Window('destination_window'), + rq.Int16('x_offset'), + rq.Int16('y_offset'), + ) class QueryExtents(rq.ReplyRequest): + _request = rq.Struct( - rq.Card8('opcode'), - rq.Opcode(5), - rq.RequestLength(), - rq.Window('window'), - ) + rq.Card8('opcode'), + rq.Opcode(5), + rq.RequestLength(), + rq.Window('destination_window'), + ) _reply = rq.Struct( - rq.ReplyCode(), - rq.Pad(1), - rq.Card16('sequence_number'), - rq.ReplyLength(), - rq.Bool('bounding_shaped'), - rq.Bool('clip_shaped'), - rq.Pad(2), - rq.Int16('bounding_x'), - rq.Int16('bounding_y'), - rq.Card16('bounding_width'), - rq.Card16('bounding_height'), - rq.Int16('clip_x'), - rq.Int16('clip_y'), - rq.Card16('clip_width'), - rq.Card16('clip_height'), - rq.Pad(4), - ) - -def query_extents(self): - return QueryExtents( - display = self.display, - opcode = self.display.get_extension_major(extname), - window = self.id, - ) - + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card8('bounding_shaped'), + rq.Card8('clip_shaped'), + rq.Pad(2), + rq.Int16('bounding_shape_extents_x'), + rq.Int16('bounding_shape_extents_y'), + rq.Card16('bounding_shape_extents_width'), + rq.Card16('bounding_shape_extents_height'), + rq.Int16('clip_shape_extents_x'), + rq.Int16('clip_shape_extents_y'), + rq.Card16('clip_shape_extents_width'), + rq.Card16('clip_shape_extents_height'), + ) class SelectInput(rq.Request): - _request = rq.Struct( - rq.Card8('opcode'), - rq.Opcode(6), - rq.RequestLength(), - rq.Window('window'), - rq.Bool('enable'), - rq.Pad(3), - ) - -def select_input(self, enable = 1): - SelectInput( - display = self.display, - opcode = self.display.get_extension_major(extname), - window = self.id, - enable = enable, - ) + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(6), + rq.RequestLength(), + rq.Window('destination_window'), + rq.Card8('enable'), + rq.Pad(3), + ) class InputSelected(rq.ReplyRequest): + _request = rq.Struct( - rq.Card8('opcode'), - rq.Opcode(7), - rq.RequestLength(), - rq.Window('window'), - ) + rq.Card8('opcode'), + rq.Opcode(7), + rq.RequestLength(), + rq.Window('destination_window'), + ) _reply = rq.Struct( - rq.ReplyCode(), - rq.Bool('enabled'), - rq.Card16('sequence_number'), - rq.ReplyLength(), - rq.Pad(24), - ) - -def input_selected(self): - reply = InputSelected( - display = self.display, - opcode = self.display.get_extension_major(extname), - window = self.id, - ) - return reply.enabled - + rq.ReplyCode(), + rq.Card8('enabled'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + ) class GetRectangles(rq.ReplyRequest): + _request = rq.Struct( - rq.Card8('opcode'), - rq.Opcode(8), - rq.RequestLength(), - rq.Window('window'), - rq.Set('region', 1, (ShapeBounding, ShapeClip)), - rq.Pad(3), - ) + rq.Card8('opcode'), + rq.Opcode(8), + rq.RequestLength(), + rq.Window('window'), + KIND('source_kind'), + rq.Pad(3), + ) _reply = rq.Struct( - rq.ReplyCode(), - rq.Card8('ordering'), - rq.Card16('sequence_number'), - rq.ReplyLength(), - rq.LengthOf('rectangles', 4), - rq.Pad(20), - rq.List('rectangles', structs.Rectangle), - ) - -def get_rectangles(self, region): + rq.ReplyCode(), + rq.Card8('ordering'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.LengthOf('rectangles', 4), + rq.Pad(20), + rq.List('rectangles', structs.Rectangle, pad=0), + ) + +class Event: + # Sub events. + Notify = 0 + +def combine(self, operation, destination_kind, source_kind, x_offset, y_offset): + Combine( + display=self.display, + opcode=self.display.get_extension_major(extname), + source_window=self, + operation=operation, + destination_kind=destination_kind, + source_kind=source_kind, + x_offset=x_offset, + y_offset=y_offset, + ) + +def get_rectangles(self, source_kind): return GetRectangles( - display = self.display, - opcode = self.display.get_extension_major(extname), - window = self.id, - region = region, - ) + display=self.display, + opcode=self.display.get_extension_major(extname), + window=self, + source_kind=source_kind, + ) + +def input_selected(self, ): + return InputSelected( + display=self.display, + opcode=self.display.get_extension_major(extname), + destination_window=self, + ) + +def mask(self, operation, destination_kind, x_offset, y_offset, source_bitmap): + Mask( + display=self.display, + opcode=self.display.get_extension_major(extname), + destination_window=self, + operation=operation, + destination_kind=destination_kind, + x_offset=x_offset, + y_offset=y_offset, + source_bitmap=source_bitmap, + ) + +def offset(self, destination_kind, x_offset, y_offset): + Offset( + display=self.display, + opcode=self.display.get_extension_major(extname), + destination_window=self, + destination_kind=destination_kind, + x_offset=x_offset, + y_offset=y_offset, + ) + +def query_extents(self, ): + return QueryExtents( + display=self.display, + opcode=self.display.get_extension_major(extname), + destination_window=self, + ) +def query_version(self, ): + return QueryVersion( + display=self.display, + opcode=self.display.get_extension_major(extname), + ) -class ShapeNotify(rq.Event): - _code = None - _fields = rq.Struct( rq.Card8('type'), - rq.Set('region', 1, (ShapeBounding, ShapeClip)), - rq.Card16('sequence_number'), - rq.Window('window'), - rq.Int16('x'), - rq.Int16('y'), - rq.Card16('width'), - rq.Card16('height'), - rq.Card32('time'), - rq.Bool('shaped'), - rq.Pad(11), - ) +def rectangles(self, operation, destination_kind, ordering, x_offset, y_offset, rectangles): + Rectangles( + display=self.display, + opcode=self.display.get_extension_major(extname), + destination_window=self, + operation=operation, + destination_kind=destination_kind, + ordering=ordering, + x_offset=x_offset, + y_offset=y_offset, + rectangles=rectangles, + ) + +def select_input(self, enable): + SelectInput( + display=self.display, + opcode=self.display.get_extension_major(extname), + destination_window=self, + enable=enable, + ) def init(disp, info): - disp.extension_add_method('display', 'shape_query_version', query_version ) - disp.extension_add_method('window', 'shape_rectangles', rectangles ) - disp.extension_add_method('window', 'shape_mask', mask ) - disp.extension_add_method('window', 'shape_combine', combine ) - disp.extension_add_method('window', 'shape_offset', offset ) - disp.extension_add_method('window', 'shape_query_extents', query_extents ) - disp.extension_add_method('window', 'shape_select_input', select_input ) - disp.extension_add_method('window', 'shape_input_selected', input_selected ) - disp.extension_add_method('window', 'shape_get_rectangles', get_rectangles ) - - disp.extension_add_event(info.first_event, ShapeNotify) + disp.extension_add_method('window', 'shape_combine', combine) + disp.extension_add_method('window', 'shape_get_rectangles', get_rectangles) + disp.extension_add_method('window', 'shape_input_selected', input_selected) + disp.extension_add_method('window', 'shape_mask', mask) + disp.extension_add_method('window', 'shape_offset', offset) + disp.extension_add_method('window', 'shape_query_extents', query_extents) + disp.extension_add_method('display', 'shape_query_version', query_version) + disp.extension_add_method('window', 'shape_rectangles', rectangles) + disp.extension_add_method('window', 'shape_select_input', select_input) + disp.extension_add_event(info.first_event + Event.Notify, NotifyEventData) + diff --git a/examples/shapewin.py b/examples/shapewin.py index d5507ff7..c9e8b0a1 100755 --- a/examples/shapewin.py +++ b/examples/shapewin.py @@ -122,13 +122,13 @@ def __init__(self, display): gc.free() # Set initial mask - self.window.shape_mask(shape.ShapeSet, shape.ShapeBounding, + self.window.shape_mask(shape.SO.Set, shape.SK.Bounding, 0, 0, self.add_pm) - self.window.shape_mask(shape.ShapeUnion, shape.ShapeBounding, + self.window.shape_mask(shape.SO.Union, shape.SK.Bounding, 400 - self.add_size, 0, self.add_pm) - self.window.shape_mask(shape.ShapeUnion, shape.ShapeBounding, + self.window.shape_mask(shape.SO.Union, shape.SK.Bounding, 0, 300 - self.add_size, self.add_pm) - self.window.shape_mask(shape.ShapeUnion, shape.ShapeBounding, + self.window.shape_mask(shape.SO.Union, shape.SK.Bounding, 400 - self.add_size, 300 - self.add_size, self.add_pm) @@ -165,7 +165,7 @@ def loop(self): self.sub_pm) # Shape has changed - elif e.type == self.d.extension_event.ShapeNotify: + elif e.type == shape.Event.Notify: print('Shape change') # Somebody wants to tell us something From 33c819e368dcf490186a9b279414aec15ae517f2 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 1 Jul 2016 16:18:35 +0200 Subject: [PATCH 106/279] protocol/display: fix encoding --- Xlib/protocol/display.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index db93f795..da8ee152 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -1,4 +1,4 @@ -# -*- coding: iso-8859-1 -*- +# -*- coding: utf-8 -*- # # Xlib.protocol.display -- core display communication # @@ -800,7 +800,7 @@ def parse_event_response(self, etype): # Decrement it by one, so that we don't remove the request # that generated these events, if there is such a one. - # Bug reported by Ilpo Nyyss�nen + # Bug reported by Ilpo Nyyssönen self.get_waiting_request((e.sequence_number - 1) % 65536) # print 'recv Event:', e From fe9e73a2e1276374f8108e8152de728e4fda355e Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 1 Jul 2016 16:22:05 +0200 Subject: [PATCH 107/279] protocol/display: fix handling of KeymapNotify events Don't try to access 'sequence_number' member for those events, since they don't have one. --- Xlib/protocol/display.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index da8ee152..566c044f 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -801,7 +801,10 @@ def parse_event_response(self, etype): # Decrement it by one, so that we don't remove the request # that generated these events, if there is such a one. # Bug reported by Ilpo Nyyssönen - self.get_waiting_request((e.sequence_number - 1) % 65536) + # Note: not all events have a sequence_number field! + # (e.g. KeymapNotify). + if hasattr(e, 'sequence_number'): + self.get_waiting_request((e.sequence_number - 1) % 65536) # print 'recv Event:', e From 07f36dfa0b5479c9dcaf4bde146caf3b7eb08d0a Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 1 Jul 2016 16:23:17 +0200 Subject: [PATCH 108/279] shape: fix ShapeNotify event handling --- Xlib/ext/shape.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Xlib/ext/shape.py b/Xlib/ext/shape.py index 6cb81afd..05a517ac 100644 --- a/Xlib/ext/shape.py +++ b/Xlib/ext/shape.py @@ -31,9 +31,9 @@ def __init__(self, name): class NotifyEventData(rq.Event): _code = None _fields = rq.Struct( - rq.Card8('response_type'), + rq.Card8('type'), KIND('shape_kind'), - rq.Card16('sequence'), + rq.Card16('sequence_number'), rq.Window('affected_window'), rq.Int16('extents_x'), rq.Int16('extents_y'), @@ -293,5 +293,5 @@ def init(disp, info): disp.extension_add_method('display', 'shape_query_version', query_version) disp.extension_add_method('window', 'shape_rectangles', rectangles) disp.extension_add_method('window', 'shape_select_input', select_input) - disp.extension_add_event(info.first_event + Event.Notify, NotifyEventData) + disp.extension_add_event(info.first_event + Event.Notify, NotifyEventData, 'ShapeNotify') From a07f5a86f447843fda6e109c6513cbe2993984a4 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 1 Jul 2016 16:23:41 +0200 Subject: [PATCH 109/279] examples: fix shape extension example --- examples/shapewin.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/shapewin.py b/examples/shapewin.py index aedd6dbb..015a03cf 100755 --- a/examples/shapewin.py +++ b/examples/shapewin.py @@ -80,7 +80,7 @@ def __init__(self, display): # special attribute values background_pixmap = bgpm, event_mask = (X.StructureNotifyMask | - X.ButtonReleaseMask), + X.ButtonPressMask | X.ButtonReleaseMask), colormap = X.CopyFromParent, ) @@ -155,20 +155,20 @@ def loop(self): # Button released, add or subtract elif e.type == X.ButtonRelease: if e.detail == 1: - self.window.shape_mask(shape.ShapeUnion, - shape.ShapeBounding, + self.window.shape_mask(shape.SO.Union, + shape.SK.Bounding, e.event_x - self.add_size // 2, e.event_y - self.add_size // 2, self.add_pm) elif e.detail == 3: - self.window.shape_mask(shape.ShapeSubtract, - shape.ShapeBounding, + self.window.shape_mask(shape.SO.Subtract, + shape.SK.Bounding, e.event_x - self.sub_size // 2, e.event_y - self.sub_size // 2, self.sub_pm) # Shape has changed - elif e.type == shape.Event.Notify: + elif e.type == self.d.extension_event.ShapeNotify: print('Shape change') # Somebody wants to tell us something From 8a4621383a733af1e50045750c32bbd0bb50dd50 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Thu, 14 Jul 2016 17:48:35 +0200 Subject: [PATCH 110/279] update news --- NEWS | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/NEWS b/NEWS index 4498eee8..c8422acc 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,36 @@ NEWS for Python X Library +* Version 0.16 + +** Licensing + +The project is now licensed under the GNU Lesser General Public License +v2.1 or later (see the LICENSE file for details). + +** Compatibility + +Support for Python versions older than 2.7 has been dropped. Support for +Python 3 (3.3, 3.4 and 3.5) has been added. Note that Python-Xlib now +depends on the six package (>=1.10) for combined Python 2 / 3 support. + +** API Changes + +With the change of license, and no way to contact the original author of +the SHAPE extension, the code had to be rewritten from scratch. This +resulted in a few minor API changes (see examples/shapewin.py). + +Partial support for the SECURITY. XInput, and XFIXES extensions has been +added. + +** Bug Fixes + +- fix RECORD extension +- fixed OS X socket path +- fix handling of generic events +- fix handling of KeymapNotify events +- several fixes for the RandR extension + * Version 0.15rc1 - 14 Nov 2009 Improved support for newer versions of Mac OS X, a couple of new From c2431eb902d38c662c465bb9832123d21dfa257f Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 16 Jul 2016 20:47:49 +0200 Subject: [PATCH 111/279] bump version to 0.16 --- Xlib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 167cde9d..f30a6dc4 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 15) +__version__ = (0, 16) __version_extra__ = '' From 231dd88b7a287c4821403356d21e82b9a4577784 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 16 Jul 2016 21:12:37 +0200 Subject: [PATCH 112/279] travis: fix access token for GitHub releases --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c25584bd..9ff12cb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ before_deploy: deploy: - provider: releases api_key: - secure: "lBEbXUeBQyDspP0XBGM/NgfzO2AhW3sMRqCKvOxWQNw4VrC+nfXCkF3OyuRkqQbw+25TKHJadjg+NxX/FtCxdKAJo2MeRrCxNmLqVhq3PnRyBSkVROxYfDFZFL12hmeFA0CrZp45uuSWdruU7a0xh9SkFVBdHSYt55jIzbHKZBdqy1fnL/ot+hnafmsUWc+EiP0s6BgLeqihfevxq87imKyzMKpyH8ofwKKWx6LTgq9khJdQt5x4LUm+Kq8HDcdDeJtz2eLFziDGA7ds+aIpbrk0bG8tmT4SaM06EmJCZoegifGWWnkf5xEe5CVmQXS8Xl3R2bgeII5O4eXUWUXk1tT2nuPLPPv4iTSsZkEd1UH/eHupIID/IKuVqo2GrhvzLBcIzDCFaZg/U8ufARmsx1FGfuzqWwzpqXb+tvDBp6Xz6xSpjrUwwJ41oDRWnDzGLN3uvH06VeMcy6pVFftRLbiMVpOEd76tNvGEEEj4ropb7VyvRL+IHGwbb0Ns62toJYDbgzHyBhisN43tFmaT8fpqLvZP7yuRCMIqs8mtH9Iw4YpOJUG8scsFtX445C4xEGw1j/E6TZkjBrfG0O1FVP1Q6wHYCyutCNjvGKnWvyd+4pg1Nzx/HC/O+ioNefVm+jOTjKtKla/kY6P3ctDWGjXgHGqRe6gn0MtwmR/T+mY=" + secure: "kZHDE09hKehX8bFRWa5qM56J3ujc3Stl5j2u9KfdXwmZyYlremZTJ5J9gdiLqqRrTI1jF5n+3miacYSdups1VSqgXYsGzoz99HurtcoMfkFxWkkeCnd6ORwvTXYFN28t2CcjWXV6jCyUABPaEv8TCK3/+LeFfuf30O5Hxg/KiUfpqBwXj6sWaht0whhay45r6D5nYb8omhqa7n4DDLlrStRqkp1SB895EElessFFuHjn/jkxlyEUjGjQ+x79h8JKiXVozYRcyb4eC75xIaE6+yeA6q2ZxMrNRdBnWbRrFBNYsx4QbMCe9vq2m0IQMkrh0kk5N53eA6/8Yy6ZpDUNAb/Alvql8+y/qWwVQl3TYwcMGd0PctmfGH6rElByiOIVV9Zv52hTK9jXky0ab+avLufXlL8tUDVSNReXR7En37vbxlq+AU+xNhHN3girkJJ7jU6saQpj1tROGBpPkLIIHQFh3dbubfgw9qdW5qYBZyLHK9yKNnlzFIr7yktqJvJ/jGz/YDER12UdlCzaoWtVdw8Ogm9faAFlMUvzExYt5BIneDYUe13GtoDw69aLiuq5YGcFKClsgDIqBqYYBTVIHwAS9kTV4CZV0L4C15ylmUIP68LFxZ/stufXW0MJxvhIaJ7gJ9d9LyCK1a0u0j5a78cX/OUx9RfqjOMCuVbGTys=" file_glob: true file: - dist/*.tar.* From e9a363002e55def297dd826313ec65f93bdcebdf Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 17 Jul 2016 19:02:17 +0200 Subject: [PATCH 113/279] travis: change source distribution format Switch to tar.bz2 as tar.xz is not supported by PyPI. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9ff12cb5..fbff035b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,9 @@ after_success: before_deploy: # Generate source distribution. - # Note: only do this with Python 3.5 so we get support for tar.xz, and - # because the contents of the distribution are the same for all versions. - - case "$TRAVIS_PYTHON_VERSION" in 3.5) python setup.py sdist --formats=xztar;; esac + # Note: only do this with Python 3.5 because the contents + # of the distribution are the same for all versions. + - case "$TRAVIS_PYTHON_VERSION" in 3.5) python setup.py sdist --formats=bztar;; esac # Generate egg distribution. - python setup.py bdist_egg # Generate wheel distribution. From d01dec0ef90f047dec8275386e06d11ae3727ba6 Mon Sep 17 00:00:00 2001 From: Paolo Montesel Date: Fri, 22 Jul 2016 18:53:14 +0200 Subject: [PATCH 114/279] CompositeGetOverlayWindow --- .gitignore | 5 +++++ Xlib/ext/composite.py | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/.gitignore b/.gitignore index 7d440988..19d67036 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,8 @@ docs/_build/ # PyBuilder target/ + +# IntelliJ + +.idea/ + diff --git a/Xlib/ext/composite.py b/Xlib/ext/composite.py index 95ff2445..8ee363db 100644 --- a/Xlib/ext/composite.py +++ b/Xlib/ext/composite.py @@ -206,6 +206,29 @@ def name_window_pixmap(self): cls = self.display.get_resource_class('pixmap', drawable.Pixmap) return cls(self.display, pid, owner = 1) +class CompositeGetOverlayWindow(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(7), + rq.RequestLength(), + rq.Window('window') + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Window('overlay_window'), + rq.Pad(20), + ) + +def get_overlay_window(self): + """Return the overlay window of the root window. + """ + + return CompositeGetOverlayWindow(display = self.display, + opcode = self.display.get_extension_major(extname), + window = self) def init(disp, info): disp.extension_add_method('display', @@ -235,3 +258,7 @@ def init(disp, info): disp.extension_add_method('window', 'composite_name_window_pixmap', name_window_pixmap) + + disp.extension_add_method('window', + 'composite_get_overlay_window', + get_overlay_window) From c40bd3bc62582a7bbfc3176c9cea837317b04a8c Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Sun, 31 Jul 2016 10:03:28 +0100 Subject: [PATCH 115/279] Fix XRECORD extension and demo Fixes the following traceback when running under py3k [osboxes@osboxes QMouseKeys]$ python record_demo.py RECORD extension version 1.13 Traceback (most recent call last): File "record_demo.py", line 105, in record_dpy.record_enable_context(ctx, record_callback) File "/usr/lib/python3.5/site-packages/Xlib/ext/record.py", line 243, in enable_context context = context) File "/usr/lib/python3.5/site-packages/Xlib/ext/record.py", line 220, in __init__ rq.ReplyRequest.__init__(self, *args, **keys) File "/usr/lib/python3.5/site-packages/Xlib/protocol/rq.py", line 1361, in __init__ self.reply() File "/usr/lib/python3.5/site-packages/Xlib/protocol/rq.py", line 1373, in reply self._display.send_and_recv(request = self._serial) File "/usr/lib/python3.5/site-packages/Xlib/protocol/display.py", line 576, in send_and_recv gotreq = self.parse_response(request) File "/usr/lib/python3.5/site-packages/Xlib/protocol/display.py", line 668, in parse_response gotreq = self.parse_request_response(request) or gotreq File "/usr/lib/python3.5/site-packages/Xlib/protocol/display.py", line 756, in parse_request_response req._parse_response(self.data_recv[:self.recv_packet_len]) File "/usr/lib/python3.5/site-packages/Xlib/ext/record.py", line 224, in _parse_response self._callback(r) File "record_demo.py", line 50, in record_callback if not len(reply.data) or reply.data[0] < 2: TypeError: unorderable types: str() < int() --- Xlib/ext/record.py | 2 +- examples/record_demo.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/ext/record.py b/Xlib/ext/record.py index 28be9433..bb53ec19 100644 --- a/Xlib/ext/record.py +++ b/Xlib/ext/record.py @@ -76,7 +76,7 @@ def pack_value(self, val): return val, len(val), None def parse_binary_value(self, data, display, length, format): - return str(data), '' + return data, '' class GetVersion(rq.ReplyRequest): diff --git a/examples/record_demo.py b/examples/record_demo.py index 62b88fe0..25ed575d 100755 --- a/examples/record_demo.py +++ b/examples/record_demo.py @@ -56,7 +56,7 @@ def record_callback(reply): if reply.client_swapped: print("* received swapped protocol data, cowardly ignored") return - if not len(reply.data) or ord(reply.data[0]) < 2: + if not len(reply.data) or reply.data[0] < 2: # not an event return From 7360dbcf44dccbc65428e37ea411136e75418d20 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 1 Aug 2016 11:06:02 +0200 Subject: [PATCH 116/279] examples: fix xlsatoms - fix Python 3 support - fix default display - enable it in run_examples.py --- examples/run_examples.py | 7 ++--- examples/xlsatoms.py | 61 +++++++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/examples/run_examples.py b/examples/run_examples.py index 48e05ef7..f97a4e0b 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -73,10 +73,9 @@ def test_xfixes(self): """ Run xfixes.py -- demonstrate the XFIXES extension """ self.assertEqual(run_example(examples_folder + "xfixes.py"), 0) -# TODO -# def test_xlsatoms(self): -# """ Run xlsatoms.py -- show list atoms on X server """ -# self.assertEqual(run_example(examples_folder + "xlsatoms.py"), 0) + def test_xlsatoms(self): + """ Run xlsatoms.py -- show list atoms on X server """ + self.assertEqual(run_example(examples_folder + "xlsatoms.py"), 0) if __name__ == '__main__': diff --git a/examples/xlsatoms.py b/examples/xlsatoms.py index 5e0a2890..02a26f6d 100755 --- a/examples/xlsatoms.py +++ b/examples/xlsatoms.py @@ -32,6 +32,9 @@ import sys import os +# Python 2/3 compatibility. +from six import PY2, MAXSIZE + # Change path so we find Xlib sys.path.append(os.path.join(os.path.dirname(__file__), '..')) @@ -39,8 +42,14 @@ from Xlib import display, error from optparse import OptionParser + +if PY2: + integer_type = long +else: + integer_type = int + parser = OptionParser() -parser.add_option("-d","--display",dest="display",help="This option specifies the X server to which to connect",metavar="dpy",default=":0.0") +parser.add_option("-d","--display",dest="display",help="This option specifies the X server to which to connect",metavar="dpy",default=None) parser.add_option("-n","--name",dest="name",help="This option specifies the name of an atom to list. If the atom does not exist, a message will be printed on the standard error.",metavar="string",default=None) parser.add_option("-m","--match",dest="match_re",help="This option specifies a regular expression to match against name of an atom to list. If the atom does not exist, a message will be printed on the standard error.",metavar="reg-exp",default=None) parser.add_option("-f","--format",dest="format",help="This option specifies a printf-style string used to list each atom pair, printed in that order (value is an unsigned long and name is a char *). Xlsatoms will supply a newline at the end of each line. The default is %ld\\t%s.",metavar="string",default="%ld\t%s") @@ -54,43 +63,43 @@ d = display.Display(options.display) def print_atom(print_format,atom,value): - print(print_format%(atom,value)) + print(print_format%(atom,value)) def list_atoms(d,re_obj,low,high): - while(low <= high): - try: - val = d.get_atom_name(low) - if (re_obj == None) : - print_atom(options.format,low,val) - elif re_obj.match(val) != None: - print_atom(options.format,low,val) - low += 1 - except: - sys.exit(0) + while(low <= high): + try: + val = d.get_atom_name(low) + if (re_obj == None) : + print_atom(options.format,low,val) + elif re_obj.match(val) != None: + print_atom(options.format,low,val) + low += 1 + except: + sys.exit(0) if options.name != None: - try: - atom = d.intern_atom(options.name) - val = d.get_atom_name(atom) - print_atom(options.format,atom,val) - except: - sys.stderr.write('xlsatoms: no atom named "%s" on server "%s"'%(options.name,options.display)) - sys.stderr.write("\n") - sys.exit(1) - sys.exit(0) + try: + atom = d.intern_atom(options.name) + val = d.get_atom_name(atom) + print_atom(options.format,atom,val) + except: + sys.stderr.write('xlsatoms: no atom named "%s" on server "%s"'%(options.name,options.display)) + sys.stderr.write("\n") + sys.exit(1) + sys.exit(0) rangeVals = options.range.split("-") if rangeVals[0] != "": - low = long(rangeVals[0]) + low = integer_type(rangeVals[0]) if rangeVals[1] != "": - high = long(rangeVals[1]) + high = integer_type(rangeVals[1]) else: - high = sys.maxint + high = MAXSIZE if options.match_re != None: - re_obj = re.compile(options.match_re) + re_obj = re.compile(options.match_re) else: - re_obj = None + re_obj = None list_atoms(d,re_obj,low,high) From 93c8fded9f9b9f46590b9d5d4bd396c1fbabbb20 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 1 Aug 2016 12:02:00 +0200 Subject: [PATCH 117/279] protocol/rq: fix String16 Python 3 support --- Xlib/protocol/rq.py | 6 +++--- test/test_struct.py | 51 ++++++++++++++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 1a899d45..bdc25420 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -27,7 +27,7 @@ import types # Python 2/3 compatibility. -from six import byte2int, indexbytes, string_types +from six import byte2int, indexbytes, iterbytes, string_types # Xlib modules from .. import X @@ -448,8 +448,8 @@ def __init__(self, name, pad = 1): def pack_value(self, val): """Convert 8-byte string into 16-byte list""" - if type(val) is bytes: - val = map(lambda c: ord(c), val) + if isinstance(val, bytes): + val = list(iterbytes(val)) slen = len(val) diff --git a/test/test_struct.py b/test/test_struct.py index c2ce4bb2..47da4e5d 100644 --- a/test/test_struct.py +++ b/test/test_struct.py @@ -5,7 +5,7 @@ import types import re -from six import binary_type +from six import binary_type, iterbytes from Xlib.protocol import rq from . import DummyDisplay, TestCase @@ -24,24 +24,25 @@ class StructTest(object): """ Test class helper for rq.Struct packing/unpacking support. """ struct = None - values = None + values_in = None binary = None + values_out = None def test_pack_value_dict(self): - self.assertBinaryEqual(self.struct.pack_value(dict(self.values)), self.binary) + self.assertBinaryEqual(self.struct.pack_value(dict(self.values_in)), self.binary) def test_pack_value_tuple(self): - self.assertBinaryEqual(self.struct.pack_value(tuple(self.values.values())), self.binary) + self.assertBinaryEqual(self.struct.pack_value(tuple(self.values_in.values())), self.binary) def test_to_binary_args(self): - self.assertBinaryEqual(self.struct.to_binary(*self.values.values()), self.binary) + self.assertBinaryEqual(self.struct.to_binary(*self.values_in.values()), self.binary) def test_to_binary_kwargs(self): - self.assertBinaryEqual(self.struct.to_binary(**dict(self.values)), self.binary) + self.assertBinaryEqual(self.struct.to_binary(**dict(self.values_in)), self.binary) def test_parse_binary(self): values, remain = self.struct.parse_binary(self.binary, dummy_display) - self.assertEqual(values, rq.DictWrapper(dict(self.values))) + self.assertEqual(values, rq.DictWrapper(dict(self.values_out))) self.assertBinaryEmpty(remain) @@ -54,35 +55,49 @@ def _struct_test(name, fields): - field_type: factory for the field type, taking one parameter only, the name of the field and returning a rq.Field subclass instance - - field_value: + - field_value_in: the raw value passed in when packing and expected output on unpacking - field_binary: the binary representation of the field value or a function to convert it to binary for creating the expected result of packing the struct + - field_value_out: + the raw value passed expected on output on unpacking + (optional, is used if not specified) """ class_name = ''.join([part.capitalize() for part in re.sub(r'[^\w]+', ' ', name).split()]) class_name += 'StructTest' struct_layout = [] - values = OrderedDict() + values_in = OrderedDict() binary = b'' - for field_name, field_type, field_value, field_binary in fields: + values_out = OrderedDict() + for field_params in fields: + assert 4 <= len(field_params) <= 5 + field_name, field_type, field_value_in, field_binary = field_params[0:4] + if len(field_params) == 5: + field_value_out = field_params[4] + else: + field_value_out = field_value_in struct_layout.append(field_type(field_name)) - if field_name is not None and field_value is not None: - values[field_name] = field_value + if field_name is not None: + if field_value_in is not None: + values_in[field_name] = field_value_in + if field_value_out is not None: + values_out[field_name] = field_value_out if isinstance(field_binary, binary_type): binary += field_binary elif isinstance(field_binary, (types.FunctionType, types.LambdaType, partial)): - binary += field_binary(field_value) + binary += field_binary(field_value_in) else: raise ValueError('unsupported type for binary: {data} [{type}]'.format( data=str(field_binary), type=type(field_binary)) ) class_dict = { 'struct': rq.Struct(*struct_layout), - 'values': values, + 'values_in': values_in, 'binary': binary, + 'values_out': values_out, } globals()[class_name] = type(class_name, (StructTest, TestCase), class_dict) @@ -147,6 +162,14 @@ def _struct_test(name, fields): ('s3', lambda name: rq.String8(name, pad=1), "supercalifragilisticexpialidocious", partial(packstr, padding=2)), )) +_struct_test('simple string16', ( + (None, lambda name: rq.LengthOf('s1', 1) , None , pack('B', 3) ), + (None, lambda name: rq.LengthOf('s2', 2) , None , pack('H', 3) ), + ('s1', lambda name: rq.String16(name, pad=0), (0, 1, 2), lambda s: struct.pack('>' + 'H' * len(s), *s)), + # An 8-bits string is also allowed on input. + ('s2', lambda name: rq.String16(name, pad=0), b'\x03\x04\x05', lambda s: struct.pack('>' + 'H' * len(s), *iterbytes(s)), (3, 4, 5)), +)) + _struct_test('binary', ( (None, lambda name: rq.LengthOf('s1', 1) , None , pack('B', 7) ), (None, lambda name: rq.LengthOf('s2', 2) , None , pack('H', 13)), From 5050121ab5474cdc75d046fba57f766fa1a545a9 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 1 Aug 2016 06:18:37 +0200 Subject: [PATCH 118/279] test: convert genprottest.py to Python 3 --- test/gen/genprottest.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/test/gen/genprottest.py b/test/gen/genprottest.py index 18f4c76f..9dde7201 100644 --- a/test/gen/genprottest.py +++ b/test/gen/genprottest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python import sys import os @@ -74,8 +74,8 @@ def build_request(endian): fc.write(C_HEADER) - reqlist = request.major_codes.items() - reqlist.sort(lambda x, y: cmp(x[0], y[0])) + reqlist = list(request.major_codes.items()) + reqlist.sort(key=lambda x: x[0]) genfuncs = [] req_args = {} @@ -185,7 +185,7 @@ def build_request(endian): reply_bins[parts[1]] = parts[2] fpy = open('../test_requests_%s.py' % endian, 'w') - os.chmod('../test_requests_%s.py' % endian, 0755) + os.chmod('../test_requests_%s.py' % endian, 0o755) if endian == 'be': e = 'BigEndian' @@ -268,8 +268,8 @@ def build_event(endian): fc.write(C_HEADER) - evtlist = event.event_class.items() - evtlist.sort(lambda x, y: cmp(x[0], y[0])) + evtlist = list(event.event_class.items()) + evtlist.sort(key=lambda x: x[0]) genfuncs = [] evt_args = {} @@ -353,7 +353,7 @@ def build_event(endian): evt_bins[parts[1]] = parts[2] fpy = open('../test_events_%s.py' % endian, 'w') - os.chmod('../test_events_%s.py' % endian, 0755) + os.chmod('../test_events_%s.py' % endian, 0o755) if endian == 'be': e = 'BigEndian' @@ -478,7 +478,7 @@ def gen_func(fc, funcname, structname, outputname, pydef, cdef, vardefs): def rand(x, rmin = rmin, rmax = rmax): return randint(rmin, rmax) - vfdata = map(rand, range(0, vflen)) + vfdata = list(map(rand, range(0, vflen))) # # Special case for a few in-line coded lists @@ -631,11 +631,11 @@ def rand(x, rmin = rmin, rmax = rmax): # elif isinstance(f, rq.TextElements8): if isinstance(f, rq.TextElements16): - vfstr = '\x02\x02\x10\x23\x00\x12\xff\x01\x02\x03\x04' + vfstr = b'\x02\x02\x10\x23\x00\x12\xff\x01\x02\x03\x04' ret = [{'delta': 2, 'string': (0x1023, 0x0012)}, 0x01020304] else: - vfstr = '\x03\x02zoo\xff\x01\x02\x03\x04\x02\x00ie' + vfstr = b'\x03\x02zoo\xff\x01\x02\x03\x04\x02\x00ie' ret = [{'delta': 2, 'string': 'zoo'}, 0x01020304, { 'delta': 0, 'string': 'ie'}] @@ -870,14 +870,16 @@ def pad4(l): return l + (4 - l % 4) % 4 def cstring(s): - return '"' + ''.join(map(lambda c: '\\x%x' % ord(c), s)) + '"' + if not isinstance(s, bytes): + s = s.encode('ascii') + return '"' + ''.join('\\x%x' % c for c in s) + '"' def build_args(args): kwlist = [] for kw, val in sorted(args.items(), key=lambda i: i[0]): if isinstance(val, rq.Event): - members = val._data.keys() + members = list(val._data.keys()) members.remove('send_event') kwlist.append(" '%s': event.%s(%s),\n" % ( kw, val.__class__.__name__, From e60ac7f997c8e2fdd506a4ed7a7b85a91d3c2419 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 1 Aug 2016 08:38:34 +0200 Subject: [PATCH 119/279] protocol/rq: fix handling of properties Stick to byte strings as a property value can be binary data even when using an X11 8-bits string. --- Xlib/protocol/rq.py | 7 +++---- test/gen/genprottest.py | 14 +++++++------- test/test_events_be.py | 2 +- test/test_events_le.py | 2 +- test/test_requests_be.py | 12 ++++++------ test/test_requests_le.py | 12 ++++++------ 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index bdc25420..c945c628 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -27,7 +27,7 @@ import types # Python 2/3 compatibility. -from six import byte2int, indexbytes, iterbytes, string_types +from six import binary_type, byte2int, indexbytes, iterbytes # Xlib modules from .. import X @@ -650,7 +650,7 @@ def parse_binary_value(self, data, display, length, format): ret = None elif format == 8: - ret = (8, data[:length].decode()) + ret = (8, data[:length]) data = data[length + ((4 - length % 4) % 4):] elif format == 16: @@ -669,8 +669,7 @@ def pack_value(self, value): if fmt not in (8, 16, 32): raise BadDataError('Invalid property data format {0}'.format(fmt)) - if isinstance(val, string_types): - val = val.encode() + if isinstance(val, binary_type): size = fmt // 8 vlen = len(val) if vlen % size: diff --git a/test/gen/genprottest.py b/test/gen/genprottest.py index 9dde7201..08a4611b 100644 --- a/test/gen/genprottest.py +++ b/test/gen/genprottest.py @@ -908,9 +908,9 @@ def build_bin(bin): request_var_defs = { 'InternAtom': ('fuzzy_prop', ), - 'ChangeProperty': [((8, ''), ), - ((8, 'foo'), ), - ((8, 'zoom'), ), + 'ChangeProperty': [((8, b''), ), + ((8, b'foo'), ), + ((8, b'zoom'), ), ((16, []), ), ((16, [1, 2, 3]), ), ((16, [1, 2, 3, 4]), ), @@ -951,9 +951,9 @@ def build_bin(bin): reply_var_defs = { 'QueryTree': (7, ), 'GetAtomName': ('WM_CLASS', ), - 'GetProperty': [((8, ''), ), - ((8, 'foo'), ), - ((8, 'zoom'), ), + 'GetProperty': [((8, b''), ), + ((8, b'foo'), ), + ((8, b'zoom'), ), ((16, []), ), ((16, [1, 2, 3]), ), ((16, [1, 2, 3, 4]), ), @@ -980,7 +980,7 @@ def build_bin(bin): } event_var_defs = { - 'ClientMessage': [((8, '01234567890123456789'), ), + 'ClientMessage': [((8, b'01234567890123456789'), ), ((16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), ), ((32, [1, 2, 3, 4, 5]), ) ], } diff --git a/test/test_events_be.py b/test/test_events_be.py index 96778ea2..d911ee11 100644 --- a/test/test_events_be.py +++ b/test/test_events_be.py @@ -726,7 +726,7 @@ class TestClientMessage(EndianTest): def setUp(self): self.evt_args_0 = { 'sequence_number': 48712, - 'data': (8, '01234567890123456789'), + 'data': (8, b'01234567890123456789'), 'type': 245, 'client_type': 1340394836, 'window': 1256861040, diff --git a/test/test_events_le.py b/test/test_events_le.py index e34871ff..e9a8a359 100644 --- a/test/test_events_le.py +++ b/test/test_events_le.py @@ -546,7 +546,7 @@ class TestClientMessage(EndianTest): def setUp(self): self.evt_args_0 = { 'client_type': 1554224294, - 'data': (8, '01234567890123456789'), + 'data': (8, b'01234567890123456789'), 'sequence_number': 44540, 'type': 140, 'window': 610247893, diff --git a/test/test_requests_be.py b/test/test_requests_be.py index ec6d2b6f..e41ccfcb 100644 --- a/test/test_requests_be.py +++ b/test/test_requests_be.py @@ -682,7 +682,7 @@ class TestChangeProperty(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 0, - 'data': (8, ''), + 'data': (8, b''), 'property': 2085394193, 'window': 266197951, 'type': 1343008022, @@ -693,7 +693,7 @@ def setUp(self): self.req_args_1 = { 'mode': 2, - 'data': (8, 'foo'), + 'data': (8, b'foo'), 'property': 449719979, 'window': 1522118044, 'type': 121096013, @@ -705,7 +705,7 @@ def setUp(self): self.req_args_2 = { 'mode': 2, - 'data': (8, 'zoom'), + 'data': (8, b'zoom'), 'property': 1009841498, 'window': 286324270, 'type': 1547457396, @@ -964,7 +964,7 @@ def setUp(self): '\x5d\x30\x8c\xce' '\x50\x42\x12\x95' self.reply_args_0 = { - 'value': (8, ''), + 'value': (8, b''), 'sequence_number': 30606, 'property_type': 1392423916, 'bytes_after': 2046056935, @@ -975,7 +975,7 @@ def setUp(self): '\x00\x00\x00\x00' '\x00\x00\x00\x00' self.reply_args_1 = { - 'value': (8, 'foo'), + 'value': (8, b'foo'), 'sequence_number': 44279, 'property_type': 186441230, 'bytes_after': 469299413, @@ -987,7 +987,7 @@ def setUp(self): '\x66\x6f\x6f\x00' self.reply_args_2 = { - 'value': (8, 'zoom'), + 'value': (8, b'zoom'), 'sequence_number': 12674, 'property_type': 1802804296, 'bytes_after': 1968158856, diff --git a/test/test_requests_le.py b/test/test_requests_le.py index 6cc5c94c..ab49c024 100644 --- a/test/test_requests_le.py +++ b/test/test_requests_le.py @@ -483,7 +483,7 @@ def testUnpackReply0(self): class TestChangeProperty(EndianTest): def setUp(self): self.req_args_0 = { - 'data': (8, ''), + 'data': (8, b''), 'mode': 1, 'property': 933688309, 'type': 974400040, @@ -494,7 +494,7 @@ def setUp(self): b'\x08\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_1 = { - 'data': (8, 'foo'), + 'data': (8, b'foo'), 'mode': 2, 'property': 565671953, 'type': 1075033221, @@ -506,7 +506,7 @@ def setUp(self): b'\x66\x6f\x6f\x00' self.req_args_2 = { - 'data': (8, 'zoom'), + 'data': (8, b'zoom'), 'mode': 0, 'property': 1869432878, 'type': 640951286, @@ -688,7 +688,7 @@ def setUp(self): 'bytes_after': 1567532733, 'property_type': 1158159724, 'sequence_number': 14082, - 'value': (8, ''), + 'value': (8, b''), } self.reply_bin_0 = b'\x01\x08\x02\x37' b'\x00\x00\x00\x00' \ b'\x6c\x1d\x08\x45' b'\xbd\xa6\x6e\x5d' \ @@ -699,7 +699,7 @@ def setUp(self): 'bytes_after': 2137067287, 'property_type': 669450745, 'sequence_number': 13387, - 'value': (8, 'foo'), + 'value': (8, b'foo'), } self.reply_bin_1 = b'\x01\x08\x4b\x34' b'\x01\x00\x00\x00' \ b'\xf9\x01\xe7\x27' b'\x17\x0f\x61\x7f' \ @@ -711,7 +711,7 @@ def setUp(self): 'bytes_after': 1111517270, 'property_type': 940849590, 'sequence_number': 42680, - 'value': (8, 'zoom'), + 'value': (8, b'zoom'), } self.reply_bin_2 = b'\x01\x08\xb8\xa6' b'\x01\x00\x00\x00' \ b'\xb6\x39\x14\x38' b'\x56\x68\x40\x42' \ From 6a945dcf99a5c3a3fad220ee08cb416205ecbf25 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 1 Aug 2016 13:20:16 +0200 Subject: [PATCH 120/279] xobject/drawable: small cleanup Avoid redefining 'type' builtin. --- Xlib/xobject/drawable.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Xlib/xobject/drawable.py b/Xlib/xobject/drawable.py index b8f7b9a1..4f179ccd 100644 --- a/Xlib/xobject/drawable.py +++ b/Xlib/xobject/drawable.py @@ -421,8 +421,7 @@ def query_tree(self): return request.QueryTree(display = self.display, window = self.id) - - def change_property(self, property, type, format, data, + def change_property(self, property, property_type, format, data, mode = X.PropModeReplace, onerror = None): request.ChangeProperty(display = self.display, @@ -430,7 +429,7 @@ def change_property(self, property, type, format, data, mode = mode, window = self.id, property = property, - type = type, + type = property_type, data = (format, data)) def delete_property(self, property, onerror = None): @@ -439,12 +438,12 @@ def delete_property(self, property, onerror = None): window = self.id, property = property) - def get_property(self, property, type, offset, length, delete = 0): + def get_property(self, property, property_type, offset, length, delete = 0): r = request.GetProperty(display = self.display, delete = delete, window = self.id, property = property, - type = type, + type = property_type, long_offset = offset, long_length = length) @@ -456,12 +455,12 @@ def get_property(self, property, type, offset, length, delete = 0): else: return None - def get_full_property(self, property, type, sizehint = 10): - prop = self.get_property(property, type, 0, sizehint) + def get_full_property(self, property, property_type, sizehint = 10): + prop = self.get_property(property, property_type, 0, sizehint) if prop: val = prop.value if prop.bytes_after: - prop = self.get_property(property, type, sizehint, + prop = self.get_property(property, property_type, sizehint, prop.bytes_after // 4 + 1) val = val + prop.value From 9d50f46d784db6b534e5b44130ad8e7077891f61 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 1 Aug 2016 16:27:30 +0200 Subject: [PATCH 121/279] xobject/drawable: improve handling of text properties --- Xlib/xobject/drawable.py | 76 +++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/Xlib/xobject/drawable.py b/Xlib/xobject/drawable.py index 4f179ccd..5832cd1c 100644 --- a/Xlib/xobject/drawable.py +++ b/Xlib/xobject/drawable.py @@ -320,6 +320,9 @@ def query_best_size(self, item_class, width, height): class Window(Drawable): __window__ = resource.Resource.__resource__ + _STRING_ENCODING = 'ISO-8859-1' + _UTF8_STRING_ENCODING = 'UTF-8' + def create_window(self, x, y, width, height, border_width, depth, window_class = X.CopyFromParent, visual = X.CopyFromParent, @@ -432,6 +435,16 @@ def change_property(self, property, property_type, format, data, type = property_type, data = (format, data)) + def change_text_property(self, property, property_type, data, + mode = X.PropModeReplace, onerror = None): + if not isinstance(data, bytes): + if property_type == Xatom.STRING: + data = data.encode(self._STRING_ENCODING) + elif property_type == self.display.get_atom('UTF8_STRING'): + data = data.encode(self._UTF8_STRING_ENCODING) + self.change_property(property, property_type, 8, data, + mode=mode, onerror=onerror) + def delete_property(self, property, onerror = None): request.DeleteProperty(display = self.display, onerror = onerror, @@ -469,6 +482,19 @@ def get_full_property(self, property, property_type, sizehint = 10): else: return None + def get_full_text_property(self, property, property_type=X.AnyPropertyType, sizehint = 10): + prop = self.get_full_property(property, property_type, + sizehint=sizehint) + if prop is None or prop.format != 8: + return None + if prop.property_type == Xatom.STRING: + prop.value = prop.value.decode(self._STRING_ENCODING) + elif prop.property_type == self.display.get_atom('UTF8_STRING'): + prop.value = prop.value.decode(self._UTF8_STRING_ENCODING) + # FIXME: at least basic support for compound text would be nice. + # elif prop.property_type == self.display.get_atom('COMPOUND_TEXT'): + return prop.value + def list_properties(self): r = request.ListProperties(display = self.display, window = self.id) @@ -636,43 +662,33 @@ def rotate_properties(self, properties, delta, onerror = None): properties = properties) def set_wm_name(self, name, onerror = None): - self.change_property(Xatom.WM_NAME, Xatom.STRING, 8, name, - onerror = onerror) + self.change_text_property(Xatom.WM_NAME, Xatom.STRING, name, + onerror = onerror) def get_wm_name(self): - d = self.get_full_property(Xatom.WM_NAME, Xatom.STRING) - if d is None or d.format != 8: - return None - else: - return d.value + return self.get_full_text_property(Xatom.WM_NAME, Xatom.STRING) def set_wm_icon_name(self, name, onerror = None): - self.change_property(Xatom.WM_ICON_NAME, Xatom.STRING, 8, name, - onerror = onerror) + self.change_text_property(Xatom.WM_ICON_NAME, Xatom.STRING, name, + onerror = onerror) def get_wm_icon_name(self): - d = self.get_full_property(Xatom.WM_ICON_NAME, Xatom.STRING) - if d is None or d.format != 8: - return None - else: - return d.value - + return self.get_full_text_property(Xatom.WM_ICON_NAME, Xatom.STRING) def set_wm_class(self, inst, cls, onerror = None): - self.change_property(Xatom.WM_CLASS, Xatom.STRING, 8, - '%s\0%s\0' % (inst, cls), - onerror = onerror) + self.change_text_property(Xatom.WM_CLASS, Xatom.STRING, + '%s\0%s\0' % (inst, cls), + onerror = onerror) def get_wm_class(self): - d = self.get_full_property(Xatom.WM_CLASS, Xatom.STRING) - if d is None or d.format != 8: + value = self.get_full_text_property(Xatom.WM_CLASS, Xatom.STRING) + if value is None: + return None + parts = value.split('\0') + if len(parts) < 2: return None else: - parts = d.value.split('\0') - if len(parts) < 2: - return None - else: - return parts[0], parts[1] + return parts[0], parts[1] def set_wm_transient_for(self, window, onerror = None): self.change_property(Xatom.WM_TRANSIENT_FOR, Xatom.WINDOW, @@ -718,15 +734,11 @@ def get_wm_colormap_windows(self): def set_wm_client_machine(self, name, onerror = None): - self.change_property(Xatom.WM_CLIENT_MACHINE, Xatom.STRING, 8, name, - onerror = onerror) + self.change_text_property(Xatom.WM_CLIENT_MACHINE, Xatom.STRING, name, + onerror = onerror) def get_wm_client_machine(self): - d = self.get_full_property(Xatom.WM_CLIENT_MACHINE, Xatom.STRING) - if d is None or d.format != 8: - return None - else: - return d.value + return self.get_full_text_property(Xatom.WM_CLIENT_MACHINE, Xatom.STRING) def set_wm_normal_hints(self, hints = {}, onerror = None, **keys): self._set_struct_prop(Xatom.WM_NORMAL_HINTS, Xatom.WM_SIZE_HINTS, From e76296e2b3e0cc9817e46daabbf2b5524c552e3e Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 1 Aug 2016 16:44:05 +0200 Subject: [PATCH 122/279] examples: fix get_selection encoding handling --- examples/get_selection.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/get_selection.py b/examples/get_selection.py index 0cbd6683..79ea739f 100755 --- a/examples/get_selection.py +++ b/examples/get_selection.py @@ -22,6 +22,7 @@ # Suite 330, # Boston, MA 02111-1307 USA +import binascii import sys import os @@ -155,7 +156,13 @@ def output_data(d, r, target_name): len(r.value)) if r.format == 8: - sys.stdout.write(r.value) + if r.property_type == Xatom.STRING: + value = r.value.decode('ISO-8859-1') + elif r.property_type == d.get_atom('UTF8_STRING'): + value = r.value.decode('UTF-8') + else: + value = binascii.hexlify(r.value).decode('ascii') + sys.stdout.write(value) elif r.format == 32 and r.property_type == Xatom.ATOM: for v in r.value: From cafe343ba440d9acbe35449dafa82e54714998fd Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 8 Aug 2016 15:30:43 +0200 Subject: [PATCH 123/279] support/unix_connect: fix Python 2 support Unlike with Python 3, `bytes(x for x in range(4))` returns a generator object with Python 2. --- Xlib/support/unix_connect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index 5da37950..4add2dba 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -109,7 +109,7 @@ def new_get_auth(sock, dname, host, dno): # Convert the prettyprinted IP number into 4-octet string. # Sometimes these modules are too damn smart... octets = sock.getpeername()[0].split('.') - addr = bytes(int(x) for x in octets) + addr = bytearray(int(x) for x in octets) else: family = xauth.FamilyLocal addr = socket.gethostname().encode() From 7129e50ebb1230af166f2c6dca29780d161c2d4d Mon Sep 17 00:00:00 2001 From: Paolo Montesel Date: Tue, 9 Aug 2016 01:22:43 +0000 Subject: [PATCH 124/279] Renamed CompositeGetOverlayWindow to GetOverlayWindow --- Xlib/ext/composite.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/ext/composite.py b/Xlib/ext/composite.py index 8ee363db..be1fac76 100644 --- a/Xlib/ext/composite.py +++ b/Xlib/ext/composite.py @@ -206,7 +206,7 @@ def name_window_pixmap(self): cls = self.display.get_resource_class('pixmap', drawable.Pixmap) return cls(self.display, pid, owner = 1) -class CompositeGetOverlayWindow(rq.ReplyRequest): +class GetOverlayWindow(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(7), @@ -226,7 +226,7 @@ def get_overlay_window(self): """Return the overlay window of the root window. """ - return CompositeGetOverlayWindow(display = self.display, + return GetOverlayWindow(display = self.display, opcode = self.display.get_extension_major(extname), window = self) From e7fc4d793d6427f6a37b213a4362b1b628682151 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 10 Aug 2016 15:19:51 +0200 Subject: [PATCH 125/279] update news --- NEWS | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/NEWS b/NEWS index c8422acc..efd096b3 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,31 @@ NEWS for Python X Library +* Version 0.17 + +** Bug Fixes + +- fix Xauth handling when using Python 2 and DISPLAY contains a remote IP +- fix String16 request field handling when using Python 3 +- fix RECORD extension and example when using Python 3 +- fix handling of properties: use byte strings for all X11 8-bits + strings, as not all of them are text properties (the window + getters/setters for wm_name, wm_icon_name, wm_class, and + wm_client_machine still return/expect Unicode strings) + +** API Changes + +Core: + +- new window getter/setter for text properties: get_full_text_property + and change_text_property; with automatic conversion to/from Unicode + when the property type encoding is supported (STRING and UTF8_STRING) + +Composite extension: + +- support for GetOverlayWindow request + + * Version 0.16 ** Licensing From eb3f4b70671afa09cdd38b43d7cb5e38d92f63a7 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 10 Aug 2016 15:52:51 +0200 Subject: [PATCH 126/279] bump version to 0.17 --- Xlib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/__init__.py b/Xlib/__init__.py index f30a6dc4..5040acd2 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 16) +__version__ = (0, 17) __version_extra__ = '' From 7db3f5a7f52845ab46b2b3465826b48ed36582bb Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 16 Oct 2016 15:42:28 +0200 Subject: [PATCH 127/279] setup: create a universal wheel --- .travis.yml | 5 ++--- setup.cfg | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 setup.cfg diff --git a/.travis.yml b/.travis.yml index fbff035b..08dacc40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,9 +32,8 @@ before_deploy: # Generate egg distribution. - python setup.py bdist_egg # Generate wheel distribution. - # Note: only do this once for each major Python version, as the minor version - # number is not encoded in the resulting filename (and contents are the same). - - case "$TRAVIS_PYTHON_VERSION" in 2.7|3.5) python setup.py bdist_wheel;; esac + # Note: only do this once, since we create a universal wheel. + - case "$TRAVIS_PYTHON_VERSION" in 3.5) python setup.py bdist_wheel;; esac deploy: - provider: releases diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..2a9acf13 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal = 1 From fda53b44b4639cb731b3e153d617b8257035451c Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 16 Oct 2016 13:49:31 +0200 Subject: [PATCH 128/279] protocol/display: fix interrupted select handling for Python 3.3/3.4 With Python >=3.3, `select.error` is now an instance of OSError. Note that there was no issue with Python 3.5 as interrupted system calls are automatically retried. --- Xlib/protocol/display.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 566c044f..309474f2 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -533,8 +533,12 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) # Ignore errors caused by a signal recieved while blocking. # All other errors are re-raised. except select.error as err: - if err[0] != errno.EINTR: - raise err + if isinstance(err, OSError): + code = err.errno + else: + code = err[0] + if code != errno.EINTR: + raise # We must lock send_and_recv before we can loop to # the start of the loop From 95ba5136409405e171163725de21cdf84c63bac5 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 21 Oct 2016 18:00:37 +0200 Subject: [PATCH 129/279] protocol/display: fix Python 3 buffer abstraction With Python 2, slicing a buffer yield new data, but with Python 3, slicing a memoryview return another memoryview: > python2 -c 'print buffer(b"12345")[1:3].decode()' 23 > python3 -c 'print(memoryview(b"12345")[1:3].decode())' Traceback (most recent call last): File "", line 1, in AttributeError: 'memoryview' object has no attribute 'decode' --- Xlib/protocol/display.py | 40 ++++++++++++++++++++++++++++++++-------- test/test_bytesview.py | 27 +++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 test/test_bytesview.py diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 309474f2..61d4c8f5 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -42,12 +42,36 @@ from . import event if PY3: - def buffer(object, offset=None, size=None): - if offset is None: - offset = 0 + + class bytesview(object): + + def __init__(self, data, offset=0, size=None): + if size is None: + size = len(data)-offset + if isinstance(data, bytes): + view = memoryview(data) + elif isinstance(data, bytesview): + view = data.view + else: + raise TypeError('unsupported type: {}'.format(type(data))) + self.view = view[offset:offset+size] + + def __len__(self): + return len(self.view) + + def __getitem__(self, key): + if isinstance(key, slice): + return bytes(self.view[key]) + return self.view[key] + +else: + + def bytesview(data, offset=0, size=None): + if not isinstance(data, (bytes, buffer)): + raise TypeError('unsupported type: {}'.format(type(data))) if size is None: - size = len(object)-offset - return memoryview(object)[offset:offset+size] + size = len(data)-offset + return buffer(data, offset, size) class Display(object): @@ -706,7 +730,7 @@ def parse_error_response(self, request): estruct = self.error_classes.get(code, error.XError) e = estruct(self, self.data_recv[:32]) - self.data_recv = buffer(self.data_recv, 32) + self.data_recv = bytesview(self.data_recv, 32) # print 'recv Error:', e @@ -760,7 +784,7 @@ def parse_request_response(self, request): req._parse_response(self.data_recv[:self.recv_packet_len]) # print 'recv Request:', req - self.data_recv = buffer(self.data_recv, self.recv_packet_len) + self.data_recv = bytesview(self.data_recv, self.recv_packet_len) self.recv_packet_len = 0 @@ -797,7 +821,7 @@ def parse_event_response(self, etype): if etype == ge.GenericEventCode: self.recv_packet_len = 0 - self.data_recv = buffer(self.data_recv, length) + self.data_recv = bytesview(self.data_recv, length) # Drop all requests having an error handler, # but which obviously succeded. diff --git a/test/test_bytesview.py b/test/test_bytesview.py new file mode 100644 index 00000000..565793a1 --- /dev/null +++ b/test/test_bytesview.py @@ -0,0 +1,27 @@ + +import unittest + +# Python 2/3 compatibility. +from six import indexbytes, text_type + +from Xlib.protocol.display import bytesview + + +class BytesViewTest(unittest.TestCase): + + def test(self): + with self.assertRaises(TypeError): + bytesview(text_type('foobar')) + data = b'0123456789ABCDEF' + view = bytesview(data) + self.assertEqual(len(view), 16) + self.assertEqual(view[:], data) + self.assertIsInstance(view[:], bytes) + self.assertEqual(view[5:-6], b'56789') + self.assertEqual(indexbytes(view, 7), ord('7')) + view = bytesview(view, 5) + self.assertEqual(view[:], b'56789ABCDEF') + self.assertEqual(indexbytes(view, 4), ord('9')) + view = bytesview(view, 0, 5) + self.assertEqual(view[:], b'56789') + self.assertEqual(indexbytes(view, 1), ord('6')) From 3f301b2e225e8eeed9117b04fa22c299ba4a34f4 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 7 Nov 2016 21:15:29 +0100 Subject: [PATCH 130/279] support/unix_connect: improve Unix socket support Use an abstract address if no matching filesystem path is found. --- Xlib/support/unix_connect.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index 4add2dba..7b09584a 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -86,8 +86,12 @@ def get_socket(dname, host, dno): # Else use Unix socket else: + address = '/tmp/.X11-unix/X%d' % dno + if not os.path.exists(address): + # Use abstract address. + address = '\0' + address s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - s.connect('/tmp/.X11-unix/X%d' % dno) + s.connect(address) except socket.error as val: raise error.DisplayConnectionError(dname, str(val)) From d8da7991cdf43d1f9e7e37c8da998d3dc4c23e31 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 22 Nov 2016 10:02:50 +0100 Subject: [PATCH 131/279] update news --- NEWS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/NEWS b/NEWS index efd096b3..396d2397 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,15 @@ NEWS for Python X Library +* Version 0.18 + +** Bug Fixes + +- fix Python 3 buffer abstraction +- fix interrupted select handling for Python 3.3/3.4 +- fix Unix socket support when only an abstract address is available + + * Version 0.17 ** Bug Fixes From 263be336193d1c11bcf48b02e619958d0cdb1fca Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 23 Nov 2016 15:06:29 +0100 Subject: [PATCH 132/279] bump version to 0.18 --- Xlib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 5040acd2..8bd7fa0a 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 17) +__version__ = (0, 18) __version_extra__ = '' From caabf9f86161458828d922e7b99696b5ed87f28b Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 23 Nov 2016 17:10:43 +0100 Subject: [PATCH 133/279] xauth: fix exception message Use the correct filename instead of hard-coded `~/.Xauthority`. --- Xlib/xauth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/xauth.py b/Xlib/xauth.py index f5c12b11..c3f06626 100644 --- a/Xlib/xauth.py +++ b/Xlib/xauth.py @@ -44,7 +44,7 @@ def __init__(self, filename = None): try: raw = open(filename, 'rb').read() except IOError as err: - raise error.XauthError('~/.Xauthority: %s' % err) + raise error.XauthError('could not read from {0}: {1}'.format(filename, err)) self.entries = [] From 884153390ffbffaa397a264546f1eb3d44647094 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 23 Nov 2016 17:12:19 +0100 Subject: [PATCH 134/279] support/unix_connect: improve Xauthority handling Be more lenient if `$XAUTHFILE` / `~/.Xauthority` does not exist. --- Xlib/support/unix_connect.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index 7b09584a..20ae5b63 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -118,7 +118,11 @@ def new_get_auth(sock, dname, host, dno): family = xauth.FamilyLocal addr = socket.gethostname().encode() - au = xauth.Xauthority() + try: + au = xauth.Xauthority() + except error.XauthError: + return b'', b'' + while 1: try: return au.get_best_auth(family, addr, dno) From 52fb96a2d41873347c30bfdbdc1c3e06736b84cd Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 23 Nov 2016 17:46:15 +0100 Subject: [PATCH 135/279] xauth: minor cleanup --- Xlib/xauth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/xauth.py b/Xlib/xauth.py index c3f06626..a8fd14ca 100644 --- a/Xlib/xauth.py +++ b/Xlib/xauth.py @@ -85,7 +85,7 @@ def __init__(self, filename = None): break self.entries.append((family, addr, num, name, data)) - except struct.error as e: + except struct.error: print("Xlib.xauth: warning, failed to parse part of xauthority file {0}, aborting all further parsing".format(filename)) if len(self.entries) == 0: From 9403309ae589ec4361eceac55d1b3918831d046b Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Thu, 24 Nov 2016 22:32:26 +0100 Subject: [PATCH 136/279] add helper to run tests --- runtests.py | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100755 runtests.py diff --git a/runtests.py b/runtests.py new file mode 100755 index 00000000..6ba2aee1 --- /dev/null +++ b/runtests.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python + +# Python 2/3 compatibility. +from __future__ import print_function + +import os +import signal +import subprocess +import sys +import tempfile + +from pkg_resources import load_entry_point + + +class SigException(BaseException): + def __init__(self, signum): + super(SigException, self).__init__() + self.signum = signum + +def xsession_sighandler(signum, frame): + raise SigException(signum) + +def xserver_start(display, executable='Xvfb', authfile=None): + pid = os.fork() + if pid != 0: + return pid + if authfile is None: + authfile = os.devnull + # This will make the xserver send us a SIGUSR1 when ready. + signal.signal(signal.SIGUSR1, signal.SIG_IGN) + cmd = [ + executable, + '-auth', authfile, + '-noreset', + display, + ] + print('starting xserver: `{0}`'.format(' '.join(cmd))) + os.execlp(cmd[0], *cmd) + +def tests_run(display, authfile=None): + pid = os.fork() + if pid != 0: + return pid + if authfile is None: + authfile = os.devnull + os.environ['DISPLAY'] = display + os.environ['XAUTHORITY'] = authfile + cmd = [ + 'nosetests', + '--exe', '--with-xunit', '--verbosity=3', + ] + has_custom_tests = False + for arg in sys.argv[1:]: + if not arg.startswith('-'): + has_custom_tests = True + cmd.append(arg) + if not has_custom_tests: + cmd.extend(('test/', 'examples/run_examples.py')) + print('running tests: `{0}`'.format(' '.join(cmd))) + sys.argv = cmd + try: + load_entry_point('nose', 'console_scripts', 'nosetests')() + except SystemExit as err: + code = err.code + else: + code = 0 + os._exit(code) + + +def runtests(): + + cleanup_funcs = [] + + try: + if hasattr(sys, 'pypy_version_info'): + server_display = ':8' + else: + server_display = ':9' + server_display += ''.join(str(n) for n in sys.version_info[:3]) + + # Setup a temporary authentication file. + cookie = subprocess.check_output('mcookie').strip() + authfile = tempfile.NamedTemporaryFile(delete=False) + cleanup_funcs.append(lambda: os.unlink(authfile.name)) + authfile.close() + subprocess.check_call(( + 'xauth', + '-f', authfile.name, + 'add', server_display, '.', cookie, + )) + + # Setup signal handler to wait for xserver to be ready. + signal.signal(signal.SIGUSR1, xsession_sighandler) + + # Start xserver. + server_pid = xserver_start(server_display, authfile=authfile.name) + cleanup_funcs.append(lambda: os.waitpid(server_pid, 0)) + cleanup_funcs.append(lambda: os.kill(server_pid, signal.SIGTERM)) + + # Give the server 3 seconds to start. + signal.alarm(3) + + # Wait for server to be ready. + try: + signal.pause() + except SigException as err: + assert signal.SIGUSR1 == err.signum + signal.alarm(0) + + # Run tests. + tests_pid = tests_run(server_display, authfile=authfile.name) + pid, status = os.waitpid(tests_pid, 0) + assert pid == tests_pid + sys.exit(status >> 8) + + except KeyboardInterrupt: + sys.exit(1) + + finally: + for func in reversed(cleanup_funcs): + func() + + +if __name__ == '__main__': + runtests() From 19e8476d11892e44ae7e44b3cbdc05df2df0056d Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Thu, 24 Nov 2016 22:32:43 +0100 Subject: [PATCH 137/279] travis: use helper to run tests --- .travis.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 08dacc40..8d46f0ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,15 +11,9 @@ install: - pip install -r requirements.txt - pip install -r dev-requirements.txt -before_script: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - - sleep 3 # give xvfb some time to start - - xauth generate :99.0 . trusted - # command to run tests -script: - nosetests --exe --with-xunit --with-coverage --cover-html --cover-html-dir=Coverage_report --verbosity=3 test/ examples/run_examples.py +script: + python runtests.py --with-coverage --cover-html --cover-html-dir=Coverage_report after_success: - codecov From 4e555e1b8b7c8876412c7d66db23bf93470e0931 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Thu, 24 Nov 2016 22:13:20 +0100 Subject: [PATCH 138/279] add tox configuration --- tox.ini | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tox.ini diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..70cc0b53 --- /dev/null +++ b/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py27,py33,py34,py35 +skip_missing_interpreters = true + +[testenv] +deps= + nose + six>=1.10.0 +commands={envpython} runtests.py {posargs} From f911234c02ea70703f58310fc4a54642e7fdda9d Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 23 Nov 2016 19:49:54 +0100 Subject: [PATCH 139/279] support/unix_connect: improve DISPLAY handling - support the optional protocol prefix - `unix:0.0` is actually equivalent to `:0.0` --- Xlib/support/unix_connect.py | 20 +++++++++--- test/test_unix_connect.py | 60 ++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 test/test_unix_connect.py diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index 20ae5b63..a70efe64 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -45,11 +45,11 @@ uname = platform.uname() if (uname[0] == 'Darwin') and ([int(x) for x in uname[2].split('.')] >= [9, 0]): - display_re = re.compile(r'^([-:a-zA-Z0-9._/]*):([0-9]+)(\.([0-9]+))?$') + display_re = re.compile(r'^(?P)(?P[-:a-zA-Z0-9._/]*):(?P[0-9]+)(\.(?P[0-9]+))?$') else: - display_re = re.compile(r'^([-:a-zA-Z0-9._]*):([0-9]+)(\.([0-9]+))?$') + display_re = re.compile(r'^((?Ptcp|unix)/)?(?P[-:a-zA-Z0-9._]*):(?P[0-9]+)(\.(?P[0-9]+))?$') def get_display(display): # Use $DISPLAY if display isn't provided @@ -61,9 +61,19 @@ def get_display(display): raise error.DisplayNameError(display) name = display - host = m.group(1) - dno = int(m.group(2)) - screen = m.group(4) + protocol, host, dno, screen = m.group('proto', 'host', 'dno', 'screen') + if protocol == 'tcp': + # Host is mandatory when protocol is TCP. + if not host: + raise error.DisplayNameError(display) + elif protocol == 'unix': + # Clear host to force Unix socket connection. + host = '' + else: + # Special case: `unix:0.0` is equivalent to `:0.0`. + if host == 'unix': + host = '' + dno = int(dno) if screen: screen = int(screen) else: diff --git a/test/test_unix_connect.py b/test/test_unix_connect.py new file mode 100644 index 00000000..8c325da9 --- /dev/null +++ b/test/test_unix_connect.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -* + +import sys +import unittest + +from Xlib.support import unix_connect +from Xlib.error import DisplayNameError + + +@unittest.skipUnless(sys.platform.startswith('linux'), 'Linux specific tests') +class TestUnixConnect(unittest.TestCase): + + def test_get_display(self): + # Valid cases. + for display, expected in ( + # Implicit Unix socket connections. + (':0.1', ('', 0, 1)), + (':4', ('', 4, 0)), + # Implicit TCP connections. + ('foo:1.2', ('foo', 1, 2)), + ('bar:5', ('bar', 5, 0)), + # Explicit Unix socket connections. + ('unix/foo:4.3', ('', 4, 3)), + ('unix/:66', ('', 66, 0)), + # Explicit TCP connections. + ('tcp/foo:11.1', ('foo', 11, 1)), + ('tcp/bar:66.6', ('bar', 66, 6)), + ('tcp/unix:54.3', ('unix', 54, 3)), + # Special case: `unix:0.0` is equivalent to `:0.0`. + ('unix:99.5', ('', 99, 5)), + ('unix:42', ('', 42, 0)), + ): + result = unix_connect.get_display(display) + self.assertEqual(result, (display,) + expected) + # Invalid cases. + for display in ( + # No display number. + '', + ':', + 'foo', + 'bar:', + # Bad screen number. + ':48.', + ':47.f', + # Bad hostname. + u'fòó:0', + u'tcp/bàr:1', + u'unix/fòóbàr:2', + # Bad protocol. + 'udp/foo:0' + # With explicit TCP connections, hostname must be set. + 'tcp/:0', + ): + with self.assertRaises(DisplayNameError): + unix_connect.get_display(display) + + +if __name__ == '__main__': + unittest.main() From 841b23c59c4d8640aef8e4a12917e844a56cc29e Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Fri, 30 Sep 2016 15:49:39 -0600 Subject: [PATCH 140/279] Fix spelling of rhomboid --- examples/draw-proto.py | 12 ++++++------ examples/draw.py | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/draw-proto.py b/examples/draw-proto.py index 3db1b994..4edc361a 100755 --- a/examples/draw-proto.py +++ b/examples/draw-proto.py @@ -107,7 +107,7 @@ def loop(self): current.motion(e) # A drawed objects, consisting of either a single -# romboid, or two romboids connected by a winding line +# rhomboid, or two rhomboids connected by a winding line class Movement(object): def __init__(self, win, ev): @@ -121,7 +121,7 @@ def __init__(self, win, ev): self.time = ev.time self.lines = [(ev.event_x, ev.event_y)] - self.first = Romboid(self.win, ev) + self.first = Rhomboid(self.win, ev) self.last = None def motion(self, ev): @@ -182,7 +182,7 @@ def motion(self, ev): def finish(self, ev): self.motion(ev) if len(self.lines) > 1: - self.last = Romboid(self.win, ev) + self.last = Rhomboid(self.win, ev) self.left = min(ev.event_x - 5, self.left) self.right = max(ev.event_x + 5, self.right) @@ -206,8 +206,8 @@ def expose(self, ev): self.last.draw() -# A romboid, drawed around the Movement endpoints -class Romboid(object): +# A rhomboid, drawed around the Movement endpoints +class Rhomboid(object): def __init__(self, win, ev): self.win = win self.x = ev.event_x @@ -215,7 +215,7 @@ def __init__(self, win, ev): self.draw() def draw(self): - # Draw the segments of the romboid + # Draw the segments of the rhomboid PolyLine(self.win.d, None, X.CoordModePrevious, self.win.window, diff --git a/examples/draw.py b/examples/draw.py index 8832a50f..f456d801 100755 --- a/examples/draw.py +++ b/examples/draw.py @@ -118,7 +118,7 @@ def loop(self): sys.exit(0) # A drawed objects, consisting of either a single -# romboid, or two romboids connected by a winding line +# rhomboid, or two rhomboids connected by a winding line class Movement(object): def __init__(self, win, ev): @@ -132,7 +132,7 @@ def __init__(self, win, ev): self.time = ev.time self.lines = [(ev.event_x, ev.event_y)] - self.first = Romboid(self.win, ev) + self.first = Rhomboid(self.win, ev) self.last = None def motion(self, ev): @@ -185,7 +185,7 @@ def motion(self, ev): def finish(self, ev): self.motion(ev) if len(self.lines) > 1: - self.last = Romboid(self.win, ev) + self.last = Rhomboid(self.win, ev) self.left = min(ev.event_x - 5, self.left) self.right = max(ev.event_x + 5, self.right) @@ -207,8 +207,8 @@ def expose(self, ev): self.last.draw() -# A romboid, drawed around the Movement endpoints -class Romboid(object): +# A rhomboid, drawed around the Movement endpoints +class Rhomboid(object): def __init__(self, win, ev): self.win = win self.x = ev.event_x @@ -216,7 +216,7 @@ def __init__(self, win, ev): self.draw() def draw(self): - # Draw the segments of the romboid + # Draw the segments of the rhomboid self.win.window.poly_line(self.win.gc, X.CoordModePrevious, [(self.x, self.y - 5), (5, 5), From 2e92a6c6e1521a751122d1bbbafecfdb4b11aaa9 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Fri, 30 Sep 2016 15:55:24 -0600 Subject: [PATCH 141/279] Fix perl usage https://sourceforge.net/p/python-xlib/bugs/41/ --- doc/html/texi2html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/html/texi2html b/doc/html/texi2html index 80bc9a13..91ae657d 100755 --- a/doc/html/texi2html +++ b/doc/html/texi2html @@ -1557,7 +1557,7 @@ sub update_sec_num { $level--; # here we start at 0 if ($name =~ /^appendix/) { # appendix style - if (defined(@appendix_sec_num)) { + if (@appendix_sec_num) { &incr_sec_num($level, @appendix_sec_num); } else { @appendix_sec_num = ('A', 0, 0, 0); @@ -1565,7 +1565,7 @@ sub update_sec_num { $ret = join('.', @appendix_sec_num[0..$level]); } else { # normal style - if (defined(@normal_sec_num)) { + if (@normal_sec_num) { &incr_sec_num($level, @normal_sec_num); } else { @normal_sec_num = (1, 0, 0, 0); From 691347b90487fb9699b795ba4fddfe4a7dea3e81 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 17 Feb 2017 16:28:57 +0100 Subject: [PATCH 142/279] support/unix_connect: fix SSH forwarding work-around under Python3 --- Xlib/support/unix_connect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index a70efe64..3b16d5dc 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -143,9 +143,9 @@ def new_get_auth(sock, dname, host, dno): # $DISPLAY to localhost:10, but stores the xauth cookie as if # DISPLAY was :10. Hence, if localhost and not found, try # again as a Unix socket. - if family == xauth.FamilyInternet and addr == '\x7f\x00\x00\x01': + if family == xauth.FamilyInternet and addr == b'\x7f\x00\x00\x01': family = xauth.FamilyLocal - addr = socket.gethostname() + addr = socket.gethostname().encode() else: return b'', b'' From 6f05d593ac3f47b51ed1ec6e595209ac1ddc1249 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 17 Feb 2017 16:38:38 +0100 Subject: [PATCH 143/279] tox: add Python 3.6 to the list of interpreters --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 70cc0b53..25016995 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py33,py34,py35 +envlist = py27,py33,py34,py35,py36 skip_missing_interpreters = true [testenv] From 2d0b91f169f547d7d99bb6d77e8c74fb8ad36711 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 17 Feb 2017 16:38:54 +0100 Subject: [PATCH 144/279] travis: add Python 3.6 build --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8d46f0ee..4d452d64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ python: - "3.3" - "3.4" - "3.5" + - "3.6" # command to install dependencies install: From 1a579e49d21a68c0ddd6a3cd697e55cff7d06a60 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 20 Feb 2017 14:13:39 +0100 Subject: [PATCH 145/279] update news --- NEWS | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/NEWS b/NEWS index 396d2397..8a6811c8 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,16 @@ NEWS for Python X Library +* Version 0.19 + +** Bug Fixes + +- don't throw an exception if $XAUTHFILE / ~/.Xauthority is missing +- fix authentication work-around for SSH forwarding under Python 3 +- improve $DISPLAY handling: support optional protocol prefix, and + correctly handle `unix:0.0` as `:0.0` + + * Version 0.18 ** Bug Fixes From 25341b98852391a75be829e99c1c3cdc9e85c380 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 20 Feb 2017 17:15:55 +0100 Subject: [PATCH 146/279] bump version to 0.19 --- Xlib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 8bd7fa0a..a3601f08 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 18) +__version__ = (0, 19) __version_extra__ = '' From 3d677981d2dff921d0b6b86df140333be03d7e90 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 11 Mar 2017 07:55:55 +0000 Subject: [PATCH 147/279] test: update big-endian tests --- test/test_events_be.py | 845 +++---- test/test_requests_be.py | 5184 +++++++++++++------------------------- 2 files changed, 2100 insertions(+), 3929 deletions(-) diff --git a/test/test_events_be.py b/test/test_events_be.py index d911ee11..827ee53d 100644 --- a/test/test_events_be.py +++ b/test/test_events_be.py @@ -14,842 +14,625 @@ class TestKeymapNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'type': 154, - 'data': [160, 192, 133, 223, 245, 128, 133, 188, 208, 142, 202, 142, 218, 238, 145, 150, 211, 150, 165, 230, 149, 162, 139, 159, 135, 255, 246, 202, 232, 185, 164], + 'data': [248, 202, 136, 187, 201, 200, 244, 146, 187, 195, 178, 236, 157, 185, 166, 196, 164, 146, 143, 170, 206, 201, 240, 159, 247, 205, 231, 197, 254, 240, 148], + 'type': 138, } - self.evt_bin_0 = '\x9a\xa0\xc0\x85' '\xdf\xf5\x80\x85' \ - '\xbc\xd0\x8e\xca' '\x8e\xda\xee\x91' \ - '\x96\xd3\x96\xa5' '\xe6\x95\xa2\x8b' \ - '\x9f\x87\xff\xf6' '\xca\xe8\xb9\xa4' + self.evt_bin_0 = b'\x8a\xf8\xca\x88' b'\xbb\xc9\xc8\xf4' \ + b'\x92\xbb\xc3\xb2' b'\xec\x9d\xb9\xa6' \ + b'\xc4\xa4\x92\x8f' b'\xaa\xce\xc9\xf0' \ + b'\x9f\xf7\xcd\xe7' b'\xc5\xfe\xf0\x94' def testPack0(self): bin = event.KeymapNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.KeymapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestExpose(EndianTest): def setUp(self): self.evt_args_0 = { - 'height': 22214, - 'sequence_number': 56268, - 'type': 254, - 'x': 16974, - 'y': 19752, - 'window': 1381709156, - 'width': 26369, - 'count': 60118, + 'count': 15258, + 'height': 6241, + 'sequence_number': 48394, + 'type': 238, + 'width': 1951, + 'window': 692245859, + 'x': 39820, + 'y': 16664, } - self.evt_bin_0 = '\xfe\x00\xdb\xcc' '\x52\x5b\x35\x64' \ - '\x42\x4e\x4d\x28' '\x67\x01\x56\xc6' \ - '\xea\xd6\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xee\x00\xbd\x0a' b'\x29\x42\xd5\x63' \ + b'\x9b\x8c\x41\x18' b'\x07\x9f\x18\x61' \ + b'\x3b\x9a\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.Expose._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.Expose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestGraphicsExpose(EndianTest): def setUp(self): self.evt_args_0 = { - 'height': 352, - 'sequence_number': 6380, - 'type': 242, - 'drawable': 820411264, - 'x': 57593, - 'y': 41762, - 'major_event': 216, - 'count': 63321, - 'width': 58556, - 'minor_event': 22632, + 'count': 49818, + 'drawable': 1443779242, + 'height': 2892, + 'major_event': 172, + 'minor_event': 50267, + 'sequence_number': 50375, + 'type': 133, + 'width': 38020, + 'x': 54088, + 'y': 17918, } - self.evt_bin_0 = '\xf2\x00\x18\xec' '\x30\xe6\x7b\x80' \ - '\xe0\xf9\xa3\x22' '\xe4\xbc\x01\x60' \ - '\x58\x68\xf7\x59' '\xd8\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\x85\x00\xc4\xc7' b'\x56\x0e\x52\xaa' \ + b'\xd3\x48\x45\xfe' b'\x94\x84\x0b\x4c' \ + b'\xc4\x5b\xc2\x9a' b'\xac\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.GraphicsExpose._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.GraphicsExpose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestNoExpose(EndianTest): def setUp(self): self.evt_args_0 = { - 'sequence_number': 46171, - 'major_event': 242, - 'type': 187, - 'window': 1319843810, - 'minor_event': 45687, + 'major_event': 199, + 'minor_event': 29237, + 'sequence_number': 34266, + 'type': 248, + 'window': 1399171519, } - self.evt_bin_0 = '\xbb\x00\xb4\x5b' '\x4e\xab\x37\xe2' \ - '\xb2\x77\xf2\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xf8\x00\x85\xda' b'\x53\x65\xa9\xbf' \ + b'\x72\x35\xc7\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.NoExpose._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.NoExpose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestVisibilityNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'state': 238, - 'sequence_number': 52805, - 'type': 242, - 'window': 1543431298, + 'sequence_number': 38616, + 'state': 253, + 'type': 174, + 'window': 936121409, } - self.evt_bin_0 = '\xf2\x00\xce\x45' '\x5b\xfe\xe4\x82' \ - '\xee\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xae\x00\x96\xd8' b'\x37\xcc\x14\x41' \ + b'\xfd\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.VisibilityNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.VisibilityNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestCreateNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'height': 15506, - 'sequence_number': 8253, - 'type': 255, - 'border_width': 53414, - 'x': -31204, - 'y': -23908, - 'override': 1, - 'parent': 654326356, - 'window': 8505372, - 'width': 8871, + 'border_width': 56468, + 'height': 7111, + 'override': 0, + 'parent': 747306217, + 'sequence_number': 31058, + 'type': 151, + 'width': 44173, + 'window': 876986399, + 'x': -21847, + 'y': -22248, } - self.evt_bin_0 = '\xff\x00\x20\x3d' '\x27\x00\x3a\x54' \ - '\x00\x81\xc8\x1c' '\x86\x1c\xa2\x9c' \ - '\x22\xa7\x3c\x92' '\xd0\xa6\x01\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\x97\x00\x79\x52' b'\x2c\x8a\xfc\xe9' \ + b'\x34\x45\xc0\x1f' b'\xaa\xa9\xa9\x18' \ + b'\xac\x8d\x1b\xc7' b'\xdc\x94\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.CreateNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.CreateNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestDestroyNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'sequence_number': 49137, - 'event': 408289937, - 'type': 223, - 'window': 1716558237, + 'event': 1489718405, + 'sequence_number': 27233, + 'type': 212, + 'window': 1064077163, } - self.evt_bin_0 = '\xdf\x00\xbf\xf1' '\x18\x56\x02\x91' \ - '\x66\x50\x99\x9d' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xd4\x00\x6a\x61' b'\x58\xcb\x4c\x85' \ + b'\x3f\x6c\x87\x6b' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.DestroyNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.DestroyNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestUnmapNotify(EndianTest): def setUp(self): self.evt_args_0 = { + 'event': 2029853215, 'from_configure': 0, - 'sequence_number': 4412, - 'event': 1122103072, - 'type': 217, - 'window': 1455493798, + 'sequence_number': 43679, + 'type': 201, + 'window': 860030193, } - self.evt_bin_0 = '\xd9\x00\x11\x3c' '\x42\xe1\xef\x20' \ - '\x56\xc1\x12\xa6' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xc9\x00\xaa\x9f' b'\x78\xfd\x1a\x1f' \ + b'\x33\x43\x04\xf1' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.UnmapNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.UnmapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestMapNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'sequence_number': 65096, - 'event': 328610268, - 'type': 228, - 'window': 1882369959, - 'override': 0, + 'event': 675485985, + 'override': 1, + 'sequence_number': 6027, + 'type': 244, + 'window': 542087937, } - self.evt_bin_0 = '\xe4\x00\xfe\x48' '\x13\x96\x31\xdc' \ - '\x70\x32\xaf\xa7' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xf4\x00\x17\x8b' b'\x28\x43\x19\x21' \ + b'\x20\x4f\x9b\x01' b'\x01\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.MapNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.MapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestMapRequest(EndianTest): def setUp(self): self.evt_args_0 = { - 'parent': 1664235152, - 'sequence_number': 51552, - 'type': 171, - 'window': 488763730, + 'parent': 1659099581, + 'sequence_number': 63838, + 'type': 157, + 'window': 868024861, } - self.evt_bin_0 = '\xab\x00\xc9\x60' '\x63\x32\x36\x90' \ - '\x1d\x21\xf1\x52' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\x9d\x00\xf9\x5e' b'\x62\xe3\xd9\xbd' \ + b'\x33\xbd\x02\x1d' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.MapRequest._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.MapRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestReparentNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'sequence_number': 9256, - 'event': 2000272853, - 'type': 229, - 'override': 1, - 'x': -28587, - 'y': -11597, - 'parent': 912114770, - 'window': 1142506827, + 'event': 1867017989, + 'override': 0, + 'parent': 992152190, + 'sequence_number': 43356, + 'type': 128, + 'window': 1165276406, + 'x': -19227, + 'y': -30992, } - self.evt_bin_0 = '\xe5\x00\x24\x28' '\x77\x39\xbd\xd5' \ - '\x44\x19\x45\x4b' '\x36\x5d\xc4\x52' \ - '\x90\x55\xd2\xb3' '\x01\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\x80\x00\xa9\x5c' b'\x6f\x48\x6f\x05' \ + b'\x45\x74\xb4\xf6' b'\x3b\x23\x0a\x7e' \ + b'\xb4\xe5\x86\xf0' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ReparentNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ReparentNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestConfigureNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'height': 16243, - 'sequence_number': 62364, - 'event': 1373455462, - 'type': 191, - 'border_width': 7244, - 'x': -12771, - 'y': -15228, - 'override': 1, - 'above_sibling': 1099666850, - 'window': 2046157981, - 'width': 8604, + 'above_sibling': 1343120585, + 'border_width': 17757, + 'event': 1624514845, + 'height': 13596, + 'override': 0, + 'sequence_number': 41060, + 'type': 220, + 'width': 3638, + 'window': 1070571314, + 'x': -18284, + 'y': -7865, } - self.evt_bin_0 = '\xbf\x00\xf3\x9c' '\x51\xdd\x44\x66' \ - '\x79\xf5\xe4\x9d' '\x41\x8b\x95\xa2' \ - '\xce\x1d\xc4\x84' '\x21\x9c\x3f\x73' \ - '\x1c\x4c\x01\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xdc\x00\xa0\x64' b'\x60\xd4\x21\x1d' \ + b'\x3f\xcf\x9f\x32' b'\x50\x0e\x64\xc9' \ + b'\xb8\x94\xe1\x47' b'\x0e\x36\x35\x1c' \ + b'\x45\x5d\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ConfigureNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ConfigureNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestConfigureRequest(EndianTest): def setUp(self): self.evt_args_0 = { - 'sequence_number': 31377, - 'value_mask': 19345, - 'type': 156, - 'border_width': 54779, - 'x': -18191, - 'y': -17663, - 'window': 1231046739, - 'width': 51620, - 'height': 47094, - 'sibling': 1154714518, - 'stack_mode': 199, - 'parent': 176713389, + 'border_width': 52639, + 'height': 40159, + 'parent': 1499546058, + 'sequence_number': 57983, + 'sibling': 260826075, + 'stack_mode': 240, + 'type': 201, + 'value_mask': 15938, + 'width': 41545, + 'window': 1040976198, + 'x': -31823, + 'y': -880, } - self.evt_bin_0 = '\x9c\xc7\x7a\x91' '\x0a\x88\x6e\xad' \ - '\x49\x60\x48\x53' '\x44\xd3\x8b\x96' \ - '\xb8\xf1\xbb\x01' '\xc9\xa4\xb7\xf6' \ - '\xd5\xfb\x4b\x91' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xc9\xf0\xe2\x7f' b'\x59\x61\x41\xca' \ + b'\x3e\x0c\x09\x46' b'\x0f\x8b\xe3\xdb' \ + b'\x83\xb1\xfc\x90' b'\xa2\x49\x9c\xdf' \ + b'\xcd\x9f\x3e\x42' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ConfigureRequest._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ConfigureRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestGravityNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'sequence_number': 43376, - 'event': 641536677, - 'type': 192, - 'window': 51697690, - 'x': -21924, - 'y': -4866, + 'event': 1182983311, + 'sequence_number': 20621, + 'type': 168, + 'window': 29431224, + 'x': -14672, + 'y': -19399, } - self.evt_bin_0 = '\xc0\x00\xa9\x70' '\x26\x3d\x12\xa5' \ - '\x03\x14\xd8\x1a' '\xaa\x5c\xec\xfe' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xa8\x00\x50\x8d' b'\x46\x82\xe4\x8f' \ + b'\x01\xc1\x15\xb8' b'\xc6\xb0\xb4\x39' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.GravityNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.GravityNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestResizeRequest(EndianTest): def setUp(self): self.evt_args_0 = { - 'height': 59752, - 'sequence_number': 21348, - 'type': 149, - 'window': 1698104652, - 'width': 41494, + 'height': 60085, + 'sequence_number': 14981, + 'type': 151, + 'width': 55398, + 'window': 2130921516, } - self.evt_bin_0 = '\x95\x00\x53\x64' '\x65\x37\x05\x4c' \ - '\xa2\x16\xe9\x68' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\x97\x00\x3a\x85' b'\x7f\x03\x48\x2c' \ + b'\xd8\x66\xea\xb5' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ResizeRequest._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ResizeRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestPropertyNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'atom': 762586168, - 'sequence_number': 29670, - 'time': 1791118117, - 'type': 188, - 'state': 181, - 'window': 334365400, + 'atom': 252322161, + 'sequence_number': 30497, + 'state': 167, + 'time': 1391011497, + 'type': 157, + 'window': 2033863003, } - self.evt_bin_0 = '\xbc\x00\x73\xe6' '\x13\xee\x02\xd8' \ - '\x2d\x74\x24\x38' '\x6a\xc2\x4b\x25' \ - '\xb5\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\x9d\x00\x77\x21' b'\x79\x3a\x49\x5b' \ + b'\x0f\x0a\x21\x71' b'\x52\xe9\x26\xa9' \ + b'\xa7\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.PropertyNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.PropertyNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestSelectionClear(EndianTest): def setUp(self): self.evt_args_0 = { - 'time': 578079299, - 'sequence_number': 13691, - 'atom': 1385452659, - 'type': 170, - 'window': 355039782, + 'atom': 1092859866, + 'sequence_number': 61378, + 'time': 1538959461, + 'type': 255, + 'window': 626833463, } - self.evt_bin_0 = '\xaa\x00\x35\x7b' '\x22\x74\xca\x43' \ - '\x15\x29\x7a\x26' '\x52\x94\x54\x73' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xff\x00\xef\xc2' b'\x5b\xba\xa8\x65' \ + b'\x25\x5c\xb8\x37' b'\x41\x23\xb7\xda' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.SelectionClear._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.SelectionClear._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestSelectionRequest(EndianTest): def setUp(self): self.evt_args_0 = { - 'sequence_number': 13254, - 'type': 162, - 'property': 397160681, - 'owner': 2075837783, - 'time': 1154635674, - 'target': 1312534659, - 'selection': 1972323175, - 'requestor': 178195168, + 'owner': 1036225485, + 'property': 981007010, + 'requestor': 2105124856, + 'selection': 1014149797, + 'sequence_number': 27485, + 'target': 523473665, + 'time': 1792621552, + 'type': 197, } - self.evt_bin_0 = '\xa2\x00\x33\xc6' '\x44\xd2\x57\x9a' \ - '\x7b\xba\xc5\x57' '\x0a\x9f\x0a\xe0' \ - '\x75\x8f\x43\x67' '\x4e\x3b\xb0\x83' \ - '\x17\xac\x30\xe9' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xc5\x00\x6b\x5d' b'\x6a\xd9\x3b\xf0' \ + b'\x3d\xc3\x8b\xcd' b'\x7d\x79\xa7\xf8' \ + b'\x3c\x72\xb2\xa5' b'\x1f\x33\x93\x01' \ + b'\x3a\x78\xfa\xa2' b'\x00\x00\x00\x00' def testPack0(self): bin = event.SelectionRequest._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.SelectionRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestSelectionNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'sequence_number': 39736, - 'type': 199, - 'property': 302372755, - 'time': 882192222, - 'target': 2131462701, - 'selection': 781895626, - 'requestor': 1242076588, + 'property': 1602716574, + 'requestor': 1979762314, + 'selection': 1287219120, + 'sequence_number': 25394, + 'target': 1091504539, + 'time': 409398186, + 'type': 165, } - self.evt_bin_0 = '\xc7\x00\x9b\x38' '\x34\x95\x2f\x5e' \ - '\x4a\x08\x95\xac' '\x2e\x9a\xc7\xca' \ - '\x7f\x0b\x8a\x2d' '\x12\x05\xd7\x93' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xa5\x00\x63\x32' b'\x18\x66\xeb\xaa' \ + b'\x76\x00\xc6\x8a' b'\x4c\xb9\x67\xb0' \ + b'\x41\x0f\x09\x9b' b'\x5f\x87\x83\x9e' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.SelectionNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.SelectionNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestColormapNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'state': 209, - 'sequence_number': 62902, - 'colormap': 300799750, - 'type': 233, - 'window': 1591667531, + 'colormap': 593302316, 'new': 1, + 'sequence_number': 56880, + 'state': 215, + 'type': 162, + 'window': 149981547, } - self.evt_bin_0 = '\xe9\x00\xf5\xb6' '\x5e\xde\xeb\x4b' \ - '\x11\xed\xd7\x06' '\x01\xd1\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xa2\x00\xde\x30' b'\x08\xf0\x89\x6b' \ + b'\x23\x5d\x13\x2c' b'\x01\xd7\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.ColormapNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ColormapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) class TestClientMessage(EndianTest): def setUp(self): self.evt_args_0 = { - 'sequence_number': 48712, + 'client_type': 607457628, 'data': (8, b'01234567890123456789'), - 'type': 245, - 'client_type': 1340394836, - 'window': 1256861040, + 'sequence_number': 54031, + 'type': 196, + 'window': 5574388, } - self.evt_bin_0 = '\xf5\x08\xbe\x48' '\x4a\xea\x2d\x70' \ - '\x4f\xe4\xcd\x54' '\x30\x31\x32\x33' \ - '\x34\x35\x36\x37' '\x38\x39\x30\x31' \ - '\x32\x33\x34\x35' '\x36\x37\x38\x39' + self.evt_bin_0 = b'\xc4\x08\xd3\x0f' b'\x00\x55\x0e\xf4' \ + b'\x24\x35\x11\x5c' b'\x30\x31\x32\x33' \ + b'\x34\x35\x36\x37' b'\x38\x39\x30\x31' \ + b'\x32\x33\x34\x35' b'\x36\x37\x38\x39' self.evt_args_1 = { - 'sequence_number': 62804, + 'client_type': 1245441508, 'data': (16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), - 'type': 250, - 'client_type': 214585025, - 'window': 151327338, + 'sequence_number': 55140, + 'type': 204, + 'window': 1260504694, } - self.evt_bin_1 = '\xfa\x10\xf5\x54' '\x09\x05\x12\x6a' \ - '\x0c\xca\x4e\xc1' '\x00\x01\x00\x02' \ - '\x00\x03\x00\x04' '\x00\x05\x00\x06' \ - '\x00\x07\x00\x08' '\x00\x09\x00\x0a' + self.evt_bin_1 = b'\xcc\x10\xd7\x64' b'\x4b\x21\xc6\x76' \ + b'\x4a\x3b\xed\xe4' b'\x00\x01\x00\x02' \ + b'\x00\x03\x00\x04' b'\x00\x05\x00\x06' \ + b'\x00\x07\x00\x08' b'\x00\x09\x00\x0a' self.evt_args_2 = { - 'sequence_number': 3122, + 'client_type': 959018764, 'data': (32, [1, 2, 3, 4, 5]), - 'type': 243, - 'client_type': 698151018, - 'window': 725159371, + 'sequence_number': 56961, + 'type': 253, + 'window': 319171761, } - self.evt_bin_2 = '\xf3\x20\x0c\x32' '\x2b\x39\x0d\xcb' \ - '\x29\x9c\xf0\x6a' '\x00\x00\x00\x01' \ - '\x00\x00\x00\x02' '\x00\x00\x00\x03' \ - '\x00\x00\x00\x04' '\x00\x00\x00\x05' + self.evt_bin_2 = b'\xfd\x20\xde\x81' b'\x13\x06\x2c\xb1' \ + b'\x39\x29\x77\x0c' b'\x00\x00\x00\x01' \ + b'\x00\x00\x00\x02' b'\x00\x00\x00\x03' \ + b'\x00\x00\x00\x04' b'\x00\x00\x00\x05' def testPack0(self): bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) def testPack1(self): bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_1) - try: - assert bin == self.evt_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_1) def testUnpack1(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_1) def testPack2(self): bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_2) - try: - assert bin == self.evt_bin_2 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_2) def testUnpack2(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_2, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_2 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_2) class TestMappingNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'sequence_number': 53541, - 'count': 151, - 'request': 141, - 'type': 252, - 'first_keycode': 218, + 'count': 244, + 'first_keycode': 224, + 'request': 213, + 'sequence_number': 22874, + 'type': 251, } - self.evt_bin_0 = '\xfc\x00\xd1\x25' '\x8d\xda\x97\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.evt_bin_0 = b'\xfb\x00\x59\x5a' b'\xd5\xe0\xf4\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): bin = event.MappingNotify._fields.to_binary(*(), **self.evt_args_0) - try: - assert bin == self.evt_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.evt_bin_0) def testUnpack0(self): args, remain = event.MappingNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.evt_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.evt_args_0) if __name__ == "__main__": - check_endian() unittest.main() diff --git a/test/test_requests_be.py b/test/test_requests_be.py index e41ccfcb..be00418c 100644 --- a/test/test_requests_be.py +++ b/test/test_requests_be.py @@ -14,2532 +14,1785 @@ class TestCreateWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'height': 38608, - 'window_class': 0, - 'border_width': 34451, - 'visual': 398069779, - 'x': -20771, - 'y': -4049, - 'parent': 1960526158, - 'attrs': {'backing_pixel': 561400151, 'cursor': 1442692293, 'background_pixmap': 1583833923, 'border_pixmap': 1992559786, 'backing_planes': 1454152605, 'win_gravity': 3, 'backing_store': 2, 'event_mask': 368242204, 'save_under': 0, 'background_pixel': 209127175, 'colormap': 377416705, 'border_pixel': 2135465356, 'bit_gravity': 0, 'do_not_propagate_mask': 597142897, 'override_redirect': 0}, - 'wid': 1828913444, - 'depth': 186, - 'width': 51466, - } - self.req_bin_0 = '\x01\xba\x00\x17' '\x6d\x03\x01\x24' \ - '\x74\xdb\x41\x4e' '\xae\xdd\xf0\x2f' \ - '\xc9\x0a\x96\xd0' '\x86\x93\x00\x00' \ - '\x17\xba\x10\x13' '\x00\x00\x7f\xff' \ - '\x5e\x67\x63\x43' '\x0c\x77\x07\x07' \ - '\x76\xc4\x0c\xaa' '\x7f\x48\x9d\x8c' \ - '\x00\x00\x00\x00' '\x03\x00\x00\x00' \ - '\x02\x00\x00\x00' '\x56\xac\x9b\x9d' \ - '\x21\x76\x49\x57' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x15\xf2\xee\x1c' \ - '\x23\x97\xad\x71' '\x16\x7e\xec\x01' \ - '\x55\xfd\xbc\xc5' + 'attrs': {'cursor': 64054583, 'override_redirect': 0, 'bit_gravity': 3, 'event_mask': 1268138548, 'border_pixel': 1592533117, 'background_pixel': 239147199, 'save_under': 0, 'colormap': 68318329, 'do_not_propagate_mask': 906135756, 'backing_store': 0, 'win_gravity': 2, 'backing_planes': 299720948, 'border_pixmap': 53775720, 'backing_pixel': 1581625428, 'background_pixmap': 1373224142}, + 'border_width': 13287, + 'depth': 151, + 'height': 37037, + 'parent': 499701004, + 'visual': 1395681732, + 'wid': 469587013, + 'width': 1995, + 'window_class': 2, + 'x': -16209, + 'y': -13042, + } + self.req_bin_0 = b'\x01\x97\x00\x17' b'\x1b\xfd\x54\x45' \ + b'\x1d\xc8\xd5\x0c' b'\xc0\xaf\xcd\x0e' \ + b'\x07\xcb\x90\xad' b'\x33\xe7\x00\x02' \ + b'\x53\x30\x69\xc4' b'\x00\x00\x7f\xff' \ + b'\x51\xd9\xbc\xce' b'\x0e\x41\x18\xbf' \ + b'\x03\x34\x8d\x68' b'\x5e\xec\x20\x7d' \ + b'\x03\x00\x00\x00' b'\x02\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x11\xdd\x60\xf4' \ + b'\x5e\x45\xb0\x54' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x4b\x96\x42\x34' \ + b'\x36\x02\x88\xcc' b'\x04\x12\x74\x79' \ + b'\x03\xd1\x65\x37' def testPackRequest0(self): bin = request.CreateWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestChangeWindowAttributes(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1813552124, - 'attrs': {'backing_pixel': 59516078, 'cursor': 1682969315, 'background_pixmap': 370313360, 'border_pixmap': 1158771722, 'backing_planes': 1432315664, 'win_gravity': 3, 'backing_store': 1, 'event_mask': 1054128649, 'save_under': 0, 'background_pixel': 1953340842, 'colormap': 1462101672, 'border_pixel': 287436510, 'bit_gravity': 10, 'do_not_propagate_mask': 1283834625, 'override_redirect': 0}, + 'attrs': {'cursor': 596789700, 'override_redirect': 0, 'bit_gravity': 6, 'event_mask': 1499308477, 'border_pixel': 473458160, 'background_pixel': 1170318459, 'save_under': 0, 'colormap': 730747963, 'do_not_propagate_mask': 907623048, 'backing_store': 1, 'win_gravity': 8, 'backing_planes': 1738304197, 'border_pixmap': 900977490, 'backing_pixel': 1866873765, 'background_pixmap': 1506149446}, + 'window': 333955224, } - self.req_bin_0 = '\x02\x00\x00\x12' '\x6c\x18\x9b\xfc' \ - '\x00\x00\x7f\xff' '\x16\x12\x88\x90' \ - '\x74\x6d\x9d\xaa' '\x45\x11\x74\x0a' \ - '\x11\x21\xee\xde' '\x0a\x00\x00\x00' \ - '\x03\x00\x00\x00' '\x01\x00\x00\x00' \ - '\x55\x5f\x67\x10' '\x03\x8c\x24\xae' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x3e\xd4\xba\x09' '\x4c\x85\xc3\x01' \ - '\x57\x25\xe6\xa8' '\x64\x50\x12\xe3' + self.req_bin_0 = b'\x02\x00\x00\x12' b'\x13\xe7\xc0\x98' \ + b'\x00\x00\x7f\xff' b'\x59\xc6\x04\x46' \ + b'\x45\xc1\xa4\x7b' b'\x35\xb3\xd3\x52' \ + b'\x1c\x38\x65\xf0' b'\x06\x00\x00\x00' \ + b'\x08\x00\x00\x00' b'\x01\x00\x00\x00' \ + b'\x67\x9c\x6a\xc5' b'\x6f\x46\x3b\xa5' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x59\x5d\xa1\xbd' b'\x36\x19\x3a\x88' \ + b'\x2b\x8e\x54\x3b' b'\x23\x92\x49\xc4' def testPackRequest0(self): bin = request.ChangeWindowAttributes._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGetWindowAttributes(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1931593850, + 'window': 462448317, } - self.req_bin_0 = '\x03\x00\x00\x02' '\x73\x21\xc8\x7a' + self.req_bin_0 = b'\x03\x00\x00\x02' b'\x1b\x90\x66\xbd' self.reply_args_0 = { - 'sequence_number': 60057, - 'backing_pixel': 136561993, - 'your_event_mask': 1332399119, + 'all_event_masks': 1980679760, + 'backing_bit_planes': 1820045833, + 'backing_pixel': 738704824, + 'backing_store': 214, + 'bit_gravity': 152, + 'colormap': 2089815718, + 'do_not_propagate_mask': 5420, 'map_is_installed': 0, - 'visual': 687387929, - 'backing_bit_planes': 990144409, - 'backing_store': 147, - 'win_class': 18284, - 'map_state': 185, - 'save_under': 0, - 'all_event_masks': 270223628, - 'colormap': 1161384334, - 'win_gravity': 157, - 'bit_gravity': 253, - 'do_not_propagate_mask': 33787, + 'map_state': 245, 'override_redirect': 0, + 'save_under': 1, + 'sequence_number': 6954, + 'visual': 199235720, + 'win_class': 25154, + 'win_gravity': 219, + 'your_event_mask': 812961929, } - self.reply_bin_0 = '\x01\x93\xea\x99' '\x00\x00\x00\x03' \ - '\x28\xf8\xb5\x19' '\x47\x6c\xfd\x9d' \ - '\x3b\x04\x67\x99' '\x08\x23\xc5\x49' \ - '\x00\x00\xb9\x00' '\x45\x39\x51\x8e' \ - '\x10\x1b\x49\x0c' '\x4f\x6a\xcc\x0f' \ - '\x83\xfb\x00\x00' + self.reply_bin_0 = b'\x01\xd6\x1b\x2a' b'\x00\x00\x00\x03' \ + b'\x0b\xe0\x18\x88' b'\x62\x42\x98\xdb' \ + b'\x6c\x7b\xb2\x09' b'\x2c\x07\xbd\xb8' \ + b'\x01\x00\xf5\x00' b'\x7c\x90\x0e\xa6' \ + b'\x76\x0e\xc6\x50' b'\x30\x74\xd0\x89' \ + b'\x15\x2c\x00\x00' def testPackRequest0(self): bin = request.GetWindowAttributes._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetWindowAttributes._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetWindowAttributes._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestDestroyWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1622184267, + 'window': 1185563768, } - self.req_bin_0 = '\x04\x00\x00\x02' '\x60\xb0\x91\x4b' + self.req_bin_0 = b'\x04\x00\x00\x02' b'\x46\xaa\x44\x78' def testPackRequest0(self): bin = request.DestroyWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.DestroyWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestDestroySubWindows(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1000376476, + 'window': 629661088, } - self.req_bin_0 = '\x05\x00\x00\x02' '\x3b\xa0\x88\x9c' + self.req_bin_0 = b'\x05\x00\x00\x02' b'\x25\x87\xdd\xa0' def testPackRequest0(self): bin = request.DestroySubWindows._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.DestroySubWindows._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestChangeSaveSet(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1577523459, - 'mode': 0, + 'mode': 1, + 'window': 1239919839, } - self.req_bin_0 = '\x06\x00\x00\x02' '\x5e\x07\x19\x03' + self.req_bin_0 = b'\x06\x01\x00\x02' b'\x49\xe7\xac\xdf' def testPackRequest0(self): bin = request.ChangeSaveSet._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeSaveSet._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestReparentWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'parent': 72188776, - 'window': 1300734112, - 'x': -5207, - 'y': -22675, + 'parent': 1513122040, + 'window': 413002134, + 'x': -30489, + 'y': -31267, } - self.req_bin_0 = '\x07\x00\x00\x04' '\x4d\x87\xa0\xa0' \ - '\x04\x4d\x83\x68' '\xeb\xa9\xa7\x6d' + self.req_bin_0 = b'\x07\x00\x00\x04' b'\x18\x9d\xe9\x96' \ + b'\x5a\x30\x68\xf8' b'\x88\xe7\x85\xdd' def testPackRequest0(self): bin = request.ReparentWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ReparentWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestMapWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 61469476, + 'window': 1420117708, } - self.req_bin_0 = '\x08\x00\x00\x02' '\x03\xa9\xf3\x24' + self.req_bin_0 = b'\x08\x00\x00\x02' b'\x54\xa5\x46\xcc' def testPackRequest0(self): bin = request.MapWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.MapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestMapSubwindows(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 818738118, + 'window': 489473351, } - self.req_bin_0 = '\x09\x00\x00\x02' '\x30\xcc\xf3\xc6' + self.req_bin_0 = b'\x09\x00\x00\x02' b'\x1d\x2c\xc5\x47' def testPackRequest0(self): bin = request.MapSubwindows._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.MapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestUnmapWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1923663468, + 'window': 1660217157, } - self.req_bin_0 = '\x0a\x00\x00\x02' '\x72\xa8\xc6\x6c' + self.req_bin_0 = b'\x0a\x00\x00\x02' b'\x62\xf4\xe7\x45' def testPackRequest0(self): bin = request.UnmapWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UnmapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestUnmapSubwindows(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 999740194, + 'window': 621521446, } - self.req_bin_0 = '\x0b\x00\x00\x02' '\x3b\x96\xd3\x22' + self.req_bin_0 = b'\x0b\x00\x00\x02' b'\x25\x0b\xaa\x26' def testPackRequest0(self): bin = request.UnmapSubwindows._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UnmapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestConfigureWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 190634459, - 'attrs': {'height': 57788, 'stack_mode': 2, 'border_width': -320, 'width': 53674, 'x': -2248, 'y': -29960, 'sibling': 1012823324}, + 'attrs': {'width': 39387, 'stack_mode': 2, 'height': 57679, 'sibling': 973756745, 'y': -17512, 'x': -27539, 'border_width': -14551}, + 'window': 349362548, } - self.req_bin_0 = '\x0c\x00\x00\x0a' '\x0b\x5c\xd9\xdb' \ - '\x00\x7f\x00\x00' '\xf7\x38\x00\x00' \ - '\x8a\xf8\x00\x00' '\xd1\xaa\x00\x00' \ - '\xe1\xbc\x00\x00' '\xfe\xc0\x00\x00' \ - '\x3c\x5e\x75\x1c' '\x02\x00\x00\x00' + self.req_bin_0 = b'\x0c\x00\x00\x0a' b'\x14\xd2\xd9\x74' \ + b'\x00\x7f\x00\x00' b'\x94\x6d\x00\x00' \ + b'\xbb\x98\x00\x00' b'\x99\xdb\x00\x00' \ + b'\xe1\x4f\x00\x00' b'\xc7\x29\x00\x00' \ + b'\x3a\x0a\x59\x49' b'\x02\x00\x00\x00' def testPackRequest0(self): bin = request.ConfigureWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ConfigureWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestCirculateWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1712979067, 'direction': 1, + 'window': 763003561, } - self.req_bin_0 = '\x0d\x01\x00\x02' '\x66\x19\xfc\x7b' + self.req_bin_0 = b'\x0d\x01\x00\x02' b'\x2d\x7a\x82\xa9' def testPackRequest0(self): bin = request.CirculateWindow._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CirculateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGetGeometry(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 680179490, + 'drawable': 449978455, } - self.req_bin_0 = '\x0e\x00\x00\x02' '\x28\x8a\xb7\x22' + self.req_bin_0 = b'\x0e\x00\x00\x02' b'\x1a\xd2\x20\x57' self.reply_args_0 = { - 'height': 64954, - 'sequence_number': 39469, - 'root': 609586545, - 'border_width': 496, - 'x': -1253, - 'y': -11180, - 'depth': 204, - 'width': 38433, + 'border_width': 41869, + 'depth': 196, + 'height': 40176, + 'root': 2011515940, + 'sequence_number': 46250, + 'width': 4935, + 'x': -10370, + 'y': -11534, } - self.reply_bin_0 = '\x01\xcc\x9a\x2d' '\x00\x00\x00\x00' \ - '\x24\x55\x8d\x71' '\xfb\x1b\xd4\x54' \ - '\x96\x21\xfd\xba' '\x01\xf0\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\xc4\xb4\xaa' b'\x00\x00\x00\x00' \ + b'\x77\xe5\x4c\x24' b'\xd7\x7e\xd2\xf2' \ + b'\x13\x47\x9c\xf0' b'\xa3\x8d\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetGeometry._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetGeometry._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetGeometry._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetGeometry._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestQueryTree(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 2052496265, + 'window': 367582976, } - self.req_bin_0 = '\x0f\x00\x00\x02' '\x7a\x56\x9b\x89' + self.req_bin_0 = b'\x0f\x00\x00\x02' b'\x15\xe8\xdf\x00' self.reply_args_0 = { - 'sequence_number': 33887, - 'children': [1795767666, 1494491557, 748301378, 729512097, 1262057849, 64238195, 1088261715], - 'root': 1856577120, - 'parent': 2105827407, + 'children': [1147122179, 1565853418, 525792997, 350969719, 992761785, 814939899, 579774073], + 'parent': 1374454548, + 'root': 1987327953, + 'sequence_number': 65105, } - self.reply_bin_0 = '\x01\x00\x84\x5f' '\x00\x00\x00\x07' \ - '\x6e\xa9\x1e\x60' '\x7d\x84\x60\x4f' \ - '\x00\x07\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x6b\x09\x3d\x72' '\x59\x14\x21\xa5' \ - '\x2c\x9a\x2c\x42' '\x2b\x7b\x78\xa1' \ - '\x4b\x39\x79\x79' '\x03\xd4\x32\x73' \ - '\x40\xdd\x8e\x53' + self.reply_bin_0 = b'\x01\x00\xfe\x51' b'\x00\x00\x00\x07' \ + b'\x76\x74\x37\xd1' b'\x51\xec\x83\x14' \ + b'\x00\x07\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x44\x5f\xb2\x03' b'\x5d\x55\x06\xea' \ + b'\x1f\x56\xf6\xe5' b'\x14\xeb\x5f\x77' \ + b'\x3b\x2c\x57\xb9' b'\x30\x92\xfe\xfb' \ + b'\x22\x8e\xa6\x79' def testPackRequest0(self): bin = request.QueryTree._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryTree._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryTree._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryTree._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestInternAtom(EndianTest): def setUp(self): self.req_args_0 = { - 'only_if_exists': 0, 'name': 'fuzzy_prop', + 'only_if_exists': 0, } - self.req_bin_0 = '\x10\x00\x00\x05' '\x00\x0a\x00\x00' \ - '\x66\x75\x7a\x7a' '\x79\x5f\x70\x72' \ - '\x6f\x70\x00\x00' + self.req_bin_0 = b'\x10\x00\x00\x05' b'\x00\x0a\x00\x00' \ + b'\x66\x75\x7a\x7a' b'\x79\x5f\x70\x72' \ + b'\x6f\x70\x00\x00' self.reply_args_0 = { - 'atom': 48723297, - 'sequence_number': 35223, + 'atom': 696457407, + 'sequence_number': 45122, } - self.reply_bin_0 = '\x01\x00\x89\x97' '\x00\x00\x00\x00' \ - '\x02\xe7\x75\x61' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\xb0\x42' b'\x00\x00\x00\x00' \ + b'\x29\x83\x18\xbf' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.InternAtom._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.InternAtom._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.InternAtom._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.InternAtom._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestGetAtomName(EndianTest): def setUp(self): self.req_args_0 = { - 'atom': 1022286544, + 'atom': 1810076242, } - self.req_bin_0 = '\x11\x00\x00\x02' '\x3c\xee\xda\xd0' + self.req_bin_0 = b'\x11\x00\x00\x02' b'\x6b\xe3\x92\x52' self.reply_args_0 = { - 'sequence_number': 22699, 'name': 'WM_CLASS', + 'sequence_number': 50608, } - self.reply_bin_0 = '\x01\x00\x58\xab' '\x00\x00\x00\x02' \ - '\x00\x08\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x57\x4d\x5f\x43' '\x4c\x41\x53\x53' + self.reply_bin_0 = b'\x01\x00\xc5\xb0' b'\x00\x00\x00\x02' \ + b'\x00\x08\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x57\x4d\x5f\x43' b'\x4c\x41\x53\x53' def testPackRequest0(self): bin = request.GetAtomName._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetAtomName._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetAtomName._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetAtomName._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestChangeProperty(EndianTest): def setUp(self): self.req_args_0 = { - 'mode': 0, 'data': (8, b''), - 'property': 2085394193, - 'window': 266197951, - 'type': 1343008022, + 'mode': 0, + 'property': 1764873173, + 'type': 69000273, + 'window': 491942524, } - self.req_bin_0 = '\x12\x00\x00\x06' '\x0f\xdd\xdb\xbf' \ - '\x7c\x4c\x97\x11' '\x50\x0c\xad\x16' \ - '\x08\x00\x00\x00' '\x00\x00\x00\x00' + self.req_bin_0 = b'\x12\x00\x00\x06' b'\x1d\x52\x72\x7c' \ + b'\x69\x31\xd3\xd5' b'\x04\x1c\xdc\x51' \ + b'\x08\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_1 = { - 'mode': 2, 'data': (8, b'foo'), - 'property': 449719979, - 'window': 1522118044, - 'type': 121096013, + 'mode': 1, + 'property': 575034703, + 'type': 142204480, + 'window': 861560365, } - self.req_bin_1 = '\x12\x02\x00\x07' '\x5a\xb9\xad\x9c' \ - '\x1a\xce\x2e\xab' '\x07\x37\xc7\x4d' \ - '\x08\x00\x00\x00' '\x00\x00\x00\x03' \ - '\x66\x6f\x6f\x00' + self.req_bin_1 = b'\x12\x01\x00\x07' b'\x33\x5a\x5e\x2d' \ + b'\x22\x46\x55\x4f' b'\x08\x79\xde\x40' \ + b'\x08\x00\x00\x00' b'\x00\x00\x00\x03' \ + b'\x66\x6f\x6f\x00' self.req_args_2 = { - 'mode': 2, 'data': (8, b'zoom'), - 'property': 1009841498, - 'window': 286324270, - 'type': 1547457396, + 'mode': 0, + 'property': 2024948722, + 'type': 1218075423, + 'window': 1961010416, } - self.req_bin_2 = '\x12\x02\x00\x07' '\x11\x10\xf6\x2e' \ - '\x3c\x30\xf5\x5a' '\x5c\x3c\x53\x74' \ - '\x08\x00\x00\x00' '\x00\x00\x00\x04' \ - '\x7a\x6f\x6f\x6d' + self.req_bin_2 = b'\x12\x00\x00\x07' b'\x74\xe2\xa4\xf0' \ + b'\x78\xb2\x43\xf2' b'\x48\x9a\x5b\x1f' \ + b'\x08\x00\x00\x00' b'\x00\x00\x00\x04' \ + b'\x7a\x6f\x6f\x6d' self.req_args_3 = { - 'mode': 0, 'data': (16, []), - 'property': 426983104, - 'window': 1964921608, - 'type': 692879036, + 'mode': 2, + 'property': 456677559, + 'type': 1407609354, + 'window': 675831147, } - self.req_bin_3 = '\x12\x00\x00\x06' '\x75\x1e\x53\x08' \ - '\x19\x73\x3e\xc0' '\x29\x4c\x7e\xbc' \ - '\x10\x00\x00\x00' '\x00\x00\x00\x00' + self.req_bin_3 = b'\x12\x02\x00\x06' b'\x28\x48\x5d\x6b' \ + b'\x1b\x38\x58\xb7' b'\x53\xe6\x6a\x0a' \ + b'\x10\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_4 = { - 'mode': 0, 'data': (16, [1, 2, 3]), - 'property': 801006756, - 'window': 560040176, - 'type': 2030208993, + 'mode': 1, + 'property': 1899908134, + 'type': 1964041522, + 'window': 849678568, } - self.req_bin_4 = '\x12\x00\x00\x08' '\x21\x61\x88\xf0' \ - '\x2f\xbe\x64\xa4' '\x79\x02\x87\xe1' \ - '\x10\x00\x00\x00' '\x00\x00\x00\x03' \ - '\x00\x01\x00\x02' '\x00\x03\x00\x00' + self.req_bin_4 = b'\x12\x01\x00\x08' b'\x32\xa5\x10\xe8' \ + b'\x71\x3e\x4c\x26' b'\x75\x10\xe5\x32' \ + b'\x10\x00\x00\x00' b'\x00\x00\x00\x03' \ + b'\x00\x01\x00\x02' b'\x00\x03\x00\x00' self.req_args_5 = { - 'mode': 0, 'data': (16, [1, 2, 3, 4]), - 'property': 1401687842, - 'window': 2016421454, - 'type': 434059096, + 'mode': 2, + 'property': 306879937, + 'type': 568891375, + 'window': 985442388, } - self.req_bin_5 = '\x12\x00\x00\x08' '\x78\x30\x26\x4e' \ - '\x53\x8c\x0f\x22' '\x19\xdf\x37\x58' \ - '\x10\x00\x00\x00' '\x00\x00\x00\x04' \ - '\x00\x01\x00\x02' '\x00\x03\x00\x04' + self.req_bin_5 = b'\x12\x02\x00\x08' b'\x3a\xbc\xa8\x54' \ + b'\x12\x4a\x9d\xc1' b'\x21\xe8\x97\xef' \ + b'\x10\x00\x00\x00' b'\x00\x00\x00\x04' \ + b'\x00\x01\x00\x02' b'\x00\x03\x00\x04' self.req_args_6 = { - 'mode': 2, 'data': (32, []), - 'property': 1008934075, - 'window': 461926013, - 'type': 613217208, + 'mode': 0, + 'property': 1599917196, + 'type': 1205594429, + 'window': 529694076, } - self.req_bin_6 = '\x12\x02\x00\x06' '\x1b\x88\x6e\x7d' \ - '\x3c\x23\x1c\xbb' '\x24\x8c\xf3\xb8' \ - '\x20\x00\x00\x00' '\x00\x00\x00\x00' + self.req_bin_6 = b'\x12\x00\x00\x06' b'\x1f\x92\x7d\x7c' \ + b'\x5f\x5c\xcc\x8c' b'\x47\xdb\xe9\x3d' \ + b'\x20\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_7 = { - 'mode': 1, 'data': (32, [1, 2, 3]), - 'property': 1472503640, - 'window': 367636986, - 'type': 1085552939, + 'mode': 2, + 'property': 1604265475, + 'type': 1255454396, + 'window': 564298846, } - self.req_bin_7 = '\x12\x01\x00\x09' '\x15\xe9\xb1\xfa' \ - '\x57\xc4\x9f\x58' '\x40\xb4\x39\x2b' \ - '\x20\x00\x00\x00' '\x00\x00\x00\x03' \ - '\x00\x00\x00\x01' '\x00\x00\x00\x02' \ - '\x00\x00\x00\x03' + self.req_bin_7 = b'\x12\x02\x00\x09' b'\x21\xa2\x84\x5e' \ + b'\x5f\x9f\x26\x03' b'\x4a\xd4\xb6\xbc' \ + b'\x20\x00\x00\x00' b'\x00\x00\x00\x03' \ + b'\x00\x00\x00\x01' b'\x00\x00\x00\x02' \ + b'\x00\x00\x00\x03' def testPackRequest0(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_1) - try: - assert bin == self.req_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_1) def testPackRequest2(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_2) - try: - assert bin == self.req_bin_2 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_2) def testUnpackRequest2(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_2, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_2 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_2) def testPackRequest3(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_3) - try: - assert bin == self.req_bin_3 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_3) def testUnpackRequest3(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_3, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_3 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_3) def testPackRequest4(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_4) - try: - assert bin == self.req_bin_4 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_4) def testUnpackRequest4(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_4, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_4 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_4) def testPackRequest5(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_5) - try: - assert bin == self.req_bin_5 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_5) def testUnpackRequest5(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_5, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_5 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_5) def testPackRequest6(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_6) - try: - assert bin == self.req_bin_6 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_6) def testUnpackRequest6(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_6, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_6 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_6) def testPackRequest7(self): bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_7) - try: - assert bin == self.req_bin_7 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_7) def testUnpackRequest7(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_7, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_7 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_7) class TestDeleteProperty(EndianTest): def setUp(self): self.req_args_0 = { - 'property': 506897017, - 'window': 381870530, + 'property': 1928125498, + 'window': 920120163, } - self.req_bin_0 = '\x13\x00\x00\x03' '\x16\xc2\xe1\xc2' \ - '\x1e\x36\xa2\x79' + self.req_bin_0 = b'\x13\x00\x00\x03' b'\x36\xd7\xeb\x63' \ + b'\x72\xec\xdc\x3a' def testPackRequest0(self): bin = request.DeleteProperty._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.DeleteProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGetProperty(EndianTest): def setUp(self): self.req_args_0 = { - 'delete': 0, - 'long_offset': 1563462862, - 'type': 1556454304, - 'property': 1007774483, - 'window': 1477792536, - 'long_length': 1346507413, + 'delete': 1, + 'long_length': 297130690, + 'long_offset': 2142261240, + 'property': 471053276, + 'type': 2141806322, + 'window': 777446987, } - self.req_bin_0 = '\x14\x00\x00\x06' '\x58\x15\x53\x18' \ - '\x3c\x11\x6b\x13' '\x5c\xc5\x9b\xa0' \ - '\x5d\x30\x8c\xce' '\x50\x42\x12\x95' + self.req_bin_0 = b'\x14\x01\x00\x06' b'\x2e\x56\xe6\x4b' \ + b'\x1c\x13\xb3\xdc' b'\x7f\xa9\x5e\xf2' \ + b'\x7f\xb0\x4f\xf8' b'\x11\xb5\xda\xc2' self.reply_args_0 = { + 'bytes_after': 195292012, + 'property_type': 1059882735, + 'sequence_number': 33648, 'value': (8, b''), - 'sequence_number': 30606, - 'property_type': 1392423916, - 'bytes_after': 2046056935, } - self.reply_bin_0 = '\x01\x08\x77\x8e' '\x00\x00\x00\x00' \ - '\x52\xfe\xb3\xec' '\x79\xf4\x59\xe7' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x08\x83\x70' b'\x00\x00\x00\x00' \ + b'\x3f\x2c\x86\xef' b'\x0b\xa3\xeb\x6c' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_1 = { + 'bytes_after': 1849269963, + 'property_type': 101247178, + 'sequence_number': 49786, 'value': (8, b'foo'), - 'sequence_number': 44279, - 'property_type': 186441230, - 'bytes_after': 469299413, } - self.reply_bin_1 = '\x01\x08\xac\xf7' '\x00\x00\x00\x01' \ - '\x0b\x1c\xde\x0e' '\x1b\xf8\xf0\xd5' \ - '\x00\x00\x00\x03' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x66\x6f\x6f\x00' + self.reply_bin_1 = b'\x01\x08\xc2\x7a' b'\x00\x00\x00\x01' \ + b'\x06\x08\xe8\xca' b'\x6e\x39\x9e\xcb' \ + b'\x00\x00\x00\x03' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x66\x6f\x6f\x00' self.reply_args_2 = { + 'bytes_after': 1347495650, + 'property_type': 328289775, + 'sequence_number': 7441, 'value': (8, b'zoom'), - 'sequence_number': 12674, - 'property_type': 1802804296, - 'bytes_after': 1968158856, } - self.reply_bin_2 = '\x01\x08\x31\x82' '\x00\x00\x00\x01' \ - '\x6b\x74\x9c\x48' '\x75\x4f\xb8\x88' \ - '\x00\x00\x00\x04' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x7a\x6f\x6f\x6d' + self.reply_bin_2 = b'\x01\x08\x1d\x11' b'\x00\x00\x00\x01' \ + b'\x13\x91\x4d\xef' b'\x50\x51\x26\xe2' \ + b'\x00\x00\x00\x04' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x7a\x6f\x6f\x6d' self.reply_args_3 = { + 'bytes_after': 1461387818, + 'property_type': 1701043014, + 'sequence_number': 10740, 'value': (16, []), - 'sequence_number': 25311, - 'property_type': 536196393, - 'bytes_after': 1874157309, } - self.reply_bin_3 = '\x01\x10\x62\xdf' '\x00\x00\x00\x00' \ - '\x1f\xf5\xb5\x29' '\x6f\xb5\x5e\xfd' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_3 = b'\x01\x10\x29\xf4' b'\x00\x00\x00\x00' \ + b'\x65\x63\xdb\x46' b'\x57\x1b\x02\x2a' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_4 = { + 'bytes_after': 136490248, + 'property_type': 1280844186, + 'sequence_number': 27922, 'value': (16, [1, 2, 3]), - 'sequence_number': 22665, - 'property_type': 1046879880, - 'bytes_after': 1952710167, } - self.reply_bin_4 = '\x01\x10\x58\x89' '\x00\x00\x00\x02' \ - '\x3e\x66\x1e\x88' '\x74\x63\xfe\x17' \ - '\x00\x00\x00\x03' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x01\x00\x02' '\x00\x03\x00\x00' + self.reply_bin_4 = b'\x01\x10\x6d\x12' b'\x00\x00\x00\x02' \ + b'\x4c\x58\x21\x9a' b'\x08\x22\xad\x08' \ + b'\x00\x00\x00\x03' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x01\x00\x02' b'\x00\x03\x00\x00' self.reply_args_5 = { + 'bytes_after': 1279726180, + 'property_type': 819586705, + 'sequence_number': 25472, 'value': (16, [1, 2, 3, 4]), - 'sequence_number': 19028, - 'property_type': 1014173132, - 'bytes_after': 1791090668, } - self.reply_bin_5 = '\x01\x10\x4a\x54' '\x00\x00\x00\x02' \ - '\x3c\x73\x0d\xcc' '\x6a\xc1\xdf\xec' \ - '\x00\x00\x00\x04' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x01\x00\x02' '\x00\x03\x00\x04' + self.reply_bin_5 = b'\x01\x10\x63\x80' b'\x00\x00\x00\x02' \ + b'\x30\xd9\xe6\x91' b'\x4c\x47\x12\x64' \ + b'\x00\x00\x00\x04' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x01\x00\x02' b'\x00\x03\x00\x04' self.reply_args_6 = { + 'bytes_after': 539973238, + 'property_type': 1136329940, + 'sequence_number': 30930, 'value': (32, []), - 'sequence_number': 47226, - 'property_type': 2053870497, - 'bytes_after': 1727548898, } - self.reply_bin_6 = '\x01\x20\xb8\x7a' '\x00\x00\x00\x00' \ - '\x7a\x6b\x93\xa1' '\x66\xf8\x4d\xe2' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_6 = b'\x01\x20\x78\xd2' b'\x00\x00\x00\x00' \ + b'\x43\xbb\x04\xd4' b'\x20\x2f\x56\x76' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_7 = { + 'bytes_after': 1848575862, + 'property_type': 1188109101, + 'sequence_number': 63896, 'value': (32, [1, 2, 3]), - 'sequence_number': 37094, - 'property_type': 704363625, - 'bytes_after': 1957409055, } - self.reply_bin_7 = '\x01\x20\x90\xe6' '\x00\x00\x00\x03' \ - '\x29\xfb\xbc\x69' '\x74\xab\xb1\x1f' \ - '\x00\x00\x00\x03' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x01' '\x00\x00\x00\x02' \ - '\x00\x00\x00\x03' + self.reply_bin_7 = b'\x01\x20\xf9\x98' b'\x00\x00\x00\x03' \ + b'\x46\xd1\x1b\x2d' b'\x6e\x2f\x07\x76' \ + b'\x00\x00\x00\x03' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x01' b'\x00\x00\x00\x02' \ + b'\x00\x00\x00\x03' def testPackRequest0(self): bin = request.GetProperty._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) def testPackReply1(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_1) - try: - assert bin == self.reply_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_1) def testUnpackReply1(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_1) def testPackReply2(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_2) - try: - assert bin == self.reply_bin_2 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_2) def testUnpackReply2(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_2, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_2 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_2) def testPackReply3(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_3) - try: - assert bin == self.reply_bin_3 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_3) def testUnpackReply3(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_3, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_3 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_3) def testPackReply4(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_4) - try: - assert bin == self.reply_bin_4 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_4) def testUnpackReply4(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_4, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_4 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_4) def testPackReply5(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_5) - try: - assert bin == self.reply_bin_5 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_5) def testUnpackReply5(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_5, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_5 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_5) def testPackReply6(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_6) - try: - assert bin == self.reply_bin_6 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_6) def testUnpackReply6(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_6, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_6 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_6) def testPackReply7(self): bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_7) - try: - assert bin == self.reply_bin_7 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_7) def testUnpackReply7(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_7, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_7 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_7) class TestListProperties(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 91262675, + 'window': 2023920407, } - self.req_bin_0 = '\x15\x00\x00\x02' '\x05\x70\x8e\xd3' + self.req_bin_0 = b'\x15\x00\x00\x02' b'\x78\xa2\x93\x17' self.reply_args_0 = { - 'atoms': [580972634, 926488735, 714741529, 408777797, 679906858, 705092899, 2063243279, 893967755, 1591182471, 571137996, 1677110101, 1783836762, 1678219148, 1992402577, 871298793, 1182885899, 1155013854, 1822076326, 2117552706, 1972668469, 1660227078, 1523268962, 694042433], - 'sequence_number': 42191, - } - self.reply_bin_0 = '\x01\x00\xa4\xcf' '\x00\x00\x00\x17' \ - '\x00\x17\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x22\xa0\xf0\x5a' '\x37\x39\x18\x9f' \ - '\x2a\x9a\x17\x19' '\x18\x5d\x74\x45' \ - '\x28\x86\x8e\x2a' '\x2a\x06\xdd\x23' \ - '\x7a\xfa\x98\x0f' '\x35\x48\xdd\x8b' \ - '\x5e\xd7\x84\x87' '\x22\x0a\xdf\xcc' \ - '\x63\xf6\xab\x55' '\x6a\x53\x30\x5a' \ - '\x64\x07\x97\x8c' '\x76\xc1\xa6\x91' \ - '\x33\xee\xf6\xe9' '\x46\x81\x68\x0b' \ - '\x44\xd8\x1c\xde' '\x6c\x9a\xad\xa6' \ - '\x7e\x37\x4a\x42' '\x75\x94\x88\x35' \ - '\x62\xf5\x0e\x06' '\x5a\xcb\x3d\x62' \ - '\x29\x5e\x3f\x41' + 'atoms': [24720840, 1460963027, 1547803868, 246063525, 1464027403, 1900134270, 1153200538, 1612563336, 573068260, 1650618737, 1376520521, 730586807, 239622004, 630352260, 933716813, 339706725, 974429777, 7034796, 2048369638, 1550746425, 1880945398, 1545568005, 565689201], + 'sequence_number': 63949, + } + self.reply_bin_0 = b'\x01\x00\xf9\xcd' b'\x00\x00\x00\x17' \ + b'\x00\x17\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x01\x79\x35\xc8' b'\x57\x14\x86\xd3' \ + b'\x5c\x41\x9c\xdc' b'\x0e\xaa\xa1\xa5' \ + b'\x57\x43\x49\x0b' b'\x71\x41\xbf\x7e' \ + b'\x44\xbc\x71\x9a' b'\x60\x1d\xc3\x88' \ + b'\x22\x28\x53\xe4' b'\x62\x62\x71\x71' \ + b'\x52\x0c\x09\x49' b'\x2b\x8b\xde\xb7' \ + b'\x0e\x48\x57\x74' b'\x25\x92\x69\x84' \ + b'\x37\xa7\x63\x4d' b'\x14\x3f\x83\x65' \ + b'\x3a\x14\x9e\x51' b'\x00\x6b\x57\xac' \ + b'\x7a\x17\xa3\xe6' b'\x5c\x6e\x83\x39' \ + b'\x70\x1c\xf2\xf6' b'\x5c\x1f\x7f\x05' \ + b'\x21\xb7\xbb\x71' def testPackRequest0(self): bin = request.ListProperties._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListProperties._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListProperties._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListProperties._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestSetSelectionOwner(EndianTest): def setUp(self): self.req_args_0 = { - 'selection': 2071258139, - 'window': 1190911777, - 'time': 1606660593, + 'selection': 1636366903, + 'time': 383717530, + 'window': 1075066031, } - self.req_bin_0 = '\x16\x00\x00\x04' '\x46\xfb\xdf\x21' \ - '\x7b\x74\xe4\x1b' '\x5f\xc3\xb1\xf1' + self.req_bin_0 = b'\x16\x00\x00\x04' b'\x40\x14\x34\xaf' \ + b'\x61\x88\xfa\x37' b'\x16\xdf\x10\x9a' def testPackRequest0(self): bin = request.SetSelectionOwner._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGetSelectionOwner(EndianTest): def setUp(self): self.req_args_0 = { - 'selection': 819576555, + 'selection': 1090303630, } - self.req_bin_0 = '\x17\x00\x00\x02' '\x30\xd9\xbe\xeb' + self.req_bin_0 = b'\x17\x00\x00\x02' b'\x40\xfc\xb6\x8e' self.reply_args_0 = { - 'sequence_number': 14152, - 'owner': 1922331178, + 'owner': 228581038, + 'sequence_number': 60065, } - self.reply_bin_0 = '\x01\x00\x37\x48' '\x00\x00\x00\x00' \ - '\x72\x94\x72\x2a' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\xea\xa1' b'\x00\x00\x00\x00' \ + b'\x0d\x9f\xde\xae' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetSelectionOwner._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetSelectionOwner._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetSelectionOwner._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestConvertSelection(EndianTest): def setUp(self): self.req_args_0 = { - 'property': 2137791927, - 'time': 1594653142, - 'target': 1972273672, - 'selection': 125139929, - 'requestor': 300355135, + 'property': 1807536699, + 'requestor': 1869489931, + 'selection': 1342887479, + 'target': 640970836, + 'time': 1372199123, } - self.req_bin_0 = '\x18\x00\x00\x06' '\x11\xe7\x0e\x3f' \ - '\x07\x75\x7b\xd9' '\x75\x8e\x82\x08' \ - '\x7f\x6c\x1d\xb7' '\x5f\x0c\x79\xd6' + self.req_bin_0 = b'\x18\x00\x00\x06' b'\x6f\x6e\x27\x0b' \ + b'\x50\x0a\xd6\x37' b'\x26\x34\x70\x54' \ + b'\x6b\xbc\xd2\x3b' b'\x51\xca\x18\xd3' def testPackRequest0(self): bin = request.ConvertSelection._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ConvertSelection._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestSendEvent(EndianTest): def setUp(self): self.req_args_0 = { - 'event': Xlib.protocol.event.Expose(height = 64784, sequence_number = 0, type = 12, x = 52546, y = 56316, window = 1322187412, width = 16612, count = 14164), - 'propagate': 1, - 'destination': 1369243800, - 'event_mask': 1594482936, + 'destination': 1158373169, + 'event': event.Expose(count=50227, height=24760, sequence_number=0, type=12, width=10272, window=1090263274, x=40165, y=13291), + 'event_mask': 2047690655, + 'propagate': 0, } - self.req_bin_0 = '\x19\x01\x00\x0b' '\x51\x9d\x00\x98' \ - '\x5f\x09\xe0\xf8' '\x0c\x00\x00\x00' \ - '\x4e\xce\xfa\x94' '\xcd\x42\xdb\xfc' \ - '\x40\xe4\xfd\x10' '\x37\x54\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' + self.req_bin_0 = b'\x19\x00\x00\x0b' b'\x45\x0b\x5f\x31' \ + b'\x7a\x0d\x47\x9f' b'\x0c\x00\x00\x00' \ + b'\x40\xfc\x18\xea' b'\x9c\xe5\x33\xeb' \ + b'\x28\x20\x60\xb8' b'\xc4\x33\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SendEvent._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SendEvent._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGrabPointer(EndianTest): def setUp(self): self.req_args_0 = { - 'owner_events': 1, - 'grab_window': 2104857020, - 'confine_to': 1988278615, - 'event_mask': 2075, - 'pointer_mode': 0, - 'time': 1316427724, - 'keyboard_mode': 1, - 'cursor': 17101598, + 'confine_to': 240299645, + 'cursor': 1995289624, + 'event_mask': 21499, + 'grab_window': 1286289242, + 'keyboard_mode': 0, + 'owner_events': 0, + 'pointer_mode': 1, + 'time': 779560794, } - self.req_bin_0 = '\x1a\x01\x00\x06' '\x7d\x75\x91\xbc' \ - '\x08\x1b\x00\x01' '\x76\x82\xb9\x57' \ - '\x01\x04\xf3\x1e' '\x4e\x77\x17\xcc' + self.req_bin_0 = b'\x1a\x00\x00\x06' b'\x4c\xab\x37\x5a' \ + b'\x53\xfb\x01\x00' b'\x0e\x52\xae\x7d' \ + b'\x76\xed\xb4\x18' b'\x2e\x77\x27\x5a' self.reply_args_0 = { - 'sequence_number': 47539, - 'status': 149, + 'sequence_number': 15948, + 'status': 206, } - self.reply_bin_0 = '\x01\x95\xb9\xb3' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\xce\x3e\x4c' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GrabPointer._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GrabPointer._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GrabPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestUngrabPointer(EndianTest): def setUp(self): self.req_args_0 = { - 'time': 209008422, + 'time': 124458893, } - self.req_bin_0 = '\x1b\x00\x00\x02' '\x0c\x75\x37\x26' + self.req_bin_0 = b'\x1b\x00\x00\x02' b'\x07\x6b\x17\x8d' def testPackRequest0(self): bin = request.UngrabPointer._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGrabButton(EndianTest): def setUp(self): self.req_args_0 = { - 'owner_events': 1, - 'grab_window': 526402184, - 'confine_to': 1843948635, - 'event_mask': 16279, - 'pointer_mode': 1, - 'modifiers': 15589, - 'button': 208, - 'keyboard_mode': 1, - 'cursor': 1070323643, + 'button': 145, + 'confine_to': 1571825127, + 'cursor': 1043722096, + 'event_mask': 37438, + 'grab_window': 1885576796, + 'keyboard_mode': 0, + 'modifiers': 64349, + 'owner_events': 0, + 'pointer_mode': 0, } - self.req_bin_0 = '\x1c\x01\x00\x06' '\x1f\x60\x42\x88' \ - '\x3f\x97\x01\x01' '\x6d\xe8\x6c\x5b' \ - '\x3f\xcb\xd7\xbb' '\xd0\x00\x3c\xe5' + self.req_bin_0 = b'\x1c\x00\x00\x06' b'\x70\x63\x9e\x5c' \ + b'\x92\x3e\x00\x00' b'\x5d\xb0\x25\xe7' \ + b'\x3e\x35\xef\x70' b'\x91\x00\xfb\x5d' def testPackRequest0(self): bin = request.GrabButton._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestUngrabButton(EndianTest): def setUp(self): self.req_args_0 = { - 'grab_window': 795414150, - 'button': 240, - 'modifiers': 51717, + 'button': 160, + 'grab_window': 275784110, + 'modifiers': 43493, } - self.req_bin_0 = '\x1d\xf0\x00\x03' '\x2f\x69\x0e\x86' \ - '\xca\x05\x00\x00' + self.req_bin_0 = b'\x1d\xa0\x00\x03' b'\x10\x70\x21\xae' \ + b'\xa9\xe5\x00\x00' def testPackRequest0(self): bin = request.UngrabButton._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestChangeActivePointerGrab(EndianTest): def setUp(self): self.req_args_0 = { - 'time': 891337572, - 'event_mask': 23423, - 'cursor': 1696594928, + 'cursor': 1020726671, + 'event_mask': 36287, + 'time': 2033407590, } - self.req_bin_0 = '\x1e\x00\x00\x04' '\x65\x1f\xfb\xf0' \ - '\x35\x20\xbb\x64' '\x5b\x7f\x00\x00' + self.req_bin_0 = b'\x1e\x00\x00\x04' b'\x3c\xd7\x0d\x8f' \ + b'\x79\x33\x56\x66' b'\x8d\xbf\x00\x00' def testPackRequest0(self): bin = request.ChangeActivePointerGrab._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeActivePointerGrab._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGrabKeyboard(EndianTest): def setUp(self): self.req_args_0 = { + 'grab_window': 569270305, + 'keyboard_mode': 0, 'owner_events': 0, - 'grab_window': 76132199, - 'time': 1562605785, 'pointer_mode': 1, - 'keyboard_mode': 1, + 'time': 1133236353, } - self.req_bin_0 = '\x1f\x00\x00\x04' '\x04\x89\xaf\x67' \ - '\x5d\x23\x78\xd9' '\x01\x01\x00\x00' + self.req_bin_0 = b'\x1f\x00\x00\x04' b'\x21\xee\x60\x21' \ + b'\x43\x8b\xd0\x81' b'\x01\x00\x00\x00' self.reply_args_0 = { - 'sequence_number': 9648, - 'status': 129, + 'sequence_number': 46979, + 'status': 179, } - self.reply_bin_0 = '\x01\x81\x25\xb0' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\xb3\xb7\x83' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GrabKeyboard._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GrabKeyboard._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GrabKeyboard._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestUngrabKeyboard(EndianTest): def setUp(self): self.req_args_0 = { - 'time': 1352311886, + 'time': 669471181, } - self.req_bin_0 = '\x20\x00\x00\x02' '\x50\x9a\xa4\x4e' + self.req_bin_0 = b'\x20\x00\x00\x02' b'\x27\xe7\x51\xcd' def testPackRequest0(self): bin = request.UngrabKeyboard._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGrabKey(EndianTest): def setUp(self): self.req_args_0 = { + 'grab_window': 2137132511, + 'key': 223, + 'keyboard_mode': 1, + 'modifiers': 44275, 'owner_events': 1, - 'grab_window': 1467490800, - 'pointer_mode': 0, - 'keyboard_mode': 0, - 'modifiers': 28819, - 'key': 193, + 'pointer_mode': 1, } - self.req_bin_0 = '\x21\x01\x00\x04' '\x57\x78\x21\xf0' \ - '\x70\x93\xc1\x00' '\x00\x00\x00\x00' + self.req_bin_0 = b'\x21\x01\x00\x04' b'\x7f\x62\x0d\xdf' \ + b'\xac\xf3\xdf\x01' b'\x01\x00\x00\x00' def testPackRequest0(self): bin = request.GrabKey._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestUngrabKey(EndianTest): def setUp(self): self.req_args_0 = { - 'grab_window': 769929659, - 'key': 215, - 'modifiers': 60588, + 'grab_window': 532438798, + 'key': 158, + 'modifiers': 14981, } - self.req_bin_0 = '\x22\xd7\x00\x03' '\x2d\xe4\x31\xbb' \ - '\xec\xac\x00\x00' + self.req_bin_0 = b'\x22\x9e\x00\x03' b'\x1f\xbc\x5f\x0e' \ + b'\x3a\x85\x00\x00' def testPackRequest0(self): bin = request.UngrabKey._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestAllowEvents(EndianTest): def setUp(self): self.req_args_0 = { - 'time': 342147129, 'mode': 1, + 'time': 726098765, } - self.req_bin_0 = '\x23\x01\x00\x02' '\x14\x64\xc0\x39' + self.req_bin_0 = b'\x23\x01\x00\x02' b'\x2b\x47\x63\x4d' def testPackRequest0(self): bin = request.AllowEvents._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllowEvents._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGrabServer(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x24\x00\x00\x01' + self.req_bin_0 = b'\x24\x00\x00\x01' def testPackRequest0(self): bin = request.GrabServer._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestUngrabServer(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x25\x00\x00\x01' + self.req_bin_0 = b'\x25\x00\x00\x01' def testPackRequest0(self): bin = request.UngrabServer._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UngrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestQueryPointer(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 561336799, + 'window': 45236268, } - self.req_bin_0 = '\x26\x00\x00\x02' '\x21\x75\x51\xdf' + self.req_bin_0 = b'\x26\x00\x00\x02' b'\x02\xb2\x40\x2c' self.reply_args_0 = { - 'win_y': -25733, + 'child': 15507755, + 'mask': 15259, + 'root': 472978779, + 'root_x': -30442, + 'root_y': -9574, 'same_screen': 0, - 'sequence_number': 41448, - 'root': 1599238998, - 'root_x': -4185, - 'root_y': -6112, - 'mask': 35955, - 'child': 1075058918, - 'win_x': -18858, + 'sequence_number': 38820, + 'win_x': -12089, + 'win_y': -30839, } - self.reply_bin_0 = '\x01\x00\xa1\xe8' '\x00\x00\x00\x00' \ - '\x5f\x52\x73\x56' '\x40\x14\x18\xe6' \ - '\xef\xa7\xe8\x20' '\xb6\x56\x9b\x7b' \ - '\x8c\x73\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\x97\xa4' b'\x00\x00\x00\x00' \ + b'\x1c\x31\x15\x5b' b'\x00\xec\xa1\x2b' \ + b'\x89\x16\xda\x9a' b'\xd0\xc7\x87\x89' \ + b'\x3b\x9b\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryPointer._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryPointer._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestGetMotionEvents(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 843681780, - 'start': 1520150500, - 'stop': 11115313, + 'start': 1944440211, + 'stop': 67524349, + 'window': 144806627, } - self.req_bin_0 = '\x27\x00\x00\x04' '\x32\x49\x8f\xf4' \ - '\x5a\x9b\xa7\xe4' '\x00\xa9\x9b\x31' + self.req_bin_0 = b'\x27\x00\x00\x04' b'\x08\xa1\x92\xe3' \ + b'\x73\xe5\xcd\x93' b'\x04\x06\x56\xfd' self.reply_args_0 = { - 'sequence_number': 52222, - 'events': [{'time': 2107444516, 'x': -649, 'y': -11631}, {'time': 1827536960, 'x': -18061, 'y': -2301}, {'time': 554175146, 'x': -32111, 'y': -13522}, {'time': 608168588, 'x': -5963, 'y': -24618}, {'time': 590416221, 'x': -3325, 'y': -19656}], + 'events': [{'y': -30447, 'x': -21941, 'time': 1846118496}, {'y': -23643, 'x': -24970, 'time': 1104207400}, {'y': -25748, 'x': -16862, 'time': 1436684371}, {'y': -9066, 'x': -28433, 'time': 1158061593}, {'y': -14057, 'x': -3855, 'time': 2009067067}], + 'sequence_number': 38018, } - self.reply_bin_0 = '\x01\x00\xcb\xfe' '\x00\x00\x00\x0a' \ - '\x00\x00\x00\x05' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x7d\x9d\x0d\x24' '\xfd\x77\xd2\x91' \ - '\x6c\xee\x00\x40' '\xb9\x73\xf7\x03' \ - '\x21\x08\x0a\xaa' '\x82\x91\xcb\x2e' \ - '\x24\x3f\xea\x8c' '\xe8\xb5\x9f\xd6' \ - '\x23\x31\x09\x5d' '\xf3\x03\xb3\x38' + self.reply_bin_0 = b'\x01\x00\x94\x82' b'\x00\x00\x00\x0a' \ + b'\x00\x00\x00\x05' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x6e\x09\x88\x60' b'\xaa\x4b\x89\x11' \ + b'\x41\xd0\xde\x28' b'\x9e\x76\xa3\xa5' \ + b'\x55\xa2\x10\x53' b'\xbe\x22\x9b\x6c' \ + b'\x45\x06\x9e\x19' b'\x90\xef\xdc\x96' \ + b'\x77\xbf\xee\x3b' b'\xf0\xf1\xc9\x17' def testPackRequest0(self): bin = request.GetMotionEvents._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetMotionEvents._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetMotionEvents._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetMotionEvents._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestTranslateCoords(EndianTest): def setUp(self): self.req_args_0 = { - 'src_y': -27247, - 'src_x': -25331, - 'src_wid': 257619448, - 'dst_wid': 1238981863, + 'dst_wid': 521898132, + 'src_wid': 1015118844, + 'src_x': -7058, + 'src_y': -17270, } - self.req_bin_0 = '\x28\x00\x00\x04' '\x0f\x5a\xf5\xf8' \ - '\x49\xd9\x5c\xe7' '\x9d\x0d\x95\x91' + self.req_bin_0 = b'\x28\x00\x00\x04' b'\x3c\x81\x7b\xfc' \ + b'\x1f\x1b\x88\x94' b'\xe4\x6e\xbc\x8a' self.reply_args_0 = { - 'child': 2050350678, + 'child': 202628650, 'same_screen': 1, - 'sequence_number': 38657, - 'x': -18096, - 'y': -5252, + 'sequence_number': 12734, + 'x': -29592, + 'y': -11175, } - self.reply_bin_0 = '\x01\x01\x97\x01' '\x00\x00\x00\x00' \ - '\x7a\x35\xde\x56' '\xb9\x50\xeb\x7c' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x01\x31\xbe' b'\x00\x00\x00\x00' \ + b'\x0c\x13\xde\x2a' b'\x8c\x68\xd4\x59' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.TranslateCoords._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.TranslateCoords._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.TranslateCoords._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.TranslateCoords._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestWarpPointer(EndianTest): def setUp(self): self.req_args_0 = { - 'src_height': 56634, - 'src_window': 1335081711, - 'dst_window': 675547124, - 'src_width': 21809, - 'src_y': -26071, - 'src_x': -27119, - 'dst_x': -30516, - 'dst_y': -24204, + 'dst_window': 760913775, + 'dst_x': -8878, + 'dst_y': -30993, + 'src_height': 56868, + 'src_width': 30862, + 'src_window': 925740905, + 'src_x': -18889, + 'src_y': -19298, } - self.req_bin_0 = '\x29\x00\x00\x06' '\x4f\x93\xba\xef' \ - '\x28\x44\x07\xf4' '\x96\x11\x9a\x29' \ - '\x55\x31\xdd\x3a' '\x88\xcc\xa1\x74' + self.req_bin_0 = b'\x29\x00\x00\x06' b'\x37\x2d\xaf\x69' \ + b'\x2d\x5a\x9f\x6f' b'\xb6\x37\xb4\x9e' \ + b'\x78\x8e\xde\x24' b'\xdd\x52\x86\xef' def testPackRequest0(self): bin = request.WarpPointer._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.WarpPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestSetInputFocus(EndianTest): def setUp(self): self.req_args_0 = { - 'revert_to': 1, - 'time': 1079702500, - 'focus': 1026400247, + 'focus': 1403350503, + 'revert_to': 2, + 'time': 2113544232, } - self.req_bin_0 = '\x2a\x01\x00\x03' '\x3d\x2d\x9f\xf7' \ - '\x40\x5a\xf3\xe4' + self.req_bin_0 = b'\x2a\x02\x00\x03' b'\x53\xa5\x6d\xe7' \ + b'\x7d\xfa\x20\x28' def testPackRequest0(self): bin = request.SetInputFocus._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGetInputFocus(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x2b\x00\x00\x01' + self.req_bin_0 = b'\x2b\x00\x00\x01' self.reply_args_0 = { - 'revert_to': 152, - 'sequence_number': 16002, - 'focus': 2024022965, + 'focus': 864688157, + 'revert_to': 153, + 'sequence_number': 4228, } - self.reply_bin_0 = '\x01\x98\x3e\x82' '\x00\x00\x00\x00' \ - '\x78\xa4\x23\xb5' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x99\x10\x84' b'\x00\x00\x00\x00' \ + b'\x33\x8a\x18\x1d' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetInputFocus._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetInputFocus._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetInputFocus._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestQueryKeymap(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x2c\x00\x00\x01' + self.req_bin_0 = b'\x2c\x00\x00\x01' self.reply_args_0 = { - 'sequence_number': 16233, - 'map': [186, 167, 191, 213, 241, 231, 234, 175, 154, 169, 132, 146, 215, 191, 196, 212, 158, 156, 177, 233, 220, 192, 130, 226, 181, 233, 238, 141, 129, 215, 245, 215], + 'map': [214, 155, 191, 177, 176, 242, 163, 236, 174, 199, 246, 191, 147, 241, 153, 140, 131, 151, 188, 170, 232, 252, 251, 182, 230, 143, 170, 225, 128, 227, 195, 244], + 'sequence_number': 18950, } - self.reply_bin_0 = '\x01\x00\x3f\x69' '\x00\x00\x00\x02' \ - '\xba\xa7\xbf\xd5' '\xf1\xe7\xea\xaf' \ - '\x9a\xa9\x84\x92' '\xd7\xbf\xc4\xd4' \ - '\x9e\x9c\xb1\xe9' '\xdc\xc0\x82\xe2' \ - '\xb5\xe9\xee\x8d' '\x81\xd7\xf5\xd7' + self.reply_bin_0 = b'\x01\x00\x4a\x06' b'\x00\x00\x00\x02' \ + b'\xd6\x9b\xbf\xb1' b'\xb0\xf2\xa3\xec' \ + b'\xae\xc7\xf6\xbf' b'\x93\xf1\x99\x8c' \ + b'\x83\x97\xbc\xaa' b'\xe8\xfc\xfb\xb6' \ + b'\xe6\x8f\xaa\xe1' b'\x80\xe3\xc3\xf4' def testPackRequest0(self): bin = request.QueryKeymap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryKeymap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryKeymap._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryKeymap._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestOpenFont(EndianTest): def setUp(self): self.req_args_0 = { - 'fid': 1728036313, + 'fid': 908467189, 'name': 'foofont', } - self.req_bin_0 = '\x2d\x00\x00\x05' '\x66\xff\xbd\xd9' \ - '\x00\x07\x00\x00' '\x66\x6f\x6f\x66' \ - '\x6f\x6e\x74\x00' + self.req_bin_0 = b'\x2d\x00\x00\x05' b'\x36\x26\x1b\xf5' \ + b'\x00\x07\x00\x00' b'\x66\x6f\x6f\x66' \ + b'\x6f\x6e\x74\x00' def testPackRequest0(self): bin = request.OpenFont._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.OpenFont._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestCloseFont(EndianTest): def setUp(self): self.req_args_0 = { - 'font': 1139770507, + 'font': 1495984396, } - self.req_bin_0 = '\x2e\x00\x00\x02' '\x43\xef\x84\x8b' + self.req_bin_0 = b'\x2e\x00\x00\x02' b'\x59\x2a\xe9\x0c' def testPackRequest0(self): bin = request.CloseFont._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CloseFont._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestQueryFont(EndianTest): def setUp(self): self.req_args_0 = { - 'font': 1867659050, + 'font': 2055889505, } - self.req_bin_0 = '\x2f\x00\x00\x02' '\x6f\x52\x37\x2a' + self.req_bin_0 = b'\x2f\x00\x00\x02' b'\x7a\x8a\x62\x61' self.reply_args_0 = { - 'sequence_number': 8877, - 'properties': [{'value': 2110348825, 'name': 1450586355}], - 'min_byte1': 190, - 'max_byte1': 168, - 'char_infos': [{'descent': -331, 'ascent': -14454, 'character_width': -28521, 'left_side_bearing': -4521, 'right_side_bearing': -9875, 'attributes': 55191}, {'descent': -18739, 'ascent': -6278, 'character_width': -4532, 'left_side_bearing': -20397, 'right_side_bearing': -25187, 'attributes': 29476}, {'descent': -18381, 'ascent': -2378, 'character_width': -21855, 'left_side_bearing': -20068, 'right_side_bearing': -906, 'attributes': 34385}], - 'max_char_or_byte2': 2516, - 'default_char': 8994, - 'min_char_or_byte2': 49360, - 'draw_direction': 143, - 'min_bounds': {'descent': -29813, 'ascent': -27033, 'character_width': -5286, 'left_side_bearing': -20740, 'right_side_bearing': -21698, 'attributes': 11392}, - 'all_chars_exist': 1, - 'font_ascent': -15646, - 'font_descent': -23067, - 'max_bounds': {'descent': -24292, 'ascent': -26972, 'character_width': -19286, 'left_side_bearing': -16363, 'right_side_bearing': -3149, 'attributes': 35968}, - } - self.reply_bin_0 = '\x01\x00\x22\xad' '\x00\x00\x00\x12' \ - '\xae\xfc\xab\x3e' '\xeb\x5a\x96\x67' \ - '\x8b\x8b\x2c\x80' '\x00\x00\x00\x00' \ - '\xc0\x15\xf3\xb3' '\xb4\xaa\x96\xa4' \ - '\xa1\x1c\x8c\x80' '\x00\x00\x00\x00' \ - '\xc0\xd0\x09\xd4' '\x23\x22\x00\x01' \ - '\x8f\xbe\xa8\x01' '\xc2\xe2\xa5\xe5' \ - '\x00\x00\x00\x03' '\x56\x76\x30\xf3' \ - '\x7d\xc9\x5e\x19' '\xee\x57\xd9\x6d' \ - '\x90\x97\xc7\x8a' '\xfe\xb5\xd7\x97' \ - '\xb0\x53\x9d\x9d' '\xee\x4c\xe7\x7a' \ - '\xb6\xcd\x73\x24' '\xb1\x9c\xfc\x76' \ - '\xaa\xa1\xf6\xb6' '\xb8\x33\x86\x51' + 'all_chars_exist': 0, + 'char_infos': [{'descent': -16821, 'right_side_bearing': -14557, 'character_width': -11080, 'left_side_bearing': -7099, 'attributes': 10400, 'ascent': -9228}, {'descent': -30852, 'right_side_bearing': -23046, 'character_width': -25635, 'left_side_bearing': -26546, 'attributes': 38213, 'ascent': -1026}, {'descent': -22492, 'right_side_bearing': -15002, 'character_width': -30771, 'left_side_bearing': -8660, 'attributes': 4002, 'ascent': -8259}], + 'default_char': 39252, + 'draw_direction': 145, + 'font_ascent': -1914, + 'font_descent': -3596, + 'max_bounds': {'descent': -30143, 'right_side_bearing': -30905, 'character_width': -1286, 'left_side_bearing': -27610, 'attributes': 56049, 'ascent': -16128}, + 'max_byte1': 231, + 'max_char_or_byte2': 4746, + 'min_bounds': {'descent': -4827, 'right_side_bearing': -17145, 'character_width': -16291, 'left_side_bearing': -13626, 'attributes': 35063, 'ascent': -2642}, + 'min_byte1': 188, + 'min_char_or_byte2': 12434, + 'properties': [{'name': 1568813755, 'value': 2137719486}], + 'sequence_number': 3542, + } + self.reply_bin_0 = b'\x01\x00\x0d\xd6' b'\x00\x00\x00\x12' \ + b'\xca\xc6\xbd\x07' b'\xc0\x5d\xf5\xae' \ + b'\xed\x25\x88\xf7' b'\x00\x00\x00\x00' \ + b'\x94\x26\x87\x47' b'\xfa\xfa\xc1\x00' \ + b'\x8a\x41\xda\xf1' b'\x00\x00\x00\x00' \ + b'\x30\x92\x12\x8a' b'\x99\x54\x00\x01' \ + b'\x91\xbc\xe7\x00' b'\xf8\x86\xf1\xf4' \ + b'\x00\x00\x00\x03' b'\x5d\x82\x32\xbb' \ + b'\x7f\x6b\x02\xbe' b'\xe4\x45\xc7\x23' \ + b'\xd4\xb8\xdb\xf4' b'\xbe\x4b\x28\xa0' \ + b'\x98\x4e\xa5\xfa' b'\x9b\xdd\xfb\xfe' \ + b'\x87\x7c\x95\x45' b'\xde\x2c\xc5\x66' \ + b'\x87\xcd\xdf\xbd' b'\xa8\x24\x0f\xa2' def testPackRequest0(self): bin = request.QueryFont._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryFont._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryFont._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryFont._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestQueryTextExtents(EndianTest): def setUp(self): self.req_args_0 = { - 'font': 1562125736, + 'font': 1223434172, 'string': (102, 111, 111), } - self.req_bin_0 = '\x30\x01\x00\x04' '\x5d\x1c\x25\xa8' \ - '\x00\x66\x00\x6f' '\x00\x6f\x00\x00' + self.req_bin_0 = b'\x30\x01\x00\x04' b'\x48\xec\x1f\xbc' \ + b'\x00\x66\x00\x6f' b'\x00\x6f\x00\x00' self.reply_args_0 = { - 'overall_width': -1378352414, - 'draw_direction': 219, - 'sequence_number': 6791, - 'font_ascent': -16915, - 'overall_ascent': -22910, - 'overall_descent': -1795, - 'overall_right': -530284310, - 'overall_left': -1046976699, - 'font_descent': -14179, - } - self.reply_bin_0 = '\x01\xdb\x1a\x87' '\x00\x00\x00\x00' \ - '\xbd\xed\xc8\x9d' '\xa6\x82\xf8\xfd' \ - '\xad\xd8\x02\xe2' '\xc1\x98\x67\x45' \ - '\xe0\x64\x80\xea' '\x00\x00\x00\x00' + 'draw_direction': 191, + 'font_ascent': -13287, + 'font_descent': -31466, + 'overall_ascent': -12473, + 'overall_descent': -30082, + 'overall_left': -735785526, + 'overall_right': -894056953, + 'overall_width': -1247205006, + 'sequence_number': 38196, + } + self.reply_bin_0 = b'\x01\xbf\x95\x34' b'\x00\x00\x00\x00' \ + b'\xcc\x19\x85\x16' b'\xcf\x47\x8a\x7e' \ + b'\xb5\xa9\x29\x72' b'\xd4\x24\xcd\xca' \ + b'\xca\xb5\xc6\x07' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryTextExtents._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryTextExtents._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryTextExtents._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryTextExtents._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestListFonts(EndianTest): def setUp(self): self.req_args_0 = { - 'max_names': 53961, + 'max_names': 37298, 'pattern': 'bhazr', } - self.req_bin_0 = '\x31\x00\x00\x04' '\xd2\xc9\x00\x05' \ - '\x62\x68\x61\x7a' '\x72\x00\x00\x00' + self.req_bin_0 = b'\x31\x00\x00\x04' b'\x91\xb2\x00\x05' \ + b'\x62\x68\x61\x7a' b'\x72\x00\x00\x00' self.reply_args_0 = { 'fonts': ['fie', 'fuzzy', 'foozooom'], - 'sequence_number': 38267, + 'sequence_number': 34517, } - self.reply_bin_0 = '\x01\x00\x95\x7b' '\x00\x00\x00\x05' \ - '\x00\x03\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x03\x66\x69\x65' '\x05\x66\x75\x7a' \ - '\x7a\x79\x08\x66' '\x6f\x6f\x7a\x6f' \ - '\x6f\x6f\x6d\x00' + self.reply_bin_0 = b'\x01\x00\x86\xd5' b'\x00\x00\x00\x05' \ + b'\x00\x03\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x03\x66\x69\x65' b'\x05\x66\x75\x7a' \ + b'\x7a\x79\x08\x66' b'\x6f\x6f\x7a\x6f' \ + b'\x6f\x6f\x6d\x00' def testPackRequest0(self): bin = request.ListFonts._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListFonts._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListFonts._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListFonts._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestListFontsWithInfo(EndianTest): def setUp(self): self.req_args_0 = { - 'max_names': 46571, + 'max_names': 20989, 'pattern': 'bhazr2', } - self.req_bin_0 = '\x32\x00\x00\x04' '\xb5\xeb\x00\x06' \ - '\x62\x68\x61\x7a' '\x72\x32\x00\x00' + self.req_bin_0 = b'\x32\x00\x00\x04' b'\x51\xfd\x00\x06' \ + b'\x62\x68\x61\x7a' b'\x72\x32\x00\x00' self.reply_args_0 = { - 'sequence_number': 20014, - 'properties': [{'value': 2110430409, 'name': 435956656}], - 'min_byte1': 214, - 'max_byte1': 217, - 'max_char_or_byte2': 2479, - 'default_char': 17041, - 'min_char_or_byte2': 26638, - 'draw_direction': 192, - 'replies_hint': 1985190562, - 'min_bounds': {'descent': -27837, 'ascent': -14775, 'character_width': -13026, 'left_side_bearing': -29767, 'right_side_bearing': -31908, 'attributes': 2465}, 'all_chars_exist': 0, + 'default_char': 61580, + 'draw_direction': 146, + 'font_ascent': -30368, + 'font_descent': -15151, + 'max_bounds': {'descent': -17786, 'right_side_bearing': -10759, 'character_width': -11617, 'left_side_bearing': -28480, 'attributes': 20976, 'ascent': -22938}, + 'max_byte1': 245, + 'max_char_or_byte2': 49530, + 'min_bounds': {'descent': -24065, 'right_side_bearing': -9300, 'character_width': -22473, 'left_side_bearing': -10823, 'attributes': 26194, 'ascent': -24947}, + 'min_byte1': 130, + 'min_char_or_byte2': 61140, 'name': 'fontfont', - 'font_ascent': -30550, - 'font_descent': -28978, - 'max_bounds': {'descent': -20692, 'ascent': -6999, 'character_width': -15180, 'left_side_bearing': -7789, 'right_side_bearing': -5339, 'attributes': 1068}, - } - self.reply_bin_0 = '\x01\x08\x4e\x2e' '\x00\x00\x00\x0b' \ - '\x8b\xb9\x83\x5c' '\xcd\x1e\xc6\x49' \ - '\x93\x43\x09\xa1' '\x00\x00\x00\x00' \ - '\xe1\x93\xeb\x25' '\xc4\xb4\xe4\xa9' \ - '\xaf\x2c\x04\x2c' '\x00\x00\x00\x00' \ - '\x68\x0e\x09\xaf' '\x42\x91\x00\x01' \ - '\xc0\xd6\xd9\x00' '\x88\xaa\x8e\xce' \ - '\x76\x53\x9a\xa2' '\x19\xfc\x2b\xb0' \ - '\x7d\xca\x9c\xc9' '\x66\x6f\x6e\x74' \ - '\x66\x6f\x6e\x74' + 'properties': [{'name': 2007331946, 'value': 560055601}], + 'replies_hint': 457810933, + 'sequence_number': 13642, + } + self.reply_bin_0 = b'\x01\x08\x35\x4a' b'\x00\x00\x00\x0b' \ + b'\xd5\xb9\xdb\xac' b'\xa8\x37\x9e\x8d' \ + b'\xa1\xff\x66\x52' b'\x00\x00\x00\x00' \ + b'\x90\xc0\xd5\xf9' b'\xd2\x9f\xa6\x66' \ + b'\xba\x86\x51\xf0' b'\x00\x00\x00\x00' \ + b'\xee\xd4\xc1\x7a' b'\xf0\x8c\x00\x01' \ + b'\x92\x82\xf5\x00' b'\x89\x60\xc4\xd1' \ + b'\x1b\x49\xa3\xf5' b'\x77\xa5\x74\x6a' \ + b'\x21\x61\xc5\x31' b'\x66\x6f\x6e\x74' \ + b'\x66\x6f\x6e\x74' def testPackRequest0(self): bin = request.ListFontsWithInfo._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListFontsWithInfo._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListFontsWithInfo._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListFontsWithInfo._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestSetFontPath(EndianTest): @@ -2547,1974 +1800,1416 @@ def setUp(self): self.req_args_0 = { 'path': ['foo', 'bar', 'gazonk'], } - self.req_bin_0 = '\x33\x00\x00\x06' '\x00\x03\x00\x00' \ - '\x03\x66\x6f\x6f' '\x03\x62\x61\x72' \ - '\x06\x67\x61\x7a' '\x6f\x6e\x6b\x00' + self.req_bin_0 = b'\x33\x00\x00\x06' b'\x00\x03\x00\x00' \ + b'\x03\x66\x6f\x6f' b'\x03\x62\x61\x72' \ + b'\x06\x67\x61\x7a' b'\x6f\x6e\x6b\x00' self.req_args_1 = { 'path': [], } - self.req_bin_1 = '\x33\x00\x00\x02' '\x00\x00\x00\x00' + self.req_bin_1 = b'\x33\x00\x00\x02' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SetFontPath._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.SetFontPath._request.to_binary(*(), **self.req_args_1) - try: - assert bin == self.req_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.SetFontPath._request.parse_binary(self.req_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_1) class TestGetFontPath(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x34\x00\x00\x01' + self.req_bin_0 = b'\x34\x00\x00\x01' self.reply_args_0 = { - 'sequence_number': 21510, 'paths': ['path1', 'path2232'], + 'sequence_number': 33409, } - self.reply_bin_0 = '\x01\x00\x54\x06' '\x00\x00\x00\x04' \ - '\x00\x02\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x05\x70\x61\x74' '\x68\x31\x08\x70' \ - '\x61\x74\x68\x32' '\x32\x33\x32\x00' + self.reply_bin_0 = b'\x01\x00\x82\x81' b'\x00\x00\x00\x04' \ + b'\x00\x02\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x05\x70\x61\x74' b'\x68\x31\x08\x70' \ + b'\x61\x74\x68\x32' b'\x32\x33\x32\x00' self.reply_args_1 = { - 'sequence_number': 62463, 'paths': [], + 'sequence_number': 17636, } - self.reply_bin_1 = '\x01\x00\xf3\xff' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_1 = b'\x01\x00\x44\xe4' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetFontPath._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetFontPath._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) def testPackReply1(self): bin = request.GetFontPath._reply.to_binary(*(), **self.reply_args_1) - try: - assert bin == self.reply_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_1) def testUnpackReply1(self): args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_1) class TestCreatePixmap(EndianTest): def setUp(self): self.req_args_0 = { - 'height': 65515, - 'drawable': 162261202, - 'pid': 926490960, - 'depth': 145, - 'width': 5641, + 'depth': 161, + 'drawable': 749556300, + 'height': 4764, + 'pid': 2004224799, + 'width': 57984, } - self.req_bin_0 = '\x35\x91\x00\x04' '\x37\x39\x21\x50' \ - '\x09\xab\xe8\xd2' '\x16\x09\xff\xeb' + self.req_bin_0 = b'\x35\xa1\x00\x04' b'\x77\x76\x0b\x1f' \ + b'\x2c\xad\x52\x4c' b'\xe2\x80\x12\x9c' def testPackRequest0(self): bin = request.CreatePixmap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreatePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestFreePixmap(EndianTest): def setUp(self): self.req_args_0 = { - 'pixmap': 213012851, + 'pixmap': 1888284001, } - self.req_bin_0 = '\x36\x00\x00\x02' '\x0c\xb2\x51\x73' + self.req_bin_0 = b'\x36\x00\x00\x02' b'\x70\x8c\xed\x61' def testPackRequest0(self): bin = request.FreePixmap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestCreateGC(EndianTest): def setUp(self): self.req_args_0 = { - 'cid': 1060658282, - 'drawable': 456876463, - 'attrs': {'dashes': 183, 'fill_rule': 0, 'clip_mask': 620422624, 'plane_mask': 1797423280, 'line_style': 1, 'tile': 77620460, 'arc_mode': 0, 'clip_y_origin': -7419, 'dash_offset': 62459, 'line_width': 50494, 'background': 44336037, 'clip_x_origin': -32045, 'join_style': 2, 'graphics_exposures': 0, 'font': 95118395, 'tile_stipple_y_origin': -17619, 'stipple': 631657813, 'fill_style': 0, 'cap_style': 0, 'subwindow_mode': 0, 'tile_stipple_x_origin': -12494, 'foreground': 2096879871, 'function': 10}, - } - self.req_bin_0 = '\x37\x00\x00\x1b' '\x3f\x38\x5c\x6a' \ - '\x1b\x3b\x61\xaf' '\x00\x7f\xff\xff' \ - '\x0a\x00\x00\x00' '\x6b\x22\x80\xb0' \ - '\x7c\xfb\xd8\xff' '\x02\xa4\x83\xa5' \ - '\xc5\x3e\x00\x00' '\x01\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x02\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x04\xa0\x64\xec' '\x25\xa6\x55\x55' \ - '\xcf\x32\x00\x00' '\xbb\x2d\x00\x00' \ - '\x05\xab\x64\x3b' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x82\xd3\x00\x00' \ - '\xe3\x05\x00\x00' '\x24\xfa\xe5\xe0' \ - '\xf3\xfb\x00\x00' '\xb7\x00\x00\x00' \ - '\x00\x00\x00\x00' + 'attrs': {'stipple': 1424681955, 'background': 338824284, 'subwindow_mode': 0, 'fill_style': 0, 'font': 568001783, 'graphics_exposures': 0, 'tile': 2000996399, 'tile_stipple_x_origin': -25980, 'dashes': 215, 'function': 7, 'foreground': 612071305, 'clip_x_origin': -22581, 'cap_style': 2, 'tile_stipple_y_origin': -23968, 'join_style': 2, 'line_width': 61484, 'dash_offset': 46571, 'clip_y_origin': -14920, 'arc_mode': 0, 'line_style': 2, 'plane_mask': 793618921, 'clip_mask': 605132525, 'fill_rule': 1}, + 'cid': 1476454377, + 'drawable': 1362081172, + } + self.req_bin_0 = b'\x37\x00\x00\x1b' b'\x58\x00\xe7\xe9' \ + b'\x51\x2f\xb5\x94' b'\x00\x7f\xff\xff' \ + b'\x07\x00\x00\x00' b'\x2f\x4d\xa9\xe9' \ + b'\x24\x7b\x77\x89' b'\x14\x32\x0c\x5c' \ + b'\xf0\x2c\x00\x00' b'\x02\x00\x00\x00' \ + b'\x02\x00\x00\x00' b'\x02\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x01\x00\x00\x00' \ + b'\x77\x44\xc8\x2f' b'\x54\xea\xeb\xe3' \ + b'\x9a\x84\x00\x00' b'\xa2\x60\x00\x00' \ + b'\x21\xdb\x04\xf7' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\xa7\xcb\x00\x00' \ + b'\xc5\xb8\x00\x00' b'\x24\x11\x96\xed' \ + b'\xb5\xeb\x00\x00' b'\xd7\x00\x00\x00' \ + b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.CreateGC._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateGC._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestChangeGC(EndianTest): def setUp(self): self.req_args_0 = { - 'attrs': {'dashes': 249, 'fill_rule': 1, 'clip_mask': 496525721, 'plane_mask': 1467281901, 'line_style': 2, 'tile': 1713935374, 'arc_mode': 0, 'clip_y_origin': -24572, 'dash_offset': 46636, 'line_width': 61036, 'background': 1598773587, 'clip_x_origin': -19725, 'join_style': 1, 'graphics_exposures': 0, 'font': 429323306, 'tile_stipple_y_origin': -11767, 'stipple': 1365263649, 'fill_style': 2, 'cap_style': 1, 'subwindow_mode': 1, 'tile_stipple_x_origin': -23501, 'foreground': 1272378077, 'function': 11}, - 'gc': 518903558, - } - self.req_bin_0 = '\x38\x00\x00\x1a' '\x1e\xed\xd7\x06' \ - '\x00\x7f\xff\xff' '\x0b\x00\x00\x00' \ - '\x57\x74\xf1\xed' '\x4b\xd6\xf2\xdd' \ - '\x5f\x4b\x59\x53' '\xee\x6c\x00\x00' \ - '\x02\x00\x00\x00' '\x01\x00\x00\x00' \ - '\x01\x00\x00\x00' '\x02\x00\x00\x00' \ - '\x01\x00\x00\x00' '\x66\x28\x94\x0e' \ - '\x51\x60\x45\x21' '\xa4\x33\x00\x00' \ - '\xd2\x09\x00\x00' '\x19\x96\xf4\x2a' \ - '\x01\x00\x00\x00' '\x00\x00\x00\x00' \ - '\xb2\xf3\x00\x00' '\xa0\x04\x00\x00' \ - '\x1d\x98\x61\x99' '\xb6\x2c\x00\x00' \ - '\xf9\x00\x00\x00' '\x00\x00\x00\x00' + 'attrs': {'stipple': 1656031462, 'background': 539344312, 'subwindow_mode': 1, 'fill_style': 0, 'font': 347060191, 'graphics_exposures': 1, 'tile': 716372747, 'tile_stipple_x_origin': -24195, 'dashes': 137, 'function': 8, 'foreground': 1049179696, 'clip_x_origin': -32135, 'cap_style': 3, 'tile_stipple_y_origin': -15601, 'join_style': 1, 'line_width': 36097, 'dash_offset': 42536, 'clip_y_origin': -25437, 'arc_mode': 1, 'line_style': 0, 'plane_mask': 1085423224, 'clip_mask': 161650480, 'fill_rule': 0}, + 'gc': 1250995304, + } + self.req_bin_0 = b'\x38\x00\x00\x1a' b'\x4a\x90\xac\x68' \ + b'\x00\x7f\xff\xff' b'\x08\x00\x00\x00' \ + b'\x40\xb2\x3e\x78' b'\x3e\x89\x36\x30' \ + b'\x20\x25\xbd\xb8' b'\x8d\x01\x00\x00' \ + b'\x00\x00\x00\x00' b'\x03\x00\x00\x00' \ + b'\x01\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x2a\xb2\xfb\x0b' \ + b'\x62\xb5\x08\xe6' b'\xa1\x7d\x00\x00' \ + b'\xc3\x0f\x00\x00' b'\x14\xaf\xb7\xdf' \ + b'\x01\x00\x00\x00' b'\x01\x00\x00\x00' \ + b'\x82\x79\x00\x00' b'\x9c\xa3\x00\x00' \ + b'\x09\xa2\x97\x30' b'\xa6\x28\x00\x00' \ + b'\x89\x00\x00\x00' b'\x01\x00\x00\x00' def testPackRequest0(self): bin = request.ChangeGC._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeGC._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestCopyGC(EndianTest): def setUp(self): self.req_args_0 = { - 'mask': 1039948946, - 'src_gc': 1958847367, - 'dst_gc': 1311353896, + 'dst_gc': 318094523, + 'mask': 923025483, + 'src_gc': 1186604145, } - self.req_bin_0 = '\x39\x00\x00\x04' '\x74\xc1\xa3\x87' \ - '\x4e\x29\xac\x28' '\x3d\xfc\x5c\x92' + self.req_bin_0 = b'\x39\x00\x00\x04' b'\x46\xba\x24\x71' \ + b'\x12\xf5\xbc\xbb' b'\x37\x04\x40\x4b' def testPackRequest0(self): bin = request.CopyGC._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyGC._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestSetDashes(EndianTest): def setUp(self): self.req_args_0 = { - 'dashes': [169, 241, 158, 238, 173, 159, 182, 139, 139], - 'dash_offset': 51693, - 'gc': 1639787502, + 'dash_offset': 51381, + 'dashes': [160, 138, 206, 221, 138, 219, 181, 191, 154], + 'gc': 759584613, } - self.req_bin_0 = '\x3a\x00\x00\x06' '\x61\xbd\x2b\xee' \ - '\xc9\xed\x00\x09' '\xa9\xf1\x9e\xee' \ - '\xad\x9f\xb6\x8b' '\x8b\x00\x00\x00' + self.req_bin_0 = b'\x3a\x00\x00\x06' b'\x2d\x46\x57\x65' \ + b'\xc8\xb5\x00\x09' b'\xa0\x8a\xce\xdd' \ + b'\x8a\xdb\xb5\xbf' b'\x9a\x00\x00\x00' def testPackRequest0(self): bin = request.SetDashes._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetDashes._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestSetClipRectangles(EndianTest): def setUp(self): self.req_args_0 = { - 'rectangles': [{'height': 59391, 'x': -15430, 'width': 46673, 'y': -3009}, {'height': 9883, 'x': -14046, 'width': 7782, 'y': -24857}], - 'gc': 1105675380, - 'x_origin': -22760, - 'y_origin': -16557, - 'ordering': 3, + 'gc': 1856792138, + 'ordering': 1, + 'rectangles': [{'y': -3797, 'x': -14422, 'height': 26888, 'width': 57581}, {'y': -12431, 'x': -858, 'height': 10384, 'width': 49373}], + 'x_origin': -27444, + 'y_origin': -780, } - self.req_bin_0 = '\x3b\x03\x00\x07' '\x41\xe7\x44\x74' \ - '\xa7\x18\xbf\x53' '\xc3\xba\xf4\x3f' \ - '\xb6\x51\xe7\xff' '\xc9\x22\x9e\xe7' \ - '\x1e\x66\x26\x9b' + self.req_bin_0 = b'\x3b\x01\x00\x07' b'\x6e\xac\x66\x4a' \ + b'\x94\xcc\xfc\xf4' b'\xc7\xaa\xf1\x2b' \ + b'\xe0\xed\x69\x08' b'\xfc\xa6\xcf\x71' \ + b'\xc0\xdd\x28\x90' self.req_args_1 = { + 'gc': 1892892424, + 'ordering': 1, 'rectangles': [], - 'gc': 291514811, - 'x_origin': -29867, - 'y_origin': -10293, - 'ordering': 0, + 'x_origin': -19258, + 'y_origin': -31956, } - self.req_bin_1 = '\x3b\x00\x00\x03' '\x11\x60\x29\xbb' \ - '\x8b\x55\xd7\xcb' + self.req_bin_1 = b'\x3b\x01\x00\x03' b'\x70\xd3\x3f\x08' \ + b'\xb4\xc6\x83\x2c' def testPackRequest0(self): bin = request.SetClipRectangles._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.SetClipRectangles._request.to_binary(*(), **self.req_args_1) - try: - assert bin == self.req_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_1) class TestFreeGC(EndianTest): def setUp(self): self.req_args_0 = { - 'gc': 371787524, + 'gc': 385239625, } - self.req_bin_0 = '\x3c\x00\x00\x02' '\x16\x29\x07\x04' + self.req_bin_0 = b'\x3c\x00\x00\x02' b'\x16\xf6\x4a\x49' def testPackRequest0(self): bin = request.FreeGC._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeGC._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestClearArea(EndianTest): def setUp(self): self.req_args_0 = { - 'exposures': 0, - 'height': 53776, - 'width': 63821, - 'window': 1253992673, - 'x': -1843, - 'y': -32148, + 'exposures': 1, + 'height': 44159, + 'width': 52831, + 'window': 1680227732, + 'x': -2268, + 'y': -19277, } - self.req_bin_0 = '\x3d\x00\x00\x04' '\x4a\xbe\x68\xe1' \ - '\xf8\xcd\x82\x6c' '\xf9\x4d\xd2\x10' + self.req_bin_0 = b'\x3d\x01\x00\x04' b'\x64\x26\x3d\x94' \ + b'\xf7\x24\xb4\xb3' b'\xce\x5f\xac\x7f' def testPackRequest0(self): bin = request.ClearArea._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ClearArea._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestCopyArea(EndianTest): def setUp(self): self.req_args_0 = { - 'src_drawable': 321720617, - 'dst_drawable': 252019697, - 'src_y': -8372, - 'src_x': -25544, - 'gc': 126071392, - 'width': 49414, - 'height': 61502, - 'dst_x': -19068, - 'dst_y': -4602, - } - self.req_bin_0 = '\x3e\x00\x00\x07' '\x13\x2d\x11\x29' \ - '\x0f\x05\x83\xf1' '\x07\x83\xb2\x60' \ - '\x9c\x38\xdf\x4c' '\xb5\x84\xee\x06' \ - '\xc1\x06\xf0\x3e' + 'dst_drawable': 1578589574, + 'dst_x': -27552, + 'dst_y': -6968, + 'gc': 1741136437, + 'height': 7340, + 'src_drawable': 1855628899, + 'src_x': -24637, + 'src_y': -24026, + 'width': 46214, + } + self.req_bin_0 = b'\x3e\x00\x00\x07' b'\x6e\x9a\xa6\x63' \ + b'\x5e\x17\x5d\x86' b'\x67\xc7\xa2\x35' \ + b'\x9f\xc3\xa2\x26' b'\x94\x60\xe4\xc8' \ + b'\xb4\x86\x1c\xac' def testPackRequest0(self): bin = request.CopyArea._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyArea._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestCopyPlane(EndianTest): def setUp(self): self.req_args_0 = { - 'src_drawable': 1988650265, - 'bit_plane': 2052065832, - 'dst_drawable': 2120887972, - 'src_y': -22401, - 'src_x': -4542, - 'gc': 1266180573, - 'width': 41241, - 'height': 33787, - 'dst_x': -24940, - 'dst_y': -13009, - } - self.req_bin_0 = '\x3f\x00\x00\x08' '\x76\x88\x65\x19' \ - '\x7e\x6a\x2e\xa4' '\x4b\x78\x61\xdd' \ - '\xee\x42\xa8\x7f' '\x9e\x94\xcd\x2f' \ - '\xa1\x19\x83\xfb' '\x7a\x50\x0a\x28' + 'bit_plane': 988559210, + 'dst_drawable': 1873029448, + 'dst_x': -25480, + 'dst_y': -26229, + 'gc': 83225989, + 'height': 60447, + 'src_drawable': 821567629, + 'src_x': -4634, + 'src_y': -17345, + 'width': 53771, + } + self.req_bin_0 = b'\x3f\x00\x00\x08' b'\x30\xf8\x20\x8d' \ + b'\x6f\xa4\x29\x48' b'\x04\xf5\xed\x85' \ + b'\xed\xe6\xbc\x3f' b'\x9c\x78\x99\x8b' \ + b'\xd2\x0b\xec\x1f' b'\x3a\xec\x37\x6a' def testPackRequest0(self): bin = request.CopyPlane._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyPlane._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestPolyPoint(EndianTest): def setUp(self): self.req_args_0 = { - 'gc': 206266633, - 'points': [{'x': -22449, 'y': -16714}, {'x': -16465, 'y': -12850}, {'x': -19616, 'y': -13131}], - 'drawable': 1008674, - 'coord_mode': 1, + 'coord_mode': 0, + 'drawable': 50884525, + 'gc': 1417476013, + 'points': [{'y': -22768, 'x': -21311}, {'y': -6707, 'x': -5881}, {'y': -25311, 'x': -4217}], } - self.req_bin_0 = '\x40\x01\x00\x06' '\x00\x0f\x64\x22' \ - '\x0c\x4b\x61\x09' '\xa8\x4f\xbe\xb6' \ - '\xbf\xaf\xcd\xce' '\xb3\x60\xcc\xb5' + self.req_bin_0 = b'\x40\x00\x00\x06' b'\x03\x08\x6f\xad' \ + b'\x54\x7c\xf7\xad' b'\xac\xc1\xa7\x10' \ + b'\xe9\x07\xe5\xcd' b'\xef\x87\x9d\x21' def testPackRequest0(self): bin = request.PolyPoint._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyPoint._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestPolyLine(EndianTest): def setUp(self): self.req_args_0 = { - 'gc': 1355594189, - 'points': [{'x': -11743, 'y': -18781}, {'x': -21373, 'y': -22722}, {'x': -17579, 'y': -13699}, {'x': -26545, 'y': -19353}, {'x': -11779, 'y': -26488}], - 'drawable': 1668889192, 'coord_mode': 1, + 'drawable': 1459319574, + 'gc': 2107068434, + 'points': [{'y': -19712, 'x': -26440}, {'y': -23639, 'x': -22012}, {'y': -30494, 'x': -4445}, {'y': -7428, 'x': -1085}, {'y': -21262, 'x': -23622}], } - self.req_bin_0 = '\x41\x01\x00\x08' '\x63\x79\x3a\x68' \ - '\x50\xcc\xb9\xcd' '\xd2\x21\xb6\xa3' \ - '\xac\x83\xa7\x3e' '\xbb\x55\xca\x7d' \ - '\x98\x4f\xb4\x67' '\xd1\xfd\x98\x88' + self.req_bin_0 = b'\x41\x01\x00\x08' b'\x56\xfb\x73\x16' \ + b'\x7d\x97\x50\x12' b'\x98\xb8\xb3\x00' \ + b'\xaa\x04\xa3\xa9' b'\xee\xa3\x88\xe2' \ + b'\xfb\xc3\xe2\xfc' b'\xa3\xba\xac\xf2' def testPackRequest0(self): bin = request.PolyLine._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyLine._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestPolySegment(EndianTest): def setUp(self): self.req_args_0 = { - 'segments': [{'y1': -24252, 'y2': -22523, 'x1': -12610, 'x2': -25770}], - 'drawable': 146511635, - 'gc': 53385255, + 'drawable': 59337240, + 'gc': 247760051, + 'segments': [{'y1': -15198, 'x2': -21917, 'x1': -5123, 'y2': -1992}], } - self.req_bin_0 = '\x42\x00\x00\x05' '\x08\xbb\x97\x13' \ - '\x03\x2e\x98\x27' '\xce\xbe\xa1\x44' \ - '\x9b\x56\xa8\x05' + self.req_bin_0 = b'\x42\x00\x00\x05' b'\x03\x89\x6a\x18' \ + b'\x0e\xc4\x84\xb3' b'\xeb\xfd\xc4\xa2' \ + b'\xaa\x63\xf8\x38' def testPackRequest0(self): bin = request.PolySegment._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolySegment._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestPolyRectangle(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 1927481661, - 'gc': 410140275, - 'rectangles': [{'height': 63567, 'x': -16992, 'width': 11122, 'y': -21320}, {'height': 34652, 'x': -18051, 'width': 59622, 'y': -30426}, {'height': 45646, 'x': -1111, 'width': 46231, 'y': -25261}], + 'drawable': 742422946, + 'gc': 1564604140, + 'rectangles': [{'y': -970, 'x': -4030, 'height': 11958, 'width': 17374}, {'y': -1228, 'x': -13744, 'height': 17653, 'width': 64713}, {'y': -29216, 'x': -31515, 'height': 28735, 'width': 39352}], } - self.req_bin_0 = '\x43\x00\x00\x09' '\x72\xe3\x09\x3d' \ - '\x18\x72\x3e\x73' '\xbd\xa0\xac\xb8' \ - '\x2b\x72\xf8\x4f' '\xb9\x7d\x89\x26' \ - '\xe8\xe6\x87\x5c' '\xfb\xa9\x9d\x53' \ - '\xb4\x97\xb2\x4e' + self.req_bin_0 = b'\x43\x00\x00\x09' b'\x2c\x40\x79\xa2' \ + b'\x5d\x41\xf6\xec' b'\xf0\x42\xfc\x36' \ + b'\x43\xde\x2e\xb6' b'\xca\x50\xfb\x34' \ + b'\xfc\xc9\x44\xf5' b'\x84\xe5\x8d\xe0' \ + b'\x99\xb8\x70\x3f' def testPackRequest0(self): bin = request.PolyRectangle._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestPolyArc(EndianTest): def setUp(self): self.req_args_0 = { - 'arcs': [{'height': 37549, 'angle1': -16979, 'x': -4943, 'angle2': -25650, 'width': 65448, 'y': -9205}, {'height': 9322, 'angle1': -20781, 'x': -13865, 'angle2': -8498, 'width': 62173, 'y': -22862}, {'height': 63266, 'angle1': -1231, 'x': -12693, 'angle2': -809, 'width': 63732, 'y': -7550}], - 'drawable': 718777148, - 'gc': 1127021391, + 'arcs': [{'height': 39984, 'width': 28855, 'angle1': -517, 'angle2': -16010, 'y': -22490, 'x': -6999}, {'height': 38043, 'width': 59205, 'angle1': -26540, 'angle2': -24422, 'y': -20146, 'x': -28979}, {'height': 366, 'width': 28833, 'angle1': -15732, 'angle2': -2439, 'y': -9543, 'x': -31314}], + 'drawable': 1732034432, + 'gc': 1156382390, } - self.req_bin_0 = '\x44\x00\x00\x0c' '\x2a\xd7\xab\x3c' \ - '\x43\x2c\xfb\x4f' '\xec\xb1\xdc\x0b' \ - '\xff\xa8\x92\xad' '\xbd\xad\x9b\xce' \ - '\xc9\xd7\xa6\xb2' '\xf2\xdd\x24\x6a' \ - '\xae\xd3\xde\xce' '\xce\x6b\xe2\x82' \ - '\xf8\xf4\xf7\x22' '\xfb\x31\xfc\xd7' + self.req_bin_0 = b'\x44\x00\x00\x0c' b'\x67\x3c\xbf\x80' \ + b'\x44\xec\xfe\xb6' b'\xe4\xa9\xa8\x26' \ + b'\x70\xb7\x9c\x30' b'\xfd\xfb\xc1\x76' \ + b'\x8e\xcd\xb1\x4e' b'\xe7\x45\x94\x9b' \ + b'\x98\x54\xa0\x9a' b'\x85\xae\xda\xb9' \ + b'\x70\xa1\x01\x6e' b'\xc2\x8c\xf6\x79' def testPackRequest0(self): bin = request.PolyArc._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyArc._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestFillPoly(EndianTest): def setUp(self): self.req_args_0 = { - 'shape': 1, - 'gc': 1070496026, - 'points': [{'x': -18749, 'y': -19415}, {'x': -8904, 'y': -26948}, {'x': -13336, 'y': -9462}], - 'drawable': 1326525185, 'coord_mode': 0, + 'drawable': 423195261, + 'gc': 782225195, + 'points': [{'y': -9194, 'x': -10262}, {'y': -8456, 'x': -1958}, {'y': -10793, 'x': -8617}], + 'shape': 1, } - self.req_bin_0 = '\x45\x00\x00\x07' '\x4f\x11\x2b\x01' \ - '\x3f\xce\x79\x1a' '\x01\x00\x00\x00' \ - '\xb6\xc3\xb4\x29' '\xdd\x38\x96\xbc' \ - '\xcb\xe8\xdb\x0a' + self.req_bin_0 = b'\x45\x00\x00\x07' b'\x19\x39\x72\x7d' \ + b'\x2e\x9f\xcf\x2b' b'\x01\x00\x00\x00' \ + b'\xd7\xea\xdc\x16' b'\xf8\x5a\xde\xf8' \ + b'\xde\x57\xd5\xd7' def testPackRequest0(self): bin = request.FillPoly._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FillPoly._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestPolyFillRectangle(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 1708671692, - 'gc': 1965498255, - 'rectangles': [{'height': 36920, 'x': -2965, 'width': 26437, 'y': -3568}, {'height': 44383, 'x': -18327, 'width': 37730, 'y': -26752}], + 'drawable': 267696363, + 'gc': 1545726032, + 'rectangles': [{'y': -11003, 'x': -1676, 'height': 21895, 'width': 60599}, {'y': -22482, 'x': -12349, 'height': 55831, 'width': 43731}], } - self.req_bin_0 = '\x46\x00\x00\x07' '\x65\xd8\x42\xcc' \ - '\x75\x27\x1f\x8f' '\xf4\x6b\xf2\x10' \ - '\x67\x45\x90\x38' '\xb8\x69\x97\x80' \ - '\x93\x62\xad\x5f' + self.req_bin_0 = b'\x46\x00\x00\x07' b'\x0f\xf4\xb8\xeb' \ + b'\x5c\x21\xe8\x50' b'\xf9\x74\xd5\x05' \ + b'\xec\xb7\x55\x87' b'\xcf\xc3\xa8\x2e' \ + b'\xaa\xd3\xda\x17' def testPackRequest0(self): bin = request.PolyFillRectangle._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyFillRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestPolyFillArc(EndianTest): def setUp(self): self.req_args_0 = { - 'arcs': [{'height': 64114, 'angle1': -28360, 'x': -10754, 'angle2': -6712, 'width': 53819, 'y': -19555}], - 'drawable': 2083870696, - 'gc': 414470877, + 'arcs': [{'height': 20525, 'width': 33490, 'angle1': -10916, 'angle2': -19386, 'y': -22928, 'x': -3276}], + 'drawable': 700537986, + 'gc': 864213787, } - self.req_bin_0 = '\x47\x00\x00\x06' '\x7c\x35\x57\xe8' \ - '\x18\xb4\x52\xdd' '\xd5\xfe\xb3\x9d' \ - '\xd2\x3b\xfa\x72' '\x91\x38\xe5\xc8' + self.req_bin_0 = b'\x47\x00\x00\x06' b'\x29\xc1\x5c\x82' \ + b'\x33\x82\xdb\x1b' b'\xf3\x34\xa6\x70' \ + b'\x82\xd2\x50\x2d' b'\xd5\x5c\xb4\x46' def testPackRequest0(self): bin = request.PolyFillArc._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyFillArc._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestPutImage(EndianTest): def setUp(self): self.req_args_0 = { - 'height': 9883, 'data': 'bit map data', - 'drawable': 1534678783, - 'left_pad': 147, - 'format': 1, - 'dst_x': -3284, - 'gc': 209913475, - 'depth': 173, - 'width': 62850, - 'dst_y': -30693, - } - self.req_bin_0 = '\x48\x01\x00\x09' '\x5b\x79\x56\xff' \ - '\x0c\x83\x06\x83' '\xf5\x82\x26\x9b' \ - '\xf3\x2c\x88\x1b' '\x93\xad\x00\x00' \ - '\x62\x69\x74\x20' '\x6d\x61\x70\x20' \ - '\x64\x61\x74\x61' + 'depth': 172, + 'drawable': 634980240, + 'dst_x': -18991, + 'dst_y': -10980, + 'format': 2, + 'gc': 1190657277, + 'height': 12828, + 'left_pad': 225, + 'width': 8597, + } + self.req_bin_0 = b'\x48\x02\x00\x09' b'\x25\xd9\x07\x90' \ + b'\x46\xf7\xfc\xfd' b'\x21\x95\x32\x1c' \ + b'\xb5\xd1\xd5\x1c' b'\xe1\xac\x00\x00' \ + b'\x62\x69\x74\x20' b'\x6d\x61\x70\x20' \ + b'\x64\x61\x74\x61' def testPackRequest0(self): bin = request.PutImage._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PutImage._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGetImage(EndianTest): def setUp(self): self.req_args_0 = { - 'height': 42657, - 'plane_mask': 1756278272, - 'drawable': 1329487747, - 'x': -27672, - 'y': -30859, - 'format': 1, - 'width': 58993, - } - self.req_bin_0 = '\x49\x01\x00\x05' '\x4f\x3e\x5f\x83' \ - '\x93\xe8\x87\x75' '\xe6\x71\xa6\xa1' \ - '\x68\xae\xae\x00' + 'drawable': 872105322, + 'format': 2, + 'height': 20170, + 'plane_mask': 616208054, + 'width': 282, + 'x': -14814, + 'y': -5449, + } + self.req_bin_0 = b'\x49\x02\x00\x05' b'\x33\xfb\x45\x6a' \ + b'\xc6\x22\xea\xb7' b'\x01\x1a\x4e\xca' \ + b'\x24\xba\x96\xb6' self.reply_args_0 = { - 'sequence_number': 54997, 'data': 'this is real ly imag e b-map', - 'visual': 1108632607, 'depth': 181, + 'sequence_number': 28429, + 'visual': 1687469773, } - self.reply_bin_0 = '\x01\xb5\xd6\xd5' '\x00\x00\x00\x07' \ - '\x42\x14\x64\x1f' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x74\x68\x69\x73' '\x20\x69\x73\x20' \ - '\x72\x65\x61\x6c' '\x20\x6c\x79\x20' \ - '\x69\x6d\x61\x67' '\x20\x65\x20\x62' \ - '\x2d\x6d\x61\x70' + self.reply_bin_0 = b'\x01\xb5\x6f\x0d' b'\x00\x00\x00\x07' \ + b'\x64\x94\xbe\xcd' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x74\x68\x69\x73' b'\x20\x69\x73\x20' \ + b'\x72\x65\x61\x6c' b'\x20\x6c\x79\x20' \ + b'\x69\x6d\x61\x67' b'\x20\x65\x20\x62' \ + b'\x2d\x6d\x61\x70' def testPackRequest0(self): bin = request.GetImage._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetImage._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetImage._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetImage._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestPolyText8(EndianTest): def setUp(self): self.req_args_0 = { - 'gc': 1481564777, - 'x': -13548, - 'drawable': 1550998666, - 'items': [{'delta': 2, 'string': 'zoo'}, 16909060, {'delta': 0, 'string': 'ie'}], - 'y': -8902, + 'drawable': 1245573363, + 'gc': 1302861330, + 'items': [{'string': 'zoo', 'delta': 2}, 16909060, {'string': 'ie', 'delta': 0}], + 'x': -11315, + 'y': -22209, } - self.req_bin_0 = '\x4a\x00\x00\x08' '\x5c\x72\x5c\x8a' \ - '\x58\x4e\xe2\x69' '\xcb\x14\xdd\x3a' \ - '\x03\x02\x7a\x6f' '\x6f\xff\x01\x02' \ - '\x03\x04\x02\x00' '\x69\x65\x00\x00' + self.req_bin_0 = b'\x4a\x00\x00\x08' b'\x4a\x3d\xf0\xf3' \ + b'\x4d\xa8\x16\x12' b'\xd3\xcd\xa9\x3f' \ + b'\x03\x02\x7a\x6f' b'\x6f\xff\x01\x02' \ + b'\x03\x04\x02\x00' b'\x69\x65\x00\x00' def testPackRequest0(self): bin = request.PolyText8._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyText8._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestPolyText16(EndianTest): def setUp(self): self.req_args_0 = { - 'gc': 400697368, - 'x': -31614, - 'drawable': 1591407092, - 'items': [{'delta': 2, 'string': (4131, 18)}, 16909060], - 'y': -2741, + 'drawable': 998620068, + 'gc': 948793778, + 'items': [{'string': (4131, 18), 'delta': 2}, 16909060], + 'x': -18280, + 'y': -10630, } - self.req_bin_0 = '\x4b\x00\x00\x07' '\x5e\xda\xf1\xf4' \ - '\x17\xe2\x28\x18' '\x84\x82\xf5\x4b' \ - '\x02\x02\x10\x23' '\x00\x12\xff\x01' \ - '\x02\x03\x04\x00' + self.req_bin_0 = b'\x4b\x00\x00\x07' b'\x3b\x85\xbb\xa4' \ + b'\x38\x8d\x71\xb2' b'\xb8\x98\xd6\x7a' \ + b'\x02\x02\x10\x23' b'\x00\x12\xff\x01' \ + b'\x02\x03\x04\x00' def testPackRequest0(self): bin = request.PolyText16._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.PolyText16._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestImageText8(EndianTest): def setUp(self): self.req_args_0 = { + 'drawable': 458985805, + 'gc': 1097803335, 'string': 'showme', - 'gc': 1393590305, - 'drawable': 1823595869, - 'x': -16077, - 'y': -4873, + 'x': -17263, + 'y': -6759, } - self.req_bin_0 = '\x4c\x06\x00\x06' '\x6c\xb1\xdd\x5d' \ - '\x53\x10\x80\x21' '\xc1\x33\xec\xf7' \ - '\x73\x68\x6f\x77' '\x6d\x65\x00\x00' + self.req_bin_0 = b'\x4c\x06\x00\x06' b'\x1b\x5b\x91\x4d' \ + b'\x41\x6f\x26\x47' b'\xbc\x91\xe5\x99' \ + b'\x73\x68\x6f\x77' b'\x6d\x65\x00\x00' def testPackRequest0(self): bin = request.ImageText8._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ImageText8._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestImageText16(EndianTest): def setUp(self): self.req_args_0 = { + 'drawable': 1935336610, + 'gc': 2061289059, 'string': (115, 104, 111, 119, 109, 111, 114, 101), - 'gc': 1702299870, - 'drawable': 33607184, - 'x': -21343, - 'y': -24237, + 'x': -6684, + 'y': -8653, } - self.req_bin_0 = '\x4d\x08\x00\x08' '\x02\x00\xce\x10' \ - '\x65\x77\x08\xde' '\xac\xa1\xa1\x53' \ - '\x00\x73\x00\x68' '\x00\x6f\x00\x77' \ - '\x00\x6d\x00\x6f' '\x00\x72\x00\x65' + self.req_bin_0 = b'\x4d\x08\x00\x08' b'\x73\x5a\xe4\xa2' \ + b'\x7a\xdc\xc6\x63' b'\xe5\xe4\xde\x33' \ + b'\x00\x73\x00\x68' b'\x00\x6f\x00\x77' \ + b'\x00\x6d\x00\x6f' b'\x00\x72\x00\x65' def testPackRequest0(self): bin = request.ImageText16._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ImageText16._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestCreateColormap(EndianTest): def setUp(self): self.req_args_0 = { - 'mid': 157536683, 'alloc': 0, - 'visual': 813982403, - 'window': 698475631, + 'mid': 1414936748, + 'visual': 609492200, + 'window': 182162564, } - self.req_bin_0 = '\x4e\x00\x00\x04' '\x09\x63\xd1\xab' \ - '\x29\xa1\xe4\x6f' '\x30\x84\x62\xc3' + self.req_bin_0 = b'\x4e\x00\x00\x04' b'\x54\x56\x38\xac' \ + b'\x0a\xdb\x94\x84' b'\x24\x54\x1c\xe8' def testPackRequest0(self): bin = request.CreateColormap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestFreeColormap(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 1296514923, + 'cmap': 1106990292, } - self.req_bin_0 = '\x4f\x00\x00\x02' '\x4d\x47\x3f\x6b' + self.req_bin_0 = b'\x4f\x00\x00\x02' b'\x41\xfb\x54\xd4' def testPackRequest0(self): bin = request.FreeColormap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestCopyColormapAndFree(EndianTest): def setUp(self): self.req_args_0 = { - 'src_cmap': 1049336329, - 'mid': 1237242690, + 'mid': 1425680795, + 'src_cmap': 1359295675, } - self.req_bin_0 = '\x50\x00\x00\x03' '\x49\xbe\xd3\x42' \ - '\x3e\x8b\x9a\x09' + self.req_bin_0 = b'\x50\x00\x00\x03' b'\x54\xfa\x29\x9b' \ + b'\x51\x05\x34\xbb' def testPackRequest0(self): bin = request.CopyColormapAndFree._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CopyColormapAndFree._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestInstallColormap(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 1539075582, + 'cmap': 1329917990, } - self.req_bin_0 = '\x51\x00\x00\x02' '\x5b\xbc\x6d\xfe' + self.req_bin_0 = b'\x51\x00\x00\x02' b'\x4f\x44\xf0\x26' def testPackRequest0(self): bin = request.InstallColormap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.InstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestUninstallColormap(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 959493342, + 'cmap': 719876845, } - self.req_bin_0 = '\x52\x00\x00\x02' '\x39\x30\xb4\xde' + self.req_bin_0 = b'\x52\x00\x00\x02' b'\x2a\xe8\x72\xed' def testPackRequest0(self): bin = request.UninstallColormap._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.UninstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestListInstalledColormaps(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1517864638, + 'window': 200613013, } - self.req_bin_0 = '\x53\x00\x00\x02' '\x5a\x78\xc6\xbe' + self.req_bin_0 = b'\x53\x00\x00\x02' b'\x0b\xf5\x1c\x95' self.reply_args_0 = { - 'cmaps': [2146327722, 1361260227], - 'sequence_number': 61652, + 'cmaps': [1757616530, 2044469232], + 'sequence_number': 49482, } - self.reply_bin_0 = '\x01\x00\xf0\xd4' '\x00\x00\x00\x02' \ - '\x00\x02\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x7f\xee\x5c\xaa' '\x51\x23\x2e\xc3' + self.reply_bin_0 = b'\x01\x00\xc1\x4a' b'\x00\x00\x00\x02' \ + b'\x00\x02\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x68\xc3\x19\x92' b'\x79\xdc\x1f\xf0' def testPackRequest0(self): bin = request.ListInstalledColormaps._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListInstalledColormaps._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListInstalledColormaps._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListInstalledColormaps._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestAllocColor(EndianTest): def setUp(self): self.req_args_0 = { - 'red': 39725, - 'green': 49854, - 'cmap': 523356125, - 'blue': 49580, + 'blue': 14978, + 'cmap': 504442007, + 'green': 20599, + 'red': 44348, } - self.req_bin_0 = '\x54\x00\x00\x04' '\x1f\x31\xc7\xdd' \ - '\x9b\x2d\xc2\xbe' '\xc1\xac\x00\x00' + self.req_bin_0 = b'\x54\x00\x00\x04' b'\x1e\x11\x2c\x97' \ + b'\xad\x3c\x50\x77' b'\x3a\x82\x00\x00' self.reply_args_0 = { - 'sequence_number': 10904, - 'red': 43784, - 'green': 3170, - 'pixel': 1067923656, - 'blue': 14525, + 'blue': 1856, + 'green': 9912, + 'pixel': 99308744, + 'red': 13306, + 'sequence_number': 53114, } - self.reply_bin_0 = '\x01\x00\x2a\x98' '\x00\x00\x00\x00' \ - '\xab\x08\x0c\x62' '\x38\xbd\x00\x00' \ - '\x3f\xa7\x38\xc8' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\xcf\x7a' b'\x00\x00\x00\x00' \ + b'\x33\xfa\x26\xb8' b'\x07\x40\x00\x00' \ + b'\x05\xeb\x54\xc8' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.AllocColor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocColor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocColor._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestAllocNamedColor(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 128217824, + 'cmap': 525860889, 'name': 'octarin', } - self.req_bin_0 = '\x55\x00\x00\x05' '\x07\xa4\x72\xe0' \ - '\x00\x07\x00\x00' '\x6f\x63\x74\x61' \ - '\x72\x69\x6e\x00' + self.req_bin_0 = b'\x55\x00\x00\x05' b'\x1f\x58\x00\x19' \ + b'\x00\x07\x00\x00' b'\x6f\x63\x74\x61' \ + b'\x72\x69\x6e\x00' self.reply_args_0 = { - 'sequence_number': 19971, - 'pixel': 1324239222, - 'screen_green': 50499, - 'screen_red': 33379, - 'exact_green': 29067, - 'exact_blue': 58811, - 'screen_blue': 43109, - 'exact_red': 64213, + 'exact_blue': 50619, + 'exact_green': 55944, + 'exact_red': 40316, + 'pixel': 1020413057, + 'screen_blue': 27416, + 'screen_green': 30102, + 'screen_red': 5028, + 'sequence_number': 64739, } - self.reply_bin_0 = '\x01\x00\x4e\x03' '\x00\x00\x00\x00' \ - '\x4e\xee\x49\x76' '\xfa\xd5\x71\x8b' \ - '\xe5\xbb\x82\x63' '\xc5\x43\xa8\x65' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\xfc\xe3' b'\x00\x00\x00\x00' \ + b'\x3c\xd2\x44\x81' b'\x9d\x7c\xda\x88' \ + b'\xc5\xbb\x13\xa4' b'\x75\x96\x6b\x18' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.AllocNamedColor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocNamedColor._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocNamedColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestAllocColorCells(EndianTest): def setUp(self): self.req_args_0 = { - 'planes': 32867, - 'colors': 58698, - 'cmap': 675372338, - 'contiguous': 1, + 'cmap': 1542701632, + 'colors': 45892, + 'contiguous': 0, + 'planes': 25420, } - self.req_bin_0 = '\x56\x01\x00\x03' '\x28\x41\x5d\x32' \ - '\xe5\x4a\x80\x63' + self.req_bin_0 = b'\x56\x00\x00\x03' b'\x5b\xf3\xc2\x40' \ + b'\xb3\x44\x63\x4c' self.reply_args_0 = { - 'masks': [733927381, 1023311668, 595898647], - 'pixels': [693075497, 1294879029, 1478712895, 1781963728, 1442185575, 1654003869, 787619123, 1049825849, 1773935772, 1689075922, 1626562257, 177731275, 661046122, 1970509470, 1918486395, 688539096, 41044851], - 'sequence_number': 54025, - } - self.reply_bin_0 = '\x01\x00\xd3\x09' '\x00\x00\x00\x14' \ - '\x00\x11\x00\x03' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x29\x4f\x7e\x29' '\x4d\x2e\x49\x35' \ - '\x58\x23\x5e\x3f' '\x6a\x36\x9b\xd0' \ - '\x55\xf6\x01\x67' '\x62\x96\x18\x9d' \ - '\x2e\xf2\x1d\x33' '\x3e\x93\x12\x39' \ - '\x69\xbc\x1c\x9c' '\x64\xad\x40\xd2' \ - '\x60\xf3\x5e\xd1' '\x0a\x97\xf6\xcb' \ - '\x27\x66\xc3\x6a' '\x75\x73\x96\x9e' \ - '\x72\x59\xc7\x7b' '\x29\x0a\x45\xd8' \ - '\x02\x72\x4b\x73' '\x2b\xbe\xd7\xd5' \ - '\x3c\xfe\x7f\x34' '\x23\x84\xb1\x17' + 'masks': [1726878301, 2057281944, 1494524694], + 'pixels': [1061732426, 858313521, 524018138, 316972578, 1408939380, 1476723430, 11972931, 1917037904, 1612749468, 1847847580, 1653727126, 1901587588, 228960010, 1671710636, 913060041, 470023299, 377779303], + 'sequence_number': 34200, + } + self.reply_bin_0 = b'\x01\x00\x85\x98' b'\x00\x00\x00\x14' \ + b'\x00\x11\x00\x03' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x3f\x48\xc0\x4a' b'\x33\x28\xd3\x31' \ + b'\x1f\x3b\xe1\xda' b'\x12\xe4\x9e\x22' \ + b'\x53\xfa\xb5\x74' b'\x58\x05\x02\xe6' \ + b'\x00\xb6\xb1\x43' b'\x72\x43\xad\x50' \ + b'\x60\x20\x9a\x9c' b'\x6e\x23\xea\x9c' \ + b'\x62\x91\xdf\x96' b'\x71\x57\xec\x84' \ + b'\x0d\xa5\xa7\x0a' b'\x63\xa4\x47\xac' \ + b'\x36\x6c\x30\xc9' b'\x1c\x03\xfc\x83' \ + b'\x16\x84\x74\x67' b'\x66\xee\x12\x5d' \ + b'\x7a\x9f\xa1\x98' b'\x59\x14\xa3\x16' self.reply_args_1 = { 'masks': [], 'pixels': [], - 'sequence_number': 6273, + 'sequence_number': 30700, } - self.reply_bin_1 = '\x01\x00\x18\x81' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_1 = b'\x01\x00\x77\xec' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.AllocColorCells._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocColorCells._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocColorCells._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) def testPackReply1(self): bin = request.AllocColorCells._reply.to_binary(*(), **self.reply_args_1) - try: - assert bin == self.reply_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_1) def testUnpackReply1(self): args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_1) class TestAllocColorPlanes(EndianTest): def setUp(self): self.req_args_0 = { - 'red': 22876, - 'colors': 58275, - 'green': 9425, - 'cmap': 308019811, + 'blue': 8209, + 'cmap': 1197085372, + 'colors': 16587, 'contiguous': 0, - 'blue': 23880, + 'green': 55852, + 'red': 60383, } - self.req_bin_0 = '\x57\x00\x00\x04' '\x12\x5c\x02\x63' \ - '\xe3\xa3\x59\x5c' '\x24\xd1\x5d\x48' + self.req_bin_0 = b'\x57\x00\x00\x04' b'\x47\x5a\x12\xbc' \ + b'\x40\xcb\xeb\xdf' b'\xda\x2c\x20\x11' self.reply_args_0 = { - 'green_mask': 265888391, - 'sequence_number': 36175, - 'pixels': [491961865, 1301906366, 1604705021, 1418751120], - 'blue_mask': 44676180, - 'red_mask': 734623206, + 'blue_mask': 1200348460, + 'green_mask': 2121548418, + 'pixels': [980309855, 286409072, 1721094583, 997879295], + 'red_mask': 1140662566, + 'sequence_number': 44006, } - self.reply_bin_0 = '\x01\x00\x8d\x4f' '\x00\x00\x00\x04' \ - '\x00\x04\x00\x00' '\x2b\xc9\x75\xe6' \ - '\x0f\xd9\x22\x87' '\x02\xa9\xb4\x54' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x1d\x52\xbe\x09' '\x4d\x99\x83\xbe' \ - '\x5f\xa5\xda\xfd' '\x54\x90\x6c\x90' + self.reply_bin_0 = b'\x01\x00\xab\xe6' b'\x00\x00\x00\x04' \ + b'\x00\x04\x00\x00' b'\x43\xfd\x21\x26' \ + b'\x7e\x74\x42\x82' b'\x47\x8b\xdd\x2c' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x3a\x6e\x57\x5f' b'\x11\x12\x41\x70' \ + b'\x66\x95\xd1\xb7' b'\x3b\x7a\x6d\xff' def testPackRequest0(self): bin = request.AllocColorPlanes._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.AllocColorPlanes._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.AllocColorPlanes._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.AllocColorPlanes._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestFreeColors(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 727008216, - 'pixels': [61281082, 398475082, 1660604639, 1516738417, 1211104329, 105034864, 884930615, 902914796, 288637231, 2097165249, 1171127263, 1027274519, 806213035, 1485898709, 542709465, 169067149, 1230881159], - 'plane_mask': 1204733200, - } - self.req_bin_0 = '\x58\x00\x00\x14' '\x2b\x55\x43\xd8' \ - '\x47\xce\xc5\x10' '\x03\xa7\x13\x3a' \ - '\x17\xc0\x3f\x4a' '\x62\xfa\xd0\xdf' \ - '\x5a\x67\x97\x71' '\x48\x2f\xfc\x49' \ - '\x06\x42\xb4\x70' '\x34\xbe\xf8\x37' \ - '\x35\xd1\x62\xec' '\x11\x34\x41\x2f' \ - '\x7d\x00\x33\xc1' '\x45\xcd\xfb\xdf' \ - '\x3d\x3a\xf7\x17' '\x30\x0d\xd5\xab' \ - '\x58\x91\x03\xd5' '\x20\x59\x16\xd9' \ - '\x0a\x13\xc2\x8d' '\x49\x5d\xc1\x87' + 'cmap': 341854532, + 'pixels': [1278789650, 681457705, 2040260049, 1621952585, 1914388136, 950484730, 1315726377, 1750278681, 1544694596, 1915664535, 1084068385, 916484334, 1783699241, 1947521244, 1176611597, 957657715, 1926805276], + 'plane_mask': 1597053435, + } + self.req_bin_0 = b'\x58\x00\x00\x14' b'\x14\x60\x49\x44' \ + b'\x5f\x31\x19\xfb' b'\x4c\x38\xc8\x12' \ + b'\x28\x9e\x38\x29' b'\x79\x9b\xe5\xd1' \ + b'\x60\xad\x08\x49' b'\x72\x1b\x3e\xa8' \ + b'\x38\xa7\x3e\xfa' b'\x4e\x6c\x64\x29' \ + b'\x68\x53\x22\x19' b'\x5c\x12\x2b\x44' \ + b'\x72\x2e\xb8\x97' b'\x40\x9d\x92\x21' \ + b'\x36\xa0\x70\xee' b'\x6a\x51\x17\x29' \ + b'\x74\x14\xd0\xdc' b'\x46\x21\xab\x0d' \ + b'\x39\x14\xb2\x73' b'\x72\xd8\xb7\x1c' def testPackRequest0(self): bin = request.FreeColors._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeColors._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestStoreColors(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 501035281, - 'items': [{'red': 27925, 'pixel': 1094971765, 'green': 3673, 'flags': 189, 'blue': 31593}, {'red': 41633, 'pixel': 1330003189, 'green': 56186, 'flags': 178, 'blue': 30263}, {'red': 36007, 'pixel': 1813524037, 'green': 29697, 'flags': 224, 'blue': 14071}, {'red': 45716, 'pixel': 1987610486, 'green': 55405, 'flags': 200, 'blue': 35734}], + 'cmap': 686636594, + 'items': [{'blue': 17242, 'flags': 191, 'green': 29751, 'pixel': 1850111768, 'red': 31364}, {'blue': 50444, 'flags': 252, 'green': 18429, 'pixel': 1803657350, 'red': 42045}, {'blue': 29083, 'flags': 147, 'green': 18252, 'pixel': 1345997556, 'red': 15935}, {'blue': 18063, 'flags': 213, 'green': 15623, 'pixel': 1532391469, 'red': 18981}], } - self.req_bin_0 = '\x59\x00\x00\x0e' '\x1d\xdd\x31\x11' \ - '\x41\x43\xf1\x75' '\x6d\x15\x0e\x59' \ - '\x7b\x69\xbd\x00' '\x4f\x46\x3c\xf5' \ - '\xa2\xa1\xdb\x7a' '\x76\x37\xb2\x00' \ - '\x6c\x18\x2e\x45' '\x8c\xa7\x74\x01' \ - '\x36\xf7\xe0\x00' '\x76\x78\x87\x76' \ - '\xb2\x94\xd8\x6d' '\x8b\x96\xc8\x00' + self.req_bin_0 = b'\x59\x00\x00\x0e' b'\x28\xed\x3e\x32' \ + b'\x6e\x46\x77\x18' b'\x7a\x84\x74\x37' \ + b'\x43\x5a\xbf\x00' b'\x6b\x81\xa0\x86' \ + b'\xa4\x3d\x47\xfd' b'\xc5\x0c\xfc\x00' \ + b'\x50\x3a\x4a\xf4' b'\x3e\x3f\x47\x4c' \ + b'\x71\x9b\x93\x00' b'\x5b\x56\x70\x2d' \ + b'\x4a\x25\x3d\x07' b'\x46\x8f\xd5\x00' def testPackRequest0(self): bin = request.StoreColors._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.StoreColors._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestStoreNamedColor(EndianTest): def setUp(self): self.req_args_0 = { + 'cmap': 297221571, + 'flags': 148, 'name': 'blue', - 'flags': 186, - 'cmap': 2061119590, - 'pixel': 1846011298, + 'pixel': 323971915, } - self.req_bin_0 = '\x5a\xba\x00\x05' '\x7a\xda\x30\x66' \ - '\x6e\x07\xe5\xa2' '\x00\x04\x00\x00' \ - '\x62\x6c\x75\x65' + self.req_bin_0 = b'\x5a\x94\x00\x05' b'\x11\xb7\x3d\xc3' \ + b'\x13\x4f\x6b\x4b' b'\x00\x04\x00\x00' \ + b'\x62\x6c\x75\x65' def testPackRequest0(self): bin = request.StoreNamedColor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.StoreNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestQueryColors(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 596369797, - 'pixels': [1018587496, 1553480933, 952694607, 341816269, 306591348, 1178729919, 173027853, 875811363], + 'cmap': 875378525, + 'pixels': [496695788, 822627561, 1490311416, 328212337, 1517089095, 459525846, 137995944, 890987562], } - self.req_bin_0 = '\x5b\x00\x00\x0a' '\x23\x8b\xe1\x85' \ - '\x3c\xb6\x69\x68' '\x5c\x98\x3c\xe5' \ - '\x38\xc8\xf7\x4f' '\x14\x5f\xb3\xcd' \ - '\x12\x46\x36\x74' '\x46\x41\xfd\xbf' \ - '\x0a\x50\x32\x0d' '\x34\x33\xd2\x23' + self.req_bin_0 = b'\x5b\x00\x00\x0a' b'\x34\x2d\x37\x5d' \ + b'\x1d\x9a\xf9\xec' b'\x31\x08\x4c\xe9' \ + b'\x58\xd4\x58\xf8' b'\x13\x90\x1f\x71' \ + b'\x5a\x6c\xf1\x47' b'\x1b\x63\xce\xd6' \ + b'\x08\x39\xa6\xa8' b'\x35\x1b\x64\x2a' self.reply_args_0 = { - 'colors': [{'red': 6715, 'blue': 40144, 'green': 56664}, {'red': 5799, 'blue': 22078, 'green': 35523}, {'red': 60111, 'blue': 58654, 'green': 25206}, {'red': 7433, 'blue': 60908, 'green': 14468}, {'red': 31213, 'blue': 9298, 'green': 27481}], - 'sequence_number': 60323, - } - self.reply_bin_0 = '\x01\x00\xeb\xa3' '\x00\x00\x00\x0a' \ - '\x00\x05\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x1a\x3b\xdd\x58' '\x9c\xd0\x00\x00' \ - '\x16\xa7\x8a\xc3' '\x56\x3e\x00\x00' \ - '\xea\xcf\x62\x76' '\xe5\x1e\x00\x00' \ - '\x1d\x09\x38\x84' '\xed\xec\x00\x00' \ - '\x79\xed\x6b\x59' '\x24\x52\x00\x00' + 'colors': [{'blue': 27504, 'green': 30790, 'red': 35816}, {'blue': 54840, 'green': 13811, 'red': 4336}, {'blue': 59555, 'green': 25780, 'red': 27790}, {'blue': 62257, 'green': 38534, 'red': 50705}, {'blue': 56402, 'green': 1536, 'red': 45837}], + 'sequence_number': 57970, + } + self.reply_bin_0 = b'\x01\x00\xe2\x72' b'\x00\x00\x00\x0a' \ + b'\x00\x05\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x8b\xe8\x78\x46' b'\x6b\x70\x00\x00' \ + b'\x10\xf0\x35\xf3' b'\xd6\x38\x00\x00' \ + b'\x6c\x8e\x64\xb4' b'\xe8\xa3\x00\x00' \ + b'\xc6\x11\x96\x86' b'\xf3\x31\x00\x00' \ + b'\xb3\x0d\x06\x00' b'\xdc\x52\x00\x00' self.req_args_1 = { - 'cmap': 79317049, + 'cmap': 710627905, 'pixels': [], } - self.req_bin_1 = '\x5b\x00\x00\x02' '\x04\xba\x48\x39' + self.req_bin_1 = b'\x5b\x00\x00\x02' b'\x2a\x5b\x52\x41' def testPackRequest0(self): bin = request.QueryColors._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryColors._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackRequest1(self): bin = request.QueryColors._request.to_binary(*(), **self.req_args_1) - try: - assert bin == self.req_bin_1 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_1) def testUnpackRequest1(self): args, remain = request.QueryColors._request.parse_binary(self.req_bin_1, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_1 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_1) def testPackReply0(self): bin = request.QueryColors._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryColors._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestLookupColor(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 789574750, + 'cmap': 1644167361, 'name': 'octarin', } - self.req_bin_0 = '\x5c\x00\x00\x05' '\x2f\x0f\xf4\x5e' \ - '\x00\x07\x00\x00' '\x6f\x63\x74\x61' \ - '\x72\x69\x6e\x00' + self.req_bin_0 = b'\x5c\x00\x00\x05' b'\x62\x00\x00\xc1' \ + b'\x00\x07\x00\x00' b'\x6f\x63\x74\x61' \ + b'\x72\x69\x6e\x00' self.reply_args_0 = { - 'sequence_number': 21040, - 'screen_green': 65314, - 'screen_red': 51033, - 'exact_green': 59546, - 'exact_blue': 61512, - 'screen_blue': 29893, - 'exact_red': 41875, + 'exact_blue': 642, + 'exact_green': 31515, + 'exact_red': 25184, + 'screen_blue': 19825, + 'screen_green': 23308, + 'screen_red': 62039, + 'sequence_number': 37984, } - self.reply_bin_0 = '\x01\x00\x52\x30' '\x00\x00\x00\x00' \ - '\xa3\x93\xe8\x9a' '\xf0\x48\xc7\x59' \ - '\xff\x22\x74\xc5' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\x94\x60' b'\x00\x00\x00\x00' \ + b'\x62\x60\x7b\x1b' b'\x02\x82\xf2\x57' \ + b'\x5b\x0c\x4d\x71' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.LookupColor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.LookupColor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.LookupColor._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.LookupColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestCreateCursor(EndianTest): def setUp(self): self.req_args_0 = { - 'x': 14199, - 'fore_red': 65323, - 'back_green': 5090, - 'mask': 420188900, - 'back_blue': 49879, - 'y': 32780, - 'cid': 2022028217, - 'fore_blue': 63540, - 'fore_green': 43028, - 'back_red': 31899, - 'source': 794739749, - } - self.req_bin_0 = '\x5d\x00\x00\x08' '\x78\x85\xb3\xb9' \ - '\x2f\x5e\xc4\x25' '\x19\x0b\x92\xe4' \ - '\xff\x2b\xa8\x14' '\xf8\x34\x7c\x9b' \ - '\x13\xe2\xc2\xd7' '\x37\x77\x80\x0c' + 'back_blue': 49245, + 'back_green': 35528, + 'back_red': 27716, + 'cid': 1618141054, + 'fore_blue': 55026, + 'fore_green': 62740, + 'fore_red': 58690, + 'mask': 1832831050, + 'source': 837555484, + 'x': 48400, + 'y': 36047, + } + self.req_bin_0 = b'\x5d\x00\x00\x08' b'\x60\x72\xdf\x7e' \ + b'\x31\xec\x15\x1c' b'\x6d\x3e\xc8\x4a' \ + b'\xe5\x42\xf5\x14' b'\xd6\xf2\x6c\x44' \ + b'\x8a\xc8\xc0\x5d' b'\xbd\x10\x8c\xcf' def testPackRequest0(self): bin = request.CreateCursor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestCreateGlyphCursor(EndianTest): def setUp(self): self.req_args_0 = { - 'fore_red': 56306, - 'source_char': 7568, - 'mask': 2018599719, - 'back_blue': 6500, - 'cid': 1999539964, - 'mask_char': 46124, - 'fore_blue': 30793, - 'fore_green': 16989, - 'back_red': 64484, - 'source': 1412345132, - 'back_green': 52966, - } - self.req_bin_0 = '\x5e\x00\x00\x08' '\x77\x2e\x8e\xfc' \ - '\x54\x2e\xad\x2c' '\x78\x51\x63\x27' \ - '\x1d\x90\xb4\x2c' '\xdb\xf2\x42\x5d' \ - '\x78\x49\xfb\xe4' '\xce\xe6\x19\x64' + 'back_blue': 25740, + 'back_green': 2158, + 'back_red': 32083, + 'cid': 1717769345, + 'fore_blue': 28818, + 'fore_green': 18143, + 'fore_red': 14636, + 'mask': 1928100723, + 'mask_char': 32252, + 'source': 1295540602, + 'source_char': 14709, + } + self.req_bin_0 = b'\x5e\x00\x00\x08' b'\x66\x63\x14\x81' \ + b'\x4d\x38\x61\x7a' b'\x72\xec\x7b\x73' \ + b'\x39\x75\x7d\xfc' b'\x39\x2c\x46\xdf' \ + b'\x70\x92\x7d\x53' b'\x08\x6e\x64\x8c' def testPackRequest0(self): bin = request.CreateGlyphCursor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.CreateGlyphCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestFreeCursor(EndianTest): def setUp(self): self.req_args_0 = { - 'cursor': 553262138, + 'cursor': 721898231, } - self.req_bin_0 = '\x5f\x00\x00\x02' '\x20\xfa\x1c\x3a' + self.req_bin_0 = b'\x5f\x00\x00\x02' b'\x2b\x07\x4a\xf7' def testPackRequest0(self): bin = request.FreeCursor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.FreeCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestRecolorCursor(EndianTest): def setUp(self): self.req_args_0 = { - 'fore_red': 44718, - 'fore_green': 33104, - 'back_blue': 49533, - 'back_green': 12163, - 'fore_blue': 17246, - 'back_red': 64013, - 'cursor': 295995276, + 'back_blue': 55339, + 'back_green': 11072, + 'back_red': 47715, + 'cursor': 1436460699, + 'fore_blue': 26753, + 'fore_green': 52563, + 'fore_red': 44764, } - self.req_bin_0 = '\x60\x00\x00\x05' '\x11\xa4\x87\x8c' \ - '\xae\xae\x81\x50' '\x43\x5e\xfa\x0d' \ - '\x2f\x83\xc1\x7d' + self.req_bin_0 = b'\x60\x00\x00\x05' b'\x55\x9e\xa6\x9b' \ + b'\xae\xdc\xcd\x53' b'\x68\x81\xba\x63' \ + b'\x2b\x40\xd8\x2b' def testPackRequest0(self): bin = request.RecolorCursor._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.RecolorCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestQueryBestSize(EndianTest): def setUp(self): self.req_args_0 = { - 'height': 34743, - 'drawable': 503496990, + 'drawable': 1974766133, + 'height': 64528, 'item_class': 1, - 'width': 27916, + 'width': 8620, } - self.req_bin_0 = '\x61\x01\x00\x03' '\x1e\x02\xc1\x1e' \ - '\x6d\x0c\x87\xb7' + self.req_bin_0 = b'\x61\x01\x00\x03' b'\x75\xb4\x8a\x35' \ + b'\x21\xac\xfc\x10' self.reply_args_0 = { - 'height': 60728, - 'sequence_number': 34070, - 'width': 35970, + 'height': 2023, + 'sequence_number': 41036, + 'width': 35260, } - self.reply_bin_0 = '\x01\x00\x85\x16' '\x00\x00\x00\x00' \ - '\x8c\x82\xed\x38' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\xa0\x4c' b'\x00\x00\x00\x00' \ + b'\x89\xbc\x07\xe7' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryBestSize._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryBestSize._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryBestSize._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryBestSize._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestQueryExtension(EndianTest): @@ -4522,662 +3217,473 @@ def setUp(self): self.req_args_0 = { 'name': 'XTRA', } - self.req_bin_0 = '\x62\x00\x00\x03' '\x00\x04\x00\x00' \ - '\x58\x54\x52\x41' + self.req_bin_0 = b'\x62\x00\x00\x03' b'\x00\x04\x00\x00' \ + b'\x58\x54\x52\x41' self.reply_args_0 = { - 'sequence_number': 39952, - 'major_opcode': 195, - 'first_error': 150, + 'first_error': 237, + 'first_event': 149, + 'major_opcode': 134, 'present': 1, - 'first_event': 202, + 'sequence_number': 59692, } - self.reply_bin_0 = '\x01\x00\x9c\x10' '\x00\x00\x00\x00' \ - '\x01\xc3\xca\x96' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\xe9\x2c' b'\x00\x00\x00\x00' \ + b'\x01\x86\x95\xed' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.QueryExtension._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.QueryExtension._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.QueryExtension._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.QueryExtension._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestListExtensions(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x63\x00\x00\x01' + self.req_bin_0 = b'\x63\x00\x00\x01' self.reply_args_0 = { - 'sequence_number': 20200, 'names': ['XTRA', 'XTRA-II'], + 'sequence_number': 9149, } - self.reply_bin_0 = '\x01\x02\x4e\xe8' '\x00\x00\x00\x04' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x04\x58\x54\x52' '\x41\x07\x58\x54' \ - '\x52\x41\x2d\x49' '\x49\x00\x00\x00' + self.reply_bin_0 = b'\x01\x02\x23\xbd' b'\x00\x00\x00\x04' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x04\x58\x54\x52' b'\x41\x07\x58\x54' \ + b'\x52\x41\x2d\x49' b'\x49\x00\x00\x00' def testPackRequest0(self): bin = request.ListExtensions._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListExtensions._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListExtensions._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListExtensions._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestChangeKeyboardMapping(EndianTest): def setUp(self): self.req_args_0 = { - 'keysyms': [[707837223, 99294840, 1205405602], [67157514, 879853050, 2059131033], [1139736188, 578113249, 1525786315], [1335349176, 246731334, 277761436], [1386594542, 1676932187, 1862777168], [535892916, 342718655, 195574000], [5712156, 1820472637, 848853860], [1123197289, 1664064022, 94999154], [380150420, 402902535, 1061375041], [510686316, 502245882, 422893644], [1423643601, 194077695, 403885178], [1571826296, 529249772, 623556591], [720045879, 37553034, 955963792], [513407882, 861125615, 219940695], [184890179, 472466494, 1649347894], [1679171989, 1991748404, 1674460475], [1762342934, 276695222, 1941684480], [886658026, 1860690072, 577030090], [227169721, 1390318675, 321524615], [2144591365, 545119116, 404205206]], - 'first_keycode': 250, - } - self.req_bin_0 = '\x64\x14\x00\x3e' '\xfa\x03\x00\x00' \ - '\x2a\x30\xbd\x27' '\x05\xeb\x1e\x78' \ - '\x47\xd9\x07\xa2' '\x04\x00\xbe\x0a' \ - '\x34\x71\x7d\xfa' '\x7a\xbb\xd8\x99' \ - '\x43\xee\xfe\x7c' '\x22\x75\x4e\xe1' \ - '\x5a\xf1\xa6\xcb' '\x4f\x97\xcf\xb8' \ - '\x0e\xb4\xd2\x46' '\x10\x8e\x4d\x9c' \ - '\x52\xa5\xc0\xee' '\x63\xf3\xf4\x5b' \ - '\x6f\x07\xb9\x50' '\x1f\xf1\x13\xb4' \ - '\x14\x6d\x78\xbf' '\x0b\xa8\x38\xf0' \ - '\x00\x57\x29\x1c' '\x6c\x82\x35\x3d' \ - '\x32\x98\x7b\x64' '\x42\xf2\xa1\x69' \ - '\x63\x2f\x9a\x16' '\x05\xa9\x92\x72' \ - '\x16\xa8\xa2\x94' '\x18\x03\xce\x07' \ - '\x3f\x43\x4c\x41' '\x1e\x70\x74\x6c' \ - '\x1d\xef\xa9\xfa' '\x19\x34\xd8\x4c' \ - '\x54\xdb\x13\xd1' '\x0b\x91\x63\xff' \ - '\x18\x12\xcc\x7a' '\x5d\xb0\x2a\x78' \ - '\x1f\x8b\xb5\xec' '\x25\x2a\xb7\xef' \ - '\x2a\xeb\x07\x37' '\x02\x3d\x03\x8a' \ - '\x38\xfa\xd9\x90' '\x1e\x99\xfb\x8a' \ - '\x33\x53\xbb\xef' '\x0d\x1c\x07\x57' \ - '\x0b\x05\x33\x43' '\x1c\x29\x44\x3e' \ - '\x62\x4f\x0d\x36' '\x64\x16\x21\x95' \ - '\x76\xb7\xab\x34' '\x63\xce\x3d\x3b' \ - '\x69\x0b\x38\x16' '\x10\x7e\x08\xb6' \ - '\x73\xbb\xc1\x00' '\x34\xd9\x53\xea' \ - '\x6e\xe7\xe0\x98' '\x22\x64\xc7\xca' \ - '\x0d\x8a\x55\xb9' '\x52\xde\x94\x53' \ - '\x13\x2a\x13\x87' '\x7f\xd3\xde\x05' \ - '\x20\x7d\xdb\x8c' '\x18\x17\xae\x96' + 'first_keycode': 157, + 'keysyms': [[1861549105, 991489870, 390260112], [107985429, 558681426, 814119353], [702984500, 454537006, 976459372], [701896028, 724776911, 1634728346], [1889012491, 814167346, 597551532], [1614928797, 2042695294, 1786543801], [905303576, 541748982, 1792957544], [175892294, 1009976242, 41625283], [1608517348, 1158393599, 111852976], [2147285698, 2044231981, 751534113], [481513427, 1396173819, 147356828], [1677685199, 2055755177, 1399632465], [86453688, 1619703478, 66636412], [2039275666, 531036848, 428123802], [1802230236, 43765755, 1334308166], [327238597, 512271361, 271057482], [1016964633, 1437651928, 245649464], [1211115441, 2035292716, 468075293], [998652876, 1502089592, 550279151], [1646901134, 792196355, 360324443]], + } + self.req_bin_0 = b'\x64\x14\x00\x3e' b'\x9d\x03\x00\x00' \ + b'\x6e\xf4\xfc\x31' b'\x3b\x18\xef\x4e' \ + b'\x17\x42\xe5\x90' b'\x06\x6f\xba\x15' \ + b'\x21\x4c\xcd\x52' b'\x30\x86\x79\xb9' \ + b'\x29\xe6\xb1\x34' b'\x1b\x17\xaf\x2e' \ + b'\x3a\x33\x96\x6c' b'\x29\xd6\x15\x5c' \ + b'\x2b\x33\x37\xcf' b'\x61\x6f\xf9\x9a' \ + b'\x70\x98\x0b\x0b' b'\x30\x87\x35\x32' \ + b'\x23\x9d\xe9\xac' b'\x60\x41\xdb\x9d' \ + b'\x79\xc1\x0e\x7e' b'\x6a\x7c\x7e\xb9' \ + b'\x35\xf5\xd6\x18' b'\x20\x4a\x6e\xf6' \ + b'\x6a\xde\x5c\x68' b'\x0a\x7b\xe7\x46' \ + b'\x3c\x33\x03\xb2' b'\x02\x7b\x26\xc3' \ + b'\x5f\xe0\x06\xe4' b'\x45\x0b\xae\xff' \ + b'\x06\xaa\xbd\xb0' b'\x7f\xfc\xfa\xc2' \ + b'\x79\xd8\x81\x2d' b'\x2c\xcb\x80\x21' \ + b'\x1c\xb3\x4f\xd3' b'\x53\x37\xeb\xfb' \ + b'\x08\xc8\x7c\x9c' b'\x63\xff\x71\xcf' \ + b'\x7a\x88\x55\xa9' b'\x53\x6c\xb2\x51' \ + b'\x05\x27\x2d\xb8' b'\x60\x8a\xb6\xb6' \ + b'\x03\xf8\xca\x7c' b'\x79\x8c\xe0\x92' \ + b'\x1f\xa6\xfa\xb0' b'\x19\x84\xa6\x9a' \ + b'\x6b\x6b\xd9\xdc' b'\x02\x9b\xcf\xfb' \ + b'\x4f\x87\xed\x46' b'\x13\x81\x43\xc5' \ + b'\x1e\x88\xa4\x01' b'\x10\x28\x02\x4a' \ + b'\x3c\x9d\xa6\x19' b'\x55\xb0\xd3\xd8' \ + b'\x0e\xa4\x50\x38' b'\x48\x30\x27\xb1' \ + b'\x79\x50\x1a\x2c' b'\x1b\xe6\x43\x1d' \ + b'\x3b\x86\x3b\xcc' b'\x59\x88\x11\x78' \ + b'\x20\xcc\x97\xef' b'\x62\x29\xb7\x8e' \ + b'\x2f\x37\xf5\x03' b'\x15\x7a\x1d\x5b' def testPackRequest0(self): bin = request.ChangeKeyboardMapping._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGetKeyboardMapping(EndianTest): def setUp(self): self.req_args_0 = { - 'count': 131, - 'first_keycode': 206, + 'count': 207, + 'first_keycode': 169, } - self.req_bin_0 = '\x65\x00\x00\x02' '\xce\x83\x00\x00' + self.req_bin_0 = b'\x65\x00\x00\x02' b'\xa9\xcf\x00\x00' self.reply_args_0 = { - 'keysyms': [[1550369014, 1683205347, 1879538861], [452613596, 1132022246, 357271408], [528724632, 2118423140, 640580111], [1981239140, 195173082, 497130901], [2001675011, 809172000, 1577756130], [739794769, 1774524806, 787951551], [1784021539, 1998872082, 1747812414], [396316053, 1525431160, 1808906812], [1676662850, 1222579650, 1205117622], [396026453, 1956747483, 1762026309], [1222502216, 1488139702, 1799119214], [1504675136, 1414564657, 419659384], [1934768917, 2095924224, 590955729], [582168798, 383228141, 1552516537], [1482483262, 1041896520, 1047041873], [1932705867, 292473490, 226147737], [780322016, 1965031752, 1481062205], [89811542, 1313413666, 686267194], [237776128, 1310737228, 792176733], [849034415, 1592538831, 837355505]], - 'sequence_number': 61409, - } - self.reply_bin_0 = '\x01\x03\xef\xe1' '\x00\x00\x00\x3c' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x5c\x68\xc0\xf6' '\x64\x53\xac\xe3' \ - '\x70\x07\x7c\xad' '\x1a\xfa\x55\xdc' \ - '\x43\x79\x49\xe6' '\x15\x4b\x87\x70' \ - '\x1f\x83\xb2\x98' '\x7e\x44\x92\x64' \ - '\x26\x2e\x7a\x0f' '\x76\x17\x4f\x64' \ - '\x0b\xa2\x1a\xda' '\x1d\xa1\x9d\x95' \ - '\x77\x4f\x23\x03' '\x30\x3a\xfc\x20' \ - '\x5e\x0a\xa5\xe2' '\x2c\x18\x5f\x51' \ - '\x69\xc5\x19\x86' '\x2e\xf7\x2f\xbf' \ - '\x6a\x56\x02\x23' '\x77\x24\x5e\x12' \ - '\x68\x2d\x80\x3e' '\x17\x9f\x4d\x95' \ - '\x5a\xec\x3b\x78' '\x6b\xd1\xba\x3c' \ - '\x63\xef\xd8\x42' '\x48\xdf\x15\xc2' \ - '\x47\xd4\xa2\xb6' '\x17\x9a\xe2\x55' \ - '\x74\xa1\x98\xdb' '\x69\x06\x63\x45' \ - '\x48\xdd\xe7\x48' '\x58\xb3\x35\xb6' \ - '\x6b\x3c\x61\x6e' '\x59\xaf\x85\x40' \ - '\x54\x50\x8b\x31' '\x19\x03\x7e\x78' \ - '\x73\x52\x3b\x15' '\x7c\xed\x44\x00' \ - '\x23\x39\x44\xd1' '\x22\xb3\x30\xde' \ - '\x16\xd7\x98\xed' '\x5c\x89\x85\xb9' \ - '\x58\x5c\xe6\x3e' '\x3e\x1a\x14\x48' \ - '\x3e\x68\x97\x51' '\x73\x32\xc0\x4b' \ - '\x11\x6e\xca\x92' '\x0d\x7a\xbd\x99' \ - '\x2e\x82\xc4\xe0' '\x75\x20\x01\x48' \ - '\x58\x47\x37\x3d' '\x05\x5a\x6a\x56' \ - '\x4e\x49\x1a\x22' '\x28\xe7\x9b\x3a' \ - '\x0e\x2c\x2d\x00' '\x4e\x20\x43\x4c' \ - '\x2f\x37\xa8\x5d' '\x32\x9b\x3c\xaf' \ - '\x5e\xec\x36\xcf' '\x31\xe9\x07\xf1' + 'keysyms': [[232140298, 1242716010, 55143985], [1994770011, 669923085, 1236514049], [1454592222, 1949971307, 2057660497], [805965556, 851808913, 2021792706], [1535482384, 425909956, 163201187], [1271520474, 1483083165, 1783638995], [1346992789, 521515080, 218831382], [1497210568, 1658890074, 647643874], [1825990828, 1469435098, 1289374120], [1729858135, 259963764, 1709884923], [2112789657, 1215330896, 1680696611], [88195295, 745614404, 1144061708], [919934772, 1420606257, 795794911], [148083460, 1086542523, 1390588550], [732788374, 27170279, 1824449766], [902069278, 1765942198, 1052700150], [226642993, 930984408, 2063275595], [777792886, 1364908620, 1914642756], [1779635393, 987282730, 1518933756], [328545991, 935201525, 378251236]], + 'sequence_number': 48346, + } + self.reply_bin_0 = b'\x01\x03\xbc\xda' b'\x00\x00\x00\x3c' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x0d\xd6\x2e\x0a' b'\x4a\x12\x57\x6a' \ + b'\x03\x49\x6e\x31' b'\x76\xe5\xc6\x5b' \ + b'\x27\xee\x37\x0d' b'\x49\xb3\xb5\x01' \ + b'\x56\xb3\x50\xde' b'\x74\x3a\x33\x6b' \ + b'\x7a\xa5\x68\x51' b'\x30\x0a\x0e\xf4' \ + b'\x32\xc5\x92\x91' b'\x78\x82\x1b\xc2' \ + b'\x5b\x85\x9a\x10' b'\x19\x62\xde\xc4' \ + b'\x09\xba\x40\xa3' b'\x4b\xc9\xdc\xda' \ + b'\x58\x66\x0d\x9d' b'\x6a\x50\x2b\xd3' \ + b'\x50\x49\x7a\x95' b'\x1f\x15\xb0\x48' \ + b'\x0d\x0b\x1a\x16' b'\x59\x3d\x9e\xc8' \ + b'\x62\xe0\xa7\x5a' b'\x26\x9a\x42\xe2' \ + b'\x6c\xd6\x68\xac' b'\x57\x95\xcc\xda' \ + b'\x4c\xda\x49\xa8' b'\x67\x1b\x8a\x57' \ + b'\x0f\x7e\xbb\x74' b'\x65\xea\xc5\xfb' \ + b'\x7d\xee\x9c\x99' b'\x48\x70\x7a\x50' \ + b'\x64\x2d\x65\x23' b'\x05\x41\xc0\xdf' \ + b'\x2c\x71\x2c\x44' b'\x44\x30\xff\x0c' \ + b'\x36\xd5\x17\x34' b'\x54\xac\xbb\x31' \ + b'\x2f\x6e\xdd\xdf' b'\x08\xd3\x93\x04' \ + b'\x40\xc3\x52\xbb' b'\x52\xe2\xb2\x86' \ + b'\x2b\xad\x76\x96' b'\x01\x9e\x95\xe7' \ + b'\x6c\xbe\xe4\xe6' b'\x35\xc4\x7c\x1e' \ + b'\x69\x42\x23\xb6' b'\x3e\xbe\xed\xf6' \ + b'\x0d\x82\x4c\x31' b'\x37\x7d\xb1\xd8' \ + b'\x7a\xfb\x16\x4b' b'\x2e\x5c\x2d\x76' \ + b'\x51\x5a\xda\x4c' b'\x72\x1f\x21\x44' \ + b'\x6a\x13\x14\xc1' b'\x3a\xd8\xbd\x2a' \ + b'\x5a\x89\x16\xfc' b'\x13\x95\x36\xc7' \ + b'\x37\xbe\x0a\xf5' b'\x16\x8b\xa7\xe4' def testPackRequest0(self): bin = request.GetKeyboardMapping._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetKeyboardMapping._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetKeyboardMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestChangeKeyboardControl(EndianTest): def setUp(self): self.req_args_0 = { - 'attrs': {'key_click_percent': -35, 'bell_percent': -53, 'led_mode': 1, 'bell_pitch': -17390, 'auto_repeat_mode': 2, 'bell_duration': -30281, 'key': 235, 'led': 192}, + 'attrs': {'led': 196, 'auto_repeat_mode': 0, 'bell_pitch': -2303, 'bell_percent': -5, 'key_click_percent': -59, 'key': 190, 'bell_duration': -4223, 'led_mode': 1}, } - self.req_bin_0 = '\x66\x00\x00\x0a' '\x00\x00\x00\xff' \ - '\xdd\x00\x00\x00' '\xcb\x00\x00\x00' \ - '\xbc\x12\x00\x00' '\x89\xb7\x00\x00' \ - '\xc0\x00\x00\x00' '\x01\x00\x00\x00' \ - '\xeb\x00\x00\x00' '\x02\x00\x00\x00' + self.req_bin_0 = b'\x66\x00\x00\x0a' b'\x00\x00\x00\xff' \ + b'\xc5\x00\x00\x00' b'\xfb\x00\x00\x00' \ + b'\xf7\x01\x00\x00' b'\xef\x81\x00\x00' \ + b'\xc4\x00\x00\x00' b'\x01\x00\x00\x00' \ + b'\xbe\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.ChangeKeyboardControl._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGetKeyboardControl(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x67\x00\x00\x01' + self.req_bin_0 = b'\x67\x00\x00\x01' self.reply_args_0 = { - 'key_click_percent': 206, - 'sequence_number': 30149, - 'bell_percent': 251, - 'bell_pitch': 13779, - 'auto_repeats': [217, 171, 167, 167, 243, 163, 129, 239, 168, 153, 225, 199, 189, 155, 228, 149, 148, 237, 139, 150, 211, 133, 135, 250, 191, 166, 146, 212, 239, 183, 214, 250], + 'auto_repeats': [199, 243, 190, 246, 225, 214, 135, 254, 211, 174, 252, 182, 218, 194, 215, 199, 198, 130, 176, 149, 189, 232, 253, 189, 249, 253, 242, 132, 151, 203, 184, 231], + 'bell_duration': 35050, + 'bell_percent': 249, + 'bell_pitch': 36528, 'global_auto_repeat': 0, - 'led_mask': 438224369, - 'bell_duration': 20235, + 'key_click_percent': 222, + 'led_mask': 1425908825, + 'sequence_number': 20323, } - self.reply_bin_0 = '\x01\x00\x75\xc5' '\x00\x00\x00\x05' \ - '\x1a\x1e\xc5\xf1' '\xce\xfb\x35\xd3' \ - '\x4f\x0b\x00\x00' '\xd9\xab\xa7\xa7' \ - '\xf3\xa3\x81\xef' '\xa8\x99\xe1\xc7' \ - '\xbd\x9b\xe4\x95' '\x94\xed\x8b\x96' \ - '\xd3\x85\x87\xfa' '\xbf\xa6\x92\xd4' \ - '\xef\xb7\xd6\xfa' + self.reply_bin_0 = b'\x01\x00\x4f\x63' b'\x00\x00\x00\x05' \ + b'\x54\xfd\xa4\x59' b'\xde\xf9\x8e\xb0' \ + b'\x88\xea\x00\x00' b'\xc7\xf3\xbe\xf6' \ + b'\xe1\xd6\x87\xfe' b'\xd3\xae\xfc\xb6' \ + b'\xda\xc2\xd7\xc7' b'\xc6\x82\xb0\x95' \ + b'\xbd\xe8\xfd\xbd' b'\xf9\xfd\xf2\x84' \ + b'\x97\xcb\xb8\xe7' def testPackRequest0(self): bin = request.GetKeyboardControl._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetKeyboardControl._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetKeyboardControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestBell(EndianTest): def setUp(self): self.req_args_0 = { - 'percent': -19, + 'percent': -40, } - self.req_bin_0 = '\x68\xed\x00\x01' + self.req_bin_0 = b'\x68\xd8\x00\x01' def testPackRequest0(self): bin = request.Bell._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.Bell._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestChangePointerControl(EndianTest): def setUp(self): self.req_args_0 = { - 'accel_denum': -32484, - 'accel_num': -9346, - 'do_accel': 0, - 'do_thresh': 0, - 'threshold': -8309, + 'accel_denum': -8326, + 'accel_num': -18826, + 'do_accel': 1, + 'do_thresh': 1, + 'threshold': -14733, } - self.req_bin_0 = '\x69\x00\x00\x03' '\xdb\x7e\x81\x1c' \ - '\xdf\x8b\x00\x00' + self.req_bin_0 = b'\x69\x00\x00\x03' b'\xb6\x76\xdf\x7a' \ + b'\xc6\x73\x01\x01' def testPackRequest0(self): bin = request.ChangePointerControl._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangePointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGetPointerControl(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x6a\x00\x00\x01' + self.req_bin_0 = b'\x6a\x00\x00\x01' self.reply_args_0 = { - 'accel_denom': 63793, - 'sequence_number': 59946, - 'threshold': 46060, - 'accel_num': 53419, + 'accel_denom': 18010, + 'accel_num': 29992, + 'sequence_number': 46318, + 'threshold': 20350, } - self.reply_bin_0 = '\x01\x00\xea\x2a' '\x00\x00\x00\x00' \ - '\xd0\xab\xf9\x31' '\xb3\xec\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\xb4\xee' b'\x00\x00\x00\x00' \ + b'\x75\x28\x46\x5a' b'\x4f\x7e\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetPointerControl._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetPointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetPointerControl._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetPointerControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestSetScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { - 'allow_exposures': 0, - 'timeout': -12675, - 'interval': -12318, - 'prefer_blank': 2, + 'allow_exposures': 2, + 'interval': -25214, + 'prefer_blank': 0, + 'timeout': -24531, } - self.req_bin_0 = '\x6b\x00\x00\x03' '\xce\x7d\xcf\xe2' \ - '\x02\x00\x00\x00' + self.req_bin_0 = b'\x6b\x00\x00\x03' b'\xa0\x2d\x9d\x82' \ + b'\x00\x02\x00\x00' def testPackRequest0(self): bin = request.SetScreenSaver._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestGetScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x6c\x00\x00\x01' + self.req_bin_0 = b'\x6c\x00\x00\x01' self.reply_args_0 = { - 'allow_exposures': 1, - 'timeout': 1865, - 'sequence_number': 14674, - 'prefer_blanking': 1, - 'interval': 60559, + 'allow_exposures': 0, + 'interval': 8091, + 'prefer_blanking': 0, + 'sequence_number': 12877, + 'timeout': 20935, } - self.reply_bin_0 = '\x01\x00\x39\x52' '\x00\x00\x00\x00' \ - '\x07\x49\xec\x8f' '\x01\x01\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\x32\x4d' b'\x00\x00\x00\x00' \ + b'\x51\xc7\x1f\x9b' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.GetScreenSaver._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetScreenSaver._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetScreenSaver._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestChangeHosts(EndianTest): def setUp(self): self.req_args_0 = { - 'host': [188, 226, 135, 199], - 'mode': 1, - 'host_family': 1, + 'host': [183, 251, 198, 200], + 'host_family': 0, + 'mode': 0, } - self.req_bin_0 = '\x6d\x01\x00\x03' '\x01\x00\x00\x04' \ - '\xbc\xe2\x87\xc7' + self.req_bin_0 = b'\x6d\x00\x00\x03' b'\x00\x00\x00\x04' \ + b'\xb7\xfb\xc6\xc8' def testPackRequest0(self): bin = request.ChangeHosts._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ChangeHosts._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestListHosts(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x6e\x00\x00\x01' + self.req_bin_0 = b'\x6e\x00\x00\x01' self.reply_args_0 = { - 'sequence_number': 31662, + 'hosts': [{'name': [34, 23, 178, 12], 'family': 0}, {'name': [130, 236, 254, 15], 'family': 0}], 'mode': 1, - 'hosts': [{'family': 0, 'name': [34, 23, 178, 12]}, {'family': 0, 'name': [130, 236, 254, 15]}], + 'sequence_number': 15164, } - self.reply_bin_0 = '\x01\x01\x7b\xae' '\x00\x00\x00\x04' \ - '\x00\x02\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x04' '\x22\x17\xb2\x0c' \ - '\x00\x00\x00\x04' '\x82\xec\xfe\x0f' + self.reply_bin_0 = b'\x01\x01\x3b\x3c' b'\x00\x00\x00\x04' \ + b'\x00\x02\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x04' b'\x22\x17\xb2\x0c' \ + b'\x00\x00\x00\x04' b'\x82\xec\xfe\x0f' def testPackRequest0(self): bin = request.ListHosts._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ListHosts._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.ListHosts._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.ListHosts._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestSetAccessControl(EndianTest): def setUp(self): self.req_args_0 = { - 'mode': 0, + 'mode': 1, } - self.req_bin_0 = '\x6f\x00\x00\x01' + self.req_bin_0 = b'\x6f\x01\x00\x01' def testPackRequest0(self): bin = request.SetAccessControl._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetAccessControl._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestSetCloseDownMode(EndianTest): @@ -5185,89 +3691,62 @@ def setUp(self): self.req_args_0 = { 'mode': 0, } - self.req_bin_0 = '\x70\x00\x00\x01' + self.req_bin_0 = b'\x70\x00\x00\x01' def testPackRequest0(self): bin = request.SetCloseDownMode._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetCloseDownMode._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestKillClient(EndianTest): def setUp(self): self.req_args_0 = { - 'resource': 1679944210, + 'resource': 649180254, } - self.req_bin_0 = '\x71\x00\x00\x02' '\x64\x21\xea\x12' + self.req_bin_0 = b'\x71\x00\x00\x02' b'\x26\xb1\xb4\x5e' def testPackRequest0(self): bin = request.KillClient._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.KillClient._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestRotateProperties(EndianTest): def setUp(self): self.req_args_0 = { - 'delta': -27095, - 'window': 109899869, - 'properties': [1758270592, 1474783027, 1362037883, 19212066, 1095428186, 1435857629, 337040311, 1202859364, 1426187239, 725785004, 1722986690, 435243112], + 'delta': -11867, + 'properties': [30448914, 1520523655, 1147111912, 271900374, 589144637, 97809756, 2092347973, 117159267, 1188394866, 627424198, 1497757970, 2027482546], + 'window': 271248673, } - self.req_bin_0 = '\x72\x00\x00\x0f' '\x06\x8c\xf0\x5d' \ - '\x00\x0c\x96\x29' '\x68\xcd\x14\x80' \ - '\x57\xe7\x67\x33' '\x51\x2f\x0c\x7b' \ - '\x01\x25\x27\x22' '\x41\x4a\xe8\x5a' \ - '\x55\x95\x72\xdd' '\x14\x16\xd3\xb7' \ - '\x47\xb2\x2d\x64' '\x55\x01\xe3\xe7' \ - '\x2b\x42\x99\xac' '\x66\xb2\xb0\xc2' \ - '\x19\xf1\x48\x68' + self.req_bin_0 = b'\x72\x00\x00\x0f' b'\x10\x2a\xed\x21' \ + b'\x00\x0c\xd1\xa5' b'\x01\xd0\x9d\x12' \ + b'\x5a\xa1\x59\x87' b'\x44\x5f\x89\xe8' \ + b'\x10\x34\xde\xd6' b'\x23\x1d\xa2\x3d' \ + b'\x05\xd4\x75\x5c' b'\x7c\xb6\xb2\x45' \ + b'\x06\xfb\xb5\x63' b'\x46\xd5\x77\x72' \ + b'\x25\x65\xbb\xc6' b'\x59\x45\xf9\x12' \ + b'\x78\xd8\xed\xb2' def testPackRequest0(self): bin = request.RotateProperties._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.RotateProperties._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestForceScreenSaver(EndianTest): @@ -5275,274 +3754,183 @@ def setUp(self): self.req_args_0 = { 'mode': 1, } - self.req_bin_0 = '\x73\x01\x00\x01' + self.req_bin_0 = b'\x73\x01\x00\x01' def testPackRequest0(self): bin = request.ForceScreenSaver._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.ForceScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) class TestSetPointerMapping(EndianTest): def setUp(self): self.req_args_0 = { - 'map': [218, 142, 195, 250, 194], + 'map': [154, 131, 200, 248, 250], } - self.req_bin_0 = '\x74\x05\x00\x03' '\xda\x8e\xc3\xfa' \ - '\xc2\x00\x00\x00' + self.req_bin_0 = b'\x74\x05\x00\x03' b'\x9a\x83\xc8\xf8' \ + b'\xfa\x00\x00\x00' self.reply_args_0 = { - 'sequence_number': 11995, - 'status': 187, + 'sequence_number': 22584, + 'status': 240, } - self.reply_bin_0 = '\x01\xbb\x2e\xdb' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\xf0\x58\x38' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SetPointerMapping._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.SetPointerMapping._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.SetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestGetPointerMapping(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x75\x00\x00\x01' + self.req_bin_0 = b'\x75\x00\x00\x01' self.reply_args_0 = { - 'sequence_number': 35825, - 'map': [165, 233, 136, 197, 230], + 'map': [175, 141, 192, 250, 157], + 'sequence_number': 54134, } - self.reply_bin_0 = '\x01\x05\x8b\xf1' '\x00\x00\x00\x02' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\xa5\xe9\x88\xc5' '\xe6\x00\x00\x00' + self.reply_bin_0 = b'\x01\x05\xd3\x76' b'\x00\x00\x00\x02' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\xaf\x8d\xc0\xfa' b'\x9d\x00\x00\x00' def testPackRequest0(self): bin = request.GetPointerMapping._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetPointerMapping._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestSetModifierMapping(EndianTest): def setUp(self): self.req_args_0 = { - 'keycodes': [[72, 169], [161, 154], [26, 10], [108, 187], [110, 198], [225, 88], [33, 66], [189, 147]], + 'keycodes': [[33, 205], [251, 37], [27, 77], [76, 155], [43, 127], [60, 213], [115, 194], [230, 226]], } - self.req_bin_0 = '\x76\x02\x00\x05' '\x48\xa9\xa1\x9a' \ - '\x1a\x0a\x6c\xbb' '\x6e\xc6\xe1\x58' \ - '\x21\x42\xbd\x93' + self.req_bin_0 = b'\x76\x02\x00\x05' b'\x21\xcd\xfb\x25' \ + b'\x1b\x4d\x4c\x9b' b'\x2b\x7f\x3c\xd5' \ + b'\x73\xc2\xe6\xe2' self.reply_args_0 = { - 'sequence_number': 44526, - 'status': 188, + 'sequence_number': 56627, + 'status': 204, } - self.reply_bin_0 = '\x01\xbc\xad\xee' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\xcc\xdd\x33' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): bin = request.SetModifierMapping._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.SetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.SetModifierMapping._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.SetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestGetModifierMapping(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x77\x00\x00\x01' + self.req_bin_0 = b'\x77\x00\x00\x01' self.reply_args_0 = { - 'sequence_number': 58377, - 'keycodes': [[3, 183], [213, 173], [9, 97], [35, 60], [249, 78], [175, 62], [237, 11], [26, 119]], + 'keycodes': [[219, 156], [30, 50], [106, 108], [135, 41], [80, 122], [88, 38], [80, 1], [209, 230]], + 'sequence_number': 45434, } - self.reply_bin_0 = '\x01\x02\xe4\x09' '\x00\x00\x00\x04' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ - '\x03\xb7\xd5\xad' '\x09\x61\x23\x3c' \ - '\xf9\x4e\xaf\x3e' '\xed\x0b\x1a\x77' + self.reply_bin_0 = b'\x01\x02\xb1\x7a' b'\x00\x00\x00\x04' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\xdb\x9c\x1e\x32' b'\x6a\x6c\x87\x29' \ + b'\x50\x7a\x58\x26' b'\x50\x01\xd1\xe6' def testPackRequest0(self): bin = request.GetModifierMapping._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.GetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) def testPackReply0(self): bin = request.GetModifierMapping._reply.to_binary(*(), **self.reply_args_0) - try: - assert bin == self.reply_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.reply_bin_0) def testUnpackReply0(self): args, remain = request.GetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.reply_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.reply_args_0) class TestNoOperation(EndianTest): def setUp(self): self.req_args_0 = { } - self.req_bin_0 = '\x7f\x00\x00\x01' + self.req_bin_0 = b'\x7f\x00\x00\x01' def testPackRequest0(self): bin = request.NoOperation._request.to_binary(*(), **self.req_args_0) - try: - assert bin == self.req_bin_0 - except AssertionError: - raise AssertionError(tohex(bin)) + self.assertBinaryEqual(bin, self.req_bin_0) def testUnpackRequest0(self): args, remain = request.NoOperation._request.parse_binary(self.req_bin_0, dummy_display, 1) - try: - assert len(remain) == 0 - except AssertionError: - raise AssertionError(tohex(remain)) - try: - assert args == self.req_args_0 - except AssertionError: - raise AssertionError(args) + self.assertBinaryEmpty(remain) + self.assertEqual(args, self.req_args_0) if __name__ == "__main__": - check_endian() unittest.main() From 15be5cd19117bdc193a95e45bf13e38c04166bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD=20=D0=9A=D0=BE=D1=80=D0=BD=D0=B5?= =?UTF-8?q?=D0=B2?= Date: Tue, 16 May 2017 18:52:41 +0300 Subject: [PATCH 148/279] Fixed an error in set_wm_transient_for Otherwise it failed: File "/usr/local/lib/python3.5/dist-packages/Xlib/protocol/rq.py", line 688, in pack_value data = array(array_unsigned_codes[size], val).tostring() TypeError: 'int' object is not iterable --- Xlib/xobject/drawable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/xobject/drawable.py b/Xlib/xobject/drawable.py index 5832cd1c..71576f8c 100644 --- a/Xlib/xobject/drawable.py +++ b/Xlib/xobject/drawable.py @@ -692,7 +692,7 @@ def get_wm_class(self): def set_wm_transient_for(self, window, onerror = None): self.change_property(Xatom.WM_TRANSIENT_FOR, Xatom.WINDOW, - 32, window.id, + 32, [window.id], onerror = onerror) def get_wm_transient_for(self): From 2cde15712de0a31cd35d7bbf247fdaa5f9aa570c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=89VEIL?= Date: Sun, 11 Jun 2017 10:07:22 +0200 Subject: [PATCH 149/279] README: add links to documentations and examples --- README.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.rst b/README.rst index 893bd79e..f145f3da 100644 --- a/README.rst +++ b/README.rst @@ -69,6 +69,14 @@ There are three advantages of implementing a pure Python library: - Maintainability: It is much easier to develop and debug native Python modules than modules written in C. + +Documentation +~~~~~~~~~~~~~ + +The reference manual is not finished by far, but is probably still useful. It can be `browsed online `__. + +There are also some `example programs `__ and, of course, `the standard X11 documentation `__ applies. + Project status ~~~~~~~~~~~~~~ From 1d83146018cdd275c23174cc28b070e95d2480d8 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 19 Jul 2017 07:54:14 +0200 Subject: [PATCH 150/279] xauth: fix unclosed file --- Xlib/xauth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Xlib/xauth.py b/Xlib/xauth.py index a8fd14ca..63eb7ef7 100644 --- a/Xlib/xauth.py +++ b/Xlib/xauth.py @@ -42,7 +42,8 @@ def __init__(self, filename = None): '$HOME not set, cannot find ~/.Xauthority') try: - raw = open(filename, 'rb').read() + with open(filename, 'rb') as fp: + raw = fp.read() except IOError as err: raise error.XauthError('could not read from {0}: {1}'.format(filename, err)) From f74d563fcb74a66a4ab2d93e722925a26ed3527a Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 3 Sep 2017 16:36:20 +0200 Subject: [PATCH 151/279] travis: enable Python warnings during tests run --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4d452d64..e1628eb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ install: # command to run tests script: - python runtests.py --with-coverage --cover-html --cover-html-dir=Coverage_report + python -W all runtests.py --with-coverage --cover-html --cover-html-dir=Coverage_report after_success: - codecov From 5594b1b49632db1b67b83b8e8e920ca310b1fb93 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 3 Sep 2017 16:51:25 +0200 Subject: [PATCH 152/279] tox: enable Python warnings during tests run --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 25016995..f13646dd 100644 --- a/tox.ini +++ b/tox.ini @@ -6,4 +6,4 @@ skip_missing_interpreters = true deps= nose six>=1.10.0 -commands={envpython} runtests.py {posargs} +commands={envpython} -W all runtests.py {posargs} From a3c8ed2d864071cff13c6451cc02da138b472faf Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 3 Sep 2017 17:38:07 +0200 Subject: [PATCH 153/279] test: update little-endian tests --- test/test_events_le.py | 412 ++++---- test/test_requests_le.py | 2116 +++++++++++++++++++------------------- 2 files changed, 1264 insertions(+), 1264 deletions(-) mode change 100644 => 100755 test/test_events_le.py mode change 100644 => 100755 test/test_requests_le.py diff --git a/test/test_events_le.py b/test/test_events_le.py old mode 100644 new mode 100755 index e9a8a359..1e5dbfd3 --- a/test/test_events_le.py +++ b/test/test_events_le.py @@ -14,13 +14,13 @@ class TestKeymapNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'data': [236, 252, 232, 206, 210, 131, 246, 234, 162, 151, 217, 167, 171, 128, 239, 200, 179, 146, 209, 131, 223, 155, 181, 171, 175, 220, 227, 200, 138, 134, 148], - 'type': 207, + 'data': [248, 202, 136, 187, 201, 200, 244, 146, 187, 195, 178, 236, 157, 185, 166, 196, 164, 146, 143, 170, 206, 201, 240, 159, 247, 205, 231, 197, 254, 240, 148], + 'type': 138, } - self.evt_bin_0 = b'\xcf\xec\xfc\xe8' b'\xce\xd2\x83\xf6' \ - b'\xea\xa2\x97\xd9' b'\xa7\xab\x80\xef' \ - b'\xc8\xb3\x92\xd1' b'\x83\xdf\x9b\xb5' \ - b'\xab\xaf\xdc\xe3' b'\xc8\x8a\x86\x94' + self.evt_bin_0 = b'\x8a\xf8\xca\x88' b'\xbb\xc9\xc8\xf4' \ + b'\x92\xbb\xc3\xb2' b'\xec\x9d\xb9\xa6' \ + b'\xc4\xa4\x92\x8f' b'\xaa\xce\xc9\xf0' \ + b'\x9f\xf7\xcd\xe7' b'\xc5\xfe\xf0\x94' def testPack0(self): @@ -36,18 +36,18 @@ def testUnpack0(self): class TestExpose(EndianTest): def setUp(self): self.evt_args_0 = { - 'count': 7686, - 'height': 49538, - 'sequence_number': 18018, - 'type': 214, - 'width': 18088, - 'window': 1421524673, - 'x': 31959, - 'y': 29112, + 'count': 15258, + 'height': 6241, + 'sequence_number': 48394, + 'type': 238, + 'width': 1951, + 'window': 692245859, + 'x': 39820, + 'y': 16664, } - self.evt_bin_0 = b'\xd6\x00\x62\x46' b'\xc1\xbe\xba\x54' \ - b'\xd7\x7c\xb8\x71' b'\xa8\x46\x82\xc1' \ - b'\x06\x1e\x00\x00' b'\x00\x00\x00\x00' \ + self.evt_bin_0 = b'\xee\x00\x0a\xbd' b'\x63\xd5\x42\x29' \ + b'\x8c\x9b\x18\x41' b'\x9f\x07\x61\x18' \ + b'\x9a\x3b\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -64,20 +64,20 @@ def testUnpack0(self): class TestGraphicsExpose(EndianTest): def setUp(self): self.evt_args_0 = { - 'count': 757, - 'drawable': 1457059207, - 'height': 26058, - 'major_event': 166, - 'minor_event': 39379, - 'sequence_number': 18746, - 'type': 183, - 'width': 3220, - 'x': 32023, - 'y': 43806, + 'count': 49818, + 'drawable': 1443779242, + 'height': 2892, + 'major_event': 172, + 'minor_event': 50267, + 'sequence_number': 50375, + 'type': 133, + 'width': 38020, + 'x': 54088, + 'y': 17918, } - self.evt_bin_0 = b'\xb7\x00\x3a\x49' b'\x87\xf5\xd8\x56' \ - b'\x17\x7d\x1e\xab' b'\x94\x0c\xca\x65' \ - b'\xd3\x99\xf5\x02' b'\xa6\x00\x00\x00' \ + self.evt_bin_0 = b'\x85\x00\xc7\xc4' b'\xaa\x52\x0e\x56' \ + b'\x48\xd3\xfe\x45' b'\x84\x94\x4c\x0b' \ + b'\x5b\xc4\x9a\xc2' b'\xac\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -94,14 +94,14 @@ def testUnpack0(self): class TestNoExpose(EndianTest): def setUp(self): self.evt_args_0 = { - 'major_event': 128, - 'minor_event': 21675, - 'sequence_number': 9214, - 'type': 155, - 'window': 548772746, + 'major_event': 199, + 'minor_event': 29237, + 'sequence_number': 34266, + 'type': 248, + 'window': 1399171519, } - self.evt_bin_0 = b'\x9b\x00\xfe\x23' b'\x8a\x9b\xb5\x20' \ - b'\xab\x54\x80\x00' b'\x00\x00\x00\x00' \ + self.evt_bin_0 = b'\xf8\x00\xda\x85' b'\xbf\xa9\x65\x53' \ + b'\x35\x72\xc7\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -119,13 +119,13 @@ def testUnpack0(self): class TestVisibilityNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'sequence_number': 11725, - 'state': 218, - 'type': 223, - 'window': 816529890, + 'sequence_number': 38616, + 'state': 253, + 'type': 174, + 'window': 936121409, } - self.evt_bin_0 = b'\xdf\x00\xcd\x2d' b'\xe2\x41\xab\x30' \ - b'\xda\x00\x00\x00' b'\x00\x00\x00\x00' \ + self.evt_bin_0 = b'\xae\x00\xd8\x96' b'\x41\x14\xcc\x37' \ + b'\xfd\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -143,20 +143,20 @@ def testUnpack0(self): class TestCreateNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'border_width': 56534, - 'height': 60389, - 'override': 1, - 'parent': 1731314417, - 'sequence_number': 54657, - 'type': 192, - 'width': 1479, - 'window': 154841762, - 'x': -4750, - 'y': -31393, + 'border_width': 56468, + 'height': 7111, + 'override': 0, + 'parent': 747306217, + 'sequence_number': 31058, + 'type': 151, + 'width': 44173, + 'window': 876986399, + 'x': -21847, + 'y': -22248, } - self.evt_bin_0 = b'\xc0\x00\x81\xd5' b'\xf1\xc2\x31\x67' \ - b'\xa2\xb2\x3a\x09' b'\x72\xed\x5f\x85' \ - b'\xc7\x05\xe5\xeb' b'\xd6\xdc\x01\x00' \ + self.evt_bin_0 = b'\x97\x00\x52\x79' b'\xe9\xfc\x8a\x2c' \ + b'\x1f\xc0\x45\x34' b'\xa9\xaa\x18\xa9' \ + b'\x8d\xac\xc7\x1b' b'\x94\xdc\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -173,13 +173,13 @@ def testUnpack0(self): class TestDestroyNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'event': 897029110, - 'sequence_number': 46572, - 'type': 201, - 'window': 247390922, + 'event': 1489718405, + 'sequence_number': 27233, + 'type': 212, + 'window': 1064077163, } - self.evt_bin_0 = b'\xc9\x00\xec\xb5' b'\xf6\x93\x77\x35' \ - b'\xca\xe2\xbe\x0e' b'\x00\x00\x00\x00' \ + self.evt_bin_0 = b'\xd4\x00\x61\x6a' b'\x85\x4c\xcb\x58' \ + b'\x6b\x87\x6c\x3f' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -197,14 +197,14 @@ def testUnpack0(self): class TestUnmapNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'event': 1720839242, - 'from_configure': 1, - 'sequence_number': 21456, - 'type': 130, - 'window': 1327438921, + 'event': 2029853215, + 'from_configure': 0, + 'sequence_number': 43679, + 'type': 201, + 'window': 860030193, } - self.evt_bin_0 = b'\x82\x00\xd0\x53' b'\x4a\xec\x91\x66' \ - b'\x49\x1c\x1f\x4f' b'\x01\x00\x00\x00' \ + self.evt_bin_0 = b'\xc9\x00\x9f\xaa' b'\x1f\x1a\xfd\x78' \ + b'\xf1\x04\x43\x33' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -222,14 +222,14 @@ def testUnpack0(self): class TestMapNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'event': 1813526544, + 'event': 675485985, 'override': 1, - 'sequence_number': 6009, - 'type': 245, - 'window': 522567740, + 'sequence_number': 6027, + 'type': 244, + 'window': 542087937, } - self.evt_bin_0 = b'\xf5\x00\x79\x17' b'\x10\x38\x18\x6c' \ - b'\x3c\xc0\x25\x1f' b'\x01\x00\x00\x00' \ + self.evt_bin_0 = b'\xf4\x00\x8b\x17' b'\x21\x19\x43\x28' \ + b'\x01\x9b\x4f\x20' b'\x01\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -247,13 +247,13 @@ def testUnpack0(self): class TestMapRequest(EndianTest): def setUp(self): self.evt_args_0 = { - 'parent': 666354749, - 'sequence_number': 26091, - 'type': 195, - 'window': 729142504, + 'parent': 1659099581, + 'sequence_number': 63838, + 'type': 157, + 'window': 868024861, } - self.evt_bin_0 = b'\xc3\x00\xeb\x65' b'\x3d\xc4\xb7\x27' \ - b'\xe8\xd4\x75\x2b' b'\x00\x00\x00\x00' \ + self.evt_bin_0 = b'\x9d\x00\x5e\xf9' b'\xbd\xd9\xe3\x62' \ + b'\x1d\x02\xbd\x33' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -271,18 +271,18 @@ def testUnpack0(self): class TestReparentNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'event': 1096286586, - 'override': 1, - 'parent': 1095145830, - 'sequence_number': 11231, - 'type': 170, - 'window': 244928407, - 'x': -3314, - 'y': -21409, + 'event': 1867017989, + 'override': 0, + 'parent': 992152190, + 'sequence_number': 43356, + 'type': 128, + 'window': 1165276406, + 'x': -19227, + 'y': -30992, } - self.evt_bin_0 = b'\xaa\x00\xdf\x2b' b'\x7a\x01\x58\x41' \ - b'\x97\x4f\x99\x0e' b'\x66\x99\x46\x41' \ - b'\x0e\xf3\x5f\xac' b'\x01\x00\x00\x00' \ + self.evt_bin_0 = b'\x80\x00\x5c\xa9' b'\x05\x6f\x48\x6f' \ + b'\xf6\xb4\x74\x45' b'\x7e\x0a\x23\x3b' \ + b'\xe5\xb4\xf0\x86' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -299,22 +299,22 @@ def testUnpack0(self): class TestConfigureNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'above_sibling': 423690578, - 'border_width': 50707, - 'event': 507433541, - 'height': 11820, + 'above_sibling': 1343120585, + 'border_width': 17757, + 'event': 1624514845, + 'height': 13596, 'override': 0, - 'sequence_number': 53461, - 'type': 232, - 'width': 43047, - 'window': 314542502, - 'x': -13183, - 'y': -8052, + 'sequence_number': 41060, + 'type': 220, + 'width': 3638, + 'window': 1070571314, + 'x': -18284, + 'y': -7865, } - self.evt_bin_0 = b'\xe8\x00\xd5\xd0' b'\x45\xd2\x3e\x1e' \ - b'\xa6\x89\xbf\x12' b'\x52\x01\x41\x19' \ - b'\x81\xcc\x8c\xe0' b'\x27\xa8\x2c\x2e' \ - b'\x13\xc6\x00\x00' b'\x00\x00\x00\x00' + self.evt_bin_0 = b'\xdc\x00\x64\xa0' b'\x1d\x21\xd4\x60' \ + b'\x32\x9f\xcf\x3f' b'\xc9\x64\x0e\x50' \ + b'\x94\xb8\x47\xe1' b'\x36\x0e\x1c\x35' \ + b'\x5d\x45\x00\x00' b'\x00\x00\x00\x00' def testPack0(self): @@ -330,23 +330,23 @@ def testUnpack0(self): class TestConfigureRequest(EndianTest): def setUp(self): self.evt_args_0 = { - 'border_width': 4713, - 'height': 10110, - 'parent': 1984611127, - 'sequence_number': 29560, - 'sibling': 1364316652, - 'stack_mode': 225, - 'type': 224, - 'value_mask': 29123, - 'width': 41200, - 'window': 1212265415, - 'x': -12463, - 'y': -4669, + 'border_width': 52639, + 'height': 40159, + 'parent': 1499546058, + 'sequence_number': 57983, + 'sibling': 260826075, + 'stack_mode': 240, + 'type': 201, + 'value_mask': 15938, + 'width': 41545, + 'window': 1040976198, + 'x': -31823, + 'y': -880, } - self.evt_bin_0 = b'\xe0\xe1\x78\x73' b'\x37\xc3\x4a\x76' \ - b'\xc7\xb3\x41\x48' b'\xec\xd1\x51\x51' \ - b'\x51\xcf\xc3\xed' b'\xf0\xa0\x7e\x27' \ - b'\x69\x12\xc3\x71' b'\x00\x00\x00\x00' + self.evt_bin_0 = b'\xc9\xf0\x7f\xe2' b'\xca\x41\x61\x59' \ + b'\x46\x09\x0c\x3e' b'\xdb\xe3\x8b\x0f' \ + b'\xb1\x83\x90\xfc' b'\x49\xa2\xdf\x9c' \ + b'\x9f\xcd\x42\x3e' b'\x00\x00\x00\x00' def testPack0(self): @@ -362,15 +362,15 @@ def testUnpack0(self): class TestGravityNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'event': 120690564, - 'sequence_number': 18186, - 'type': 166, - 'window': 1089529951, - 'x': -22676, - 'y': -18075, + 'event': 1182983311, + 'sequence_number': 20621, + 'type': 168, + 'window': 29431224, + 'x': -14672, + 'y': -19399, } - self.evt_bin_0 = b'\xa6\x00\x0a\x47' b'\x84\x97\x31\x07' \ - b'\x5f\xe8\xf0\x40' b'\x6c\xa7\x65\xb9' \ + self.evt_bin_0 = b'\xa8\x00\x8d\x50' b'\x8f\xe4\x82\x46' \ + b'\xb8\x15\xc1\x01' b'\xb0\xc6\x39\xb4' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -388,14 +388,14 @@ def testUnpack0(self): class TestResizeRequest(EndianTest): def setUp(self): self.evt_args_0 = { - 'height': 56089, - 'sequence_number': 54549, - 'type': 135, - 'width': 56674, - 'window': 164839077, + 'height': 60085, + 'sequence_number': 14981, + 'type': 151, + 'width': 55398, + 'window': 2130921516, } - self.evt_bin_0 = b'\x87\x00\x15\xd5' b'\xa5\x3e\xd3\x09' \ - b'\x62\xdd\x19\xdb' b'\x00\x00\x00\x00' \ + self.evt_bin_0 = b'\x97\x00\x85\x3a' b'\x2c\x48\x03\x7f' \ + b'\x66\xd8\xb5\xea' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -413,16 +413,16 @@ def testUnpack0(self): class TestPropertyNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'atom': 1190414551, - 'sequence_number': 33357, - 'state': 242, - 'time': 1700429414, - 'type': 206, - 'window': 993700932, + 'atom': 252322161, + 'sequence_number': 30497, + 'state': 167, + 'time': 1391011497, + 'type': 157, + 'window': 2033863003, } - self.evt_bin_0 = b'\xce\x00\x4d\x82' b'\x44\xac\x3a\x3b' \ - b'\xd7\x48\xf4\x46' b'\x66\x7e\x5a\x65' \ - b'\xf2\x00\x00\x00' b'\x00\x00\x00\x00' \ + self.evt_bin_0 = b'\x9d\x00\x21\x77' b'\x5b\x49\x3a\x79' \ + b'\x71\x21\x0a\x0f' b'\xa9\x26\xe9\x52' \ + b'\xa7\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -439,14 +439,14 @@ def testUnpack0(self): class TestSelectionClear(EndianTest): def setUp(self): self.evt_args_0 = { - 'atom': 1021439924, - 'sequence_number': 53120, - 'time': 1399833091, - 'type': 185, - 'window': 690517929, + 'atom': 1092859866, + 'sequence_number': 61378, + 'time': 1538959461, + 'type': 255, + 'window': 626833463, } - self.evt_bin_0 = b'\xb9\x00\x80\xcf' b'\x03\xc2\x6f\x53' \ - b'\xa9\x77\x28\x29' b'\xb4\xef\xe1\x3c' \ + self.evt_bin_0 = b'\xff\x00\xc2\xef' b'\x65\xa8\xba\x5b' \ + b'\x37\xb8\x5c\x25' b'\xda\xb7\x23\x41' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -464,19 +464,19 @@ def testUnpack0(self): class TestSelectionRequest(EndianTest): def setUp(self): self.evt_args_0 = { - 'owner': 1930866783, - 'property': 370621667, - 'requestor': 737570035, - 'selection': 1533999683, - 'sequence_number': 4295, - 'target': 1083543199, - 'time': 222327341, - 'type': 147, + 'owner': 1036225485, + 'property': 981007010, + 'requestor': 2105124856, + 'selection': 1014149797, + 'sequence_number': 27485, + 'target': 523473665, + 'time': 1792621552, + 'type': 197, } - self.evt_bin_0 = b'\x93\x00\xc7\x10' b'\x2d\x72\x40\x0d' \ - b'\x5f\xb0\x16\x73' b'\xf3\x6c\xf6\x2b' \ - b'\x43\xfa\x6e\x5b' b'\x9f\x8e\x95\x40' \ - b'\xe3\x3c\x17\x16' b'\x00\x00\x00\x00' + self.evt_bin_0 = b'\xc5\x00\x5d\x6b' b'\xf0\x3b\xd9\x6a' \ + b'\xcd\x8b\xc3\x3d' b'\xf8\xa7\x79\x7d' \ + b'\xa5\xb2\x72\x3c' b'\x01\x93\x33\x1f' \ + b'\xa2\xfa\x78\x3a' b'\x00\x00\x00\x00' def testPack0(self): @@ -492,17 +492,17 @@ def testUnpack0(self): class TestSelectionNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'property': 607556330, - 'requestor': 1122624134, - 'selection': 340960018, - 'sequence_number': 28832, - 'target': 800734635, - 'time': 943687849, - 'type': 159, + 'property': 1602716574, + 'requestor': 1979762314, + 'selection': 1287219120, + 'sequence_number': 25394, + 'target': 1091504539, + 'time': 409398186, + 'type': 165, } - self.evt_bin_0 = b'\x9f\x00\xa0\x70' b'\xa9\x88\x3f\x38' \ - b'\x86\xe2\xe9\x42' b'\x12\xa3\x52\x14' \ - b'\xab\x3d\xba\x2f' b'\xea\x92\x36\x24' \ + self.evt_bin_0 = b'\xa5\x00\x32\x63' b'\xaa\xeb\x66\x18' \ + b'\x8a\xc6\x00\x76' b'\xb0\x67\xb9\x4c' \ + b'\x9b\x09\x0f\x41' b'\x9e\x83\x87\x5f' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -519,15 +519,15 @@ def testUnpack0(self): class TestColormapNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'colormap': 1694865742, + 'colormap': 593302316, 'new': 1, - 'sequence_number': 22344, - 'state': 136, - 'type': 180, - 'window': 1283976465, + 'sequence_number': 56880, + 'state': 215, + 'type': 162, + 'window': 149981547, } - self.evt_bin_0 = b'\xb4\x00\x48\x57' b'\x11\xed\x87\x4c' \ - b'\x4e\x99\x05\x65' b'\x01\x88\x00\x00' \ + self.evt_bin_0 = b'\xa2\x00\x30\xde' b'\x6b\x89\xf0\x08' \ + b'\x2c\x13\x5d\x23' b'\x01\xd7\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -545,38 +545,38 @@ def testUnpack0(self): class TestClientMessage(EndianTest): def setUp(self): self.evt_args_0 = { - 'client_type': 1554224294, + 'client_type': 607457628, 'data': (8, b'01234567890123456789'), - 'sequence_number': 44540, - 'type': 140, - 'window': 610247893, + 'sequence_number': 54031, + 'type': 196, + 'window': 5574388, } - self.evt_bin_0 = b'\x8c\x08\xfc\xad' b'\xd5\xa4\x5f\x24' \ - b'\xa6\x94\xa3\x5c' b'\x30\x31\x32\x33' \ + self.evt_bin_0 = b'\xc4\x08\x0f\xd3' b'\xf4\x0e\x55\x00' \ + b'\x5c\x11\x35\x24' b'\x30\x31\x32\x33' \ b'\x34\x35\x36\x37' b'\x38\x39\x30\x31' \ b'\x32\x33\x34\x35' b'\x36\x37\x38\x39' self.evt_args_1 = { - 'client_type': 715933209, + 'client_type': 1245441508, 'data': (16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), - 'sequence_number': 59422, - 'type': 212, - 'window': 1875362098, + 'sequence_number': 55140, + 'type': 204, + 'window': 1260504694, } - self.evt_bin_1 = b'\xd4\x10\x1e\xe8' b'\x32\xc1\xc7\x6f' \ - b'\x19\x46\xac\x2a' b'\x01\x00\x02\x00' \ + self.evt_bin_1 = b'\xcc\x10\x64\xd7' b'\x76\xc6\x21\x4b' \ + b'\xe4\xed\x3b\x4a' b'\x01\x00\x02\x00' \ b'\x03\x00\x04\x00' b'\x05\x00\x06\x00' \ b'\x07\x00\x08\x00' b'\x09\x00\x0a\x00' self.evt_args_2 = { - 'client_type': 2078114542, + 'client_type': 959018764, 'data': (32, [1, 2, 3, 4, 5]), - 'sequence_number': 9488, - 'type': 202, - 'window': 751277030, + 'sequence_number': 56961, + 'type': 253, + 'window': 319171761, } - self.evt_bin_2 = b'\xca\x20\x10\x25' b'\xe6\x93\xc7\x2c' \ - b'\xee\x82\xdd\x7b' b'\x01\x00\x00\x00' \ + self.evt_bin_2 = b'\xfd\x20\x81\xde' b'\xb1\x2c\x06\x13' \ + b'\x0c\x77\x29\x39' b'\x01\x00\x00\x00' \ b'\x02\x00\x00\x00' b'\x03\x00\x00\x00' \ b'\x04\x00\x00\x00' b'\x05\x00\x00\x00' @@ -612,13 +612,13 @@ def testUnpack2(self): class TestMappingNotify(EndianTest): def setUp(self): self.evt_args_0 = { - 'count': 167, - 'first_keycode': 248, - 'request': 204, - 'sequence_number': 25843, - 'type': 217, + 'count': 244, + 'first_keycode': 224, + 'request': 213, + 'sequence_number': 22874, + 'type': 251, } - self.evt_bin_0 = b'\xd9\x00\xf3\x64' b'\xcc\xf8\xa7\x00' \ + self.evt_bin_0 = b'\xfb\x00\x5a\x59' b'\xd5\xe0\xf4\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' diff --git a/test/test_requests_le.py b/test/test_requests_le.py old mode 100644 new mode 100755 index ab49c024..b5690b2e --- a/test/test_requests_le.py +++ b/test/test_requests_le.py @@ -14,30 +14,30 @@ class TestCreateWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'attrs': {'cursor': 1395639147, 'override_redirect': 0, 'bit_gravity': 7, 'event_mask': 1085274634, 'border_pixel': 479392317, 'background_pixel': 53774084, 'save_under': 0, 'colormap': 427053108, 'do_not_propagate_mask': 57049357, 'backing_store': 2, 'win_gravity': 6, 'backing_planes': 186759559, 'border_pixmap': 590668475, 'backing_pixel': 906108093, 'background_pixmap': 1373182223}, - 'border_width': 22467, - 'depth': 197, - 'height': 45830, - 'parent': 1265465337, - 'visual': 2055602223, - 'wid': 473443720, - 'width': 52859, - 'window_class': 0, - 'x': -6451, - 'y': -32557, - } - self.req_bin_0 = b'\x01\xc5\x17\x00' b'\x88\x2d\x38\x1c' \ - b'\xf9\x77\x6d\x4b' b'\xcd\xe6\xd3\x80' \ - b'\x7b\xce\x06\xb3' b'\xc3\x57\x00\x00' \ - b'\x2f\x00\x86\x7a' b'\xff\x7f\x00\x00' \ - b'\x0f\x19\xd9\x51' b'\x04\x87\x34\x03' \ - b'\xbb\xe2\x34\x23' b'\x3d\xf2\x92\x1c' \ - b'\x07\x00\x00\x00' b'\x06\x00\x00\x00' \ - b'\x02\x00\x00\x00' b'\x87\xb9\x21\x0b' \ - b'\xbd\x1c\x02\x36' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x0a\xfa\xaf\x40' \ - b'\x0d\x81\x66\x03' b'\x34\x50\x74\x19' \ - b'\x6b\xc3\x2f\x53' + 'attrs': {'background_pixmap': 1373224142, 'background_pixel': 239147199, 'border_pixmap': 53775720, 'border_pixel': 1592533117, 'bit_gravity': 3, 'win_gravity': 2, 'backing_store': 0, 'backing_planes': 299720948, 'backing_pixel': 1581625428, 'override_redirect': 0, 'save_under': 0, 'event_mask': 1268138548, 'do_not_propagate_mask': 906135756, 'colormap': 68318329, 'cursor': 64054583}, + 'border_width': 13287, + 'depth': 151, + 'height': 37037, + 'parent': 499701004, + 'visual': 1395681732, + 'wid': 469587013, + 'width': 1995, + 'window_class': 2, + 'x': -16209, + 'y': -13042, + } + self.req_bin_0 = b'\x01\x97\x17\x00' b'\x45\x54\xfd\x1b' \ + b'\x0c\xd5\xc8\x1d' b'\xaf\xc0\x0e\xcd' \ + b'\xcb\x07\xad\x90' b'\xe7\x33\x02\x00' \ + b'\xc4\x69\x30\x53' b'\xff\x7f\x00\x00' \ + b'\xce\xbc\xd9\x51' b'\xbf\x18\x41\x0e' \ + b'\x68\x8d\x34\x03' b'\x7d\x20\xec\x5e' \ + b'\x03\x00\x00\x00' b'\x02\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\xf4\x60\xdd\x11' \ + b'\x54\xb0\x45\x5e' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x34\x42\x96\x4b' \ + b'\xcc\x88\x02\x36' b'\x79\x74\x12\x04' \ + b'\x37\x65\xd1\x03' def testPackRequest0(self): @@ -53,18 +53,18 @@ def testUnpackRequest0(self): class TestChangeWindowAttributes(EndianTest): def setUp(self): self.req_args_0 = { - 'attrs': {'cursor': 1239881989, 'override_redirect': 0, 'bit_gravity': 5, 'event_mask': 1781144133, 'border_pixel': 1819990287, 'background_pixel': 199229639, 'save_under': 1, 'colormap': 1850510540, 'do_not_propagate_mask': 1328286054, 'backing_store': 2, 'win_gravity': 7, 'backing_planes': 1151571451, 'border_pixmap': 207756035, 'backing_pixel': 2089751951, 'background_pixmap': 722874758}, - 'window': 1513075857, + 'attrs': {'background_pixmap': 1506149446, 'background_pixel': 1170318459, 'border_pixmap': 900977490, 'border_pixel': 473458160, 'bit_gravity': 6, 'win_gravity': 8, 'backing_store': 1, 'backing_planes': 1738304197, 'backing_pixel': 1866873765, 'override_redirect': 0, 'save_under': 0, 'event_mask': 1499308477, 'do_not_propagate_mask': 907623048, 'colormap': 730747963, 'cursor': 596789700}, + 'window': 333955224, } - self.req_bin_0 = b'\x02\x00\x12\x00' b'\x91\xb4\x2f\x5a' \ - b'\xff\x7f\x00\x00' b'\x86\x31\x16\x2b' \ - b'\xc7\x00\xe0\x0b' b'\x03\x1b\x62\x0c' \ - b'\x0f\xd9\x7a\x6c' b'\x05\x00\x00\x00' \ - b'\x07\x00\x00\x00' b'\x02\x00\x00\x00' \ - b'\xfb\x95\xa3\x44' b'\x8f\x15\x8f\x7c' \ - b'\x00\x00\x00\x00' b'\x01\x00\x00\x00' \ - b'\x45\x1a\x2a\x6a' b'\x66\x09\x2c\x4f' \ - b'\xcc\x8c\x4c\x6e' b'\x05\x19\xe7\x49' + self.req_bin_0 = b'\x02\x00\x12\x00' b'\x98\xc0\xe7\x13' \ + b'\xff\x7f\x00\x00' b'\x46\x04\xc6\x59' \ + b'\x7b\xa4\xc1\x45' b'\x52\xd3\xb3\x35' \ + b'\xf0\x65\x38\x1c' b'\x06\x00\x00\x00' \ + b'\x08\x00\x00\x00' b'\x01\x00\x00\x00' \ + b'\xc5\x6a\x9c\x67' b'\xa5\x3b\x46\x6f' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\xbd\xa1\x5d\x59' b'\x88\x3a\x19\x36' \ + b'\x3b\x54\x8e\x2b' b'\xc4\x49\x92\x23' def testPackRequest0(self): @@ -80,34 +80,34 @@ def testUnpackRequest0(self): class TestGetWindowAttributes(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 98469647, + 'window': 462448317, } - self.req_bin_0 = b'\x03\x00\x02\x00' b'\x0f\x87\xde\x05' + self.req_bin_0 = b'\x03\x00\x02\x00' b'\xbd\x66\x90\x1b' self.reply_args_0 = { - 'all_event_masks': 1308124489, - 'backing_bit_planes': 1365145824, - 'backing_pixel': 783512764, - 'backing_store': 157, - 'bit_gravity': 140, - 'colormap': 1391668458, - 'do_not_propagate_mask': 47853, + 'all_event_masks': 1980679760, + 'backing_bit_planes': 1820045833, + 'backing_pixel': 738704824, + 'backing_store': 214, + 'bit_gravity': 152, + 'colormap': 2089815718, + 'do_not_propagate_mask': 5420, 'map_is_installed': 0, - 'map_state': 162, - 'override_redirect': 1, - 'save_under': 0, - 'sequence_number': 19147, - 'visual': 171412272, - 'win_class': 15452, - 'win_gravity': 163, - 'your_event_mask': 367571768, + 'map_state': 245, + 'override_redirect': 0, + 'save_under': 1, + 'sequence_number': 6954, + 'visual': 199235720, + 'win_class': 25154, + 'win_gravity': 219, + 'your_event_mask': 812961929, } - self.reply_bin_0 = b'\x01\x9d\xcb\x4a' b'\x03\x00\x00\x00' \ - b'\x30\x8b\x37\x0a' b'\x5c\x3c\x8c\xa3' \ - b'\xe0\x78\x5e\x51' b'\xbc\x74\xb3\x2e' \ - b'\x00\x00\xa2\x01' b'\xea\x2c\xf3\x52' \ - b'\x49\x65\xf8\x4d' b'\x38\xb3\xe8\x15' \ - b'\xed\xba\x00\x00' + self.reply_bin_0 = b'\x01\xd6\x2a\x1b' b'\x03\x00\x00\x00' \ + b'\x88\x18\xe0\x0b' b'\x42\x62\x98\xdb' \ + b'\x09\xb2\x7b\x6c' b'\xb8\xbd\x07\x2c' \ + b'\x01\x00\xf5\x00' b'\xa6\x0e\x90\x7c' \ + b'\x50\xc6\x0e\x76' b'\x89\xd0\x74\x30' \ + b'\x2c\x15\x00\x00' def testPackRequest0(self): @@ -132,9 +132,9 @@ def testUnpackReply0(self): class TestDestroyWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 350959010, + 'window': 1185563768, } - self.req_bin_0 = b'\x04\x00\x02\x00' b'\xa2\x35\xeb\x14' + self.req_bin_0 = b'\x04\x00\x02\x00' b'\x78\x44\xaa\x46' def testPackRequest0(self): @@ -150,9 +150,9 @@ def testUnpackRequest0(self): class TestDestroySubWindows(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 814915023, + 'window': 629661088, } - self.req_bin_0 = b'\x05\x00\x02\x00' b'\xcf\x9d\x92\x30' + self.req_bin_0 = b'\x05\x00\x02\x00' b'\xa0\xdd\x87\x25' def testPackRequest0(self): @@ -169,9 +169,9 @@ class TestChangeSaveSet(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 1, - 'window': 1374412611, + 'window': 1239919839, } - self.req_bin_0 = b'\x06\x01\x02\x00' b'\x43\xdf\xeb\x51' + self.req_bin_0 = b'\x06\x01\x02\x00' b'\xdf\xac\xe7\x49' def testPackRequest0(self): @@ -187,13 +187,13 @@ def testUnpackRequest0(self): class TestReparentWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'parent': 1470218577, - 'window': 1196069502, - 'x': -5365, - 'y': -7538, + 'parent': 1513122040, + 'window': 413002134, + 'x': -30489, + 'y': -31267, } - self.req_bin_0 = b'\x07\x00\x04\x00' b'\x7e\x92\x4a\x47' \ - b'\x51\xc1\xa1\x57' b'\x0b\xeb\x8e\xe2' + self.req_bin_0 = b'\x07\x00\x04\x00' b'\x96\xe9\x9d\x18' \ + b'\xf8\x68\x30\x5a' b'\xe7\x88\xdd\x85' def testPackRequest0(self): @@ -209,9 +209,9 @@ def testUnpackRequest0(self): class TestMapWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 491927514, + 'window': 1420117708, } - self.req_bin_0 = b'\x08\x00\x02\x00' b'\xda\x37\x52\x1d' + self.req_bin_0 = b'\x08\x00\x02\x00' b'\xcc\x46\xa5\x54' def testPackRequest0(self): @@ -227,9 +227,9 @@ def testUnpackRequest0(self): class TestMapSubwindows(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 68998181, + 'window': 489473351, } - self.req_bin_0 = b'\x09\x00\x02\x00' b'\x25\xd4\x1c\x04' + self.req_bin_0 = b'\x09\x00\x02\x00' b'\x47\xc5\x2c\x1d' def testPackRequest0(self): @@ -245,9 +245,9 @@ def testUnpackRequest0(self): class TestUnmapWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 677475124, + 'window': 1660217157, } - self.req_bin_0 = b'\x0a\x00\x02\x00' b'\x34\x73\x61\x28' + self.req_bin_0 = b'\x0a\x00\x02\x00' b'\x45\xe7\xf4\x62' def testPackRequest0(self): @@ -263,9 +263,9 @@ def testUnpackRequest0(self): class TestUnmapSubwindows(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 575017142, + 'window': 621521446, } - self.req_bin_0 = b'\x0b\x00\x02\x00' b'\xb6\x10\x46\x22' + self.req_bin_0 = b'\x0b\x00\x02\x00' b'\x26\xaa\x0b\x25' def testPackRequest0(self): @@ -281,14 +281,14 @@ def testUnpackRequest0(self): class TestConfigureWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'attrs': {'width': 61485, 'stack_mode': 4, 'height': 43079, 'sibling': 849652645, 'y': -1871, 'x': -25855, 'border_width': -11291}, - 'window': 985412314, + 'attrs': {'x': -27539, 'y': -17512, 'width': 39387, 'height': 57679, 'border_width': -14551, 'sibling': 973756745, 'stack_mode': 2}, + 'window': 349362548, } - self.req_bin_0 = b'\x0c\x00\x0a\x00' b'\xda\x32\xbc\x3a' \ - b'\x7f\x00\x00\x00' b'\x01\x9b\x00\x00' \ - b'\xb1\xf8\x00\x00' b'\x2d\xf0\x00\x00' \ - b'\x47\xa8\x00\x00' b'\xe5\xd3\x00\x00' \ - b'\xa5\xab\xa4\x32' b'\x04\x00\x00\x00' + self.req_bin_0 = b'\x0c\x00\x0a\x00' b'\x74\xd9\xd2\x14' \ + b'\x7f\x00\x00\x00' b'\x6d\x94\x00\x00' \ + b'\x98\xbb\x00\x00' b'\xdb\x99\x00\x00' \ + b'\x4f\xe1\x00\x00' b'\x29\xc7\x00\x00' \ + b'\x49\x59\x0a\x3a' b'\x02\x00\x00\x00' def testPackRequest0(self): @@ -304,10 +304,10 @@ def testUnpackRequest0(self): class TestCirculateWindow(EndianTest): def setUp(self): self.req_args_0 = { - 'direction': 0, - 'window': 529677912, + 'direction': 1, + 'window': 763003561, } - self.req_bin_0 = b'\x0d\x00\x02\x00' b'\x58\x3e\x92\x1f' + self.req_bin_0 = b'\x0d\x01\x02\x00' b'\xa9\x82\x7a\x2d' def testPackRequest0(self): @@ -323,23 +323,23 @@ def testUnpackRequest0(self): class TestGetGeometry(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 1205557634, + 'drawable': 449978455, } - self.req_bin_0 = b'\x0e\x00\x02\x00' b'\x82\x59\xdb\x47' + self.req_bin_0 = b'\x0e\x00\x02\x00' b'\x57\x20\xd2\x1a' self.reply_args_0 = { - 'border_width': 6190, - 'depth': 161, - 'height': 33517, - 'root': 1928066656, - 'sequence_number': 38417, - 'width': 65375, - 'x': -19783, - 'y': -25638, - } - self.reply_bin_0 = b'\x01\xa1\x11\x96' b'\x00\x00\x00\x00' \ - b'\x60\xf6\xeb\x72' b'\xb9\xb2\xda\x9b' \ - b'\x5f\xff\xed\x82' b'\x2e\x18\x00\x00' \ + 'border_width': 41869, + 'depth': 196, + 'height': 40176, + 'root': 2011515940, + 'sequence_number': 46250, + 'width': 4935, + 'x': -10370, + 'y': -11534, + } + self.reply_bin_0 = b'\x01\xc4\xaa\xb4' b'\x00\x00\x00\x00' \ + b'\x24\x4c\xe5\x77' b'\x7e\xd7\xf2\xd2' \ + b'\x47\x13\xf0\x9c' b'\x8d\xa3\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -365,24 +365,24 @@ def testUnpackReply0(self): class TestQueryTree(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 101244093, + 'window': 367582976, } - self.req_bin_0 = b'\x0f\x00\x02\x00' b'\xbd\xdc\x08\x06' + self.req_bin_0 = b'\x0f\x00\x02\x00' b'\x00\xdf\xe8\x15' self.reply_args_0 = { - 'children': [235528064, 1347454529, 1700991108, 906619494, 136486082, 819561703, 2139154628], - 'parent': 1848519458, - 'root': 2085376831, - 'sequence_number': 34796, + 'children': [1147122179, 1565853418, 525792997, 350969719, 992761785, 814939899, 579774073], + 'parent': 1374454548, + 'root': 1987327953, + 'sequence_number': 65105, } - self.reply_bin_0 = b'\x01\x00\xec\x87' b'\x07\x00\x00\x00' \ - b'\x3f\x53\x4c\x7c' b'\x22\x2b\x2e\x6e' \ + self.reply_bin_0 = b'\x01\x00\x51\xfe' b'\x07\x00\x00\x00' \ + b'\xd1\x37\x74\x76' b'\x14\x83\xec\x51' \ b'\x07\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x80\xdf\x09\x0e' b'\x41\x86\x50\x50' \ - b'\x84\x10\x63\x65' b'\x66\xea\x09\x36' \ - b'\xc2\x9c\x22\x08' b'\xe7\x84\xd9\x30' \ - b'\xc4\xe8\x80\x7f' + b'\x03\xb2\x5f\x44' b'\xea\x06\x55\x5d' \ + b'\xe5\xf6\x56\x1f' b'\x77\x5f\xeb\x14' \ + b'\xb9\x57\x2c\x3b' b'\xfb\xfe\x92\x30' \ + b'\x79\xa6\x8e\x22' def testPackRequest0(self): @@ -415,11 +415,11 @@ def setUp(self): b'\x6f\x70\x00\x00' self.reply_args_0 = { - 'atom': 1463982728, - 'sequence_number': 47304, + 'atom': 696457407, + 'sequence_number': 45122, } - self.reply_bin_0 = b'\x01\x00\xc8\xb8' b'\x00\x00\x00\x00' \ - b'\x88\x9a\x42\x57' b'\x00\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\x42\xb0' b'\x00\x00\x00\x00' \ + b'\xbf\x18\x83\x29' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -446,15 +446,15 @@ def testUnpackReply0(self): class TestGetAtomName(EndianTest): def setUp(self): self.req_args_0 = { - 'atom': 1153165348, + 'atom': 1810076242, } - self.req_bin_0 = b'\x11\x00\x02\x00' b'\x24\xe8\xbb\x44' + self.req_bin_0 = b'\x11\x00\x02\x00' b'\x52\x92\xe3\x6b' self.reply_args_0 = { 'name': 'WM_CLASS', - 'sequence_number': 17674, + 'sequence_number': 50608, } - self.reply_bin_0 = b'\x01\x00\x0a\x45' b'\x02\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\xb0\xc5' b'\x02\x00\x00\x00' \ b'\x08\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ @@ -484,94 +484,94 @@ class TestChangeProperty(EndianTest): def setUp(self): self.req_args_0 = { 'data': (8, b''), - 'mode': 1, - 'property': 933688309, - 'type': 974400040, - 'window': 239614693, + 'mode': 0, + 'property': 1764873173, + 'type': 69000273, + 'window': 491942524, } - self.req_bin_0 = b'\x12\x01\x06\x00' b'\xe5\x3a\x48\x0e' \ - b'\xf5\xf3\xa6\x37' b'\x28\x2a\x14\x3a' \ + self.req_bin_0 = b'\x12\x00\x06\x00' b'\x7c\x72\x52\x1d' \ + b'\xd5\xd3\x31\x69' b'\x51\xdc\x1c\x04' \ b'\x08\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_1 = { 'data': (8, b'foo'), - 'mode': 2, - 'property': 565671953, - 'type': 1075033221, - 'window': 1880888002, + 'mode': 1, + 'property': 575034703, + 'type': 142204480, + 'window': 861560365, } - self.req_bin_1 = b'\x12\x02\x07\x00' b'\xc2\x12\x1c\x70' \ - b'\x11\x78\xb7\x21' b'\x85\xb4\x13\x40' \ + self.req_bin_1 = b'\x12\x01\x07\x00' b'\x2d\x5e\x5a\x33' \ + b'\x4f\x55\x46\x22' b'\x40\xde\x79\x08' \ b'\x08\x00\x00\x00' b'\x03\x00\x00\x00' \ b'\x66\x6f\x6f\x00' self.req_args_2 = { 'data': (8, b'zoom'), 'mode': 0, - 'property': 1869432878, - 'type': 640951286, - 'window': 1959859086, + 'property': 2024948722, + 'type': 1218075423, + 'window': 1961010416, } - self.req_bin_2 = b'\x12\x00\x07\x00' b'\x8e\x13\xd1\x74' \ - b'\x2e\x48\x6d\x6f' b'\xf6\x23\x34\x26' \ + self.req_bin_2 = b'\x12\x00\x07\x00' b'\xf0\xa4\xe2\x74' \ + b'\xf2\x43\xb2\x78' b'\x1f\x5b\x9a\x48' \ b'\x08\x00\x00\x00' b'\x04\x00\x00\x00' \ b'\x7a\x6f\x6f\x6d' self.req_args_3 = { 'data': (16, []), - 'mode': 1, - 'property': 328275349, - 'type': 1637495037, - 'window': 1307779197, + 'mode': 2, + 'property': 456677559, + 'type': 1407609354, + 'window': 675831147, } - self.req_bin_3 = b'\x12\x01\x06\x00' b'\x7d\x20\xf3\x4d' \ - b'\x95\x15\x91\x13' b'\xfd\x30\x9a\x61' \ + self.req_bin_3 = b'\x12\x02\x06\x00' b'\x6b\x5d\x48\x28' \ + b'\xb7\x58\x38\x1b' b'\x0a\x6a\xe6\x53' \ b'\x10\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_4 = { 'data': (16, [1, 2, 3]), 'mode': 1, - 'property': 1138956616, - 'type': 1293636, - 'window': 1672102137, + 'property': 1899908134, + 'type': 1964041522, + 'window': 849678568, } - self.req_bin_4 = b'\x12\x01\x08\x00' b'\xf9\x40\xaa\x63' \ - b'\x48\x19\xe3\x43' b'\x44\xbd\x13\x00' \ + self.req_bin_4 = b'\x12\x01\x08\x00' b'\xe8\x10\xa5\x32' \ + b'\x26\x4c\x3e\x71' b'\x32\xe5\x10\x75' \ b'\x10\x00\x00\x00' b'\x03\x00\x00\x00' \ b'\x01\x00\x02\x00' b'\x03\x00\x00\x00' self.req_args_5 = { 'data': (16, [1, 2, 3, 4]), - 'mode': 0, - 'property': 1995228731, - 'type': 1887048810, - 'window': 41890245, + 'mode': 2, + 'property': 306879937, + 'type': 568891375, + 'window': 985442388, } - self.req_bin_5 = b'\x12\x00\x08\x00' b'\xc5\x31\x7f\x02' \ - b'\x3b\xc6\xec\x76' b'\x6a\x14\x7a\x70' \ + self.req_bin_5 = b'\x12\x02\x08\x00' b'\x54\xa8\xbc\x3a' \ + b'\xc1\x9d\x4a\x12' b'\xef\x97\xe8\x21' \ b'\x10\x00\x00\x00' b'\x04\x00\x00\x00' \ b'\x01\x00\x02\x00' b'\x03\x00\x04\x00' self.req_args_6 = { 'data': (32, []), - 'mode': 2, - 'property': 124455087, - 'type': 1885519250, - 'window': 660426938, + 'mode': 0, + 'property': 1599917196, + 'type': 1205594429, + 'window': 529694076, } - self.req_bin_6 = b'\x12\x02\x06\x00' b'\xba\x50\x5d\x27' \ - b'\xaf\x08\x6b\x07' b'\x92\xbd\x62\x70' \ + self.req_bin_6 = b'\x12\x00\x06\x00' b'\x7c\x7d\x92\x1f' \ + b'\x8c\xcc\x5c\x5f' b'\x3d\xe9\xdb\x47' \ b'\x20\x00\x00\x00' b'\x00\x00\x00\x00' self.req_args_7 = { 'data': (32, [1, 2, 3]), 'mode': 2, - 'property': 1043690258, - 'type': 148693751, - 'window': 183999310, + 'property': 1604265475, + 'type': 1255454396, + 'window': 564298846, } - self.req_bin_7 = b'\x12\x02\x09\x00' b'\x4e\x9b\xf7\x0a' \ - b'\x12\x73\x35\x3e' b'\xf7\xe2\xdc\x08' \ + self.req_bin_7 = b'\x12\x02\x09\x00' b'\x5e\x84\xa2\x21' \ + b'\x03\x26\x9f\x5f' b'\xbc\xb6\xd4\x4a' \ b'\x20\x00\x00\x00' b'\x03\x00\x00\x00' \ b'\x01\x00\x00\x00' b'\x02\x00\x00\x00' \ b'\x03\x00\x00\x00' @@ -653,11 +653,11 @@ def testUnpackRequest7(self): class TestDeleteProperty(EndianTest): def setUp(self): self.req_args_0 = { - 'property': 1644632259, - 'window': 1633396400, + 'property': 1928125498, + 'window': 920120163, } - self.req_bin_0 = b'\x13\x00\x03\x00' b'\xb0\xa6\x5b\x61' \ - b'\xc3\x18\x07\x62' + self.req_bin_0 = b'\x13\x00\x03\x00' b'\x63\xeb\xd7\x36' \ + b'\x3a\xdc\xec\x72' def testPackRequest0(self): @@ -673,106 +673,106 @@ def testUnpackRequest0(self): class TestGetProperty(EndianTest): def setUp(self): self.req_args_0 = { - 'delete': 0, - 'long_length': 908719612, - 'long_offset': 1873544049, - 'property': 1180723730, - 'type': 569252941, - 'window': 1020695522, + 'delete': 1, + 'long_length': 297130690, + 'long_offset': 2142261240, + 'property': 471053276, + 'type': 2141806322, + 'window': 777446987, } - self.req_bin_0 = b'\x14\x00\x06\x00' b'\xe2\x93\xd6\x3c' \ - b'\x12\x6a\x60\x46' b'\x4d\x1c\xee\x21' \ - b'\x71\x03\xac\x6f' b'\xfc\xf5\x29\x36' + self.req_bin_0 = b'\x14\x01\x06\x00' b'\x4b\xe6\x56\x2e' \ + b'\xdc\xb3\x13\x1c' b'\xf2\x5e\xa9\x7f' \ + b'\xf8\x4f\xb0\x7f' b'\xc2\xda\xb5\x11' self.reply_args_0 = { - 'bytes_after': 1567532733, - 'property_type': 1158159724, - 'sequence_number': 14082, + 'bytes_after': 195292012, + 'property_type': 1059882735, + 'sequence_number': 33648, 'value': (8, b''), } - self.reply_bin_0 = b'\x01\x08\x02\x37' b'\x00\x00\x00\x00' \ - b'\x6c\x1d\x08\x45' b'\xbd\xa6\x6e\x5d' \ + self.reply_bin_0 = b'\x01\x08\x70\x83' b'\x00\x00\x00\x00' \ + b'\xef\x86\x2c\x3f' b'\x6c\xeb\xa3\x0b' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_1 = { - 'bytes_after': 2137067287, - 'property_type': 669450745, - 'sequence_number': 13387, + 'bytes_after': 1849269963, + 'property_type': 101247178, + 'sequence_number': 49786, 'value': (8, b'foo'), } - self.reply_bin_1 = b'\x01\x08\x4b\x34' b'\x01\x00\x00\x00' \ - b'\xf9\x01\xe7\x27' b'\x17\x0f\x61\x7f' \ + self.reply_bin_1 = b'\x01\x08\x7a\xc2' b'\x01\x00\x00\x00' \ + b'\xca\xe8\x08\x06' b'\xcb\x9e\x39\x6e' \ b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x66\x6f\x6f\x00' self.reply_args_2 = { - 'bytes_after': 1111517270, - 'property_type': 940849590, - 'sequence_number': 42680, + 'bytes_after': 1347495650, + 'property_type': 328289775, + 'sequence_number': 7441, 'value': (8, b'zoom'), } - self.reply_bin_2 = b'\x01\x08\xb8\xa6' b'\x01\x00\x00\x00' \ - b'\xb6\x39\x14\x38' b'\x56\x68\x40\x42' \ + self.reply_bin_2 = b'\x01\x08\x11\x1d' b'\x01\x00\x00\x00' \ + b'\xef\x4d\x91\x13' b'\xe2\x26\x51\x50' \ b'\x04\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x7a\x6f\x6f\x6d' self.reply_args_3 = { - 'bytes_after': 726076595, - 'property_type': 482584667, - 'sequence_number': 8155, + 'bytes_after': 1461387818, + 'property_type': 1701043014, + 'sequence_number': 10740, 'value': (16, []), } - self.reply_bin_3 = b'\x01\x10\xdb\x1f' b'\x00\x00\x00\x00' \ - b'\x5b\xa8\xc3\x1c' b'\xb3\x0c\x47\x2b' \ + self.reply_bin_3 = b'\x01\x10\xf4\x29' b'\x00\x00\x00\x00' \ + b'\x46\xdb\x63\x65' b'\x2a\x02\x1b\x57' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_4 = { - 'bytes_after': 472964335, - 'property_type': 494218080, - 'sequence_number': 38660, + 'bytes_after': 136490248, + 'property_type': 1280844186, + 'sequence_number': 27922, 'value': (16, [1, 2, 3]), } - self.reply_bin_4 = b'\x01\x10\x04\x97' b'\x02\x00\x00\x00' \ - b'\x60\x2b\x75\x1d' b'\xef\xdc\x30\x1c' \ + self.reply_bin_4 = b'\x01\x10\x12\x6d' b'\x02\x00\x00\x00' \ + b'\x9a\x21\x58\x4c' b'\x08\xad\x22\x08' \ b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x01\x00\x02\x00' b'\x03\x00\x00\x00' self.reply_args_5 = { - 'bytes_after': 491699268, - 'property_type': 1355307456, - 'sequence_number': 4890, + 'bytes_after': 1279726180, + 'property_type': 819586705, + 'sequence_number': 25472, 'value': (16, [1, 2, 3, 4]), } - self.reply_bin_5 = b'\x01\x10\x1a\x13' b'\x02\x00\x00\x00' \ - b'\xc0\x59\xc8\x50' b'\x44\xbc\x4e\x1d' \ + self.reply_bin_5 = b'\x01\x10\x80\x63' b'\x02\x00\x00\x00' \ + b'\x91\xe6\xd9\x30' b'\x64\x12\x47\x4c' \ b'\x04\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x01\x00\x02\x00' b'\x03\x00\x04\x00' self.reply_args_6 = { - 'bytes_after': 152225892, - 'property_type': 1846062163, - 'sequence_number': 59361, + 'bytes_after': 539973238, + 'property_type': 1136329940, + 'sequence_number': 30930, 'value': (32, []), } - self.reply_bin_6 = b'\x01\x20\xe1\xe7' b'\x00\x00\x00\x00' \ - b'\x53\xac\x08\x6e' b'\x64\xc8\x12\x09' \ + self.reply_bin_6 = b'\x01\x20\xd2\x78' b'\x00\x00\x00\x00' \ + b'\xd4\x04\xbb\x43' b'\x76\x56\x2f\x20' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' self.reply_args_7 = { - 'bytes_after': 460121536, - 'property_type': 1436640532, - 'sequence_number': 15792, + 'bytes_after': 1848575862, + 'property_type': 1188109101, + 'sequence_number': 63896, 'value': (32, [1, 2, 3]), } - self.reply_bin_7 = b'\x01\x20\xb0\x3d' b'\x03\x00\x00\x00' \ - b'\x14\x65\xa1\x55' b'\xc0\xe5\x6c\x1b' \ + self.reply_bin_7 = b'\x01\x20\x98\xf9' b'\x03\x00\x00\x00' \ + b'\x2d\x1b\xd1\x46' b'\x76\x07\x2f\x6e' \ b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x01\x00\x00\x00' b'\x02\x00\x00\x00' \ @@ -864,30 +864,30 @@ def testUnpackReply7(self): class TestListProperties(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 284194396, + 'window': 2023920407, } - self.req_bin_0 = b'\x15\x00\x02\x00' b'\x5c\x76\xf0\x10' + self.req_bin_0 = b'\x15\x00\x02\x00' b'\x17\x93\xa2\x78' self.reply_args_0 = { - 'atoms': [2009005759, 1226333816, 1015087858, 1684971497, 1734099213, 408955234, 208216521, 925712651, 909665942, 1002962766, 1565696219, 1446060760, 2113479735, 211409854, 864661769, 728690095, 1850436746, 534034650, 408523590, 963426393, 906021810, 598218424, 536504426], - 'sequence_number': 60526, + 'atoms': [24720840, 1460963027, 1547803868, 246063525, 1464027403, 1900134270, 1153200538, 1612563336, 573068260, 1650618737, 1376520521, 730586807, 239622004, 630352260, 933716813, 339706725, 974429777, 7034796, 2048369638, 1550746425, 1880945398, 1545568005, 565689201], + 'sequence_number': 63949, } - self.reply_bin_0 = b'\x01\x00\x6e\xec' b'\x17\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\xcd\xf9' b'\x17\x00\x00\x00' \ b'\x17\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\xbf\xfe\xbe\x77' b'\x78\x5e\x18\x49' \ - b'\xf2\x02\x81\x3c' b'\xe9\x9f\x6e\x64' \ - b'\x0d\x41\x5c\x67' b'\x62\x29\x60\x18' \ - b'\xc9\x21\x69\x0c' b'\x0b\x41\x2d\x37' \ - b'\x96\x66\x38\x36' b'\x4e\xff\xc7\x3b' \ - b'\xdb\xa0\x52\x5d' b'\xd8\x22\x31\x56' \ - b'\x37\x24\xf9\x7d' b'\xbe\xdb\x99\x0c' \ - b'\x09\xb1\x89\x33' b'\xaf\xed\x6e\x2b' \ - b'\x8a\x6c\x4b\x6e' b'\xda\xb8\xd4\x1f' \ - b'\x46\x93\x59\x18' b'\x59\xb8\x6c\x39' \ - b'\xb2\xcb\x00\x36' b'\xb8\x16\xa8\x23' \ - b'\x6a\x68\xfa\x1f' + b'\xc8\x35\x79\x01' b'\xd3\x86\x14\x57' \ + b'\xdc\x9c\x41\x5c' b'\xa5\xa1\xaa\x0e' \ + b'\x0b\x49\x43\x57' b'\x7e\xbf\x41\x71' \ + b'\x9a\x71\xbc\x44' b'\x88\xc3\x1d\x60' \ + b'\xe4\x53\x28\x22' b'\x71\x71\x62\x62' \ + b'\x49\x09\x0c\x52' b'\xb7\xde\x8b\x2b' \ + b'\x74\x57\x48\x0e' b'\x84\x69\x92\x25' \ + b'\x4d\x63\xa7\x37' b'\x65\x83\x3f\x14' \ + b'\x51\x9e\x14\x3a' b'\xac\x57\x6b\x00' \ + b'\xe6\xa3\x17\x7a' b'\x39\x83\x6e\x5c' \ + b'\xf6\xf2\x1c\x70' b'\x05\x7f\x1f\x5c' \ + b'\x71\xbb\xb7\x21' def testPackRequest0(self): @@ -912,12 +912,12 @@ def testUnpackReply0(self): class TestSetSelectionOwner(EndianTest): def setUp(self): self.req_args_0 = { - 'selection': 1849742203, - 'time': 1181844078, - 'window': 951652523, + 'selection': 1636366903, + 'time': 383717530, + 'window': 1075066031, } - self.req_bin_0 = b'\x16\x00\x04\x00' b'\xab\x10\xb9\x38' \ - b'\x7b\xd3\x40\x6e' b'\x6e\x82\x71\x46' + self.req_bin_0 = b'\x16\x00\x04\x00' b'\xaf\x34\x14\x40' \ + b'\x37\xfa\x88\x61' b'\x9a\x10\xdf\x16' def testPackRequest0(self): @@ -933,16 +933,16 @@ def testUnpackRequest0(self): class TestGetSelectionOwner(EndianTest): def setUp(self): self.req_args_0 = { - 'selection': 108699831, + 'selection': 1090303630, } - self.req_bin_0 = b'\x17\x00\x02\x00' b'\xb7\xa0\x7a\x06' + self.req_bin_0 = b'\x17\x00\x02\x00' b'\x8e\xb6\xfc\x40' self.reply_args_0 = { - 'owner': 1795366313, - 'sequence_number': 65489, + 'owner': 228581038, + 'sequence_number': 60065, } - self.reply_bin_0 = b'\x01\x00\xd1\xff' b'\x00\x00\x00\x00' \ - b'\xa9\x1d\x03\x6b' b'\x00\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\xa1\xea' b'\x00\x00\x00\x00' \ + b'\xae\xde\x9f\x0d' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -969,15 +969,15 @@ def testUnpackReply0(self): class TestConvertSelection(EndianTest): def setUp(self): self.req_args_0 = { - 'property': 357205026, - 'requestor': 2080905648, - 'selection': 1989362772, - 'target': 1822570126, - 'time': 1042940084, + 'property': 1807536699, + 'requestor': 1869489931, + 'selection': 1342887479, + 'target': 640970836, + 'time': 1372199123, } - self.req_bin_0 = b'\x18\x00\x06\x00' b'\xb0\x19\x08\x7c' \ - b'\x54\x44\x93\x76' b'\x8e\x36\xa2\x6c' \ - b'\x22\x84\x4a\x15' b'\xb4\x00\x2a\x3e' + self.req_bin_0 = b'\x18\x00\x06\x00' b'\x0b\x27\x6e\x6f' \ + b'\x37\xd6\x0a\x50' b'\x54\x70\x34\x26' \ + b'\x3b\xd2\xbc\x6b' b'\xd3\x18\xca\x51' def testPackRequest0(self): @@ -993,15 +993,15 @@ def testUnpackRequest0(self): class TestSendEvent(EndianTest): def setUp(self): self.req_args_0 = { - 'destination': 977158744, - 'event': event.Expose(count=17568, height=64576, sequence_number=0, type=12, width=24995, window=459070357, x=26435, y=4083), - 'event_mask': 908439472, - 'propagate': 1, + 'destination': 1158373169, + 'event': event.Expose(count=50227, height=24760, sequence_number=0, type=12, width=10272, window=1090263274, x=40165, y=13291), + 'event_mask': 2047690655, + 'propagate': 0, } - self.req_bin_0 = b'\x19\x01\x0b\x00' b'\x58\x42\x3e\x3a' \ - b'\xb0\xaf\x25\x36' b'\x0c\x00\x00\x00' \ - b'\x95\xdb\x5c\x1b' b'\x43\x67\xf3\x0f' \ - b'\xa3\x61\x40\xfc' b'\xa0\x44\x00\x00' \ + self.req_bin_0 = b'\x19\x00\x0b\x00' b'\x31\x5f\x0b\x45' \ + b'\x9f\x47\x0d\x7a' b'\x0c\x00\x00\x00' \ + b'\xea\x18\xfc\x40' b'\xe5\x9c\xeb\x33' \ + b'\x20\x28\xb8\x60' b'\x33\xc4\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' @@ -1019,24 +1019,24 @@ def testUnpackRequest0(self): class TestGrabPointer(EndianTest): def setUp(self): self.req_args_0 = { - 'confine_to': 637221294, - 'cursor': 2080289570, - 'event_mask': 36536, - 'grab_window': 2137654247, + 'confine_to': 240299645, + 'cursor': 1995289624, + 'event_mask': 21499, + 'grab_window': 1286289242, 'keyboard_mode': 0, - 'owner_events': 1, + 'owner_events': 0, 'pointer_mode': 1, - 'time': 1243807782, + 'time': 779560794, } - self.req_bin_0 = b'\x1a\x01\x06\x00' b'\xe7\x03\x6a\x7f' \ - b'\xb8\x8e\x01\x00' b'\xae\x39\xfb\x25' \ - b'\x22\xb3\xfe\x7b' b'\x26\x00\x23\x4a' + self.req_bin_0 = b'\x1a\x00\x06\x00' b'\x5a\x37\xab\x4c' \ + b'\xfb\x53\x01\x00' b'\x7d\xae\x52\x0e' \ + b'\x18\xb4\xed\x76' b'\x5a\x27\x77\x2e' self.reply_args_0 = { - 'sequence_number': 49083, - 'status': 197, + 'sequence_number': 15948, + 'status': 206, } - self.reply_bin_0 = b'\x01\xc5\xbb\xbf' b'\x00\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\xce\x4c\x3e' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -1064,9 +1064,9 @@ def testUnpackReply0(self): class TestUngrabPointer(EndianTest): def setUp(self): self.req_args_0 = { - 'time': 122823278, + 'time': 124458893, } - self.req_bin_0 = b'\x1b\x00\x02\x00' b'\x6e\x22\x52\x07' + self.req_bin_0 = b'\x1b\x00\x02\x00' b'\x8d\x17\x6b\x07' def testPackRequest0(self): @@ -1082,19 +1082,19 @@ def testUnpackRequest0(self): class TestGrabButton(EndianTest): def setUp(self): self.req_args_0 = { - 'button': 204, - 'confine_to': 172098347, - 'cursor': 399109422, - 'event_mask': 55921, - 'grab_window': 1079895555, - 'keyboard_mode': 1, - 'modifiers': 44333, - 'owner_events': 1, + 'button': 145, + 'confine_to': 1571825127, + 'cursor': 1043722096, + 'event_mask': 37438, + 'grab_window': 1885576796, + 'keyboard_mode': 0, + 'modifiers': 64349, + 'owner_events': 0, 'pointer_mode': 0, } - self.req_bin_0 = b'\x1c\x01\x06\x00' b'\x03\xe6\x5d\x40' \ - b'\x71\xda\x00\x01' b'\x2b\x03\x42\x0a' \ - b'\x2e\xed\xc9\x17' b'\xcc\x00\x2d\xad' + self.req_bin_0 = b'\x1c\x00\x06\x00' b'\x5c\x9e\x63\x70' \ + b'\x3e\x92\x00\x00' b'\xe7\x25\xb0\x5d' \ + b'\x70\xef\x35\x3e' b'\x91\x00\x5d\xfb' def testPackRequest0(self): @@ -1110,12 +1110,12 @@ def testUnpackRequest0(self): class TestUngrabButton(EndianTest): def setUp(self): self.req_args_0 = { - 'button': 158, - 'grab_window': 257512222, - 'modifiers': 58373, + 'button': 160, + 'grab_window': 275784110, + 'modifiers': 43493, } - self.req_bin_0 = b'\x1d\x9e\x03\x00' b'\x1e\x53\x59\x0f' \ - b'\x05\xe4\x00\x00' + self.req_bin_0 = b'\x1d\xa0\x03\x00' b'\xae\x21\x70\x10' \ + b'\xe5\xa9\x00\x00' def testPackRequest0(self): @@ -1131,12 +1131,12 @@ def testUnpackRequest0(self): class TestChangeActivePointerGrab(EndianTest): def setUp(self): self.req_args_0 = { - 'cursor': 528792833, - 'event_mask': 40689, - 'time': 1276746733, + 'cursor': 1020726671, + 'event_mask': 36287, + 'time': 2033407590, } - self.req_bin_0 = b'\x1e\x00\x04\x00' b'\x01\xbd\x84\x1f' \ - b'\xed\x9b\x19\x4c' b'\xf1\x9e\x00\x00' + self.req_bin_0 = b'\x1e\x00\x04\x00' b'\x8f\x0d\xd7\x3c' \ + b'\x66\x56\x33\x79' b'\xbf\x8d\x00\x00' def testPackRequest0(self): @@ -1152,20 +1152,20 @@ def testUnpackRequest0(self): class TestGrabKeyboard(EndianTest): def setUp(self): self.req_args_0 = { - 'grab_window': 1253453980, + 'grab_window': 569270305, 'keyboard_mode': 0, 'owner_events': 0, 'pointer_mode': 1, - 'time': 1122698607, + 'time': 1133236353, } - self.req_bin_0 = b'\x1f\x00\x04\x00' b'\x9c\x30\xb6\x4a' \ - b'\x6f\x05\xeb\x42' b'\x01\x00\x00\x00' + self.req_bin_0 = b'\x1f\x00\x04\x00' b'\x21\x60\xee\x21' \ + b'\x81\xd0\x8b\x43' b'\x01\x00\x00\x00' self.reply_args_0 = { - 'sequence_number': 15837, - 'status': 219, + 'sequence_number': 46979, + 'status': 179, } - self.reply_bin_0 = b'\x01\xdb\xdd\x3d' b'\x00\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\xb3\x83\xb7' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -1193,9 +1193,9 @@ def testUnpackReply0(self): class TestUngrabKeyboard(EndianTest): def setUp(self): self.req_args_0 = { - 'time': 849983231, + 'time': 669471181, } - self.req_bin_0 = b'\x20\x00\x02\x00' b'\xff\xb6\xa9\x32' + self.req_bin_0 = b'\x20\x00\x02\x00' b'\xcd\x51\xe7\x27' def testPackRequest0(self): @@ -1211,15 +1211,15 @@ def testUnpackRequest0(self): class TestGrabKey(EndianTest): def setUp(self): self.req_args_0 = { - 'grab_window': 644284698, - 'key': 224, - 'keyboard_mode': 0, - 'modifiers': 20896, + 'grab_window': 2137132511, + 'key': 223, + 'keyboard_mode': 1, + 'modifiers': 44275, 'owner_events': 1, - 'pointer_mode': 0, + 'pointer_mode': 1, } - self.req_bin_0 = b'\x21\x01\x04\x00' b'\x1a\x01\x67\x26' \ - b'\xa0\x51\xe0\x00' b'\x00\x00\x00\x00' + self.req_bin_0 = b'\x21\x01\x04\x00' b'\xdf\x0d\x62\x7f' \ + b'\xf3\xac\xdf\x01' b'\x01\x00\x00\x00' def testPackRequest0(self): @@ -1235,12 +1235,12 @@ def testUnpackRequest0(self): class TestUngrabKey(EndianTest): def setUp(self): self.req_args_0 = { - 'grab_window': 2139101088, - 'key': 255, - 'modifiers': 5038, + 'grab_window': 532438798, + 'key': 158, + 'modifiers': 14981, } - self.req_bin_0 = b'\x22\xff\x03\x00' b'\xa0\x17\x80\x7f' \ - b'\xae\x13\x00\x00' + self.req_bin_0 = b'\x22\x9e\x03\x00' b'\x0e\x5f\xbc\x1f' \ + b'\x85\x3a\x00\x00' def testPackRequest0(self): @@ -1257,9 +1257,9 @@ class TestAllowEvents(EndianTest): def setUp(self): self.req_args_0 = { 'mode': 1, - 'time': 569561709, + 'time': 726098765, } - self.req_bin_0 = b'\x23\x01\x02\x00' b'\x6d\xd2\xf2\x21' + self.req_bin_0 = b'\x23\x01\x02\x00' b'\x4d\x63\x47\x2b' def testPackRequest0(self): @@ -1309,25 +1309,25 @@ def testUnpackRequest0(self): class TestQueryPointer(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 2004163626, + 'window': 45236268, } - self.req_bin_0 = b'\x26\x00\x02\x00' b'\x2a\x1c\x75\x77' + self.req_bin_0 = b'\x26\x00\x02\x00' b'\x2c\x40\xb2\x02' self.reply_args_0 = { - 'child': 338813940, - 'mask': 42947, - 'root': 793594698, - 'root_x': -5661, - 'root_y': -9894, - 'same_screen': 1, - 'sequence_number': 57654, - 'win_x': -12881, - 'win_y': -671, + 'child': 15507755, + 'mask': 15259, + 'root': 472978779, + 'root_x': -30442, + 'root_y': -9574, + 'same_screen': 0, + 'sequence_number': 38820, + 'win_x': -12089, + 'win_y': -30839, } - self.reply_bin_0 = b'\x01\x01\x36\xe1' b'\x00\x00\x00\x00' \ - b'\x4a\x4b\x4d\x2f' b'\xf4\xe3\x31\x14' \ - b'\xe3\xe9\x5a\xd9' b'\xaf\xcd\x61\xfd' \ - b'\xc3\xa7\x00\x00' b'\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\x00\xa4\x97' b'\x00\x00\x00\x00' \ + b'\x5b\x15\x31\x1c' b'\x2b\xa1\xec\x00' \ + b'\x16\x89\x9a\xda' b'\xc7\xd0\x89\x87' \ + b'\x9b\x3b\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1352,26 +1352,26 @@ def testUnpackReply0(self): class TestGetMotionEvents(EndianTest): def setUp(self): self.req_args_0 = { - 'start': 1754729754, - 'stop': 642956890, - 'window': 16865017, + 'start': 1944440211, + 'stop': 67524349, + 'window': 144806627, } - self.req_bin_0 = b'\x27\x00\x04\x00' b'\xf9\x56\x01\x01' \ - b'\x1a\x0d\x97\x68' b'\x5a\xbe\x52\x26' + self.req_bin_0 = b'\x27\x00\x04\x00' b'\xe3\x92\xa1\x08' \ + b'\x93\xcd\xe5\x73' b'\xfd\x56\x06\x04' self.reply_args_0 = { - 'events': [{'y': -28402, 'x': -2241, 'time': 1424638477}, {'y': -14782, 'x': -29288, 'time': 247939153}, {'y': -9437, 'x': -13104, 'time': 584911019}, {'y': -24186, 'x': -12148, 'time': 437274091}, {'y': -5259, 'x': -3333, 'time': 1049147683}], - 'sequence_number': 6281, + 'events': [{'time': 1846118496, 'x': -21941, 'y': -30447}, {'time': 1104207400, 'x': -24970, 'y': -23643}, {'time': 1436684371, 'x': -16862, 'y': -25748}, {'time': 1158061593, 'x': -28433, 'y': -9066}, {'time': 2009067067, 'x': -3855, 'y': -14057}], + 'sequence_number': 38018, } - self.reply_bin_0 = b'\x01\x00\x89\x18' b'\x0a\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\x82\x94' b'\x0a\x00\x00\x00' \ b'\x05\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x0d\x42\xea\x54' b'\x3f\xf7\x0e\x91' \ - b'\x51\x40\xc7\x0e' b'\x98\x8d\x42\xc6' \ - b'\xab\x08\xdd\x22' b'\xd0\xcc\x23\xdb' \ - b'\xeb\x45\x10\x1a' b'\x8c\xd0\x86\xa1' \ - b'\x23\xb9\x88\x3e' b'\xfb\xf2\x75\xeb' + b'\x60\x88\x09\x6e' b'\x4b\xaa\x11\x89' \ + b'\x28\xde\xd0\x41' b'\x76\x9e\xa5\xa3' \ + b'\x53\x10\xa2\x55' b'\x22\xbe\x6c\x9b' \ + b'\x19\x9e\x06\x45' b'\xef\x90\x96\xdc' \ + b'\x3b\xee\xbf\x77' b'\xf1\xf0\x17\xc9' def testPackRequest0(self): @@ -1396,23 +1396,23 @@ def testUnpackReply0(self): class TestTranslateCoords(EndianTest): def setUp(self): self.req_args_0 = { - 'dst_wid': 594213659, - 'src_wid': 909659821, - 'src_x': -32653, - 'src_y': -7697, + 'dst_wid': 521898132, + 'src_wid': 1015118844, + 'src_x': -7058, + 'src_y': -17270, } - self.req_bin_0 = b'\x28\x00\x04\x00' b'\xad\x4e\x38\x36' \ - b'\x1b\xfb\x6a\x23' b'\x73\x80\xef\xe1' + self.req_bin_0 = b'\x28\x00\x04\x00' b'\xfc\x7b\x81\x3c' \ + b'\x94\x88\x1b\x1f' b'\x6e\xe4\x8a\xbc' self.reply_args_0 = { - 'child': 1591798213, + 'child': 202628650, 'same_screen': 1, - 'sequence_number': 17356, - 'x': -14832, - 'y': -18863, + 'sequence_number': 12734, + 'x': -29592, + 'y': -11175, } - self.reply_bin_0 = b'\x01\x01\xcc\x43' b'\x00\x00\x00\x00' \ - b'\xc5\xe9\xe0\x5e' b'\x10\xc6\x51\xb6' \ + self.reply_bin_0 = b'\x01\x01\xbe\x31' b'\x00\x00\x00\x00' \ + b'\x2a\xde\x13\x0c' b'\x68\x8c\x59\xd4' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -1439,18 +1439,18 @@ def testUnpackReply0(self): class TestWarpPointer(EndianTest): def setUp(self): self.req_args_0 = { - 'dst_window': 161645563, - 'dst_x': -13829, - 'dst_y': -27954, - 'src_height': 54738, - 'src_width': 35872, - 'src_window': 20830424, - 'src_x': -4056, - 'src_y': -3379, + 'dst_window': 760913775, + 'dst_x': -8878, + 'dst_y': -30993, + 'src_height': 56868, + 'src_width': 30862, + 'src_window': 925740905, + 'src_x': -18889, + 'src_y': -19298, } - self.req_bin_0 = b'\x29\x00\x06\x00' b'\xd8\xd8\x3d\x01' \ - b'\xfb\x83\xa2\x09' b'\x28\xf0\xcd\xf2' \ - b'\x20\x8c\xd2\xd5' b'\xfb\xc9\xce\x92' + self.req_bin_0 = b'\x29\x00\x06\x00' b'\x69\xaf\x2d\x37' \ + b'\x6f\x9f\x5a\x2d' b'\x37\xb6\x9e\xb4' \ + b'\x8e\x78\x24\xde' b'\x52\xdd\xef\x86' def testPackRequest0(self): @@ -1466,12 +1466,12 @@ def testUnpackRequest0(self): class TestSetInputFocus(EndianTest): def setUp(self): self.req_args_0 = { - 'focus': 662025099, - 'revert_to': 0, - 'time': 1930554666, + 'focus': 1403350503, + 'revert_to': 2, + 'time': 2113544232, } - self.req_bin_0 = b'\x2a\x00\x03\x00' b'\x8b\xb3\x75\x27' \ - b'\x2a\xed\x11\x73' + self.req_bin_0 = b'\x2a\x02\x03\x00' b'\xe7\x6d\xa5\x53' \ + b'\x28\x20\xfa\x7d' def testPackRequest0(self): @@ -1491,12 +1491,12 @@ def setUp(self): self.req_bin_0 = b'\x2b\x00\x01\x00' self.reply_args_0 = { - 'focus': 1930432580, - 'revert_to': 229, - 'sequence_number': 56442, + 'focus': 864688157, + 'revert_to': 153, + 'sequence_number': 4228, } - self.reply_bin_0 = b'\x01\xe5\x7a\xdc' b'\x00\x00\x00\x00' \ - b'\x44\x10\x10\x73' b'\x00\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x99\x84\x10' b'\x00\x00\x00\x00' \ + b'\x1d\x18\x8a\x33' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -1527,14 +1527,14 @@ def setUp(self): self.req_bin_0 = b'\x2c\x00\x01\x00' self.reply_args_0 = { - 'map': [154, 159, 141, 227, 241, 180, 207, 147, 247, 238, 252, 231, 240, 131, 222, 170, 247, 230, 238, 231, 162, 228, 141, 239, 237, 156, 232, 186, 167, 229, 157, 131], - 'sequence_number': 12863, + 'map': [214, 155, 191, 177, 176, 242, 163, 236, 174, 199, 246, 191, 147, 241, 153, 140, 131, 151, 188, 170, 232, 252, 251, 182, 230, 143, 170, 225, 128, 227, 195, 244], + 'sequence_number': 18950, } - self.reply_bin_0 = b'\x01\x00\x3f\x32' b'\x02\x00\x00\x00' \ - b'\x9a\x9f\x8d\xe3' b'\xf1\xb4\xcf\x93' \ - b'\xf7\xee\xfc\xe7' b'\xf0\x83\xde\xaa' \ - b'\xf7\xe6\xee\xe7' b'\xa2\xe4\x8d\xef' \ - b'\xed\x9c\xe8\xba' b'\xa7\xe5\x9d\x83' + self.reply_bin_0 = b'\x01\x00\x06\x4a' b'\x02\x00\x00\x00' \ + b'\xd6\x9b\xbf\xb1' b'\xb0\xf2\xa3\xec' \ + b'\xae\xc7\xf6\xbf' b'\x93\xf1\x99\x8c' \ + b'\x83\x97\xbc\xaa' b'\xe8\xfc\xfb\xb6' \ + b'\xe6\x8f\xaa\xe1' b'\x80\xe3\xc3\xf4' def testPackRequest0(self): @@ -1559,10 +1559,10 @@ def testUnpackReply0(self): class TestOpenFont(EndianTest): def setUp(self): self.req_args_0 = { - 'fid': 704981195, + 'fid': 908467189, 'name': 'foofont', } - self.req_bin_0 = b'\x2d\x00\x05\x00' b'\xcb\x28\x05\x2a' \ + self.req_bin_0 = b'\x2d\x00\x05\x00' b'\xf5\x1b\x26\x36' \ b'\x07\x00\x00\x00' b'\x66\x6f\x6f\x66' \ b'\x6f\x6e\x74\x00' @@ -1580,9 +1580,9 @@ def testUnpackRequest0(self): class TestCloseFont(EndianTest): def setUp(self): self.req_args_0 = { - 'font': 1856192698, + 'font': 1495984396, } - self.req_bin_0 = b'\x2e\x00\x02\x00' b'\xba\x40\xa3\x6e' + self.req_bin_0 = b'\x2e\x00\x02\x00' b'\x0c\xe9\x2a\x59' def testPackRequest0(self): @@ -1598,39 +1598,39 @@ def testUnpackRequest0(self): class TestQueryFont(EndianTest): def setUp(self): self.req_args_0 = { - 'font': 2076380709, + 'font': 2055889505, } - self.req_bin_0 = b'\x2f\x00\x02\x00' b'\x25\x0e\xc3\x7b' + self.req_bin_0 = b'\x2f\x00\x02\x00' b'\x61\x62\x8a\x7a' self.reply_args_0 = { 'all_chars_exist': 0, - 'char_infos': [{'descent': -29018, 'right_side_bearing': -868, 'character_width': -15335, 'left_side_bearing': -19774, 'attributes': 63603, 'ascent': -2231}, {'descent': -18640, 'right_side_bearing': -1474, 'character_width': -24137, 'left_side_bearing': -26963, 'attributes': 47815, 'ascent': -29244}, {'descent': -14022, 'right_side_bearing': -13059, 'character_width': -16141, 'left_side_bearing': -22570, 'attributes': 16884, 'ascent': -20245}], - 'default_char': 20446, - 'draw_direction': 180, - 'font_ascent': -19099, - 'font_descent': -2194, - 'max_bounds': {'descent': -22562, 'right_side_bearing': -30493, 'character_width': -11172, 'left_side_bearing': -20927, 'attributes': 55614, 'ascent': -22033}, - 'max_byte1': 165, - 'max_char_or_byte2': 19861, - 'min_bounds': {'descent': -8645, 'right_side_bearing': -2675, 'character_width': -15262, 'left_side_bearing': -32714, 'attributes': 44034, 'ascent': -9378}, - 'min_byte1': 179, - 'min_char_or_byte2': 47241, - 'properties': [{'name': 599463600, 'value': 1377595039}], - 'sequence_number': 46525, - } - self.reply_bin_0 = b'\x01\x00\xbd\xb5' b'\x12\x00\x00\x00' \ - b'\x36\x80\x8d\xf5' b'\x62\xc4\x5e\xdb' \ - b'\x3b\xde\x02\xac' b'\x00\x00\x00\x00' \ - b'\x41\xae\xe3\x88' b'\x5c\xd4\xef\xa9' \ - b'\xde\xa7\x3e\xd9' b'\x00\x00\x00\x00' \ - b'\x89\xb8\x95\x4d' b'\xde\x4f\x01\x00' \ - b'\xb4\xb3\xa5\x00' b'\x65\xb5\x6e\xf7' \ - b'\x03\x00\x00\x00' b'\xb0\x16\xbb\x23' \ - b'\x9f\x6e\x1c\x52' b'\xc2\xb2\x9c\xfc' \ - b'\x19\xc4\x49\xf7' b'\xa6\x8e\x73\xf8' \ - b'\xad\x96\x3e\xfa' b'\xb7\xa1\xc4\x8d' \ - b'\x30\xb7\xc7\xba' b'\xd6\xa7\xfd\xcc' \ - b'\xf3\xc0\xeb\xb0' b'\x3a\xc9\xf4\x41' + 'char_infos': [{'left_side_bearing': -7099, 'right_side_bearing': -14557, 'character_width': -11080, 'ascent': -9228, 'descent': -16821, 'attributes': 10400}, {'left_side_bearing': -26546, 'right_side_bearing': -23046, 'character_width': -25635, 'ascent': -1026, 'descent': -30852, 'attributes': 38213}, {'left_side_bearing': -8660, 'right_side_bearing': -15002, 'character_width': -30771, 'ascent': -8259, 'descent': -22492, 'attributes': 4002}], + 'default_char': 39252, + 'draw_direction': 145, + 'font_ascent': -1914, + 'font_descent': -3596, + 'max_bounds': {'left_side_bearing': -27610, 'right_side_bearing': -30905, 'character_width': -1286, 'ascent': -16128, 'descent': -30143, 'attributes': 56049}, + 'max_byte1': 231, + 'max_char_or_byte2': 4746, + 'min_bounds': {'left_side_bearing': -13626, 'right_side_bearing': -17145, 'character_width': -16291, 'ascent': -2642, 'descent': -4827, 'attributes': 35063}, + 'min_byte1': 188, + 'min_char_or_byte2': 12434, + 'properties': [{'name': 1568813755, 'value': 2137719486}], + 'sequence_number': 3542, + } + self.reply_bin_0 = b'\x01\x00\xd6\x0d' b'\x12\x00\x00\x00' \ + b'\xc6\xca\x07\xbd' b'\x5d\xc0\xae\xf5' \ + b'\x25\xed\xf7\x88' b'\x00\x00\x00\x00' \ + b'\x26\x94\x47\x87' b'\xfa\xfa\x00\xc1' \ + b'\x41\x8a\xf1\xda' b'\x00\x00\x00\x00' \ + b'\x92\x30\x8a\x12' b'\x54\x99\x01\x00' \ + b'\x91\xbc\xe7\x00' b'\x86\xf8\xf4\xf1' \ + b'\x03\x00\x00\x00' b'\xbb\x32\x82\x5d' \ + b'\xbe\x02\x6b\x7f' b'\x45\xe4\x23\xc7' \ + b'\xb8\xd4\xf4\xdb' b'\x4b\xbe\xa0\x28' \ + b'\x4e\x98\xfa\xa5' b'\xdd\x9b\xfe\xfb' \ + b'\x7c\x87\x45\x95' b'\x2c\xde\x66\xc5' \ + b'\xcd\x87\xbd\xdf' b'\x24\xa8\xa2\x0f' def testPackRequest0(self): @@ -1655,27 +1655,27 @@ def testUnpackReply0(self): class TestQueryTextExtents(EndianTest): def setUp(self): self.req_args_0 = { - 'font': 1454550358, + 'font': 1223434172, 'string': (102, 111, 111), } - self.req_bin_0 = b'\x30\x01\x04\x00' b'\x56\xad\xb2\x56' \ + self.req_bin_0 = b'\x30\x01\x04\x00' b'\xbc\x1f\xec\x48' \ b'\x00\x66\x00\x6f' b'\x00\x6f\x00\x00' self.reply_args_0 = { - 'draw_direction': 243, - 'font_ascent': -22984, - 'font_descent': -14953, - 'overall_ascent': -32755, - 'overall_descent': -23440, - 'overall_left': -902013824, - 'overall_right': -741556933, - 'overall_width': -1224334048, - 'sequence_number': 40436, + 'draw_direction': 191, + 'font_ascent': -13287, + 'font_descent': -31466, + 'overall_ascent': -12473, + 'overall_descent': -30082, + 'overall_left': -735785526, + 'overall_right': -894056953, + 'overall_width': -1247205006, + 'sequence_number': 38196, } - self.reply_bin_0 = b'\x01\xf3\xf4\x9d' b'\x00\x00\x00\x00' \ - b'\x38\xa6\x97\xc5' b'\x0d\x80\x70\xa4' \ - b'\x20\x25\x06\xb7' b'\x80\x5c\x3c\xca' \ - b'\x3b\xbd\xcc\xd3' b'\x00\x00\x00\x00' + self.reply_bin_0 = b'\x01\xbf\x34\x95' b'\x00\x00\x00\x00' \ + b'\x19\xcc\x16\x85' b'\x47\xcf\x7e\x8a' \ + b'\x72\x29\xa9\xb5' b'\xca\xcd\x24\xd4' \ + b'\x07\xc6\xb5\xca' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1700,17 +1700,17 @@ def testUnpackReply0(self): class TestListFonts(EndianTest): def setUp(self): self.req_args_0 = { - 'max_names': 30610, + 'max_names': 37298, 'pattern': 'bhazr', } - self.req_bin_0 = b'\x31\x00\x04\x00' b'\x92\x77\x05\x00' \ + self.req_bin_0 = b'\x31\x00\x04\x00' b'\xb2\x91\x05\x00' \ b'\x62\x68\x61\x7a' b'\x72\x00\x00\x00' self.reply_args_0 = { 'fonts': ['fie', 'fuzzy', 'foozooom'], - 'sequence_number': 29120, + 'sequence_number': 34517, } - self.reply_bin_0 = b'\x01\x00\xc0\x71' b'\x05\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\xd5\x86' b'\x05\x00\x00\x00' \ b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ @@ -1741,38 +1741,38 @@ def testUnpackReply0(self): class TestListFontsWithInfo(EndianTest): def setUp(self): self.req_args_0 = { - 'max_names': 14206, + 'max_names': 20989, 'pattern': 'bhazr2', } - self.req_bin_0 = b'\x32\x00\x04\x00' b'\x7e\x37\x06\x00' \ + self.req_bin_0 = b'\x32\x00\x04\x00' b'\xfd\x51\x06\x00' \ b'\x62\x68\x61\x7a' b'\x72\x32\x00\x00' self.reply_args_0 = { - 'all_chars_exist': 1, - 'default_char': 5010, - 'draw_direction': 181, - 'font_ascent': -16695, - 'font_descent': -24836, - 'max_bounds': {'descent': -31974, 'right_side_bearing': -10894, 'character_width': -25465, 'left_side_bearing': -8347, 'attributes': 16239, 'ascent': -26294}, - 'max_byte1': 152, - 'max_char_or_byte2': 55726, - 'min_bounds': {'descent': -21871, 'right_side_bearing': -30012, 'character_width': -16010, 'left_side_bearing': -27251, 'attributes': 53682, 'ascent': -12190}, - 'min_byte1': 208, - 'min_char_or_byte2': 31272, + 'all_chars_exist': 0, + 'default_char': 61580, + 'draw_direction': 146, + 'font_ascent': -30368, + 'font_descent': -15151, + 'max_bounds': {'left_side_bearing': -28480, 'right_side_bearing': -10759, 'character_width': -11617, 'ascent': -22938, 'descent': -17786, 'attributes': 20976}, + 'max_byte1': 245, + 'max_char_or_byte2': 49530, + 'min_bounds': {'left_side_bearing': -10823, 'right_side_bearing': -9300, 'character_width': -22473, 'ascent': -24947, 'descent': -24065, 'attributes': 26194}, + 'min_byte1': 130, + 'min_char_or_byte2': 61140, 'name': 'fontfont', - 'properties': [{'name': 1016194121, 'value': 1935277562}], - 'replies_hint': 1408896390, - 'sequence_number': 52220, - } - self.reply_bin_0 = b'\x01\x08\xfc\xcb' b'\x0b\x00\x00\x00' \ - b'\x8d\x95\xc4\x8a' b'\x76\xc1\x62\xd0' \ - b'\x91\xaa\xb2\xd1' b'\x00\x00\x00\x00' \ - b'\x65\xdf\x72\xd5' b'\x87\x9c\x4a\x99' \ - b'\x1a\x83\x6f\x3f' b'\x00\x00\x00\x00' \ - b'\x28\x7a\xae\xd9' b'\x92\x13\x01\x00' \ - b'\xb5\xd0\x98\x01' b'\xc9\xbe\xfc\x9e' \ - b'\x86\x0d\xfa\x53' b'\x49\xe4\x91\x3c' \ - b'\xfa\xfd\x59\x73' b'\x66\x6f\x6e\x74' \ + 'properties': [{'name': 2007331946, 'value': 560055601}], + 'replies_hint': 457810933, + 'sequence_number': 13642, + } + self.reply_bin_0 = b'\x01\x08\x4a\x35' b'\x0b\x00\x00\x00' \ + b'\xb9\xd5\xac\xdb' b'\x37\xa8\x8d\x9e' \ + b'\xff\xa1\x52\x66' b'\x00\x00\x00\x00' \ + b'\xc0\x90\xf9\xd5' b'\x9f\xd2\x66\xa6' \ + b'\x86\xba\xf0\x51' b'\x00\x00\x00\x00' \ + b'\xd4\xee\x7a\xc1' b'\x8c\xf0\x01\x00' \ + b'\x92\x82\xf5\x00' b'\x60\x89\xd1\xc4' \ + b'\xf5\xa3\x49\x1b' b'\x6a\x74\xa5\x77' \ + b'\x31\xc5\x61\x21' b'\x66\x6f\x6e\x74' \ b'\x66\x6f\x6e\x74' @@ -1837,9 +1837,9 @@ def setUp(self): self.reply_args_0 = { 'paths': ['path1', 'path2232'], - 'sequence_number': 617, + 'sequence_number': 33409, } - self.reply_bin_0 = b'\x01\x00\x69\x02' b'\x04\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\x81\x82' b'\x04\x00\x00\x00' \ b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ @@ -1848,9 +1848,9 @@ def setUp(self): self.reply_args_1 = { 'paths': [], - 'sequence_number': 49278, + 'sequence_number': 17636, } - self.reply_bin_1 = b'\x01\x00\x7e\xc0' b'\x00\x00\x00\x00' \ + self.reply_bin_1 = b'\x01\x00\xe4\x44' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -1887,14 +1887,14 @@ def testUnpackReply1(self): class TestCreatePixmap(EndianTest): def setUp(self): self.req_args_0 = { - 'depth': 226, - 'drawable': 913032172, - 'height': 62792, - 'pid': 228953027, - 'width': 11737, + 'depth': 161, + 'drawable': 749556300, + 'height': 4764, + 'pid': 2004224799, + 'width': 57984, } - self.req_bin_0 = b'\x35\xe2\x04\x00' b'\xc3\x8b\xa5\x0d' \ - b'\xec\xc3\x6b\x36' b'\xd9\x2d\x48\xf5' + self.req_bin_0 = b'\x35\xa1\x04\x00' b'\x1f\x0b\x76\x77' \ + b'\x4c\x52\xad\x2c' b'\x80\xe2\x9c\x12' def testPackRequest0(self): @@ -1910,9 +1910,9 @@ def testUnpackRequest0(self): class TestFreePixmap(EndianTest): def setUp(self): self.req_args_0 = { - 'pixmap': 1112337390, + 'pixmap': 1888284001, } - self.req_bin_0 = b'\x36\x00\x02\x00' b'\xee\xeb\x4c\x42' + self.req_bin_0 = b'\x36\x00\x02\x00' b'\x61\xed\x8c\x70' def testPackRequest0(self): @@ -1928,24 +1928,24 @@ def testUnpackRequest0(self): class TestCreateGC(EndianTest): def setUp(self): self.req_args_0 = { - 'attrs': {'stipple': 1544647467, 'background': 980279926, 'subwindow_mode': 1, 'fill_style': 3, 'font': 1176575685, 'graphics_exposures': 1, 'tile': 1315686229, 'tile_stipple_x_origin': -16228, 'dashes': 226, 'function': 0, 'foreground': 1821798372, 'clip_x_origin': -17214, 'cap_style': 3, 'tile_stipple_y_origin': -5552, 'join_style': 1, 'line_width': 59029, 'dash_offset': 53663, 'clip_y_origin': -24275, 'arc_mode': 1, 'line_style': 2, 'plane_mask': 535198434, 'clip_mask': 530992626, 'fill_rule': 1}, - 'cid': 1345956480, - 'drawable': 589741066, + 'attrs': {'function': 7, 'plane_mask': 793618921, 'foreground': 612071305, 'background': 338824284, 'line_width': 61484, 'line_style': 2, 'cap_style': 2, 'join_style': 2, 'fill_style': 0, 'fill_rule': 1, 'tile': 2000996399, 'stipple': 1424681955, 'tile_stipple_x_origin': -25980, 'tile_stipple_y_origin': -23968, 'font': 568001783, 'subwindow_mode': 0, 'graphics_exposures': 0, 'clip_x_origin': -22581, 'clip_y_origin': -14920, 'clip_mask': 605132525, 'dash_offset': 46571, 'dashes': 215, 'arc_mode': 0}, + 'cid': 1476454377, + 'drawable': 1362081172, } - self.req_bin_0 = b'\x37\x00\x1b\x00' b'\x80\xaa\x39\x50' \ - b'\x0a\xbc\x26\x23' b'\xff\xff\x7f\x00' \ - b'\x00\x00\x00\x00' b'\xe2\x7a\xe6\x1f' \ - b'\xe4\x6f\x96\x6c' b'\x76\xe2\x6d\x3a' \ - b'\x95\xe6\x00\x00' b'\x02\x00\x00\x00' \ - b'\x03\x00\x00\x00' b'\x01\x00\x00\x00' \ - b'\x03\x00\x00\x00' b'\x01\x00\x00\x00' \ - b'\x55\xc7\x6b\x4e' b'\x2b\x73\x11\x5c' \ - b'\x9c\xc0\x00\x00' b'\x50\xea\x00\x00' \ - b'\xc5\x1e\x21\x46' b'\x01\x00\x00\x00' \ - b'\x01\x00\x00\x00' b'\xc2\xbc\x00\x00' \ - b'\x2d\xa1\x00\x00' b'\xf2\x4d\xa6\x1f' \ - b'\x9f\xd1\x00\x00' b'\xe2\x00\x00\x00' \ - b'\x01\x00\x00\x00' + self.req_bin_0 = b'\x37\x00\x1b\x00' b'\xe9\xe7\x00\x58' \ + b'\x94\xb5\x2f\x51' b'\xff\xff\x7f\x00' \ + b'\x07\x00\x00\x00' b'\xe9\xa9\x4d\x2f' \ + b'\x89\x77\x7b\x24' b'\x5c\x0c\x32\x14' \ + b'\x2c\xf0\x00\x00' b'\x02\x00\x00\x00' \ + b'\x02\x00\x00\x00' b'\x02\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x01\x00\x00\x00' \ + b'\x2f\xc8\x44\x77' b'\xe3\xeb\xea\x54' \ + b'\x84\x9a\x00\x00' b'\x60\xa2\x00\x00' \ + b'\xf7\x04\xdb\x21' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\xcb\xa7\x00\x00' \ + b'\xb8\xc5\x00\x00' b'\xed\x96\x11\x24' \ + b'\xeb\xb5\x00\x00' b'\xd7\x00\x00\x00' \ + b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -1961,22 +1961,22 @@ def testUnpackRequest0(self): class TestChangeGC(EndianTest): def setUp(self): self.req_args_0 = { - 'attrs': {'stipple': 1165278526, 'background': 686615653, 'subwindow_mode': 1, 'fill_style': 2, 'font': 902289335, 'graphics_exposures': 1, 'tile': 875351804, 'tile_stipple_x_origin': -19144, 'dashes': 128, 'function': 1, 'foreground': 583551477, 'clip_x_origin': -9978, 'cap_style': 0, 'tile_stipple_y_origin': -25991, 'join_style': 2, 'line_width': 50468, 'dash_offset': 45232, 'clip_y_origin': -4695, 'arc_mode': 0, 'line_style': 0, 'plane_mask': 613643341, 'clip_mask': 1644117194, 'fill_rule': 0}, - 'gc': 1618091665, + 'attrs': {'function': 8, 'plane_mask': 1085423224, 'foreground': 1049179696, 'background': 539344312, 'line_width': 36097, 'line_style': 0, 'cap_style': 3, 'join_style': 1, 'fill_style': 0, 'fill_rule': 0, 'tile': 716372747, 'stipple': 1656031462, 'tile_stipple_x_origin': -24195, 'tile_stipple_y_origin': -15601, 'font': 347060191, 'subwindow_mode': 1, 'graphics_exposures': 1, 'clip_x_origin': -32135, 'clip_y_origin': -25437, 'clip_mask': 161650480, 'dash_offset': 42536, 'dashes': 137, 'arc_mode': 1}, + 'gc': 1250995304, } - self.req_bin_0 = b'\x38\x00\x1a\x00' b'\x91\x1e\x72\x60' \ - b'\xff\xff\x7f\x00' b'\x01\x00\x00\x00' \ - b'\x4d\x74\x93\x24' b'\xf5\x49\xc8\x22' \ - b'\x65\xec\xec\x28' b'\x24\xc5\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x02\x00\x00\x00' b'\x02\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\xfc\xce\x2c\x34' \ - b'\x3e\xbd\x74\x45' b'\x38\xb5\x00\x00' \ - b'\x79\x9a\x00\x00' b'\xb7\xd7\xc7\x35' \ + self.req_bin_0 = b'\x38\x00\x1a\x00' b'\x68\xac\x90\x4a' \ + b'\xff\xff\x7f\x00' b'\x08\x00\x00\x00' \ + b'\x78\x3e\xb2\x40' b'\x30\x36\x89\x3e' \ + b'\xb8\xbd\x25\x20' b'\x01\x8d\x00\x00' \ + b'\x00\x00\x00\x00' b'\x03\x00\x00\x00' \ + b'\x01\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x0b\xfb\xb2\x2a' \ + b'\xe6\x08\xb5\x62' b'\x7d\xa1\x00\x00' \ + b'\x0f\xc3\x00\x00' b'\xdf\xb7\xaf\x14' \ b'\x01\x00\x00\x00' b'\x01\x00\x00\x00' \ - b'\x06\xd9\x00\x00' b'\xa9\xed\x00\x00' \ - b'\xca\x3c\xff\x61' b'\xb0\xb0\x00\x00' \ - b'\x80\x00\x00\x00' b'\x00\x00\x00\x00' + b'\x79\x82\x00\x00' b'\xa3\x9c\x00\x00' \ + b'\x30\x97\xa2\x09' b'\x28\xa6\x00\x00' \ + b'\x89\x00\x00\x00' b'\x01\x00\x00\x00' def testPackRequest0(self): @@ -1992,12 +1992,12 @@ def testUnpackRequest0(self): class TestCopyGC(EndianTest): def setUp(self): self.req_args_0 = { - 'dst_gc': 2047479112, - 'mask': 899879427, - 'src_gc': 1832775121, + 'dst_gc': 318094523, + 'mask': 923025483, + 'src_gc': 1186604145, } - self.req_bin_0 = b'\x39\x00\x04\x00' b'\xd1\xed\x3d\x6d' \ - b'\x48\x0d\x0a\x7a' b'\x03\x12\xa3\x35' + self.req_bin_0 = b'\x39\x00\x04\x00' b'\x71\x24\xba\x46' \ + b'\xbb\xbc\xf5\x12' b'\x4b\x40\x04\x37' def testPackRequest0(self): @@ -2013,13 +2013,13 @@ def testUnpackRequest0(self): class TestSetDashes(EndianTest): def setUp(self): self.req_args_0 = { - 'dash_offset': 11030, - 'dashes': [223, 197, 205, 156, 156, 183, 131, 171, 214], - 'gc': 868302473, + 'dash_offset': 51381, + 'dashes': [160, 138, 206, 221, 138, 219, 181, 191, 154], + 'gc': 759584613, } - self.req_bin_0 = b'\x3a\x00\x06\x00' b'\x89\x3e\xc1\x33' \ - b'\x16\x2b\x09\x00' b'\xdf\xc5\xcd\x9c' \ - b'\x9c\xb7\x83\xab' b'\xd6\x00\x00\x00' + self.req_bin_0 = b'\x3a\x00\x06\x00' b'\x65\x57\x46\x2d' \ + b'\xb5\xc8\x09\x00' b'\xa0\x8a\xce\xdd' \ + b'\x8a\xdb\xb5\xbf' b'\x9a\x00\x00\x00' def testPackRequest0(self): @@ -2035,26 +2035,26 @@ def testUnpackRequest0(self): class TestSetClipRectangles(EndianTest): def setUp(self): self.req_args_0 = { - 'gc': 991525136, - 'ordering': 0, - 'rectangles': [{'y': -28619, 'x': -17572, 'height': 2016, 'width': 40876}, {'y': -14418, 'x': -19958, 'height': 42214, 'width': 2025}], - 'x_origin': -31134, - 'y_origin': -20443, + 'gc': 1856792138, + 'ordering': 1, + 'rectangles': [{'x': -14422, 'y': -3797, 'width': 57581, 'height': 26888}, {'x': -858, 'y': -12431, 'width': 49373, 'height': 10384}], + 'x_origin': -27444, + 'y_origin': -780, } - self.req_bin_0 = b'\x3b\x00\x07\x00' b'\x10\x79\x19\x3b' \ - b'\x62\x86\x25\xb0' b'\x5c\xbb\x35\x90' \ - b'\xac\x9f\xe0\x07' b'\x0a\xb2\xae\xc7' \ - b'\xe9\x07\xe6\xa4' + self.req_bin_0 = b'\x3b\x01\x07\x00' b'\x4a\x66\xac\x6e' \ + b'\xcc\x94\xf4\xfc' b'\xaa\xc7\x2b\xf1' \ + b'\xed\xe0\x08\x69' b'\xa6\xfc\x71\xcf' \ + b'\xdd\xc0\x90\x28' self.req_args_1 = { - 'gc': 701940136, - 'ordering': 0, + 'gc': 1892892424, + 'ordering': 1, 'rectangles': [], - 'x_origin': -8019, - 'y_origin': -20442, + 'x_origin': -19258, + 'y_origin': -31956, } - self.req_bin_1 = b'\x3b\x00\x03\x00' b'\xa8\xc1\xd6\x29' \ - b'\xad\xe0\x26\xb0' + self.req_bin_1 = b'\x3b\x01\x03\x00' b'\x08\x3f\xd3\x70' \ + b'\xc6\xb4\x2c\x83' def testPackRequest0(self): @@ -2079,9 +2079,9 @@ def testUnpackRequest1(self): class TestFreeGC(EndianTest): def setUp(self): self.req_args_0 = { - 'gc': 1614945050, + 'gc': 385239625, } - self.req_bin_0 = b'\x3c\x00\x02\x00' b'\x1a\x1b\x42\x60' + self.req_bin_0 = b'\x3c\x00\x02\x00' b'\x49\x4a\xf6\x16' def testPackRequest0(self): @@ -2098,14 +2098,14 @@ class TestClearArea(EndianTest): def setUp(self): self.req_args_0 = { 'exposures': 1, - 'height': 65529, - 'width': 35469, - 'window': 541797992, - 'x': -30105, - 'y': -32138, + 'height': 44159, + 'width': 52831, + 'window': 1680227732, + 'x': -2268, + 'y': -19277, } - self.req_bin_0 = b'\x3d\x01\x04\x00' b'\x68\x2e\x4b\x20' \ - b'\x67\x8a\x76\x82' b'\x8d\x8a\xf9\xff' + self.req_bin_0 = b'\x3d\x01\x04\x00' b'\x94\x3d\x26\x64' \ + b'\x24\xf7\xb3\xb4' b'\x5f\xce\x7f\xac' def testPackRequest0(self): @@ -2121,20 +2121,20 @@ def testUnpackRequest0(self): class TestCopyArea(EndianTest): def setUp(self): self.req_args_0 = { - 'dst_drawable': 1396196736, - 'dst_x': -1894, - 'dst_y': -26287, - 'gc': 1677699535, - 'height': 10203, - 'src_drawable': 751576716, - 'src_x': -11578, - 'src_y': -8246, - 'width': 1586, + 'dst_drawable': 1578589574, + 'dst_x': -27552, + 'dst_y': -6968, + 'gc': 1741136437, + 'height': 7340, + 'src_drawable': 1855628899, + 'src_x': -24637, + 'src_y': -24026, + 'width': 46214, } - self.req_bin_0 = b'\x3e\x00\x07\x00' b'\x8c\x26\xcc\x2c' \ - b'\x80\x45\x38\x53' b'\xcf\xa9\xff\x63' \ - b'\xc6\xd2\xca\xdf' b'\x9a\xf8\x51\x99' \ - b'\x32\x06\xdb\x27' + self.req_bin_0 = b'\x3e\x00\x07\x00' b'\x63\xa6\x9a\x6e' \ + b'\x86\x5d\x17\x5e' b'\x35\xa2\xc7\x67' \ + b'\xc3\x9f\x26\xa2' b'\x60\x94\xc8\xe4' \ + b'\x86\xb4\xac\x1c' def testPackRequest0(self): @@ -2150,21 +2150,21 @@ def testUnpackRequest0(self): class TestCopyPlane(EndianTest): def setUp(self): self.req_args_0 = { - 'bit_plane': 246015498, - 'dst_drawable': 1437673583, - 'dst_x': -7834, - 'dst_y': -27313, - 'gc': 1211144030, - 'height': 49080, - 'src_drawable': 271114743, - 'src_x': -25682, - 'src_y': -10027, - 'width': 39897, + 'bit_plane': 988559210, + 'dst_drawable': 1873029448, + 'dst_x': -25480, + 'dst_y': -26229, + 'gc': 83225989, + 'height': 60447, + 'src_drawable': 821567629, + 'src_x': -4634, + 'src_y': -17345, + 'width': 53771, } - self.req_bin_0 = b'\x3f\x00\x08\x00' b'\xf7\xe1\x28\x10' \ - b'\x6f\x28\xb1\x55' b'\x5e\x97\x30\x48' \ - b'\xae\x9b\xd5\xd8' b'\x66\xe1\x4f\x95' \ - b'\xd9\x9b\xb8\xbf' b'\x0a\xe6\xa9\x0e' + self.req_bin_0 = b'\x3f\x00\x08\x00' b'\x8d\x20\xf8\x30' \ + b'\x48\x29\xa4\x6f' b'\x85\xed\xf5\x04' \ + b'\xe6\xed\x3f\xbc' b'\x78\x9c\x8b\x99' \ + b'\x0b\xd2\x1f\xec' b'\x6a\x37\xec\x3a' def testPackRequest0(self): @@ -2180,14 +2180,14 @@ def testUnpackRequest0(self): class TestPolyPoint(EndianTest): def setUp(self): self.req_args_0 = { - 'coord_mode': 1, - 'drawable': 851848467, - 'gc': 1535501063, - 'points': [{'y': -1403, 'x': -6131}, {'y': -31934, 'x': -29254}, {'y': -10746, 'x': -22626}], + 'coord_mode': 0, + 'drawable': 50884525, + 'gc': 1417476013, + 'points': [{'x': -21311, 'y': -22768}, {'x': -5881, 'y': -6707}, {'x': -4217, 'y': -25311}], } - self.req_bin_0 = b'\x40\x01\x06\x00' b'\x13\x2d\xc6\x32' \ - b'\x07\xe3\x85\x5b' b'\x0d\xe8\x85\xfa' \ - b'\xba\x8d\x42\x83' b'\x9e\xa7\x06\xd6' + self.req_bin_0 = b'\x40\x00\x06\x00' b'\xad\x6f\x08\x03' \ + b'\xad\xf7\x7c\x54' b'\xc1\xac\x10\xa7' \ + b'\x07\xe9\xcd\xe5' b'\x87\xef\x21\x9d' def testPackRequest0(self): @@ -2203,15 +2203,15 @@ def testUnpackRequest0(self): class TestPolyLine(EndianTest): def setUp(self): self.req_args_0 = { - 'coord_mode': 0, - 'drawable': 919972239, - 'gc': 795836146, - 'points': [{'y': -10315, 'x': -30298}, {'y': -29455, 'x': -12375}, {'y': -5123, 'x': -7653}, {'y': -28833, 'x': -13247}, {'y': -7323, 'x': -781}], + 'coord_mode': 1, + 'drawable': 1459319574, + 'gc': 2107068434, + 'points': [{'x': -26440, 'y': -19712}, {'x': -22012, 'y': -23639}, {'x': -4445, 'y': -30494}, {'x': -1085, 'y': -7428}, {'x': -23622, 'y': -21262}], } - self.req_bin_0 = b'\x41\x00\x08\x00' b'\x8f\xa9\xd5\x36' \ - b'\xf2\x7e\x6f\x2f' b'\xa6\x89\xb5\xd7' \ - b'\xa9\xcf\xf1\x8c' b'\x1b\xe2\xfd\xeb' \ - b'\x41\xcc\x5f\x8f' b'\xf3\xfc\x65\xe3' + self.req_bin_0 = b'\x41\x01\x08\x00' b'\x16\x73\xfb\x56' \ + b'\x12\x50\x97\x7d' b'\xb8\x98\x00\xb3' \ + b'\x04\xaa\xa9\xa3' b'\xa3\xee\xe2\x88' \ + b'\xc3\xfb\xfc\xe2' b'\xba\xa3\xf2\xac' def testPackRequest0(self): @@ -2227,13 +2227,13 @@ def testUnpackRequest0(self): class TestPolySegment(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 226701618, - 'gc': 2063278158, - 'segments': [{'y1': -21674, 'x2': -5146, 'x1': -16318, 'y2': -6032}], + 'drawable': 59337240, + 'gc': 247760051, + 'segments': [{'x1': -5123, 'y1': -15198, 'x2': -21917, 'y2': -1992}], } - self.req_bin_0 = b'\x42\x00\x05\x00' b'\x32\x31\x83\x0d' \ - b'\x4e\x20\xfb\x7a' b'\x42\xc0\x56\xab' \ - b'\xe6\xeb\x70\xe8' + self.req_bin_0 = b'\x42\x00\x05\x00' b'\x18\x6a\x89\x03' \ + b'\xb3\x84\xc4\x0e' b'\xfd\xeb\xa2\xc4' \ + b'\x63\xaa\x38\xf8' def testPackRequest0(self): @@ -2249,15 +2249,15 @@ def testUnpackRequest0(self): class TestPolyRectangle(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 576422975, - 'gc': 1829049801, - 'rectangles': [{'y': -5825, 'x': -12104, 'height': 28684, 'width': 46429}, {'y': -1378, 'x': -8911, 'height': 53015, 'width': 17886}, {'y': -17049, 'x': -15271, 'height': 47977, 'width': 28690}], + 'drawable': 742422946, + 'gc': 1564604140, + 'rectangles': [{'x': -4030, 'y': -970, 'width': 17374, 'height': 11958}, {'x': -13744, 'y': -1228, 'width': 64713, 'height': 17653}, {'x': -31515, 'y': -29216, 'width': 39352, 'height': 28735}], } - self.req_bin_0 = b'\x43\x00\x09\x00' b'\x3f\x84\x5b\x22' \ - b'\xc9\x15\x05\x6d' b'\xb8\xd0\x3f\xe9' \ - b'\x5d\xb5\x0c\x70' b'\x31\xdd\x9e\xfa' \ - b'\xde\x45\x17\xcf' b'\x59\xc4\x67\xbd' \ - b'\x12\x70\x69\xbb' + self.req_bin_0 = b'\x43\x00\x09\x00' b'\xa2\x79\x40\x2c' \ + b'\xec\xf6\x41\x5d' b'\x42\xf0\x36\xfc' \ + b'\xde\x43\xb6\x2e' b'\x50\xca\x34\xfb' \ + b'\xc9\xfc\xf5\x44' b'\xe5\x84\xe0\x8d' \ + b'\xb8\x99\x3f\x70' def testPackRequest0(self): @@ -2273,16 +2273,16 @@ def testUnpackRequest0(self): class TestPolyArc(EndianTest): def setUp(self): self.req_args_0 = { - 'arcs': [{'height': 16175, 'width': 57808, 'angle1': -17659, 'angle2': -12925, 'y': -29951, 'x': -5759}, {'height': 12126, 'width': 55806, 'angle1': -25872, 'angle2': -6829, 'y': -31835, 'x': -20446}, {'height': 18290, 'width': 46029, 'angle1': -32438, 'angle2': -1944, 'y': -4147, 'x': -21703}], - 'drawable': 183912361, - 'gc': 1546366910, + 'arcs': [{'x': -6999, 'y': -22490, 'width': 28855, 'height': 39984, 'angle1': -517, 'angle2': -16010}, {'x': -28979, 'y': -20146, 'width': 59205, 'height': 38043, 'angle1': -26540, 'angle2': -24422}, {'x': -31314, 'y': -9543, 'width': 28833, 'height': 366, 'angle1': -15732, 'angle2': -2439}], + 'drawable': 1732034432, + 'gc': 1156382390, } - self.req_bin_0 = b'\x44\x00\x0c\x00' b'\xa9\x47\xf6\x0a' \ - b'\xbe\xaf\x2b\x5c' b'\x81\xe9\x01\x8b' \ - b'\xd0\xe1\x2f\x3f' b'\x05\xbb\x83\xcd' \ - b'\x22\xb0\xa5\x83' b'\xfe\xd9\x5e\x2f' \ - b'\xf0\x9a\x53\xe5' b'\x39\xab\xcd\xef' \ - b'\xcd\xb3\x72\x47' b'\x4a\x81\x68\xf8' + self.req_bin_0 = b'\x44\x00\x0c\x00' b'\x80\xbf\x3c\x67' \ + b'\xb6\xfe\xec\x44' b'\xa9\xe4\x26\xa8' \ + b'\xb7\x70\x30\x9c' b'\xfb\xfd\x76\xc1' \ + b'\xcd\x8e\x4e\xb1' b'\x45\xe7\x9b\x94' \ + b'\x54\x98\x9a\xa0' b'\xae\x85\xb9\xda' \ + b'\xa1\x70\x6e\x01' b'\x8c\xc2\x79\xf6' def testPackRequest0(self): @@ -2299,15 +2299,15 @@ class TestFillPoly(EndianTest): def setUp(self): self.req_args_0 = { 'coord_mode': 0, - 'drawable': 199889986, - 'gc': 475925659, - 'points': [{'y': -8118, 'x': -16883}, {'y': -11768, 'x': -10315}, {'y': -6988, 'x': -16810}], - 'shape': 2, + 'drawable': 423195261, + 'gc': 782225195, + 'points': [{'x': -10262, 'y': -9194}, {'x': -1958, 'y': -8456}, {'x': -8617, 'y': -10793}], + 'shape': 1, } - self.req_bin_0 = b'\x45\x00\x07\x00' b'\x42\x14\xea\x0b' \ - b'\x9b\x0c\x5e\x1c' b'\x02\x00\x00\x00' \ - b'\x0d\xbe\x4a\xe0' b'\xb5\xd7\x08\xd2' \ - b'\x56\xbe\xb4\xe4' + self.req_bin_0 = b'\x45\x00\x07\x00' b'\x7d\x72\x39\x19' \ + b'\x2b\xcf\x9f\x2e' b'\x01\x00\x00\x00' \ + b'\xea\xd7\x16\xdc' b'\x5a\xf8\xf8\xde' \ + b'\x57\xde\xd7\xd5' def testPackRequest0(self): @@ -2323,14 +2323,14 @@ def testUnpackRequest0(self): class TestPolyFillRectangle(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 539934343, - 'gc': 259164168, - 'rectangles': [{'y': -17381, 'x': -13860, 'height': 28032, 'width': 34914}, {'y': -22013, 'x': -8516, 'height': 17941, 'width': 46138}], + 'drawable': 267696363, + 'gc': 1545726032, + 'rectangles': [{'x': -1676, 'y': -11003, 'width': 60599, 'height': 21895}, {'x': -12349, 'y': -22482, 'width': 43731, 'height': 55831}], } - self.req_bin_0 = b'\x46\x00\x07\x00' b'\x87\xbe\x2e\x20' \ - b'\x08\x88\x72\x0f' b'\xdc\xc9\x1b\xbc' \ - b'\x62\x88\x80\x6d' b'\xbc\xde\x03\xaa' \ - b'\x3a\xb4\x15\x46' + self.req_bin_0 = b'\x46\x00\x07\x00' b'\xeb\xb8\xf4\x0f' \ + b'\x50\xe8\x21\x5c' b'\x74\xf9\x05\xd5' \ + b'\xb7\xec\x87\x55' b'\xc3\xcf\x2e\xa8' \ + b'\xd3\xaa\x17\xda' def testPackRequest0(self): @@ -2346,13 +2346,13 @@ def testUnpackRequest0(self): class TestPolyFillArc(EndianTest): def setUp(self): self.req_args_0 = { - 'arcs': [{'height': 50011, 'width': 35237, 'angle1': -26749, 'angle2': -25733, 'y': -28881, 'x': -26507}], - 'drawable': 1039842351, - 'gc': 1556052490, + 'arcs': [{'x': -3276, 'y': -22928, 'width': 33490, 'height': 20525, 'angle1': -10916, 'angle2': -19386}], + 'drawable': 700537986, + 'gc': 864213787, } - self.req_bin_0 = b'\x47\x00\x06\x00' b'\x2f\xbc\xfa\x3d' \ - b'\x0a\x7a\xbf\x5c' b'\x75\x98\x2f\x8f' \ - b'\xa5\x89\x5b\xc3' b'\x83\x97\x7b\x9b' + self.req_bin_0 = b'\x47\x00\x06\x00' b'\x82\x5c\xc1\x29' \ + b'\x1b\xdb\x82\x33' b'\x34\xf3\x70\xa6' \ + b'\xd2\x82\x2d\x50' b'\x5c\xd5\x46\xb4' def testPackRequest0(self): @@ -2369,19 +2369,19 @@ class TestPutImage(EndianTest): def setUp(self): self.req_args_0 = { 'data': 'bit map data', - 'depth': 196, - 'drawable': 1126680250, - 'dst_x': -25372, - 'dst_y': -26934, + 'depth': 172, + 'drawable': 634980240, + 'dst_x': -18991, + 'dst_y': -10980, 'format': 2, - 'gc': 607782076, - 'height': 12927, - 'left_pad': 129, - 'width': 6818, - } - self.req_bin_0 = b'\x48\x02\x09\x00' b'\xba\xc6\x27\x43' \ - b'\xbc\x04\x3a\x24' b'\xa2\x1a\x7f\x32' \ - b'\xe4\x9c\xca\x96' b'\x81\xc4\x00\x00' \ + 'gc': 1190657277, + 'height': 12828, + 'left_pad': 225, + 'width': 8597, + } + self.req_bin_0 = b'\x48\x02\x09\x00' b'\x90\x07\xd9\x25' \ + b'\xfd\xfc\xf7\x46' b'\x95\x21\x1c\x32' \ + b'\xd1\xb5\x1c\xd5' b'\xe1\xac\x00\x00' \ b'\x62\x69\x74\x20' b'\x6d\x61\x70\x20' \ b'\x64\x61\x74\x61' @@ -2399,26 +2399,26 @@ def testUnpackRequest0(self): class TestGetImage(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 2092284116, - 'format': 1, - 'height': 56949, - 'plane_mask': 1054187334, - 'width': 8499, - 'x': -14777, - 'y': -10093, + 'drawable': 872105322, + 'format': 2, + 'height': 20170, + 'plane_mask': 616208054, + 'width': 282, + 'x': -14814, + 'y': -5449, } - self.req_bin_0 = b'\x49\x01\x05\x00' b'\xd4\xb8\xb5\x7c' \ - b'\x47\xc6\x93\xd8' b'\x33\x21\x75\xde' \ - b'\x46\x9f\xd5\x3e' + self.req_bin_0 = b'\x49\x02\x05\x00' b'\x6a\x45\xfb\x33' \ + b'\x22\xc6\xb7\xea' b'\x1a\x01\xca\x4e' \ + b'\xb6\x96\xba\x24' self.reply_args_0 = { 'data': 'this is real ly imag e b-map', - 'depth': 239, - 'sequence_number': 37730, - 'visual': 1008057036, + 'depth': 181, + 'sequence_number': 28429, + 'visual': 1687469773, } - self.reply_bin_0 = b'\x01\xef\x62\x93' b'\x07\x00\x00\x00' \ - b'\xcc\xba\x15\x3c' b'\x00\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\xb5\x0d\x6f' b'\x07\x00\x00\x00' \ + b'\xcd\xbe\x94\x64' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x74\x68\x69\x73' b'\x20\x69\x73\x20' \ @@ -2449,14 +2449,14 @@ def testUnpackReply0(self): class TestPolyText8(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 945936210, - 'gc': 395971420, - 'items': [{'string': 'zoo', 'delta': 2}, 16909060, {'string': 'ie', 'delta': 0}], - 'x': -31098, - 'y': -2172, + 'drawable': 1245573363, + 'gc': 1302861330, + 'items': [{'delta': 2, 'string': 'zoo'}, 16909060, {'delta': 0, 'string': 'ie'}], + 'x': -11315, + 'y': -22209, } - self.req_bin_0 = b'\x4a\x00\x08\x00' b'\x52\xd7\x61\x38' \ - b'\x5c\x0b\x9a\x17' b'\x86\x86\x84\xf7' \ + self.req_bin_0 = b'\x4a\x00\x08\x00' b'\xf3\xf0\x3d\x4a' \ + b'\x12\x16\xa8\x4d' b'\xcd\xd3\x3f\xa9' \ b'\x03\x02\x7a\x6f' b'\x6f\xff\x01\x02' \ b'\x03\x04\x02\x00' b'\x69\x65\x00\x00' @@ -2474,14 +2474,14 @@ def testUnpackRequest0(self): class TestPolyText16(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 1025949844, - 'gc': 1765491562, - 'items': [{'string': (4131, 18), 'delta': 2}, 16909060], - 'x': -19740, - 'y': -30360, + 'drawable': 998620068, + 'gc': 948793778, + 'items': [{'delta': 2, 'string': (4131, 18)}, 16909060], + 'x': -18280, + 'y': -10630, } - self.req_bin_0 = b'\x4b\x00\x07\x00' b'\x94\xc0\x26\x3d' \ - b'\x6a\x43\x3b\x69' b'\xe4\xb2\x68\x89' \ + self.req_bin_0 = b'\x4b\x00\x07\x00' b'\xa4\xbb\x85\x3b' \ + b'\xb2\x71\x8d\x38' b'\x98\xb8\x7a\xd6' \ b'\x02\x02\x10\x23' b'\x00\x12\xff\x01' \ b'\x02\x03\x04\x00' @@ -2499,14 +2499,14 @@ def testUnpackRequest0(self): class TestImageText8(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 1351748646, - 'gc': 115186633, + 'drawable': 458985805, + 'gc': 1097803335, 'string': 'showme', - 'x': -27918, - 'y': -14469, + 'x': -17263, + 'y': -6759, } - self.req_bin_0 = b'\x4c\x06\x06\x00' b'\x26\x0c\x92\x50' \ - b'\xc9\x9b\xdd\x06' b'\xf2\x92\x7b\xc7' \ + self.req_bin_0 = b'\x4c\x06\x06\x00' b'\x4d\x91\x5b\x1b' \ + b'\x47\x26\x6f\x41' b'\x91\xbc\x99\xe5' \ b'\x73\x68\x6f\x77' b'\x6d\x65\x00\x00' @@ -2523,14 +2523,14 @@ def testUnpackRequest0(self): class TestImageText16(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 652527416, - 'gc': 2134423313, + 'drawable': 1935336610, + 'gc': 2061289059, 'string': (115, 104, 111, 119, 109, 111, 114, 101), - 'x': -28917, - 'y': -7914, + 'x': -6684, + 'y': -8653, } - self.req_bin_0 = b'\x4d\x08\x08\x00' b'\x38\xc7\xe4\x26' \ - b'\x11\xb7\x38\x7f' b'\x0b\x8f\x16\xe1' \ + self.req_bin_0 = b'\x4d\x08\x08\x00' b'\xa2\xe4\x5a\x73' \ + b'\x63\xc6\xdc\x7a' b'\xe4\xe5\x33\xde' \ b'\x00\x73\x00\x68' b'\x00\x6f\x00\x77' \ b'\x00\x6d\x00\x6f' b'\x00\x72\x00\x65' @@ -2548,13 +2548,13 @@ def testUnpackRequest0(self): class TestCreateColormap(EndianTest): def setUp(self): self.req_args_0 = { - 'alloc': 1, - 'mid': 1698116715, - 'visual': 1122247262, - 'window': 484710181, + 'alloc': 0, + 'mid': 1414936748, + 'visual': 609492200, + 'window': 182162564, } - self.req_bin_0 = b'\x4e\x01\x04\x00' b'\x6b\x34\x37\x65' \ - b'\x25\x17\xe4\x1c' b'\x5e\x22\xe4\x42' + self.req_bin_0 = b'\x4e\x00\x04\x00' b'\xac\x38\x56\x54' \ + b'\x84\x94\xdb\x0a' b'\xe8\x1c\x54\x24' def testPackRequest0(self): @@ -2570,9 +2570,9 @@ def testUnpackRequest0(self): class TestFreeColormap(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 967508457, + 'cmap': 1106990292, } - self.req_bin_0 = b'\x4f\x00\x02\x00' b'\xe9\x01\xab\x39' + self.req_bin_0 = b'\x4f\x00\x02\x00' b'\xd4\x54\xfb\x41' def testPackRequest0(self): @@ -2588,11 +2588,11 @@ def testUnpackRequest0(self): class TestCopyColormapAndFree(EndianTest): def setUp(self): self.req_args_0 = { - 'mid': 950772638, - 'src_cmap': 1847203012, + 'mid': 1425680795, + 'src_cmap': 1359295675, } - self.req_bin_0 = b'\x50\x00\x03\x00' b'\x9e\xa3\xab\x38' \ - b'\xc4\x14\x1a\x6e' + self.req_bin_0 = b'\x50\x00\x03\x00' b'\x9b\x29\xfa\x54' \ + b'\xbb\x34\x05\x51' def testPackRequest0(self): @@ -2608,9 +2608,9 @@ def testUnpackRequest0(self): class TestInstallColormap(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 2126076595, + 'cmap': 1329917990, } - self.req_bin_0 = b'\x51\x00\x02\x00' b'\xb3\x5a\xb9\x7e' + self.req_bin_0 = b'\x51\x00\x02\x00' b'\x26\xf0\x44\x4f' def testPackRequest0(self): @@ -2626,9 +2626,9 @@ def testUnpackRequest0(self): class TestUninstallColormap(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 655844603, + 'cmap': 719876845, } - self.req_bin_0 = b'\x52\x00\x02\x00' b'\xfb\x64\x17\x27' + self.req_bin_0 = b'\x52\x00\x02\x00' b'\xed\x72\xe8\x2a' def testPackRequest0(self): @@ -2644,19 +2644,19 @@ def testUnpackRequest0(self): class TestListInstalledColormaps(EndianTest): def setUp(self): self.req_args_0 = { - 'window': 1333670852, + 'window': 200613013, } - self.req_bin_0 = b'\x53\x00\x02\x00' b'\xc4\x33\x7e\x4f' + self.req_bin_0 = b'\x53\x00\x02\x00' b'\x95\x1c\xf5\x0b' self.reply_args_0 = { - 'cmaps': [1309197997, 1589346714], - 'sequence_number': 62114, + 'cmaps': [1757616530, 2044469232], + 'sequence_number': 49482, } - self.reply_bin_0 = b'\x01\x00\xa2\xf2' b'\x02\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\x4a\xc1' b'\x02\x00\x00\x00' \ b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\xad\xc6\x08\x4e' b'\x9a\x81\xbb\x5e' + b'\x92\x19\xc3\x68' b'\xf0\x1f\xdc\x79' def testPackRequest0(self): @@ -2681,24 +2681,24 @@ def testUnpackReply0(self): class TestAllocColor(EndianTest): def setUp(self): self.req_args_0 = { - 'blue': 10508, - 'cmap': 446273048, - 'green': 43368, - 'red': 14031, + 'blue': 14978, + 'cmap': 504442007, + 'green': 20599, + 'red': 44348, } - self.req_bin_0 = b'\x54\x00\x04\x00' b'\x18\x96\x99\x1a' \ - b'\xcf\x36\x68\xa9' b'\x0c\x29\x00\x00' + self.req_bin_0 = b'\x54\x00\x04\x00' b'\x97\x2c\x11\x1e' \ + b'\x3c\xad\x77\x50' b'\x82\x3a\x00\x00' self.reply_args_0 = { - 'blue': 29664, - 'green': 430, - 'pixel': 1275226450, - 'red': 5156, - 'sequence_number': 11602, - } - self.reply_bin_0 = b'\x01\x00\x52\x2d' b'\x00\x00\x00\x00' \ - b'\x24\x14\xae\x01' b'\xe0\x73\x00\x00' \ - b'\x52\x69\x02\x4c' b'\x00\x00\x00\x00' \ + 'blue': 1856, + 'green': 9912, + 'pixel': 99308744, + 'red': 13306, + 'sequence_number': 53114, + } + self.reply_bin_0 = b'\x01\x00\x7a\xcf' b'\x00\x00\x00\x00' \ + b'\xfa\x33\xb8\x26' b'\x40\x07\x00\x00' \ + b'\xc8\x54\xeb\x05' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -2724,26 +2724,26 @@ def testUnpackReply0(self): class TestAllocNamedColor(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 625521008, + 'cmap': 525860889, 'name': 'octarin', } - self.req_bin_0 = b'\x55\x00\x05\x00' b'\x70\xb1\x48\x25' \ + self.req_bin_0 = b'\x55\x00\x05\x00' b'\x19\x00\x58\x1f' \ b'\x07\x00\x00\x00' b'\x6f\x63\x74\x61' \ b'\x72\x69\x6e\x00' self.reply_args_0 = { - 'exact_blue': 45128, - 'exact_green': 29895, - 'exact_red': 46147, - 'pixel': 1518195288, - 'screen_blue': 41059, - 'screen_green': 51685, - 'screen_red': 60568, - 'sequence_number': 15366, - } - self.reply_bin_0 = b'\x01\x00\x06\x3c' b'\x00\x00\x00\x00' \ - b'\x58\xd2\x7d\x5a' b'\x43\xb4\xc7\x74' \ - b'\x48\xb0\x98\xec' b'\xe5\xc9\x63\xa0' \ + 'exact_blue': 50619, + 'exact_green': 55944, + 'exact_red': 40316, + 'pixel': 1020413057, + 'screen_blue': 27416, + 'screen_green': 30102, + 'screen_red': 5028, + 'sequence_number': 64739, + } + self.reply_bin_0 = b'\x01\x00\xe3\xfc' b'\x00\x00\x00\x00' \ + b'\x81\x44\xd2\x3c' b'\x7c\x9d\x88\xda' \ + b'\xbb\xc5\xa4\x13' b'\x96\x75\x18\x6b' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -2769,40 +2769,40 @@ def testUnpackReply0(self): class TestAllocColorCells(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 2005042093, - 'colors': 28009, - 'contiguous': 1, - 'planes': 35805, + 'cmap': 1542701632, + 'colors': 45892, + 'contiguous': 0, + 'planes': 25420, } - self.req_bin_0 = b'\x56\x01\x03\x00' b'\xad\x83\x82\x77' \ - b'\x69\x6d\xdd\x8b' + self.req_bin_0 = b'\x56\x00\x03\x00' b'\x40\xc2\xf3\x5b' \ + b'\x44\xb3\x4c\x63' self.reply_args_0 = { - 'masks': [927811713, 692224741, 537710104], - 'pixels': [1390808070, 1950804725, 1775188259, 153412312, 356371138, 660636713, 1608390912, 1222391062, 619833140, 267104833, 1478945126, 1502686323, 2024385568, 1074788553, 1060450333, 172807825, 85663305], - 'sequence_number': 6217, + 'masks': [1726878301, 2057281944, 1494524694], + 'pixels': [1061732426, 858313521, 524018138, 316972578, 1408939380, 1476723430, 11972931, 1917037904, 1612749468, 1847847580, 1653727126, 1901587588, 228960010, 1671710636, 913060041, 470023299, 377779303], + 'sequence_number': 34200, } - self.reply_bin_0 = b'\x01\x00\x49\x18' b'\x14\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\x98\x85' b'\x14\x00\x00\x00' \ b'\x11\x00\x03\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x06\x0c\xe6\x52' b'\xf5\xea\x46\x74' \ - b'\x23\x39\xcf\x69' b'\xd8\xe2\x24\x09' \ - b'\xc2\xca\x3d\x15' b'\x29\x84\x60\x27' \ - b'\x00\x19\xde\x5f' b'\x16\x35\xdc\x48' \ - b'\x34\xe7\xf1\x24' b'\x41\xb2\xeb\x0f' \ - b'\x66\xe9\x26\x58' b'\x73\x2c\x91\x59' \ - b'\x20\xac\xa9\x78' b'\xc9\xf8\x0f\x40' \ - b'\x1d\x30\x35\x3f' b'\x91\xd6\x4c\x0a' \ - b'\x49\x1e\x1b\x05' b'\x81\x48\x4d\x37' \ - b'\xe5\x82\x42\x29' b'\x18\xce\x0c\x20' + b'\x4a\xc0\x48\x3f' b'\x31\xd3\x28\x33' \ + b'\xda\xe1\x3b\x1f' b'\x22\x9e\xe4\x12' \ + b'\x74\xb5\xfa\x53' b'\xe6\x02\x05\x58' \ + b'\x43\xb1\xb6\x00' b'\x50\xad\x43\x72' \ + b'\x9c\x9a\x20\x60' b'\x9c\xea\x23\x6e' \ + b'\x96\xdf\x91\x62' b'\x84\xec\x57\x71' \ + b'\x0a\xa7\xa5\x0d' b'\xac\x47\xa4\x63' \ + b'\xc9\x30\x6c\x36' b'\x83\xfc\x03\x1c' \ + b'\x67\x74\x84\x16' b'\x5d\x12\xee\x66' \ + b'\x98\xa1\x9f\x7a' b'\x16\xa3\x14\x59' self.reply_args_1 = { 'masks': [], 'pixels': [], - 'sequence_number': 63049, + 'sequence_number': 30700, } - self.reply_bin_1 = b'\x01\x00\x49\xf6' b'\x00\x00\x00\x00' \ + self.reply_bin_1 = b'\x01\x00\xec\x77' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -2839,29 +2839,29 @@ def testUnpackReply1(self): class TestAllocColorPlanes(EndianTest): def setUp(self): self.req_args_0 = { - 'blue': 17849, - 'cmap': 1235258520, - 'colors': 62323, - 'contiguous': 1, - 'green': 44142, - 'red': 65508, + 'blue': 8209, + 'cmap': 1197085372, + 'colors': 16587, + 'contiguous': 0, + 'green': 55852, + 'red': 60383, } - self.req_bin_0 = b'\x57\x01\x04\x00' b'\x98\x8c\xa0\x49' \ - b'\x73\xf3\xe4\xff' b'\x6e\xac\xb9\x45' + self.req_bin_0 = b'\x57\x00\x04\x00' b'\xbc\x12\x5a\x47' \ + b'\xcb\x40\xdf\xeb' b'\x2c\xda\x11\x20' self.reply_args_0 = { - 'blue_mask': 1363213739, - 'green_mask': 1257012974, - 'pixels': [86459759, 1624090919, 1010427525, 1399128813], - 'red_mask': 389798617, - 'sequence_number': 60057, + 'blue_mask': 1200348460, + 'green_mask': 2121548418, + 'pixels': [980309855, 286409072, 1721094583, 997879295], + 'red_mask': 1140662566, + 'sequence_number': 44006, } - self.reply_bin_0 = b'\x01\x00\x99\xea' b'\x04\x00\x00\x00' \ - b'\x04\x00\x00\x00' b'\xd9\xda\x3b\x17' \ - b'\xee\x7e\xec\x4a' b'\xab\xfd\x40\x51' \ + self.reply_bin_0 = b'\x01\x00\xe6\xab' b'\x04\x00\x00\x00' \ + b'\x04\x00\x00\x00' b'\x26\x21\xfd\x43' \ + b'\x82\x42\x74\x7e' b'\x2c\xdd\x8b\x47' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x6f\x45\x27\x05' b'\x27\xa9\xcd\x60' \ - b'\x85\xe6\x39\x3c' b'\xed\x02\x65\x53' + b'\x5f\x57\x6e\x3a' b'\x70\x41\x12\x11' \ + b'\xb7\xd1\x95\x66' b'\xff\x6d\x7a\x3b' def testPackRequest0(self): @@ -2886,20 +2886,20 @@ def testUnpackReply0(self): class TestFreeColors(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 1105118848, - 'pixels': [1056006429, 196001131, 747283410, 715818017, 1439122371, 1841977117, 708291896, 1489672946, 618989649, 2029791261, 1747131973, 1181352956, 976766929, 675465375, 694269519, 2083457789, 867998373], - 'plane_mask': 2121970633, + 'cmap': 341854532, + 'pixels': [1278789650, 681457705, 2040260049, 1621952585, 1914388136, 950484730, 1315726377, 1750278681, 1544694596, 1915664535, 1084068385, 916484334, 1783699241, 1947521244, 1176611597, 957657715, 1926805276], + 'plane_mask': 1597053435, } - self.req_bin_0 = b'\x58\x00\x14\x00' b'\x80\xc6\xde\x41' \ - b'\xc9\xb3\x7a\x7e' b'\x1d\x61\xf1\x3e' \ - b'\x6b\xbd\xae\x0b' b'\xd2\xa3\x8a\x2c' \ - b'\x21\x84\xaa\x2a' b'\xc3\x43\xc7\x55' \ - b'\x1d\x57\xca\x6d' b'\x38\xad\x37\x2a' \ - b'\xf2\x9a\xca\x58' b'\x51\x08\xe5\x24' \ - b'\x1d\x28\xfc\x78' b'\x45\x1e\x23\x68' \ - b'\xfc\x03\x6a\x46' b'\xd1\x47\x38\x3a' \ - b'\x9f\xc8\x42\x28' b'\x4f\xb6\x61\x29' \ - b'\xfd\x0a\x2f\x7c' b'\xa5\x9a\xbc\x33' + self.req_bin_0 = b'\x58\x00\x14\x00' b'\x44\x49\x60\x14' \ + b'\xfb\x19\x31\x5f' b'\x12\xc8\x38\x4c' \ + b'\x29\x38\x9e\x28' b'\xd1\xe5\x9b\x79' \ + b'\x49\x08\xad\x60' b'\xa8\x3e\x1b\x72' \ + b'\xfa\x3e\xa7\x38' b'\x29\x64\x6c\x4e' \ + b'\x19\x22\x53\x68' b'\x44\x2b\x12\x5c' \ + b'\x97\xb8\x2e\x72' b'\x21\x92\x9d\x40' \ + b'\xee\x70\xa0\x36' b'\x29\x17\x51\x6a' \ + b'\xdc\xd0\x14\x74' b'\x0d\xab\x21\x46' \ + b'\x73\xb2\x14\x39' b'\x1c\xb7\xd8\x72' def testPackRequest0(self): @@ -2915,16 +2915,16 @@ def testUnpackRequest0(self): class TestStoreColors(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 200224662, - 'items': [{'blue': 12501, 'flags': 174, 'green': 27232, 'pixel': 1412337360, 'red': 35676}, {'blue': 13544, 'flags': 198, 'green': 49868, 'pixel': 1624465264, 'red': 41082}, {'blue': 8182, 'flags': 252, 'green': 45837, 'pixel': 1992166823, 'red': 28856}, {'blue': 36214, 'flags': 198, 'green': 10594, 'pixel': 1307567581, 'red': 15877}], + 'cmap': 686636594, + 'items': [{'pixel': 1850111768, 'red': 31364, 'green': 29751, 'blue': 17242, 'flags': 191}, {'pixel': 1803657350, 'red': 42045, 'green': 18429, 'blue': 50444, 'flags': 252}, {'pixel': 1345997556, 'red': 15935, 'green': 18252, 'blue': 29083, 'flags': 147}, {'pixel': 1532391469, 'red': 18981, 'green': 15623, 'blue': 18063, 'flags': 213}], } - self.req_bin_0 = b'\x59\x00\x0e\x00' b'\x96\x2f\xef\x0b' \ - b'\xd0\x8e\x2e\x54' b'\x5c\x8b\x60\x6a' \ - b'\xd5\x30\xae\x00' b'\x70\x5f\xd3\x60' \ - b'\x7a\xa0\xcc\xc2' b'\xe8\x34\xc6\x00' \ - b'\xa7\x0d\xbe\x76' b'\xb8\x70\x0d\xb3' \ - b'\xf6\x1f\xfc\x00' b'\xdd\xe5\xef\x4d' \ - b'\x05\x3e\x62\x29' b'\x76\x8d\xc6\x00' + self.req_bin_0 = b'\x59\x00\x0e\x00' b'\x32\x3e\xed\x28' \ + b'\x18\x77\x46\x6e' b'\x84\x7a\x37\x74' \ + b'\x5a\x43\xbf\x00' b'\x86\xa0\x81\x6b' \ + b'\x3d\xa4\xfd\x47' b'\x0c\xc5\xfc\x00' \ + b'\xf4\x4a\x3a\x50' b'\x3f\x3e\x4c\x47' \ + b'\x9b\x71\x93\x00' b'\x2d\x70\x56\x5b' \ + b'\x25\x4a\x07\x3d' b'\x8f\x46\xd5\x00' def testPackRequest0(self): @@ -2940,13 +2940,13 @@ def testUnpackRequest0(self): class TestStoreNamedColor(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 1960507691, - 'flags': 255, + 'cmap': 297221571, + 'flags': 148, 'name': 'blue', - 'pixel': 990987101, + 'pixel': 323971915, } - self.req_bin_0 = b'\x5a\xff\x05\x00' b'\x2b\xf9\xda\x74' \ - b'\x5d\x43\x11\x3b' b'\x04\x00\x00\x00' \ + self.req_bin_0 = b'\x5a\x94\x05\x00' b'\xc3\x3d\xb7\x11' \ + b'\x4b\x6b\x4f\x13' b'\x04\x00\x00\x00' \ b'\x62\x6c\x75\x65' @@ -2963,34 +2963,34 @@ def testUnpackRequest0(self): class TestQueryColors(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 523457697, - 'pixels': [252314471, 1787024858, 1070286120, 1538912496, 1092826517, 587223111, 1792566854, 2105060613], + 'cmap': 875378525, + 'pixels': [496695788, 822627561, 1490311416, 328212337, 1517089095, 459525846, 137995944, 890987562], } - self.req_bin_0 = b'\x5b\x00\x0a\x00' b'\xa1\x54\x33\x1f' \ - b'\x67\x03\x0a\x0f' b'\xda\xd5\x83\x6a' \ - b'\x28\x45\xcb\x3f' b'\xf0\xf0\xb9\x5b' \ - b'\x95\x35\x23\x41' b'\x47\x50\x00\x23' \ - b'\x46\x66\xd8\x6a' b'\x05\xad\x78\x7d' + self.req_bin_0 = b'\x5b\x00\x0a\x00' b'\x5d\x37\x2d\x34' \ + b'\xec\xf9\x9a\x1d' b'\xe9\x4c\x08\x31' \ + b'\xf8\x58\xd4\x58' b'\x71\x1f\x90\x13' \ + b'\x47\xf1\x6c\x5a' b'\xd6\xce\x63\x1b' \ + b'\xa8\xa6\x39\x08' b'\x2a\x64\x1b\x35' self.reply_args_0 = { - 'colors': [{'blue': 33433, 'green': 60435, 'red': 25296}, {'blue': 18289, 'green': 56659, 'red': 57658}, {'blue': 61243, 'green': 27343, 'red': 51827}, {'blue': 18719, 'green': 53821, 'red': 33401}, {'blue': 65464, 'green': 38571, 'red': 19745}], - 'sequence_number': 32219, + 'colors': [{'red': 35816, 'green': 30790, 'blue': 27504}, {'red': 4336, 'green': 13811, 'blue': 54840}, {'red': 27790, 'green': 25780, 'blue': 59555}, {'red': 50705, 'green': 38534, 'blue': 62257}, {'red': 45837, 'green': 1536, 'blue': 56402}], + 'sequence_number': 57970, } - self.reply_bin_0 = b'\x01\x00\xdb\x7d' b'\x0a\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\x72\xe2' b'\x0a\x00\x00\x00' \ b'\x05\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\xd0\x62\x13\xec' b'\x99\x82\x00\x00' \ - b'\x3a\xe1\x53\xdd' b'\x71\x47\x00\x00' \ - b'\x73\xca\xcf\x6a' b'\x3b\xef\x00\x00' \ - b'\x79\x82\x3d\xd2' b'\x1f\x49\x00\x00' \ - b'\x21\x4d\xab\x96' b'\xb8\xff\x00\x00' + b'\xe8\x8b\x46\x78' b'\x70\x6b\x00\x00' \ + b'\xf0\x10\xf3\x35' b'\x38\xd6\x00\x00' \ + b'\x8e\x6c\xb4\x64' b'\xa3\xe8\x00\x00' \ + b'\x11\xc6\x86\x96' b'\x31\xf3\x00\x00' \ + b'\x0d\xb3\x00\x06' b'\x52\xdc\x00\x00' self.req_args_1 = { - 'cmap': 1183862146, + 'cmap': 710627905, 'pixels': [], } - self.req_bin_1 = b'\x5b\x00\x02\x00' b'\x82\x4d\x90\x46' + self.req_bin_1 = b'\x5b\x00\x02\x00' b'\x41\x52\x5b\x2a' def testPackRequest0(self): @@ -3024,25 +3024,25 @@ def testUnpackReply0(self): class TestLookupColor(EndianTest): def setUp(self): self.req_args_0 = { - 'cmap': 319162028, + 'cmap': 1644167361, 'name': 'octarin', } - self.req_bin_0 = b'\x5c\x00\x05\x00' b'\xac\x06\x06\x13' \ + self.req_bin_0 = b'\x5c\x00\x05\x00' b'\xc1\x00\x00\x62' \ b'\x07\x00\x00\x00' b'\x6f\x63\x74\x61' \ b'\x72\x69\x6e\x00' self.reply_args_0 = { - 'exact_blue': 35731, - 'exact_green': 36285, - 'exact_red': 22785, - 'screen_blue': 12571, - 'screen_green': 21261, - 'screen_red': 29980, - 'sequence_number': 35414, - } - self.reply_bin_0 = b'\x01\x00\x56\x8a' b'\x00\x00\x00\x00' \ - b'\x01\x59\xbd\x8d' b'\x93\x8b\x1c\x75' \ - b'\x0d\x53\x1b\x31' b'\x00\x00\x00\x00' \ + 'exact_blue': 642, + 'exact_green': 31515, + 'exact_red': 25184, + 'screen_blue': 19825, + 'screen_green': 23308, + 'screen_red': 62039, + 'sequence_number': 37984, + } + self.reply_bin_0 = b'\x01\x00\x60\x94' b'\x00\x00\x00\x00' \ + b'\x60\x62\x1b\x7b' b'\x82\x02\x57\xf2' \ + b'\x0c\x5b\x71\x4d' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -3068,22 +3068,22 @@ def testUnpackReply0(self): class TestCreateCursor(EndianTest): def setUp(self): self.req_args_0 = { - 'back_blue': 25459, - 'back_green': 53224, - 'back_red': 46293, - 'cid': 1497886291, - 'fore_blue': 48870, - 'fore_green': 3105, - 'fore_red': 50883, - 'mask': 501621762, - 'source': 1227954148, - 'x': 43581, - 'y': 53834, + 'back_blue': 49245, + 'back_green': 35528, + 'back_red': 27716, + 'cid': 1618141054, + 'fore_blue': 55026, + 'fore_green': 62740, + 'fore_red': 58690, + 'mask': 1832831050, + 'source': 837555484, + 'x': 48400, + 'y': 36047, } - self.req_bin_0 = b'\x5d\x00\x08\x00' b'\x53\xee\x47\x59' \ - b'\xe4\x17\x31\x49' b'\x02\x24\xe6\x1d' \ - b'\xc3\xc6\x21\x0c' b'\xe6\xbe\xd5\xb4' \ - b'\xe8\xcf\x73\x63' b'\x3d\xaa\x4a\xd2' + self.req_bin_0 = b'\x5d\x00\x08\x00' b'\x7e\xdf\x72\x60' \ + b'\x1c\x15\xec\x31' b'\x4a\xc8\x3e\x6d' \ + b'\x42\xe5\x14\xf5' b'\xf2\xd6\x44\x6c' \ + b'\xc8\x8a\x5d\xc0' b'\x10\xbd\xcf\x8c' def testPackRequest0(self): @@ -3099,22 +3099,22 @@ def testUnpackRequest0(self): class TestCreateGlyphCursor(EndianTest): def setUp(self): self.req_args_0 = { - 'back_blue': 47417, - 'back_green': 30084, - 'back_red': 34590, - 'cid': 2106292170, - 'fore_blue': 28999, - 'fore_green': 57323, - 'fore_red': 57030, - 'mask': 79562119, - 'mask_char': 38782, - 'source': 1063743249, - 'source_char': 33045, + 'back_blue': 25740, + 'back_green': 2158, + 'back_red': 32083, + 'cid': 1717769345, + 'fore_blue': 28818, + 'fore_green': 18143, + 'fore_red': 14636, + 'mask': 1928100723, + 'mask_char': 32252, + 'source': 1295540602, + 'source_char': 14709, } - self.req_bin_0 = b'\x5e\x00\x08\x00' b'\xca\x77\x8b\x7d' \ - b'\x11\x6f\x67\x3f' b'\x87\x05\xbe\x04' \ - b'\x15\x81\x7e\x97' b'\xc6\xde\xeb\xdf' \ - b'\x47\x71\x1e\x87' b'\x84\x75\x39\xb9' + self.req_bin_0 = b'\x5e\x00\x08\x00' b'\x81\x14\x63\x66' \ + b'\x7a\x61\x38\x4d' b'\x73\x7b\xec\x72' \ + b'\x75\x39\xfc\x7d' b'\x2c\x39\xdf\x46' \ + b'\x92\x70\x53\x7d' b'\x6e\x08\x8c\x64' def testPackRequest0(self): @@ -3130,9 +3130,9 @@ def testUnpackRequest0(self): class TestFreeCursor(EndianTest): def setUp(self): self.req_args_0 = { - 'cursor': 880461049, + 'cursor': 721898231, } - self.req_bin_0 = b'\x5f\x00\x02\x00' b'\xf9\xc4\x7a\x34' + self.req_bin_0 = b'\x5f\x00\x02\x00' b'\xf7\x4a\x07\x2b' def testPackRequest0(self): @@ -3148,17 +3148,17 @@ def testUnpackRequest0(self): class TestRecolorCursor(EndianTest): def setUp(self): self.req_args_0 = { - 'back_blue': 42677, - 'back_green': 45475, - 'back_red': 22357, - 'cursor': 1406154815, - 'fore_blue': 63525, - 'fore_green': 30904, - 'fore_red': 10332, + 'back_blue': 55339, + 'back_green': 11072, + 'back_red': 47715, + 'cursor': 1436460699, + 'fore_blue': 26753, + 'fore_green': 52563, + 'fore_red': 44764, } - self.req_bin_0 = b'\x60\x00\x05\x00' b'\x3f\x38\xd0\x53' \ - b'\x5c\x28\xb8\x78' b'\x25\xf8\x55\x57' \ - b'\xa3\xb1\xb5\xa6' + self.req_bin_0 = b'\x60\x00\x05\x00' b'\x9b\xa6\x9e\x55' \ + b'\xdc\xae\x53\xcd' b'\x81\x68\x63\xba' \ + b'\x40\x2b\x2b\xd8' def testPackRequest0(self): @@ -3174,21 +3174,21 @@ def testUnpackRequest0(self): class TestQueryBestSize(EndianTest): def setUp(self): self.req_args_0 = { - 'drawable': 1830398758, - 'height': 25063, - 'item_class': 2, - 'width': 56353, + 'drawable': 1974766133, + 'height': 64528, + 'item_class': 1, + 'width': 8620, } - self.req_bin_0 = b'\x61\x02\x03\x00' b'\x26\xab\x19\x6d' \ - b'\x21\xdc\xe7\x61' + self.req_bin_0 = b'\x61\x01\x03\x00' b'\x35\x8a\xb4\x75' \ + b'\xac\x21\x10\xfc' self.reply_args_0 = { - 'height': 49829, - 'sequence_number': 20927, - 'width': 47173, + 'height': 2023, + 'sequence_number': 41036, + 'width': 35260, } - self.reply_bin_0 = b'\x01\x00\xbf\x51' b'\x00\x00\x00\x00' \ - b'\x45\xb8\xa5\xc2' b'\x00\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\x4c\xa0' b'\x00\x00\x00\x00' \ + b'\xbc\x89\xe7\x07' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -3221,14 +3221,14 @@ def setUp(self): b'\x58\x54\x52\x41' self.reply_args_0 = { - 'first_error': 245, - 'first_event': 208, - 'major_opcode': 136, - 'present': 0, - 'sequence_number': 57205, + 'first_error': 237, + 'first_event': 149, + 'major_opcode': 134, + 'present': 1, + 'sequence_number': 59692, } - self.reply_bin_0 = b'\x01\x00\x75\xdf' b'\x00\x00\x00\x00' \ - b'\x00\x88\xd0\xf5' b'\x00\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\x2c\xe9' b'\x00\x00\x00\x00' \ + b'\x01\x86\x95\xed' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -3260,9 +3260,9 @@ def setUp(self): self.reply_args_0 = { 'names': ['XTRA', 'XTRA-II'], - 'sequence_number': 65367, + 'sequence_number': 9149, } - self.reply_bin_0 = b'\x01\x02\x57\xff' b'\x04\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x02\xbd\x23' b'\x04\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ @@ -3292,40 +3292,40 @@ def testUnpackReply0(self): class TestChangeKeyboardMapping(EndianTest): def setUp(self): self.req_args_0 = { - 'first_keycode': 209, - 'keysyms': [[1603668560, 931946639, 211405004], [1360963098, 1873849632, 952792434], [1490356148, 1940088399, 98764853], [1709705072, 630002501, 804965110], [312608755, 1140670982, 1215321258], [1701922610, 365037106, 169583241], [1870113797, 1330817882, 517178039], [1960285384, 307342963, 990311897], [545412183, 548309930, 20180830], [1727936374, 1935332499, 1455158296], [339250065, 948607486, 742096527], [1261800628, 1372110414, 911196506], [537081847, 1815276355, 427815247], [826122461, 1037681409, 509395365], [1228194629, 1234399220, 2131789930], [634003216, 2100119788, 1413537765], [589442127, 1215323309, 1472743195], [1599164158, 105321726, 1302248027], [1066713724, 1941658701, 614597260], [1715539042, 1303662156, 756603491]], - } - self.req_bin_0 = b'\x64\x14\x3e\x00' b'\xd1\x03\x00\x00' \ - b'\x50\x0a\x96\x5f' b'\x8f\x60\x8c\x37' \ - b'\xcc\xc8\x99\x0c' b'\x1a\xa6\x1e\x51' \ - b'\x20\xad\xb0\x6f' b'\x72\x75\xca\x38' \ - b'\xb4\x07\xd5\x58' b'\x4f\x66\xa3\x73' \ - b'\x35\x08\xe3\x05' b'\x70\x07\xe8\x65' \ - b'\x45\x13\x8d\x25' b'\xf6\xca\xfa\x2f' \ - b'\xf3\x07\xa2\x12' b'\x06\x42\xfd\x43' \ - b'\xaa\x54\x70\x48' b'\x32\x47\x71\x65' \ - b'\x32\x06\xc2\x15' b'\x89\xa2\x1b\x0a' \ - b'\x05\xac\x77\x6f' b'\x5a\xab\x52\x4f' \ - b'\xb7\x82\xd3\x1e' b'\xc8\x94\xd7\x74' \ - b'\x73\xae\x51\x12' b'\xd9\xf5\x06\x3b' \ - b'\x57\x54\x82\x20' b'\xaa\x8b\xae\x20' \ - b'\x5e\xef\x33\x01' b'\x76\x37\xfe\x66' \ - b'\x93\xd4\x5a\x73' b'\x18\xf4\xbb\x56' \ - b'\x91\x8b\x38\x14' b'\xfe\x99\x8a\x38' \ - b'\x8f\x7e\x3b\x2c' b'\xb4\x8c\x35\x4b' \ - b'\x4e\xbe\xc8\x51' b'\x5a\xc1\x4f\x36' \ - b'\xf7\x37\x03\x20' b'\x43\xeb\x32\x6c' \ - b'\x4f\xf1\x7f\x19' b'\xdd\xa0\x3d\x31' \ - b'\x01\xc3\xd9\x3d' b'\xa5\xc1\x5c\x1e' \ - b'\x45\xc3\x34\x49' b'\xf4\x6f\x93\x49' \ - b'\x6a\x88\x10\x7f' b'\x10\x1f\xca\x25' \ - b'\xec\x48\x2d\x7d' b'\xe5\xdf\x40\x54' \ - b'\x4f\x2c\x22\x23' b'\xad\x5c\x70\x48' \ - b'\x1b\x47\xc8\x57' b'\xfe\x4e\x51\x5f' \ - b'\xfe\x14\x47\x06' b'\x5b\xba\x9e\x4d' \ - b'\x7c\xc2\x94\x3f' b'\x4d\x5c\xbb\x73' \ - b'\x8c\x02\xa2\x24' b'\x62\x0c\x41\x66' \ - b'\x4c\x4e\xb4\x4d' b'\x63\xda\x18\x2d' + 'first_keycode': 157, + 'keysyms': [[1861549105, 991489870, 390260112], [107985429, 558681426, 814119353], [702984500, 454537006, 976459372], [701896028, 724776911, 1634728346], [1889012491, 814167346, 597551532], [1614928797, 2042695294, 1786543801], [905303576, 541748982, 1792957544], [175892294, 1009976242, 41625283], [1608517348, 1158393599, 111852976], [2147285698, 2044231981, 751534113], [481513427, 1396173819, 147356828], [1677685199, 2055755177, 1399632465], [86453688, 1619703478, 66636412], [2039275666, 531036848, 428123802], [1802230236, 43765755, 1334308166], [327238597, 512271361, 271057482], [1016964633, 1437651928, 245649464], [1211115441, 2035292716, 468075293], [998652876, 1502089592, 550279151], [1646901134, 792196355, 360324443]], + } + self.req_bin_0 = b'\x64\x14\x3e\x00' b'\x9d\x03\x00\x00' \ + b'\x31\xfc\xf4\x6e' b'\x4e\xef\x18\x3b' \ + b'\x90\xe5\x42\x17' b'\x15\xba\x6f\x06' \ + b'\x52\xcd\x4c\x21' b'\xb9\x79\x86\x30' \ + b'\x34\xb1\xe6\x29' b'\x2e\xaf\x17\x1b' \ + b'\x6c\x96\x33\x3a' b'\x5c\x15\xd6\x29' \ + b'\xcf\x37\x33\x2b' b'\x9a\xf9\x6f\x61' \ + b'\x0b\x0b\x98\x70' b'\x32\x35\x87\x30' \ + b'\xac\xe9\x9d\x23' b'\x9d\xdb\x41\x60' \ + b'\x7e\x0e\xc1\x79' b'\xb9\x7e\x7c\x6a' \ + b'\x18\xd6\xf5\x35' b'\xf6\x6e\x4a\x20' \ + b'\x68\x5c\xde\x6a' b'\x46\xe7\x7b\x0a' \ + b'\xb2\x03\x33\x3c' b'\xc3\x26\x7b\x02' \ + b'\xe4\x06\xe0\x5f' b'\xff\xae\x0b\x45' \ + b'\xb0\xbd\xaa\x06' b'\xc2\xfa\xfc\x7f' \ + b'\x2d\x81\xd8\x79' b'\x21\x80\xcb\x2c' \ + b'\xd3\x4f\xb3\x1c' b'\xfb\xeb\x37\x53' \ + b'\x9c\x7c\xc8\x08' b'\xcf\x71\xff\x63' \ + b'\xa9\x55\x88\x7a' b'\x51\xb2\x6c\x53' \ + b'\xb8\x2d\x27\x05' b'\xb6\xb6\x8a\x60' \ + b'\x7c\xca\xf8\x03' b'\x92\xe0\x8c\x79' \ + b'\xb0\xfa\xa6\x1f' b'\x9a\xa6\x84\x19' \ + b'\xdc\xd9\x6b\x6b' b'\xfb\xcf\x9b\x02' \ + b'\x46\xed\x87\x4f' b'\xc5\x43\x81\x13' \ + b'\x01\xa4\x88\x1e' b'\x4a\x02\x28\x10' \ + b'\x19\xa6\x9d\x3c' b'\xd8\xd3\xb0\x55' \ + b'\x38\x50\xa4\x0e' b'\xb1\x27\x30\x48' \ + b'\x2c\x1a\x50\x79' b'\x1d\x43\xe6\x1b' \ + b'\xcc\x3b\x86\x3b' b'\x78\x11\x88\x59' \ + b'\xef\x97\xcc\x20' b'\x8e\xb7\x29\x62' \ + b'\x03\xf5\x37\x2f' b'\x5b\x1d\x7a\x15' def testPackRequest0(self): @@ -3341,49 +3341,49 @@ def testUnpackRequest0(self): class TestGetKeyboardMapping(EndianTest): def setUp(self): self.req_args_0 = { - 'count': 214, - 'first_keycode': 207, + 'count': 207, + 'first_keycode': 169, } - self.req_bin_0 = b'\x65\x00\x02\x00' b'\xcf\xd6\x00\x00' + self.req_bin_0 = b'\x65\x00\x02\x00' b'\xa9\xcf\x00\x00' self.reply_args_0 = { - 'keysyms': [[1548181899, 1415581578, 1800315249], [1349152528, 1940044681, 1388005887], [663428316, 946660592, 1244625269], [1572730625, 193559950, 633744868], [1605202933, 377184179, 283811004], [1158369341, 2086257988, 1139996791], [1961698339, 1783426369, 551839054], [1771007886, 1034760334, 1731920851], [1603223997, 727385468, 247325063], [2067797600, 302273387, 2075543394], [1847137865, 1555243546, 2104409941], [2077195964, 1727838808, 785495937], [1697976597, 29890084, 1152280257], [976645557, 1444887947, 1443840867], [1255333237, 1766127705, 2019261461], [232671482, 502128711, 53740025], [1898879870, 1205613172, 1965497096], [475382442, 135757562, 1769215894], [1952895082, 648948458, 876808673], [300168848, 2032081167, 653617967]], - 'sequence_number': 32414, - } - self.reply_bin_0 = b'\x01\x03\x9e\x7e' b'\x3c\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x8b\x61\x47\x5c' b'\x8a\x0f\x60\x54' \ - b'\x71\xa1\x4e\x6b' b'\x10\x6f\x6a\x50' \ - b'\x89\xbb\xa2\x73' b'\xff\x49\xbb\x52' \ - b'\xdc\x1c\x8b\x27' b'\xf0\xe4\x6c\x38' \ - b'\x75\x79\x2f\x4a' b'\x01\xf7\xbd\x5d' \ - b'\x8e\x7d\x89\x0b' b'\xe4\x2d\xc6\x25' \ - b'\xf5\x73\xad\x5f' b'\xb3\x5f\x7b\x16' \ - b'\xbc\x9c\xea\x10' b'\x3d\x50\x0b\x45' \ - b'\x44\xc5\x59\x7c' b'\x77\xf8\xf2\x43' \ - b'\x23\x24\xed\x74' b'\x41\xed\x4c\x6a' \ - b'\x4e\x65\xe4\x20' b'\x8e\x6f\x8f\x69' \ - b'\x8e\x30\xad\x3d' b'\xd3\x03\x3b\x67' \ - b'\xbd\x41\x8f\x5f' b'\x7c\x05\x5b\x2b' \ - b'\x87\xe1\xbd\x0e' b'\x60\x16\x40\x7b' \ - b'\x6b\x53\x04\x12' b'\x62\x47\xb6\x7b' \ - b'\x49\x16\x19\x6e' b'\x1a\x22\xb3\x5c' \ - b'\x55\xbf\x6e\x7d' b'\xbc\x7e\xcf\x7b' \ - b'\x58\xba\xfc\x66' b'\x81\xb7\xd1\x2e' \ - b'\x15\x11\x35\x65' b'\x24\x16\xc8\x01' \ - b'\xc1\x66\xae\x44' b'\xb5\x6d\x36\x3a' \ - b'\x8b\x3d\x1f\x56' b'\x63\x43\x0f\x56' \ - b'\x75\xdd\xd2\x4a' b'\x59\xf8\x44\x69' \ - b'\x15\x7c\x5b\x78' b'\xfa\x48\xde\x0d' \ - b'\x47\xe0\xed\x1d' b'\xf9\x01\x34\x03' \ - b'\x7e\x9b\x2e\x71' b'\x74\x32\xdc\x47' \ - b'\x08\x1b\x27\x75' b'\xaa\xc2\x55\x1c' \ - b'\xfa\x7e\x17\x08' b'\x96\x17\x74\x69' \ - b'\x6a\xd0\x66\x74' b'\xea\x2a\xae\x26' \ - b'\xe1\x09\x43\x34' b'\x90\x36\xe4\x11' \ - b'\x0f\x19\x1f\x79' b'\x2f\x6b\xf5\x26' + 'keysyms': [[232140298, 1242716010, 55143985], [1994770011, 669923085, 1236514049], [1454592222, 1949971307, 2057660497], [805965556, 851808913, 2021792706], [1535482384, 425909956, 163201187], [1271520474, 1483083165, 1783638995], [1346992789, 521515080, 218831382], [1497210568, 1658890074, 647643874], [1825990828, 1469435098, 1289374120], [1729858135, 259963764, 1709884923], [2112789657, 1215330896, 1680696611], [88195295, 745614404, 1144061708], [919934772, 1420606257, 795794911], [148083460, 1086542523, 1390588550], [732788374, 27170279, 1824449766], [902069278, 1765942198, 1052700150], [226642993, 930984408, 2063275595], [777792886, 1364908620, 1914642756], [1779635393, 987282730, 1518933756], [328545991, 935201525, 378251236]], + 'sequence_number': 48346, + } + self.reply_bin_0 = b'\x01\x03\xda\xbc' b'\x3c\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ + b'\x0a\x2e\xd6\x0d' b'\x6a\x57\x12\x4a' \ + b'\x31\x6e\x49\x03' b'\x5b\xc6\xe5\x76' \ + b'\x0d\x37\xee\x27' b'\x01\xb5\xb3\x49' \ + b'\xde\x50\xb3\x56' b'\x6b\x33\x3a\x74' \ + b'\x51\x68\xa5\x7a' b'\xf4\x0e\x0a\x30' \ + b'\x91\x92\xc5\x32' b'\xc2\x1b\x82\x78' \ + b'\x10\x9a\x85\x5b' b'\xc4\xde\x62\x19' \ + b'\xa3\x40\xba\x09' b'\xda\xdc\xc9\x4b' \ + b'\x9d\x0d\x66\x58' b'\xd3\x2b\x50\x6a' \ + b'\x95\x7a\x49\x50' b'\x48\xb0\x15\x1f' \ + b'\x16\x1a\x0b\x0d' b'\xc8\x9e\x3d\x59' \ + b'\x5a\xa7\xe0\x62' b'\xe2\x42\x9a\x26' \ + b'\xac\x68\xd6\x6c' b'\xda\xcc\x95\x57' \ + b'\xa8\x49\xda\x4c' b'\x57\x8a\x1b\x67' \ + b'\x74\xbb\x7e\x0f' b'\xfb\xc5\xea\x65' \ + b'\x99\x9c\xee\x7d' b'\x50\x7a\x70\x48' \ + b'\x23\x65\x2d\x64' b'\xdf\xc0\x41\x05' \ + b'\x44\x2c\x71\x2c' b'\x0c\xff\x30\x44' \ + b'\x34\x17\xd5\x36' b'\x31\xbb\xac\x54' \ + b'\xdf\xdd\x6e\x2f' b'\x04\x93\xd3\x08' \ + b'\xbb\x52\xc3\x40' b'\x86\xb2\xe2\x52' \ + b'\x96\x76\xad\x2b' b'\xe7\x95\x9e\x01' \ + b'\xe6\xe4\xbe\x6c' b'\x1e\x7c\xc4\x35' \ + b'\xb6\x23\x42\x69' b'\xf6\xed\xbe\x3e' \ + b'\x31\x4c\x82\x0d' b'\xd8\xb1\x7d\x37' \ + b'\x4b\x16\xfb\x7a' b'\x76\x2d\x5c\x2e' \ + b'\x4c\xda\x5a\x51' b'\x44\x21\x1f\x72' \ + b'\xc1\x14\x13\x6a' b'\x2a\xbd\xd8\x3a' \ + b'\xfc\x16\x89\x5a' b'\xc7\x36\x95\x13' \ + b'\xf5\x0a\xbe\x37' b'\xe4\xa7\x8b\x16' def testPackRequest0(self): @@ -3408,13 +3408,13 @@ def testUnpackReply0(self): class TestChangeKeyboardControl(EndianTest): def setUp(self): self.req_args_0 = { - 'attrs': {'led': 213, 'auto_repeat_mode': 1, 'bell_pitch': -28323, 'bell_percent': -15, 'key_click_percent': -116, 'key': 249, 'bell_duration': -17904, 'led_mode': 1}, + 'attrs': {'key_click_percent': -59, 'bell_percent': -5, 'bell_pitch': -2303, 'bell_duration': -4223, 'led': 196, 'led_mode': 1, 'key': 190, 'auto_repeat_mode': 0}, } self.req_bin_0 = b'\x66\x00\x0a\x00' b'\xff\x00\x00\x00' \ - b'\x8c\x00\x00\x00' b'\xf1\x00\x00\x00' \ - b'\x5d\x91\x00\x00' b'\x10\xba\x00\x00' \ - b'\xd5\x00\x00\x00' b'\x01\x00\x00\x00' \ - b'\xf9\x00\x00\x00' b'\x01\x00\x00\x00' + b'\xc5\x00\x00\x00' b'\xfb\x00\x00\x00' \ + b'\x01\xf7\x00\x00' b'\x81\xef\x00\x00' \ + b'\xc4\x00\x00\x00' b'\x01\x00\x00\x00' \ + b'\xbe\x00\x00\x00' b'\x00\x00\x00\x00' def testPackRequest0(self): @@ -3434,22 +3434,22 @@ def setUp(self): self.req_bin_0 = b'\x67\x00\x01\x00' self.reply_args_0 = { - 'auto_repeats': [223, 147, 181, 140, 190, 180, 249, 132, 175, 184, 249, 237, 140, 215, 197, 253, 173, 178, 152, 143, 236, 186, 212, 210, 204, 130, 228, 159, 144, 200, 136, 225], - 'bell_duration': 441, - 'bell_percent': 146, - 'bell_pitch': 59042, + 'auto_repeats': [199, 243, 190, 246, 225, 214, 135, 254, 211, 174, 252, 182, 218, 194, 215, 199, 198, 130, 176, 149, 189, 232, 253, 189, 249, 253, 242, 132, 151, 203, 184, 231], + 'bell_duration': 35050, + 'bell_percent': 249, + 'bell_pitch': 36528, 'global_auto_repeat': 0, - 'key_click_percent': 170, - 'led_mask': 1867665246, - 'sequence_number': 14353, + 'key_click_percent': 222, + 'led_mask': 1425908825, + 'sequence_number': 20323, } - self.reply_bin_0 = b'\x01\x00\x11\x38' b'\x05\x00\x00\x00' \ - b'\x5e\x4f\x52\x6f' b'\xaa\x92\xa2\xe6' \ - b'\xb9\x01\x00\x00' b'\xdf\x93\xb5\x8c' \ - b'\xbe\xb4\xf9\x84' b'\xaf\xb8\xf9\xed' \ - b'\x8c\xd7\xc5\xfd' b'\xad\xb2\x98\x8f' \ - b'\xec\xba\xd4\xd2' b'\xcc\x82\xe4\x9f' \ - b'\x90\xc8\x88\xe1' + self.reply_bin_0 = b'\x01\x00\x63\x4f' b'\x05\x00\x00\x00' \ + b'\x59\xa4\xfd\x54' b'\xde\xf9\xb0\x8e' \ + b'\xea\x88\x00\x00' b'\xc7\xf3\xbe\xf6' \ + b'\xe1\xd6\x87\xfe' b'\xd3\xae\xfc\xb6' \ + b'\xda\xc2\xd7\xc7' b'\xc6\x82\xb0\x95' \ + b'\xbd\xe8\xfd\xbd' b'\xf9\xfd\xf2\x84' \ + b'\x97\xcb\xb8\xe7' def testPackRequest0(self): @@ -3474,9 +3474,9 @@ def testUnpackReply0(self): class TestBell(EndianTest): def setUp(self): self.req_args_0 = { - 'percent': -19, + 'percent': -40, } - self.req_bin_0 = b'\x68\xed\x01\x00' + self.req_bin_0 = b'\x68\xd8\x01\x00' def testPackRequest0(self): @@ -3492,14 +3492,14 @@ def testUnpackRequest0(self): class TestChangePointerControl(EndianTest): def setUp(self): self.req_args_0 = { - 'accel_denum': -28542, - 'accel_num': -28064, - 'do_accel': 0, + 'accel_denum': -8326, + 'accel_num': -18826, + 'do_accel': 1, 'do_thresh': 1, - 'threshold': -24619, + 'threshold': -14733, } - self.req_bin_0 = b'\x69\x00\x03\x00' b'\x60\x92\x82\x90' \ - b'\xd5\x9f\x00\x01' + self.req_bin_0 = b'\x69\x00\x03\x00' b'\x76\xb6\x7a\xdf' \ + b'\x73\xc6\x01\x01' def testPackRequest0(self): @@ -3519,13 +3519,13 @@ def setUp(self): self.req_bin_0 = b'\x6a\x00\x01\x00' self.reply_args_0 = { - 'accel_denom': 51826, - 'accel_num': 1226, - 'sequence_number': 1938, - 'threshold': 15788, + 'accel_denom': 18010, + 'accel_num': 29992, + 'sequence_number': 46318, + 'threshold': 20350, } - self.reply_bin_0 = b'\x01\x00\x92\x07' b'\x00\x00\x00\x00' \ - b'\xca\x04\x72\xca' b'\xac\x3d\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\xee\xb4' b'\x00\x00\x00\x00' \ + b'\x28\x75\x5a\x46' b'\x7e\x4f\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -3553,11 +3553,11 @@ class TestSetScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { 'allow_exposures': 2, - 'interval': -27103, + 'interval': -25214, 'prefer_blank': 0, - 'timeout': -22242, + 'timeout': -24531, } - self.req_bin_0 = b'\x6b\x00\x03\x00' b'\x1e\xa9\x21\x96' \ + self.req_bin_0 = b'\x6b\x00\x03\x00' b'\x2d\xa0\x82\x9d' \ b'\x00\x02\x00\x00' @@ -3578,14 +3578,14 @@ def setUp(self): self.req_bin_0 = b'\x6c\x00\x01\x00' self.reply_args_0 = { - 'allow_exposures': 1, - 'interval': 31345, - 'prefer_blanking': 1, - 'sequence_number': 34598, - 'timeout': 48933, + 'allow_exposures': 0, + 'interval': 8091, + 'prefer_blanking': 0, + 'sequence_number': 12877, + 'timeout': 20935, } - self.reply_bin_0 = b'\x01\x00\x26\x87' b'\x00\x00\x00\x00' \ - b'\x25\xbf\x71\x7a' b'\x01\x01\x00\x00' \ + self.reply_bin_0 = b'\x01\x00\x4d\x32' b'\x00\x00\x00\x00' \ + b'\xc7\x51\x9b\x1f' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -3612,12 +3612,12 @@ def testUnpackReply0(self): class TestChangeHosts(EndianTest): def setUp(self): self.req_args_0 = { - 'host': [141, 192, 249, 133], - 'host_family': 2, - 'mode': 1, + 'host': [183, 251, 198, 200], + 'host_family': 0, + 'mode': 0, } - self.req_bin_0 = b'\x6d\x01\x03\x00' b'\x02\x00\x04\x00' \ - b'\x8d\xc0\xf9\x85' + self.req_bin_0 = b'\x6d\x00\x03\x00' b'\x00\x00\x04\x00' \ + b'\xb7\xfb\xc6\xc8' def testPackRequest0(self): @@ -3637,11 +3637,11 @@ def setUp(self): self.req_bin_0 = b'\x6e\x00\x01\x00' self.reply_args_0 = { - 'hosts': [{'name': [34, 23, 178, 12], 'family': 0}, {'name': [130, 236, 254, 15], 'family': 0}], + 'hosts': [{'family': 0, 'name': [34, 23, 178, 12]}, {'family': 0, 'name': [130, 236, 254, 15]}], 'mode': 1, - 'sequence_number': 30157, + 'sequence_number': 15164, } - self.reply_bin_0 = b'\x01\x01\xcd\x75' b'\x04\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x01\x3c\x3b' b'\x04\x00\x00\x00' \ b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ @@ -3707,9 +3707,9 @@ def testUnpackRequest0(self): class TestKillClient(EndianTest): def setUp(self): self.req_args_0 = { - 'resource': 1028639966, + 'resource': 649180254, } - self.req_bin_0 = b'\x71\x00\x02\x00' b'\xde\xcc\x4f\x3d' + self.req_bin_0 = b'\x71\x00\x02\x00' b'\x5e\xb4\xb1\x26' def testPackRequest0(self): @@ -3725,18 +3725,18 @@ def testUnpackRequest0(self): class TestRotateProperties(EndianTest): def setUp(self): self.req_args_0 = { - 'delta': -15519, - 'properties': [862505702, 1473403724, 1052877752, 1953573572, 157880830, 173556470, 1306334440, 141112753, 590639874, 1359545959, 1177616073, 698374646], - 'window': 2135947192, + 'delta': -11867, + 'properties': [30448914, 1520523655, 1147111912, 271900374, 589144637, 97809756, 2092347973, 117159267, 1188394866, 627424198, 1497757970, 2027482546], + 'window': 271248673, } - self.req_bin_0 = b'\x72\x00\x0f\x00' b'\xb8\xf7\x4f\x7f' \ - b'\x0c\x00\x61\xc3' b'\xe6\xca\x68\x33' \ - b'\x4c\x5b\xd2\x57' b'\xb8\xa3\xc1\x3e' \ - b'\xc4\x2a\x71\x74' b'\xfe\x11\x69\x09' \ - b'\xf6\x42\x58\x0a' b'\xe8\x14\xdd\x4d' \ - b'\xb1\x35\x69\x08' b'\x02\x73\x34\x23' \ - b'\x67\x06\x09\x51' b'\xc9\xfe\x30\x46' \ - b'\xf6\x59\xa0\x29' + self.req_bin_0 = b'\x72\x00\x0f\x00' b'\x21\xed\x2a\x10' \ + b'\x0c\x00\xa5\xd1' b'\x12\x9d\xd0\x01' \ + b'\x87\x59\xa1\x5a' b'\xe8\x89\x5f\x44' \ + b'\xd6\xde\x34\x10' b'\x3d\xa2\x1d\x23' \ + b'\x5c\x75\xd4\x05' b'\x45\xb2\xb6\x7c' \ + b'\x63\xb5\xfb\x06' b'\x72\x77\xd5\x46' \ + b'\xc6\xbb\x65\x25' b'\x12\xf9\x45\x59' \ + b'\xb2\xed\xd8\x78' def testPackRequest0(self): @@ -3752,9 +3752,9 @@ def testUnpackRequest0(self): class TestForceScreenSaver(EndianTest): def setUp(self): self.req_args_0 = { - 'mode': 0, + 'mode': 1, } - self.req_bin_0 = b'\x73\x00\x01\x00' + self.req_bin_0 = b'\x73\x01\x01\x00' def testPackRequest0(self): @@ -3770,16 +3770,16 @@ def testUnpackRequest0(self): class TestSetPointerMapping(EndianTest): def setUp(self): self.req_args_0 = { - 'map': [205, 140, 217, 237, 211], + 'map': [154, 131, 200, 248, 250], } - self.req_bin_0 = b'\x74\x05\x03\x00' b'\xcd\x8c\xd9\xed' \ - b'\xd3\x00\x00\x00' + self.req_bin_0 = b'\x74\x05\x03\x00' b'\x9a\x83\xc8\xf8' \ + b'\xfa\x00\x00\x00' self.reply_args_0 = { - 'sequence_number': 47312, - 'status': 226, + 'sequence_number': 22584, + 'status': 240, } - self.reply_bin_0 = b'\x01\xe2\xd0\xb8' b'\x00\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\xf0\x38\x58' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -3811,14 +3811,14 @@ def setUp(self): self.req_bin_0 = b'\x75\x00\x01\x00' self.reply_args_0 = { - 'map': [155, 185, 157, 171, 186], - 'sequence_number': 27411, + 'map': [175, 141, 192, 250, 157], + 'sequence_number': 54134, } - self.reply_bin_0 = b'\x01\x05\x13\x6b' b'\x02\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x05\x76\xd3' b'\x02\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x9b\xb9\x9d\xab' b'\xba\x00\x00\x00' + b'\xaf\x8d\xc0\xfa' b'\x9d\x00\x00\x00' def testPackRequest0(self): @@ -3843,17 +3843,17 @@ def testUnpackReply0(self): class TestSetModifierMapping(EndianTest): def setUp(self): self.req_args_0 = { - 'keycodes': [[24, 109], [170, 95], [39, 236], [17, 212], [23, 24], [189, 207], [142, 150], [143, 84]], + 'keycodes': [[33, 205], [251, 37], [27, 77], [76, 155], [43, 127], [60, 213], [115, 194], [230, 226]], } - self.req_bin_0 = b'\x76\x02\x05\x00' b'\x18\x6d\xaa\x5f' \ - b'\x27\xec\x11\xd4' b'\x17\x18\xbd\xcf' \ - b'\x8e\x96\x8f\x54' + self.req_bin_0 = b'\x76\x02\x05\x00' b'\x21\xcd\xfb\x25' \ + b'\x1b\x4d\x4c\x9b' b'\x2b\x7f\x3c\xd5' \ + b'\x73\xc2\xe6\xe2' self.reply_args_0 = { - 'sequence_number': 23338, - 'status': 143, + 'sequence_number': 56627, + 'status': 204, } - self.reply_bin_0 = b'\x01\x8f\x2a\x5b' b'\x00\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\xcc\x33\xdd' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' @@ -3885,15 +3885,15 @@ def setUp(self): self.req_bin_0 = b'\x77\x00\x01\x00' self.reply_args_0 = { - 'keycodes': [[170, 192], [222, 184], [247, 153], [90, 147], [54, 168], [57, 27], [216, 94], [195, 146]], - 'sequence_number': 52951, + 'keycodes': [[219, 156], [30, 50], [106, 108], [135, 41], [80, 122], [88, 38], [80, 1], [209, 230]], + 'sequence_number': 45434, } - self.reply_bin_0 = b'\x01\x02\xd7\xce' b'\x04\x00\x00\x00' \ + self.reply_bin_0 = b'\x01\x02\x7a\xb1' b'\x04\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\xaa\xc0\xde\xb8' b'\xf7\x99\x5a\x93' \ - b'\x36\xa8\x39\x1b' b'\xd8\x5e\xc3\x92' + b'\xdb\x9c\x1e\x32' b'\x6a\x6c\x87\x29' \ + b'\x50\x7a\x58\x26' b'\x50\x01\xd1\xe6' def testPackRequest0(self): From bc133a556aa62f1010a3ebd6e15ba17d29374472 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 3 Sep 2017 15:57:18 +0000 Subject: [PATCH 154/279] test: update big-endian tests --- test/test_events_be.py | 0 test/test_requests_be.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/test_events_be.py mode change 100644 => 100755 test/test_requests_be.py diff --git a/test/test_events_be.py b/test/test_events_be.py old mode 100644 new mode 100755 diff --git a/test/test_requests_be.py b/test/test_requests_be.py old mode 100644 new mode 100755 From 61faba2eeefd7d1570ddd5dfaca72533b9880975 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 3 Sep 2017 17:23:43 +0200 Subject: [PATCH 155/279] protocol/request: fix XGetImage/XPutImage support The image data is not a string. --- Xlib/protocol/request.py | 4 ++-- test/gen/genprottest.py | 6 +++--- test/test_requests_be.py | 16 ++++++++-------- test/test_requests_le.py | 16 ++++++++-------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Xlib/protocol/request.py b/Xlib/protocol/request.py index 578f4a68..efe62ddb 100644 --- a/Xlib/protocol/request.py +++ b/Xlib/protocol/request.py @@ -1066,7 +1066,7 @@ class PutImage(rq.Request): rq.Card8('left_pad'), rq.Card8('depth'), rq.Pad(2), - rq.String8('data'), + rq.Binary('data'), ) class GetImage(rq.ReplyRequest): @@ -1089,7 +1089,7 @@ class GetImage(rq.ReplyRequest): rq.ReplyLength(), rq.Card32('visual'), rq.Pad(20), - rq.String8('data'), + rq.Binary('data'), ) class PolyText8(rq.Request): diff --git a/test/gen/genprottest.py b/test/gen/genprottest.py index 08a4611b..86619af1 100644 --- a/test/gen/genprottest.py +++ b/test/gen/genprottest.py @@ -585,7 +585,7 @@ def rand(x, rmin = rmin, rmax = rmax): # # byte-char string # - elif isinstance(f, rq.String8): + elif isinstance(f, (rq.String8, rq.Binary)): vfstr = vardefs[i] vflen = len(vfstr) @@ -933,7 +933,7 @@ def build_bin(bin): 'FillPoly': (('Point', 3), ), 'PolyFillRectangle': (('Rectangle', 2), ), 'PolyFillArc': (('Arc', 1), ), - 'PutImage': ('bit map data', ), + 'PutImage': (b'\xe9\x10\xf2o\x7f{\xae-\xe6\x18\xce\x83', ), 'ImageText8': ('showme', ), 'ImageText16': ('showmore', ), 'AllocNamedColor': ('octarin', ), @@ -967,7 +967,7 @@ def build_bin(bin): 'ListFontsWithInfo': (('FontProp', 1), 'fontfont'), 'GetFontPath': [(['path1', 'path2232'], ), ([], ) ], - 'GetImage': ('this is real ly imag e b-map', ), + 'GetImage': (b'\xeb?:\xa7\xc6\x8b\xc2\x96o-S\xe6\xd6z6\x94\xd7v\xd2R.\xa2\xeaw\t\x13\x95\x85',), 'ListInstalledColormaps': (2, ), 'AllocColorCells': [(17, 3), (0, 0) ], diff --git a/test/test_requests_be.py b/test/test_requests_be.py index be00418c..0ffdc67a 100755 --- a/test/test_requests_be.py +++ b/test/test_requests_be.py @@ -2368,7 +2368,7 @@ def testUnpackRequest0(self): class TestPutImage(EndianTest): def setUp(self): self.req_args_0 = { - 'data': 'bit map data', + 'data': b'\xe9\x10\xf2o\x7f{\xae-\xe6\x18\xce\x83', 'depth': 172, 'drawable': 634980240, 'dst_x': -18991, @@ -2382,8 +2382,8 @@ def setUp(self): self.req_bin_0 = b'\x48\x02\x00\x09' b'\x25\xd9\x07\x90' \ b'\x46\xf7\xfc\xfd' b'\x21\x95\x32\x1c' \ b'\xb5\xd1\xd5\x1c' b'\xe1\xac\x00\x00' \ - b'\x62\x69\x74\x20' b'\x6d\x61\x70\x20' \ - b'\x64\x61\x74\x61' + b'\xe9\x10\xf2\x6f' b'\x7f\x7b\xae\x2d' \ + b'\xe6\x18\xce\x83' def testPackRequest0(self): @@ -2412,7 +2412,7 @@ def setUp(self): b'\x24\xba\x96\xb6' self.reply_args_0 = { - 'data': 'this is real ly imag e b-map', + 'data': b'\xeb?:\xa7\xc6\x8b\xc2\x96o-S\xe6\xd6z6\x94\xd7v\xd2R.\xa2\xeaw\t\x13\x95\x85', 'depth': 181, 'sequence_number': 28429, 'visual': 1687469773, @@ -2421,10 +2421,10 @@ def setUp(self): b'\x64\x94\xbe\xcd' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x74\x68\x69\x73' b'\x20\x69\x73\x20' \ - b'\x72\x65\x61\x6c' b'\x20\x6c\x79\x20' \ - b'\x69\x6d\x61\x67' b'\x20\x65\x20\x62' \ - b'\x2d\x6d\x61\x70' + b'\xeb\x3f\x3a\xa7' b'\xc6\x8b\xc2\x96' \ + b'\x6f\x2d\x53\xe6' b'\xd6\x7a\x36\x94' \ + b'\xd7\x76\xd2\x52' b'\x2e\xa2\xea\x77' \ + b'\x09\x13\x95\x85' def testPackRequest0(self): diff --git a/test/test_requests_le.py b/test/test_requests_le.py index b5690b2e..1ddfc547 100755 --- a/test/test_requests_le.py +++ b/test/test_requests_le.py @@ -2368,7 +2368,7 @@ def testUnpackRequest0(self): class TestPutImage(EndianTest): def setUp(self): self.req_args_0 = { - 'data': 'bit map data', + 'data': b'\xe9\x10\xf2o\x7f{\xae-\xe6\x18\xce\x83', 'depth': 172, 'drawable': 634980240, 'dst_x': -18991, @@ -2382,8 +2382,8 @@ def setUp(self): self.req_bin_0 = b'\x48\x02\x09\x00' b'\x90\x07\xd9\x25' \ b'\xfd\xfc\xf7\x46' b'\x95\x21\x1c\x32' \ b'\xd1\xb5\x1c\xd5' b'\xe1\xac\x00\x00' \ - b'\x62\x69\x74\x20' b'\x6d\x61\x70\x20' \ - b'\x64\x61\x74\x61' + b'\xe9\x10\xf2\x6f' b'\x7f\x7b\xae\x2d' \ + b'\xe6\x18\xce\x83' def testPackRequest0(self): @@ -2412,7 +2412,7 @@ def setUp(self): b'\xb6\x96\xba\x24' self.reply_args_0 = { - 'data': 'this is real ly imag e b-map', + 'data': b'\xeb?:\xa7\xc6\x8b\xc2\x96o-S\xe6\xd6z6\x94\xd7v\xd2R.\xa2\xeaw\t\x13\x95\x85', 'depth': 181, 'sequence_number': 28429, 'visual': 1687469773, @@ -2421,10 +2421,10 @@ def setUp(self): b'\xcd\xbe\x94\x64' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \ - b'\x74\x68\x69\x73' b'\x20\x69\x73\x20' \ - b'\x72\x65\x61\x6c' b'\x20\x6c\x79\x20' \ - b'\x69\x6d\x61\x67' b'\x20\x65\x20\x62' \ - b'\x2d\x6d\x61\x70' + b'\xeb\x3f\x3a\xa7' b'\xc6\x8b\xc2\x96' \ + b'\x6f\x2d\x53\xe6' b'\xd6\x7a\x36\x94' \ + b'\xd7\x76\xd2\x52' b'\x2e\xa2\xea\x77' \ + b'\x09\x13\x95\x85' def testPackRequest0(self): From 1958a822757e71dc2d79b4de7ca241dd0fc12955 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 4 Sep 2017 14:06:27 +0200 Subject: [PATCH 156/279] protocol/display: improve response processing Improve performance for large responses by calling `socket.recv` with an increased size: - calculate default size according to socket parameters - if we know it, take into account current response size and how much data is needed to get the complete response --- Xlib/protocol/display.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 61d4c8f5..9c816516 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -22,11 +22,12 @@ # Boston, MA 02111-1307 USA # Standard modules -import sys -import select -import struct import errno +import math +import select import socket +import struct +import sys # Python 2/3 compatibility. from six import PY3, byte2int, indexbytes @@ -120,6 +121,12 @@ def __init__(self, display = None): self.request_waiting = 0 self.request_wait_lock = lock.allocate_lock() + # Calculate optimal default buffer size for recv. + buffer_size = self.socket.getsockopt(socket.SOL_SOCKET, + socket.SO_RCVBUF) + buffer_size = math.pow(2, math.floor(math.log(buffer_size, 2))) + self.recv_buffer_size = int(buffer_size) + # Data used by the send-and-recieve loop self.sent_requests = [] self.recv_packet_len = 0 @@ -590,7 +597,9 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) # We're the recieving thread, parse the data if recieving: try: - bytes_recv = self.socket.recv(2048) + count = self.recv_packet_len - len(self.data_recv) + count = max(self.recv_buffer_size, count) + bytes_recv = self.socket.recv(count) except socket.error as err: self.close_internal('server: %s' % err[1]) raise self.socket_error From ccbd01ec9f84f81ab552dde3edde90c432459387 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 4 Sep 2017 15:20:32 +0200 Subject: [PATCH 157/279] add `nose` to development requirements --- dev-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index abadd128..22fc7108 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,3 +1,4 @@ coverage codecov +nose setuptools-scm From 04b78fa44563fe92e8cde288d5327a435957f55a Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 4 Sep 2017 15:21:09 +0200 Subject: [PATCH 158/279] runtests: fix subprocess call to run tests Make sure the correct Python interpreter is used. --- runtests.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/runtests.py b/runtests.py index 6ba2aee1..4e77de87 100755 --- a/runtests.py +++ b/runtests.py @@ -8,6 +8,7 @@ import subprocess import sys import tempfile +import textwrap from pkg_resources import load_entry_point @@ -46,7 +47,15 @@ def tests_run(display, authfile=None): os.environ['DISPLAY'] = display os.environ['XAUTHORITY'] = authfile cmd = [ - 'nosetests', + sys.executable, + '-c', textwrap.dedent( + ''' + from pkg_resources import load_entry_point + sys.exit(load_entry_point( + 'nose', 'console_scripts', 'nosetests', + )()) + ''' + ).lstrip(), '--exe', '--with-xunit', '--verbosity=3', ] has_custom_tests = False From ede34548902ae4ef01f58d234d87856f6a06fc11 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 4 Sep 2017 15:22:32 +0200 Subject: [PATCH 159/279] tox: use requirements files to specify dependencies --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index f13646dd..360451f1 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,6 @@ skip_missing_interpreters = true [testenv] deps= - nose - six>=1.10.0 + -rdev-requirements.txt + -rrequirements.txt commands={envpython} -W all runtests.py {posargs} From b057a30a821b6acac15c759851ad66228db44ed0 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 4 Sep 2017 15:41:43 +0200 Subject: [PATCH 160/279] codecov: ignore examples/ --- codecov.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/codecov.yml b/codecov.yml index 3d26ddea..72bff4bf 100644 --- a/codecov.yml +++ b/codecov.yml @@ -2,6 +2,7 @@ comment: layout: header, changes, diff coverage: ignore: + - examples/.* - test/.* status: patch: false From b547c10d97e23024a99027b0cd16ec6f4dcb0138 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 4 Sep 2017 17:50:46 +0200 Subject: [PATCH 161/279] update news --- NEWS | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/NEWS b/NEWS index 8a6811c8..74f50aee 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,20 @@ NEWS for Python X Library +* In development + +** Bug Fixes + +- fix unclosed file in Xauth implementation +- fix support for `Window.set_wm_transient_for` +- fix support for `Drawable.put_image` / `Drawable.get_image` + +** Misc + +Improve response processing performance: reduce the number of `socket.recv` +calls needed to receive a full response. + + * Version 0.19 ** Bug Fixes From d303d1e4e63eef9e39f1ae37fb46e7f4e4c76d68 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 6 Sep 2017 22:53:13 +0200 Subject: [PATCH 162/279] protocol/rq: fix string decoding when using Python 3 X11 text strings are encoded with the Host Portable Character Encoding, which means we should be using ASCII, the same as the default with Python 2, and not UTF-8. --- NEWS | 1 + Xlib/protocol/rq.py | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 74f50aee..3ec36d14 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ - fix unclosed file in Xauth implementation - fix support for `Window.set_wm_transient_for` - fix support for `Drawable.put_image` / `Drawable.get_image` +- use ASCII for decoding strings in Python 3 (same as Python 2) ** Misc diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index c945c628..f0962e9b 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -34,6 +34,10 @@ from ..support import lock +def decode_string(bs): + return bs.decode('ascii') + + class BadDataError(Exception): pass # These are struct codes, we know their byte sizes @@ -424,17 +428,14 @@ def pack_value(self, val): def parse_binary_value(self, data, display, length, format): if length is None: - return data.decode(), b'' + return decode_string(data), b'' if self.pad: slen = length + ((4 - length % 4) % 4) else: slen = length - if sys.version_info < (3, 0): - data_str = data[:length] - else: - data_str = data[:length].decode() + data_str = decode_string(data[:length]) return data_str, data[slen:] @@ -903,7 +904,7 @@ def pack_value(self, val): def parse_binary(self, data, display): slen = byte2int(data) + 1 - return data[1:slen].decode(), data[slen:] + return decode_string(data[1:slen]), data[slen:] Str = StrClass() From 2729e5ebb69012db5cef89e015c770b319b85cda Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 6 Sep 2017 23:10:06 +0200 Subject: [PATCH 163/279] protocol/rq: fix Python 3 warnings about `array.tostring()` --- NEWS | 1 + Xlib/protocol/rq.py | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 3ec36d14..fd128bc6 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ - fix support for `Window.set_wm_transient_for` - fix support for `Drawable.put_image` / `Drawable.get_image` - use ASCII for decoding strings in Python 3 (same as Python 2) +- fix Python 3 warnings about `array.tostring()` (deprecated) ** Misc diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index f0962e9b..4f5f16a6 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -27,7 +27,7 @@ import types # Python 2/3 compatibility. -from six import binary_type, byte2int, indexbytes, iterbytes +from six import PY3, binary_type, byte2int, indexbytes, iterbytes # Xlib modules from .. import X @@ -37,6 +37,13 @@ def decode_string(bs): return bs.decode('ascii') +if PY3: + def encode_array(a): + return a.tobytes() +else: + def encode_array(a): + return a.tostring() + class BadDataError(Exception): pass @@ -553,8 +560,8 @@ def pack_value(self, val): if self.type.structcode and len(self.type.structcode) == 1: if self.type.check_value is not None: val = [self.type.check_value(v) for v in val] - data = array(struct_to_array_codes[self.type.structcode], - val).tostring() + a = array(struct_to_array_codes[self.type.structcode], val) + data = encode_array(a) else: data = [] for v in val: @@ -686,7 +693,8 @@ def pack_value(self, value): val = list(val) size = fmt // 8 - data = array(array_unsigned_codes[size], val).tostring() + a = array(array_unsigned_codes[size], val) + data = encode_array(a) dlen = len(val) dl = len(data) @@ -807,7 +815,7 @@ def pack_value(self, value): for i in range(len(v), keycodes): a.append(X.NoSymbol) - return a.tostring(), len(value), keycodes + return encode_array(a), len(value), keycodes class ModifierMapping(ValueField): @@ -838,7 +846,7 @@ def pack_value(self, value): for i in range(len(v), keycodes): a.append(0) - return a.tostring(), len(value), keycodes + return encode_array(a), len(value), keycodes class EventField(ValueField): structcode = None From 3ebc37734d0e54ff0912d95c2056b1a8cf2a5cd9 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Thu, 7 Sep 2017 14:05:28 +0200 Subject: [PATCH 164/279] bump version number --- NEWS | 2 +- Xlib/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index fd128bc6..fdda9820 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ NEWS for Python X Library -* In development +* Version 0.20 ** Bug Fixes diff --git a/Xlib/__init__.py b/Xlib/__init__.py index a3601f08..95a3c733 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 19) +__version__ = (0, 20) __version_extra__ = '' From b70898267114bbb45d8e001c9466307811cdceeb Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Thu, 7 Sep 2017 14:20:35 +0200 Subject: [PATCH 165/279] travis: fix deployment --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e1628eb0..d5fb8fca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,3 +41,4 @@ deploy: - dist/*.whl on: tags: true + skip_cleanup: true From 0925e02ec903292f3a9ea249eb6367293b6f37a5 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 11 Nov 2017 04:17:02 +0100 Subject: [PATCH 166/279] doc: don't bundle a copy of texi2html Use the distribution version, instead of bundling our own copy. --- doc/html/Makefile | 2 +- doc/html/texi2html | 2128 -------------------------------------------- 2 files changed, 1 insertion(+), 2129 deletions(-) delete mode 100755 doc/html/texi2html diff --git a/doc/html/Makefile b/doc/html/Makefile index 7f20e89d..2fd50997 100644 --- a/doc/html/Makefile +++ b/doc/html/Makefile @@ -3,7 +3,7 @@ include ../src/defs python-xlib_toc.html: $(SRCS) - ./texi2html -splitnode -menu $(TOPSRC) + texi2html --output=. --split=node --menu $(TOPSRC) ln -sf python-xlib_toc.html index.html clean: diff --git a/doc/html/texi2html b/doc/html/texi2html deleted file mode 100755 index 91ae657d..00000000 --- a/doc/html/texi2html +++ /dev/null @@ -1,2128 +0,0 @@ -eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q' - if 0; -'di '; -'ig 00 '; -#+############################################################################## -# # -# File: texi2html # -# # -# Description: Program to transform most Texinfo documents to HTML # -# # -#-############################################################################## - -# From @(#)texi2html 1.52 01/05/98 Written (mainly) by Lionel Cons, Lionel.Cons@cern.ch -# This version of texi2html is currently maintained at -# ftp://ftp.cs.umb.edu/pub/tex/texi2html by kb@cs.umb.edu. - -# The man page for this program is included at the end of this file and can be -# viewed using the command 'nroff -man texi2html'. -# Please read the copyright at the end of the man page. - -#+++############################################################################ -# # -# Constants # -# # -#---############################################################################ - -$DEBUG_TOC = 1; -$DEBUG_INDEX = 2; -$DEBUG_BIB = 4; -$DEBUG_GLOSS = 8; -$DEBUG_DEF = 16; -$DEBUG_HTML = 32; -$DEBUG_USER = 64; - -$BIBRE = '\[[\w\/-]+\]'; # RE for a bibliography reference -$FILERE = '[\/\w.+-]+'; # RE for a file name -$VARRE = '[^\s\{\}]+'; # RE for a variable name -$NODERE = '[^@{}:\'`",]+'; # RE for a node name -$NODESRE = '[^@{}:\'`"]+'; # RE for a list of node names -$XREFRE = '[^@{}]+'; # RE for a xref (should use NODERE) - -$ERROR = "***"; # prefix for errors and warnings -$THISVERSION = "1.56k"; -$THISPROG = "texi2html $THISVERSION"; # program name and version -$HOMEPAGE = "http://wwwinfo.cern.ch/dis/texi2html/"; # program home page -$TODAY = &pretty_date; # like "20 September 1993" -$SPLITTAG = "\n"; # tag to know where to split -$PROTECTTAG = "_ThisIsProtected_"; # tag to recognize protected sections -$html2_doctype = ''; - -# -# language dependent constants -# -#$LDC_SEE = 'see'; -#$LDC_SECTION = 'section'; -#$LDC_IN = 'in'; -#$LDC_TOC = 'Table of Contents'; -#$LDC_GOTO = 'Go to the'; -#$LDC_FOOT = 'Footnotes'; -# TODO: @def* shortcuts - -# -# pre-defined indices -# -%predefined_index = ( - 'cp', 'c', - 'fn', 'f', - 'vr', 'v', - 'ky', 'k', - 'pg', 'p', - 'tp', 't', - ); - -# -# valid indices -# -%valid_index = ( - 'c', 1, - 'f', 1, - 'v', 1, - 'k', 1, - 'p', 1, - 't', 1, - ); - -# -# texinfo section names to level -# -%sec2level = ( - 'top', 0, - 'chapter', 1, - 'unnumbered', 1, - 'majorheading', 1, - 'chapheading', 1, - 'appendix', 1, - 'section', 2, - 'unnumberedsec', 2, - 'heading', 2, - 'appendixsec', 2, - 'appendixsection', 2, - 'subsection', 3, - 'unnumberedsubsec', 3, - 'subheading', 3, - 'appendixsubsec', 3, - 'subsubsection', 4, - 'unnumberedsubsubsec', 4, - 'subsubheading', 4, - 'appendixsubsubsec', 4, - ); - -# -# accent map, TeX command to ISO name -# -%accent_map = ( - '"', 'uml', - '~', 'tilde', - '^', 'circ', - '`', 'grave', - '\'', 'acute', - ); - -# -# texinfo "simple things" (@foo) to HTML ones -# -%simple_map = ( - # cf. makeinfo.c - "*", "
", # HTML+ - " ", " ", - "\t", " ", - "-", "­", # soft hyphen - "\n", "\n", - "|", "", - 'tab', '<\/TD>', - # spacing commands - ":", "", - "!", "!", - "?", "?", - ".", ".", - "-", "", - ); - -# -# texinfo "things" (@foo{}) to HTML ones -# -%things_map = ( - 'TeX', 'TeX', - 'br', '

', # paragraph break - 'bullet', '*', - 'copyright', '(C)', - 'dots', '...', - 'equiv', '==', - 'error', 'error-->', - 'expansion', '==>', - 'minus', '-', - 'point', '-!-', - 'print', '-|', - 'result', '=>', - 'today', $TODAY, - ); - -# -# texinfo styles (@foo{bar}) to HTML ones -# -%style_map = ( - 'asis', '', - 'b', 'B', - 'cite', 'CITE', - 'code', 'CODE', - 'ctrl', '&do_ctrl', # special case - 'dfn', 'EM', # DFN tag is illegal in the standard - 'dmn', '', # useless - 'email', '&do_email', # insert a clickable email address - 'emph', 'EM', - 'file', '"TT', # will put quotes, cf. &apply_style - 'i', 'I', - 'kbd', 'KBD', - 'key', 'KBD', - 'math', 'EM', - 'r', '', # unsupported - 'samp', '"SAMP', # will put quotes, cf. &apply_style - 'sc', '&do_sc', # special case - 'strong', 'STRONG', - 't', 'TT', - 'titlefont', '', # useless - 'uref', '&do_uref', # insert a clickable URL - 'url', '&do_url', # insert a clickable URL - 'var', 'VAR', - 'w', '', # unsupported - ); - -# -# texinfo format (@foo/@end foo) to HTML ones -# -%format_map = ( - 'display', 'PRE', - 'example', 'PRE', - 'format', 'PRE', - 'lisp', 'PRE', - 'quotation', 'BLOCKQUOTE', - 'smallexample', 'PRE', - 'smalllisp', 'PRE', - # lists - 'itemize', 'UL', - 'enumerate', 'OL', - # poorly supported - 'flushleft', 'PRE', - 'flushright', 'PRE', - ); - -# -# texinfo definition shortcuts to real ones -# -%def_map = ( - # basic commands - 'deffn', 0, - 'defvr', 0, - 'deftypefn', 0, - 'deftypevr', 0, - 'defcv', 0, - 'defop', 0, - 'deftp', 0, - # basic x commands - 'deffnx', 0, - 'defvrx', 0, - 'deftypefnx', 0, - 'deftypevrx', 0, - 'defcvx', 0, - 'defopx', 0, - 'deftpx', 0, - # shortcuts - 'defun', 'deffn Function', - 'defmac', 'deffn Macro', - 'defspec', 'deffn {Special Form}', - 'defvar', 'defvr Variable', - 'defopt', 'defvr {User Option}', - 'deftypefun', 'deftypefn Function', - 'deftypevar', 'deftypevr Variable', - 'defivar', 'defcv {Instance Variable}', - 'defmethod', 'defop Method', - # x shortcuts - 'defunx', 'deffnx Function', - 'defmacx', 'deffnx Macro', - 'defspecx', 'deffnx {Special Form}', - 'defvarx', 'defvrx Variable', - 'defoptx', 'defvrx {User Option}', - 'deftypefunx', 'deftypefnx Function', - 'deftypevarx', 'deftypevrx Variable', - 'defivarx', 'defcvx {Instance Variable}', - 'defmethodx', 'defopx Method', - ); - -# -# things to skip -# -%to_skip = ( - # comments - 'c', 1, - 'comment', 1, - 'ifnothtml', 1, - # useless - 'detailmenu', 1, - 'direntry', 1, - 'contents', 1, - 'shortcontents', 1, - 'summarycontents', 1, - 'footnotestyle', 1, - 'end ifclear', 1, - 'end ifset', 1, - 'titlepage', 1, - 'end titlepage', 1, - # unsupported commands (formatting) - 'afourpaper', 1, - 'cropmarks', 1, - 'finalout', 1, - 'headings', 1, - 'sp', 1, - 'need', 1, - 'page', 1, - 'setchapternewpage', 1, - 'everyheading', 1, - 'everyfooting', 1, - 'evenheading', 1, - 'evenfooting', 1, - 'oddheading', 1, - 'oddfooting', 1, - 'smallbook', 1, - 'vskip', 1, - 'filbreak', 1, - 'paragraphindent', 1, - # unsupported formats - 'cartouche', 1, - 'end cartouche', 1, - 'group', 1, - 'end group', 1, - ); - -#+++############################################################################ -# # -# Argument parsing, initialisation # -# # -#---############################################################################ - -%value = (); # hold texinfo variables, see also -D - -$use_bibliography = 1; -$use_acc = 0; -$debug = 0; -$doctype = ''; -$check = 0; -$expandinfo = 0; -$use_glossary = 0; -$invisible_mark = ''; -$use_iso = 0; -@include_dirs = (); -$show_menu = 0; -$number_sections = 0; -$split_node = 0; -$split_chapter = 0; -$monolithic = 0; -$verbose = 0; -$usage = < 0; - ✓ - exit; -} - -if (($split_node || $split_chapter) && $monolithic) { - warn "Can't use -monolithic with -split, -monolithic ignored.\n"; - $monolithic = 0; -} -if ($expandinfo) { - $to_skip{'ifinfo'}++; - $to_skip{'end ifinfo'}++; - $to_skip{'ifnottex'}++; - $to_skip{'end ifnottex'}++; -} else { - $to_skip{'iftex'}++; - $to_skip{'end iftex'}++; -} -$invisible_mark = '' if $invisible_mark eq 'xbm'; -die $usage unless @ARGV == 1; -$docu = shift(@ARGV); -if ($docu =~ /.*\//) { - chop($docu_dir = $&); - $docu_name = $'; -} else { - $docu_dir = '.'; - $docu_name = $docu; -} -unshift(@include_dirs, $docu_dir); -$docu_name =~ s/\.te?x(i|info)?$//; # basename of the document - -$docu_doc = "$docu_name.html"; # document's contents -if ($monolithic) { - $docu_toc = $docu_foot = $docu_doc; -} else { - $docu_toc = "${docu_name}_toc.html"; # document's table of contents - $docu_foot = "${docu_name}_foot.html"; # document's footnotes -} - -# -# variables -# -$value{'html'} = 1; # predefine html (the output format) -$value{'texi2html'} = $THISVERSION; # predefine texi2html (the translator) -# _foo: internal to track @foo -foreach ('_author', '_title', '_subtitle', - '_settitle', '_setfilename') { - $value{$_} = ''; # prevent -w warnings -} -%node2sec = (); # node to section name -%node2href = (); # node to HREF -%bib2href = (); # bibliography reference to HREF -%gloss2href = (); # glossary term to HREF -@sections = (); # list of sections -%tag2pro = (); # protected sections - -# -# initial indexes -# -$bib_num = 0; -$foot_num = 0; -$gloss_num = 0; -$idx_num = 0; -$sec_num = 0; -$doc_num = 0; -$html_num = 0; - -# -# can I use ISO8879 characters? (HTML+) -# -if ($use_iso) { - $things_map{'bullet'} = "•"; - $things_map{'copyright'} = "©"; - $things_map{'dots'} = "…"; - $things_map{'equiv'} = "≡"; - $things_map{'expansion'} = "→"; - $things_map{'point'} = "∗"; - $things_map{'result'} = "⇒"; -} - -# -# read texi2html extensions (if any) -# -$extensions = 'texi2html.ext'; # extensions in working directory -if (-f $extensions) { - print "# reading extensions from $extensions\n" if $verbose; - require($extensions); -} -($progdir = $0) =~ s/[^\/]+$//; -if ($progdir && ($progdir ne './')) { - $extensions = "${progdir}texi2html.ext"; # extensions in texi2html directory - if (-f $extensions) { - print "# reading extensions from $extensions\n" if $verbose; - require($extensions); - } -} - -print "# reading from $docu\n" if $verbose; - -#+++############################################################################ -# # -# Pass 1: read source, handle command, variable, simple substitution # -# # -#---############################################################################ - -@lines = (); # whole document -@toc_lines = (); # table of contents -$toplevel = 0; # top level seen in hierarchy -$curlevel = 0; # current level in TOC -$node = ''; # current node name -$in_table = 0; # am I inside a table -$table_type = ''; # type of table ('', 'f', 'v', 'multi') -@tables = (); # nested table support -$in_bibliography = 0; # am I inside a bibliography -$in_glossary = 0; # am I inside a glossary -$in_top = 0; # am I inside the top node -$in_pre = 0; # am I inside a preformatted section -$in_list = 0; # am I inside a list -$in_html = 0; # am I inside an HTML section -$first_line = 1; # is it the first line -$dont_html = 0; # don't protect HTML on this line -$split_num = 0; # split index -$deferred_ref = ''; # deferred reference for indexes -@html_stack = (); # HTML elements stack -$html_element = ''; # current HTML element -&html_reset; - -# build code for simple substitutions -# the maps used (%simple_map and %things_map) MUST be aware of this -# watch out for regexps, / and escaped characters! -$subst_code = ''; -foreach (keys(%simple_map)) { - ($re = $_) =~ s/(\W)/\\$1/g; # protect regexp chars - $subst_code .= "s/\\\@$re/$simple_map{$_}/g;\n"; -} -foreach (keys(%things_map)) { - $subst_code .= "s/\\\@$_\\{\\}/$things_map{$_}/g;\n"; -} -if ($use_acc) { - # accentuated characters - foreach (keys(%accent_map)) { - if ($_ eq "`") { - $subst_code .= "s/$;3"; - } elsif ($_ eq "'") { - $subst_code .= "s/$;4"; - } else { - $subst_code .= "s/\\\@\\$_"; - } - $subst_code .= "([aeiou])/&\${1}$accent_map{$_};/gi;\n"; - } -} -eval("sub simple_substitutions { $subst_code }"); - -&init_input; -while ($_ = &next_line) { - # - # remove \input on the first lines only - # - if ($first_line) { - next if /^\\input/; - $first_line = 0; - } - # - # parse texinfo tags - # - $tag = ''; - $end_tag = ''; - if (/^\s*\@end\s+(\w+)\b/) { - $end_tag = $1; - } elsif (/^\s*\@(\w+)\b/) { - $tag = $1; - } - # - # handle @ifhtml / @end ifhtml - # - if ($in_html) { - if ($end_tag eq 'ifhtml') { - $in_html = 0; - } else { - $tag2pro{$in_html} .= $_; - } - next; - } elsif ($tag eq 'ifhtml') { - $in_html = $PROTECTTAG . ++$html_num; - push(@lines, $in_html); - next; - } - # - # try to skip the line - # - if ($end_tag) { - next if $to_skip{"end $end_tag"}; - } elsif ($tag) { - next if $to_skip{$tag}; - last if $tag eq 'bye'; - } - if ($in_top) { - # parsing the top node - if ($tag eq 'node' || $tag eq 'include' || $sec2level{$tag}) { - # no more in top - $in_top = 0; - } else { - # skip it - next; - } - } - # - # try to remove inlined comments - # syntax from tex-mode.el comment-start-skip - # - s/((^|[^\@])(\@\@)*)\@c(omment)? .*/$1/; - # non-@ substitutions cf. texinfmt.el - unless ($in_pre) { - s/``/\"/g; - s/''/\"/g; - s/([\w ])---([\w ])/$1--$2/g; - } - # - # analyze the tag - # - if ($tag) { - # skip lines - &skip_until($tag), next if $tag eq 'ignore'; - if ($expandinfo) { - &skip_until($tag), next if $tag eq 'iftex'; - } else { - &skip_until($tag), next if $tag eq 'ifinfo'; - } - &skip_until($tag), next if $tag eq 'tex'; - # handle special tables - if ($tag =~ /^(|f|v|multi)table$/) { - $table_type = $1; - $tag = 'table'; - } - # special cases - if ($tag eq 'top' || ($tag eq 'node' && /^\@node\s+top\s*,/i)) { - $in_top = 1; - @lines = (); # ignore all lines before top (title page garbage) - next; - } elsif ($tag eq 'node') { - $in_top = 0; - warn "$ERROR Bad node line: $_" unless $_ =~ /^\@node\s$NODESRE$/o; - $_ = &protect_html($_); # if node contains '&' for instance - s/^\@node\s+//; - ($node) = split(/,/); - &normalise_node($node); - if ($split_node) { - &next_doc; - push(@lines, $SPLITTAG) if $split_num++; - push(@sections, $node); - } - next; - } elsif ($tag eq 'include') { - if (/^\@include\s+($FILERE)\s*$/o) { - $file = $1; - unless (-e $file) { - foreach $dir (@include_dirs) { - $file = "$dir/$1"; - last if -e $file; - } - } - if (-e $file) { - &open($file); - print "# including $file\n" if $verbose; - } else { - warn "$ERROR Can't find $file, skipping"; - } - } else { - warn "$ERROR Bad include line: $_"; - } - next; - } elsif ($tag eq 'ifclear') { - if (/^\@ifclear\s+($VARRE)\s*$/o) { - next unless defined($value{$1}); - &skip_until($tag); - } else { - warn "$ERROR Bad ifclear line: $_"; - } - next; - } elsif ($tag eq 'ifset') { - if (/^\@ifset\s+($VARRE)\s*$/o) { - next if defined($value{$1}); - &skip_until($tag); - } else { - warn "$ERROR Bad ifset line: $_"; - } - next; - } elsif ($tag eq 'menu') { - unless ($show_menu) { - &skip_until($tag); - next; - } - &html_push_if($tag); - push(@lines, &html_debug("\n", __LINE__)); - } elsif ($format_map{$tag}) { - $in_pre = 1 if $format_map{$tag} eq 'PRE'; - &html_push_if($format_map{$tag}); - push(@lines, &html_debug("\n", __LINE__)); - $in_list++ if $format_map{$tag} eq 'UL' || $format_map{$tag} eq 'OL' ; - push(@lines, &debug("<$format_map{$tag}>\n", __LINE__)); - next; - } elsif ($tag eq 'table') { - if (/^\s*\@(|f|v)table\s+\@(\w+)/ || /^\s*\@multitable\s+/) { - $in_table = $2; - unshift(@tables, join($;, $table_type, $in_table)); - if ($table_type eq "multi") { - push(@lines, &debug("\n", __LINE__)); - &html_push_if('TABLE'); - } else { - push(@lines, &debug("
\n", __LINE__)); - &html_push_if('DL'); - } - push(@lines, &html_debug("\n", __LINE__)); - } else { - warn "$ERROR Bad table line: $_"; - } - next; - } elsif ($tag eq 'synindex' || $tag eq 'syncodeindex') { - if (/^\@$tag\s+(\w)\w\s+(\w)\w\s*$/) { - eval("*${1}index = *${2}index"); - } else { - warn "$ERROR Bad syn*index line: $_"; - } - next; - } elsif ($tag eq 'sp') { - push(@lines, &debug("

\n", __LINE__)); - next; - } elsif ($tag eq 'setref') { - &protect_html; # if setref contains '&' for instance - if (/^\@$tag\s*{($NODERE)}\s*$/) { - $setref = $1; - $setref =~ s/\s+/ /g; # normalize - $setref =~ s/ $//; - $node2sec{$setref} = $name; - $node2href{$setref} = "$docu_doc#$docid"; - } else { - warn "$ERROR Bad setref line: $_"; - } - next; - } elsif ($tag eq 'defindex' || $tag eq 'defcodeindex') { - if (/^\@$tag\s+(\w\w)\s*$/) { - $valid_index{$1} = 1; - } else { - warn "$ERROR Bad defindex line: $_"; - } - next; - } elsif ($tag eq 'lowersections') { - local ($sec, $level); - while (($sec, $level) = each %sec2level) { - $sec2level{$sec} = $level + 1; - } - next; - } elsif ($tag eq 'raisesections') { - local ($sec, $level); - while (($sec, $level) = each %sec2level) { - $sec2level{$sec} = $level - 1; - } - next; - } elsif (defined($def_map{$tag})) { - if ($def_map{$tag}) { - s/^\@$tag\s+//; - $tag = $def_map{$tag}; - $_ = "\@$tag $_"; - $tag =~ s/\s.*//; - } - } elsif (defined($user_sub{$tag})) { - s/^\@$tag\s+//; - $sub = $user_sub{$tag}; - print "# user $tag = $sub, arg: $_" if $debug & $DEBUG_USER; - if (defined(&$sub)) { - chop($_); - &$sub($_); - } else { - warn "$ERROR Bad user sub for $tag: $sub\n"; - } - next; - } - if (defined($def_map{$tag})) { - s/^\@$tag\s+//; - if ($tag =~ /x$/) { - # extra definition line - $tag = $`; - $is_extra = 1; - } else { - $is_extra = 0; - } - while (/\{([^\{\}]*)\}/) { - # this is a {} construct - ($before, $contents, $after) = ($`, $1, $'); - # protect spaces - $contents =~ s/\s+/$;9/g; - # restore $_ protecting {} - $_ = "$before$;7$contents$;8$after"; - } - @args = split(/\s+/, &protect_html($_)); - foreach (@args) { - s/$;9/ /g; # unprotect spaces - s/$;7/\{/g; # ... { - s/$;8/\}/g; # ... } - } - $type = shift(@args); - $type =~ s/^\{(.*)\}$/$1/; - print "# def ($tag): {$type} ", join(', ', @args), "\n" - if $debug & $DEBUG_DEF; - $type .= ':'; # it's nicer like this - $name = shift(@args); - $name =~ s/^\{(.*)\}$/$1/; - if ($is_extra) { - $_ = &debug("

", __LINE__); - } else { - $_ = &debug("
\n
", __LINE__); - } - if ($tag eq 'deffn' || $tag eq 'defvr' || $tag eq 'deftp') { - $_ .= "$type $name"; - $_ .= " @args" if @args; - } elsif ($tag eq 'deftypefn' || $tag eq 'deftypevr' - || $tag eq 'defcv' || $tag eq 'defop') { - $ftype = $name; - $name = shift(@args); - $name =~ s/^\{(.*)\}$/$1/; - $_ .= "$type $ftype $name"; - $_ .= " @args" if @args; - } else { - warn "$ERROR Unknown definition type: $tag\n"; - $_ .= "$type $name"; - $_ .= " @args" if @args; - } - $_ .= &debug("\n
", __LINE__); - $name = &unprotect_html($name); - if ($tag eq 'deffn' || $tag eq 'deftypefn') { - unshift(@input_spool, "\@findex $name\n"); - } elsif ($tag eq 'defop') { - unshift(@input_spool, "\@findex $name on $ftype\n"); - } elsif ($tag eq 'defvr' || $tag eq 'deftypevr' || $tag eq 'defcv') { - unshift(@input_spool, "\@vindex $name\n"); - } else { - unshift(@input_spool, "\@tindex $name\n"); - } - $dont_html = 1; - } - } elsif ($end_tag) { - if ($format_map{$end_tag}) { - $in_pre = 0 if $format_map{$end_tag} eq 'PRE'; - $in_list-- if $format_map{$end_tag} eq 'UL' || $format_map{$end_tag} eq 'OL' ; - &html_pop_if('LI', 'P'); - &html_pop_if(); - push(@lines, &debug("\n", __LINE__)); - push(@lines, &html_debug("\n", __LINE__)); - } elsif ($end_tag =~ /^(|f|v|multi)table$/) { - unless (@tables) { - warn "$ERROR \@end $end_tag without \@*table\n"; - next; - } - ($table_type, $in_table) = split($;, shift(@tables)); - unless ($1 eq $table_type) { - warn "$ERROR \@end $end_tag without matching \@$end_tag\n"; - next; - } - if ($table_type eq "multi") { - push(@lines, "
\n"); - &html_pop_if('TR'); - } else { - push(@lines, "\n"); - &html_pop_if('DD'); - } - &html_pop_if(); - if (@tables) { - ($table_type, $in_table) = split($;, $tables[0]); - } else { - $in_table = 0; - } - } elsif (defined($def_map{$end_tag})) { - push(@lines, &debug("\n", __LINE__)); - } elsif ($end_tag eq 'menu') { - &html_pop_if(); - push(@lines, $_); # must keep it for pass 2 - } - next; - } - # - # misc things - # - # protect texi and HTML things - &protect_texi; - $_ = &protect_html($_) unless $dont_html; - $dont_html = 0; - # substitution (unsupported things) - s/^\@center\s+//g; - s/^\@exdent\s+//g; - s/\@noindent\s+//g; - s/\@refill\s+//g; - # other substitutions - &simple_substitutions; - s/\@value{($VARRE)}/$value{$1}/eg; - s/\@footnote\{/\@footnote$docu_doc\{/g; # mark footnotes, cf. pass 4 - # - # analyze the tag again - # - if ($tag) { - if (defined($sec2level{$tag}) && $sec2level{$tag} > 0) { - if (/^\@$tag\s+(.+)$/) { - $name = $1; - $name =~ s/\s+$//; - $level = $sec2level{$tag}; - $name = &update_sec_num($tag, $level) . " $name" - if $number_sections && $tag !~ /^unnumbered/; - if ($tag =~ /heading$/) { - push(@lines, &html_debug("\n", __LINE__)); - if ($html_element ne 'body') { - # We are in a nice pickle here. We are trying to get a H? heading - # even though we are not in the body level. So, we convert it to a - # nice, bold, line by itself. - $_ = &debug("\n\n

$name\n\n", __LINE__); - } else { - $_ = &debug("$name\n", __LINE__); - &html_push_if('body'); - } - print "# heading, section $name, level $level\n" - if $debug & $DEBUG_TOC; - } else { - if ($split_chapter) { - unless ($toplevel) { - # first time we see a "section" - unless ($level == 1) { - warn "$ERROR The first section found is not of level 1: $_"; - warn "$ERROR I'll split on sections of level $level...\n"; - } - $toplevel = $level; - } - if ($level == $toplevel) { - &next_doc; - push(@lines, $SPLITTAG) if $split_num++; - push(@sections, $name); - } - } - $sec_num++; - $docid = "SEC$sec_num"; - $tocid = "TOC$sec_num"; - # check biblio and glossary - $in_bibliography = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*bibliography$/i); - $in_glossary = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*glossary$/i); - # check node - if ($node) { - if ($node2sec{$node}) { - warn "$ERROR Duplicate node found: $node\n"; - } else { - $node2sec{$node} = $name; - $node2href{$node} = "$docu_doc#$docid"; - print "# node $node, section $name, level $level\n" - if $debug & $DEBUG_TOC; - } - $node = ''; - } else { - print "# no node, section $name, level $level\n" - if $debug & $DEBUG_TOC; - } - # update TOC - while ($level > $curlevel) { - $curlevel++; - push(@toc_lines, "

    \n"); - } - while ($level < $curlevel) { - $curlevel--; - push(@toc_lines, "
\n"); - } - $_ = "
  • " . &anchor($tocid, "$docu_doc#$docid", $name, 1); - push(@toc_lines, &substitute_style($_)); - # update DOC - push(@lines, &html_debug("\n", __LINE__)); - &html_reset; - $_ = "".&anchor($docid, "$docu_toc#$tocid", $name)."\n"; - $_ = &debug($_, __LINE__); - push(@lines, &html_debug("\n", __LINE__)); - } - # update DOC - foreach $line (split(/\n+/, $_)) { - push(@lines, "$line\n"); - } - next; - } else { - warn "$ERROR Bad section line: $_"; - } - } else { - # track variables - $value{$1} = $2, next if /^\@set\s+($VARRE)\s+(.*)$/o; - delete $value{$1}, next if /^\@clear\s+($VARRE)\s*$/o; - # store things - $value{'_setfilename'} = $1, next if /^\@setfilename\s+(.*)$/; - $value{'_settitle'} = $1, next if /^\@settitle\s+(.*)$/; - $value{'_author'} .= "$1\n", next if /^\@author\s+(.*)$/; - $value{'_subtitle'} .= "$1\n", next if /^\@subtitle\s+(.*)$/; - $value{'_title'} .= "$1\n", next if /^\@title\s+(.*)$/; - # index - if (/^\@(..?)index\s+/) { - unless ($valid_index{$1}) { - warn "$ERROR Undefined index command: $_"; - next; - } - $id = 'IDX' . ++$idx_num; - $index = $1 . 'index'; - $what = &substitute_style($'); - $what =~ s/\s+$//; - print "# found $index for '$what' id $id\n" - if $debug & $DEBUG_INDEX; - eval(<\n", __LINE__)); - push(@lines, &anchor($id, '', $invisible_mark, !$in_pre)); - &html_push('P'); - } elsif ($html_element eq 'DL' || - $html_element eq 'UL' || - $html_element eq 'OL' ) { - $deferred_ref .= &anchor($id, '', $invisible_mark, !$in_pre) . " "; - } - next; - } - # list item - if (/^\s*\@itemx?\s+/) { - $what = $'; - $what =~ s/\s+$//; - if ($in_bibliography && $use_bibliography) { - if ($what =~ /^$BIBRE$/o) { - $id = 'BIB' . ++$bib_num; - $bib2href{$what} = "$docu_doc#$id"; - print "# found bibliography for '$what' id $id\n" - if $debug & $DEBUG_BIB; - $what = &anchor($id, '', $what); - } - } elsif ($in_glossary && $use_glossary) { - $id = 'GLOSS' . ++$gloss_num; - $entry = $what; - $entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/; - $gloss2href{$entry} = "$docu_doc#$id"; - print "# found glossary for '$entry' id $id\n" - if $debug & $DEBUG_GLOSS; - $what = &anchor($id, '', $what); - } - &html_pop_if('P'); - if ($html_element eq 'DL' || $html_element eq 'DD') { - if ($things_map{$in_table} && !$what) { - # special case to allow @table @bullet for instance - push(@lines, &debug("
    $things_map{$in_table}\n", __LINE__)); - } else { - push(@lines, &debug("
    \@$in_table\{$what\}\n", __LINE__)); - } - push(@lines, "
    "); - &html_push('DD') unless $html_element eq 'DD'; - if ($table_type) { # add also an index - unshift(@input_spool, "\@${table_type}index $what\n"); - } - } elsif ($html_element eq 'TABLE') { - push(@lines, &debug("$what\n", __LINE__)); - &html_push('TR'); - } elsif ($html_element eq 'TR') { - push(@lines, &debug("\n", __LINE__)); - push(@lines, &debug("$what\n", __LINE__)); - } else { - push(@lines, &debug("
  • $what\n", __LINE__)); - &html_push('LI') unless $html_element eq 'LI'; - } - push(@lines, &html_debug("\n", __LINE__)); - if ($deferred_ref) { - push(@lines, &debug("$deferred_ref\n", __LINE__)); - $deferred_ref = ''; - } - next; - } elsif (/^\@tab\s+(.*)$/) { - push(@lines, "$1\n"); - next; - } - } - } - # paragraph separator - if ($_ eq "\n") { - next if $#lines >= 0 && $lines[$#lines] eq "\n"; - if ($html_element eq 'P') { - push(@lines, "\n"); - $_ = &debug("\n", __LINE__); - &html_pop; - } - } elsif ($html_element eq 'body' || $html_element eq 'BLOCKQUOTE') { - push(@lines, "

    \n"); - &html_push('P'); - $_ = &debug($_, __LINE__); - } - # otherwise - push(@lines, $_); -} - -# finish TOC -$level = 0; -while ($level < $curlevel) { - $curlevel--; - push(@toc_lines, "\n"); -} - -print "# end of pass 1\n" if $verbose; - -#+++############################################################################ -# # -# Pass 2/3: handle style, menu, index, cross-reference # -# # -#---############################################################################ - -@lines2 = (); # whole document (2nd pass) -@lines3 = (); # whole document (3rd pass) -$in_menu = 0; # am I inside a menu - -while (@lines) { - $_ = shift(@lines); - # - # special case (protected sections) - # - if (/^$PROTECTTAG/o) { - push(@lines2, $_); - next; - } - # - # menu - # - $in_menu = 1, push(@lines2, &debug("

      \n", __LINE__)), next if /^\@menu\b/; - $in_menu = 0, push(@lines2, &debug("
    \n", __LINE__)), next if /^\@end\s+menu\b/; - if ($in_menu) { - if (/^\*\s+($NODERE)::/o) { - $descr = $'; - chop($descr); - &menu_entry($1, $1, $descr); - } elsif (/^\*\s+(.+):\s+([^\t,\.\n]+)[\t,\.\n]/) { - $descr = $'; - chop($descr); - &menu_entry($1, $2, $descr); - } elsif (/^\*/) { - warn "$ERROR Bad menu line: $_"; - } else { # description continued? - push(@lines2, $_); - } - next; - } - # - # printindex - # - if (/^\@printindex\s+(\w\w)\b/) { - local($index, *ary, @keys, $key, $letter, $last_letter, @refs); - if ($predefined_index{$1}) { - $index = $predefined_index{$1} . 'index'; - } else { - $index = $1 . 'index'; - } - eval("*ary = *$index"); - @keys = keys(%ary); - foreach $key (@keys) { - $_ = $key; - 1 while s/<(\w+)>\`(.*)\'<\/\1>/$2/; # remove HTML tags with quotes - 1 while s/<(\w+)>(.*)<\/\1>/$2/; # remove HTML tags - $_ = &unprotect_html($_); - &unprotect_texi; - tr/A-Z/a-z/; # lowercase - $key2alpha{$key} = $_; - print "# index $key sorted as $_\n" - if $key ne $_ && $debug & $DEBUG_INDEX; - } - push(@lines2, "Jump to:\n"); - $last_letter = undef; - foreach $key (sort byalpha @keys) { - $letter = substr($key2alpha{$key}, 0, 1); - $letter = substr($key2alpha{$key}, 0, 2) if $letter eq $;; - if (!defined($last_letter) || $letter ne $last_letter) { - push(@lines2, "-\n") if defined($last_letter); - push(@lines2, "" . &protect_html($letter) . "\n"); - $last_letter = $letter; - } - } - push(@lines2, "

    \n"); - $last_letter = undef; - foreach $key (sort byalpha @keys) { - $letter = substr($key2alpha{$key}, 0, 1); - $letter = substr($key2alpha{$key}, 0, 2) if $letter eq $;; - if (!defined($last_letter) || $letter ne $last_letter) { - push(@lines2, "\n") if defined($last_letter); - push(@lines2, "

    " . &protect_html($letter) . "

    \n"); - push(@lines2, "\n"); - $last_letter = $letter; - } - @refs = (); - foreach (split(/$;/, $ary{$key})) { - push(@refs, &anchor('', $_, $key, 0)); - } - push(@lines2, "
  • " . join(", ", @refs) . "\n"); - } - push(@lines2, "
  • \n") if defined($last_letter); - next; - } - # - # simple style substitutions - # - $_ = &substitute_style($_); - # - # xref - # - while (/\@(x|px|info|)ref{($XREFRE)(}?)/o) { - # note: Texinfo may accept other characters - ($type, $nodes, $full) = ($1, $2, $3); - ($before, $after) = ($`, $'); - if (! $full && $after) { - warn "$ERROR Bad xref (no ending } on line): $_"; - $_ = "$before$;0${type}ref\{$nodes$after"; - next; # while xref - } - if ($type eq 'x') { - $type = 'See '; - } elsif ($type eq 'px') { - $type = 'see '; - } elsif ($type eq 'info') { - $type = 'See Info'; - } else { - $type = ''; - } - unless ($full) { - $next = shift(@lines); - $next = &substitute_style($next); - chop($nodes); # remove final newline - if ($next =~ /\}/) { # split on 2 lines - $nodes .= " $`"; - $after = $'; - } else { - $nodes .= " $next"; - $next = shift(@lines); - $next = &substitute_style($next); - chop($nodes); - if ($next =~ /\}/) { # split on 3 lines - $nodes .= " $`"; - $after = $'; - } else { - warn "$ERROR Bad xref (no ending }): $_"; - $_ = "$before$;0xref\{$nodes$after"; - unshift(@lines, $next); - next; # while xref - } - } - } - $nodes =~ s/\s+/ /g; # remove useless spaces - @args = split(/\s*,\s*/, $nodes); - $node = $args[0]; # the node is always the first arg - &normalise_node($node); - $sec = $node2sec{$node}; - if (@args == 5) { # reference to another manual - $sec = $args[2] || $node; - $man = $args[4] || $args[3]; - $_ = "${before}${type}section `$sec' in \@cite{$man}$after"; - } elsif ($type =~ /Info/) { # inforef - warn "$ERROR Wrong number of arguments: $_" unless @args == 3; - ($nn, $_, $in) = @args; - $_ = "${before}${type} file `$in', node `$nn'$after"; - } elsif ($sec) { - $href = $node2href{$node}; - $_ = "${before}${type}section " . &anchor('', $href, $sec) . $after; - } else { - warn "$ERROR Undefined node ($node): $_"; - $_ = "$before$;0xref{$nodes}$after"; - } - } - - if (/^\@image\s*{/) { - s/\@image\s*{//; - my (@args) = split (/,/); - my $base = $args[0]; - my $image; - if (-r "$base.jpg") { - $image = "$base.jpg"; - } elsif (-r "$base.png") { - $image = "$base.png"; - } elsif (-r "$base.gif") { - $image = "$base.gif"; - } else { - warn "$ERROR no image file for $base: $_"; - } - $_ = "\"$base\""; - } - - # - # try to guess bibliography references or glossary terms - # - unless (/^/) { - $done .= $pre . &anchor('', $href, $what); - } else { - $done .= "$pre$what"; - } - $_ = $post; - } - $_ = $done . $_; - } - if ($use_glossary) { - $done = ''; - while (/\b\w+\b/) { - ($pre, $what, $post) = ($`, $&, $'); - $entry = $what; - $entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/; - $href = $gloss2href{$entry}; - if (defined($href) && $post !~ /^[^<]*<\/A>/) { - $done .= $pre . &anchor('', $href, $what); - } else { - $done .= "$pre$what"; - } - $_ = $post; - } - $_ = $done . $_; - } - } - # otherwise - push(@lines2, $_); -} -print "# end of pass 2\n" if $verbose; - -# -# split style substitutions -# -while (@lines2) { - $_ = shift(@lines2); - # - # special case (protected sections) - # - if (/^$PROTECTTAG/o) { - push(@lines3, $_); - next; - } - # - # split style substitutions - # - $old = ''; - while ($old ne $_) { - $old = $_; - if (/\@(\w+)\{/) { - ($before, $style, $after) = ($`, $1, $'); - if (defined($style_map{$style})) { - $_ = $after; - $text = ''; - $after = ''; - $failed = 1; - while (@lines2) { - if (/\}/) { - $text .= $`; - $after = $'; - $failed = 0; - last; - } else { - $text .= $_; - $_ = shift(@lines2); - } - } - if ($failed) { - die "* Bad syntax (\@$style) after: $before\n"; - } else { - $text = &apply_style($style, $text); - $_ = "$before$text$after"; - } - } - } - } - # otherwise - push(@lines3, $_); -} -print "# end of pass 3\n" if $verbose; - -#+++############################################################################ -# # -# Pass 4: foot notes, final cleanup # -# # -#---############################################################################ - -@foot_lines = (); # footnotes -@doc_lines = (); # final document -$end_of_para = 0; # true if last line is

    - -while (@lines3) { - $_ = shift(@lines3); - # - # special case (protected sections) - # - if (/^$PROTECTTAG/o) { - push(@doc_lines, $_); - $end_of_para = 0; - next; - } - # - # footnotes - # - while (/\@footnote([^\{\s]+)\{/) { - ($before, $d, $after) = ($`, $1, $'); - $_ = $after; - $text = ''; - $after = ''; - $failed = 1; - while (@lines3) { - if (/\}/) { - $text .= $`; - $after = $'; - $failed = 0; - last; - } else { - $text .= $_; - $_ = shift(@lines3); - } - } - if ($failed) { - die "* Bad syntax (\@footnote) after: $before\n"; - } else { - $foot_num++; - $docid = "DOCF$foot_num"; - $footid = "FOOT$foot_num"; - $foot = "($foot_num)"; - push(@foot_lines, "

    " . &anchor($footid, "$d#$docid", $foot) . "

    \n"); - $text = "

    $text" unless $text =~ /^\s*

    /; - push(@foot_lines, "$text\n"); - $_ = $before . &anchor($docid, "$docu_foot#$footid", $foot) . $after; - } - } - # - # remove unnecessary

    - # - if (/^\s*

    \s*$/) { - next if $end_of_para++; - } else { - $end_of_para = 0; - } - # otherwise - push(@doc_lines, $_); -} -print "# end of pass 4\n" if $verbose; - -#+++############################################################################ -# # -# Pass 5: print things # -# # -#---############################################################################ - -$header = < -EOT - -$full_title = $value{'_title'} || $value{'_settitle'} || "Untitled Document"; -$title = $value{'_settitle'} || $full_title; -$_ = &substitute_style($full_title); -&unprotect_texi; -s/\n$//; # rmv last \n (if any) -$full_title = "

    " . join("

    \n

    ", split(/\n/, $_)) . "

    \n"; - -# -# print ToC -# -if (!$monolithic && @toc_lines) { - if (open(FILE, "> $docu_toc")) { - print "# creating $docu_toc...\n" if $verbose; - &print_toplevel_header("$title - Table of Contents"); - &print_ruler; - &print(*toc_lines, FILE); - &print_toplevel_footer; - close(FILE); - } else { - warn "$ERROR Can't write to $docu_toc: $!\n"; - } -} - -# -# print footnotes -# -if (!$monolithic && @foot_lines) { - if (open(FILE, "> $docu_foot")) { - print "# creating $docu_foot...\n" if $verbose; - &print_toplevel_header("$title - Footnotes"); - &print_ruler; - &print(*foot_lines, FILE); - &print_toplevel_footer; - close(FILE); - } else { - warn "$ERROR Can't write to $docu_foot: $!\n"; - } -} - -# -# print document -# -if ($split_chapter || $split_node) { # split - $doc_num = 0; - $last_num = scalar(@sections); - $first_doc = &doc_name(1); - $last_doc = &doc_name($last_num); - while (@sections) { - $section = shift(@sections); - &next_doc; - if (open(FILE, "> $docu_doc")) { - print "# creating $docu_doc...\n" if $verbose; - &print_header("$title - $section"); - $prev_doc = ($doc_num == 1 ? undef : &doc_name($doc_num - 1)); - $next_doc = ($doc_num == $last_num ? undef : &doc_name($doc_num + 1)); - $navigation = "Go to the "; - $navigation .= ($prev_doc ? &anchor('', $first_doc, "first") : "first"); - $navigation .= ", "; - $navigation .= ($prev_doc ? &anchor('', $prev_doc, "previous") : "previous"); - $navigation .= ", "; - $navigation .= ($next_doc ? &anchor('', $next_doc, "next") : "next"); - $navigation .= ", "; - $navigation .= ($next_doc ? &anchor('', $last_doc, "last") : "last"); - $navigation .= " section, " . &anchor('', $docu_toc, "table of contents") . ".\n"; - print FILE $navigation; - &print_ruler; - # find corresponding lines - @tmp_lines = (); - while (@doc_lines) { - $_ = shift(@doc_lines); - last if ($_ eq $SPLITTAG); - push(@tmp_lines, $_); - } - &print(*tmp_lines, FILE); - &print_ruler; - print FILE $navigation; - &print_footer; - close(FILE); - } else { - warn "$ERROR Can't write to $docu_doc: $!\n"; - } - } -} else { # not split - if (open(FILE, "> $docu_doc")) { - print "# creating $docu_doc...\n" if $verbose; - if ($monolithic || !@toc_lines) { - &print_toplevel_header($title); - } else { - &print_header($title); - print FILE $full_title; - } - if ($monolithic && @toc_lines) { - &print_ruler; - print FILE "

    Table of Contents

    \n"; - &print(*toc_lines, FILE); - } - &print_ruler; - &print(*doc_lines, FILE); - if ($monolithic && @foot_lines) { - &print_ruler; - print FILE "

    Footnotes

    \n"; - &print(*foot_lines, FILE); - } - if ($monolithic || !@toc_lines) { - &print_toplevel_footer; - } else { - &print_footer; - } - close(FILE); - } else { - warn "$ERROR Can't write to $docu_doc: $!\n"; - } -} - -print "# that's all folks\n" if $verbose; - -#+++############################################################################ -# # -# Low level functions # -# # -#---############################################################################ - -sub update_sec_num { - local($name, $level) = @_; - my $ret; - - $level--; # here we start at 0 - if ($name =~ /^appendix/) { - # appendix style - if (@appendix_sec_num) { - &incr_sec_num($level, @appendix_sec_num); - } else { - @appendix_sec_num = ('A', 0, 0, 0); - } - $ret = join('.', @appendix_sec_num[0..$level]); - } else { - # normal style - if (@normal_sec_num) { - &incr_sec_num($level, @normal_sec_num); - } else { - @normal_sec_num = (1, 0, 0, 0); - } - $ret = join('.', @normal_sec_num[0..$level]); - } - - $ret .= "." if $level == 0; - return $ret; -} - -sub incr_sec_num { - local($level, $l); - $level = shift(@_); - $_[$level]++; - foreach $l ($level+1 .. 3) { - $_[$l] = 0; - } -} - -sub check { - local($_, %seen, %context, $before, $match, $after); - - while (<>) { - if (/\@(\*|\.|\:|\@|\{|\})/) { - $seen{$&}++; - $context{$&} .= "> $_" if $verbose; - $_ = "$`XX$'"; - redo; - } - if (/\@(\w+)/) { - ($before, $match, $after) = ($`, $&, $'); - if ($before =~ /\b[\w-]+$/ && $after =~ /^[\w-.]*\b/) { # e-mail address - $seen{'e-mail address'}++; - $context{'e-mail address'} .= "> $_" if $verbose; - } else { - $seen{$match}++; - $context{$match} .= "> $_" if $verbose; - } - $match =~ s/^\@/X/; - $_ = "$before$match$after"; - redo; - } - } - - foreach (sort(keys(%seen))) { - if ($verbose) { - print "$_\n"; - print $context{$_}; - } else { - print "$_ ($seen{$_})\n"; - } - } -} - -sub open { - local($name) = @_; - - ++$fh_name; - if (open($fh_name, $name)) { - unshift(@fhs, $fh_name); - } else { - warn "$ERROR Can't read file $name: $!\n"; - } -} - -sub init_input { - @fhs = (); # hold the file handles to read - @input_spool = (); # spooled lines to read - $fh_name = 'FH000'; - &open($docu); -} - -sub next_line { - local($fh, $line); - - if (@input_spool) { - $line = shift(@input_spool); - return($line); - } - while (@fhs) { - $fh = $fhs[0]; - $line = <$fh>; - return($line) if $line; - close($fh); - shift(@fhs); - } - return(undef); -} - -# used in pass 1, use &next_line -sub skip_until { - local($tag) = @_; - local($_); - - while ($_ = &next_line) { - return if /^\@end\s+$tag\s*$/; - } - die "* Failed to find '$tag' after: " . $lines[$#lines]; -} - -# -# HTML stacking to have a better HTML output -# - -sub html_reset { - @html_stack = ('html'); - $html_element = 'body'; -} - -sub html_push { - local($what) = @_; - push(@html_stack, $html_element); - $html_element = $what; -} - -sub html_push_if { - local($what) = @_; - push(@html_stack, $html_element) - if ($html_element && $html_element ne 'P'); - $html_element = $what; -} - -sub html_pop { - $html_element = pop(@html_stack); -} - -sub html_pop_if { - local($elt); - - if (@_) { - foreach $elt (@_) { - if ($elt eq $html_element) { - $html_element = pop(@html_stack) if @html_stack; - last; - } - } - } else { - $html_element = pop(@html_stack) if @html_stack; - } -} - -sub html_debug { - local($what, $line) = @_; - return("$what") - if $debug & $DEBUG_HTML; - return($what); -} - -# to debug the output... -sub debug { - local($what, $line) = @_; - return("$what") - if $debug & $DEBUG_HTML; - return($what); -} - -sub normalise_node { - $_[0] =~ s/\s+/ /g; - $_[0] =~ s/ $//; - $_[0] =~ s/^ //; -} - -sub menu_entry { - local($entry, $node, $descr) = @_; - local($href); - - &normalise_node($node); - $href = $node2href{$node}; - if ($href) { - $descr =~ s/^\s+//; - $descr = ": $descr" if $descr; - push(@lines2, "
  • " . &anchor('', $href, $entry) . "$descr\n"); - } else { - warn "$ERROR Undefined node ($node): $_"; - } -} - -sub do_ctrl { "^$_[0]" } - -sub do_email { - local($addr, $text) = split(/,\s*/, $_[0]); - - $text = $addr unless $text; - &anchor('', "mailto:$addr", $text); -} - -sub do_sc { "\U$_[0]\E" } - -sub do_uref { - local($url, $text) = split(/,\s*/, $_[0]); - - $text = $url unless $text; - &anchor('', $url, $text); -} - -sub do_url { &anchor('', $_[0], $_[0]) } - -sub apply_style { - local($texi_style, $text) = @_; - local($style); - - $style = $style_map{$texi_style}; - if (defined($style)) { # known style - if ($style =~ /^\"/) { # add quotes - $style = $'; - $text = "\`$text\'"; - } - if ($style =~ /^\&/) { # custom - $style = $'; - $text = &$style($text); - } elsif ($style) { # good style - $text = "<$style>$text"; - } else { # no style - } - } else { # unknown style - $text = undef; - } - return($text); -} - -# remove Texinfo styles -sub remove_style { - local($_) = @_; - s/\@\w+{([^\{\}]+)}/$1/g; - return($_); -} - -sub substitute_style { - local($_) = @_; - local($changed, $done, $style, $text); - - $changed = 1; - while ($changed) { - $changed = 0; - $done = ''; - while (/\@(\w+){([^\{\}]+)}/) { - $text = &apply_style($1, $2); - if ($text) { - $_ = "$`$text$'"; - $changed = 1; - } else { - $done .= "$`\@$1"; - $_ = "{$2}$'"; - } - } - $_ = $done . $_; - } - return($_); -} - -sub anchor { - local($name, $href, $text, $newline) = @_; - local($result); - - $result = "

    \n"; -} - -sub print_header { - local($_); - - # clean the title - $_ = &remove_style($_[0]); - &unprotect_texi; - # print the header - if ($doctype eq 'html2') { - print FILE $html2_doctype; - } elsif ($doctype) { - print FILE $doctype; - } - print FILE < - -$header -$_ - - -EOT -} - -sub print_toplevel_header { - local($_); - - &print_header; # pass given arg... - print FILE $full_title; - if ($value{'_subtitle'}) { - $value{'_subtitle'} =~ s/\n+$//; - foreach (split(/\n/, $value{'_subtitle'})) { - $_ = &substitute_style($_); - &unprotect_texi; - print FILE "

    $_

    \n"; - } - } - if ($value{'_author'}) { - $value{'_author'} =~ s/\n+$//; - foreach (split(/\n/, $value{'_author'})) { - $_ = &substitute_style($_); - &unprotect_texi; - s/[\w.-]+\@[\w.-]+/
    $&<\/A>/g; - print FILE "
    $_
    \n"; - } - } - print FILE "

    \n"; -} - -sub print_footer { - print FILE < - -EOT -} - -sub print_toplevel_footer { - &print_ruler; - print FILE <texi2html $value{texi2html}. -EOT - &print_footer; -} - -sub protect_texi { - # protect @ { } ` ' - s/\@\@/$;0/go; - s/\@\{/$;1/go; - s/\@\}/$;2/go; - s/\@\`/$;3/go; - s/\@\'/$;4/go; -} - -sub protect_html { - local($what) = @_; - # protect & < > - $what =~ s/\&/\&\#38;/g; - $what =~ s/\/\&\#62;/g; - # but recognize some HTML things - $what =~ s/\&\#60;\/A\&\#62;/<\/A>/g; # - $what =~ s/\&\#60;A ([^\&]+)\&\#62;//g; # - $what =~ s/\&\#60;IMG ([^\&]+)\&\#62;//g; # - return($what); -} - -sub unprotect_texi { - s/$;0/\@/go; - s/$;1/\{/go; - s/$;2/\}/go; - s/$;3/\`/go; - s/$;4/\'/go; -} - -sub unprotect_html { - local($what) = @_; - $what =~ s/\&\#38;/\&/g; - $what =~ s/\&\#60;/\/g; - return($what); -} - -sub byalpha { - $key2alpha{$a} cmp $key2alpha{$b}; -} - -############################################################################## - - # These next few lines are legal in both Perl and nroff. - -.00 ; # finish .ig - -'di \" finish diversion--previous line must be blank -.nr nl 0-1 \" fake up transition to first page again -.nr % 0 \" start at page 1 -'; __END__ ############# From here on it's a standard manual page ############ -.TH TEXI2HTML 1 "01/05/98" -.AT 3 -.SH NAME -texi2html \- a Texinfo to HTML converter -.SH SYNOPSIS -.B texi2html [options] file -.PP -.B texi2html -check [-verbose] files -.SH DESCRIPTION -.I Texi2html -converts the given Texinfo file to a set of HTML files. It tries to handle -most of the Texinfo commands. It creates hypertext links for cross-references, -footnotes... -.PP -It also tries to add links from a reference to its corresponding entry in the -bibliography (if any). It may also handle a glossary (see the -.B \-glossary -option). -.PP -.I Texi2html -creates several files depending on the contents of the Texinfo file and on -the chosen options (see FILES). -.PP -The HTML files created by -.I texi2html -are closer to TeX than to Info, that's why -.I texi2html -converts @iftex sections and not @ifinfo ones by default. You can reverse -this with the \-expandinfo option. -.SH OPTIONS -.TP 12 -.B \-check -Check the given file and give the list of all things that may be Texinfo commands. -This may be used to check the output of -.I texi2html -to find the Texinfo commands that have been left in the HTML file. -.TP -.B \-expandinfo -Expand @ifinfo sections, not @iftex ones. -.TP -.B \-glossary -Use the section named 'Glossary' to build a list of terms and put links in the HTML -document from each term toward its definition. -.TP -.B \-invisible \fIname\fP -Use \fIname\fP to create invisible destination anchors for index links -(you can for instance use the invisible.xbm file shipped with this program). -This is a workaround for a known bug of many WWW browsers, including netscape. -.TP -.B \-I \fIdir\fP -Look also in \fIdir\fP to find included files. -.TP -.B \-menu -Show the Texinfo menus; by default they are ignored. -.TP -.B \-monolithic -Output only one file, including the table of contents and footnotes. -.TP -.B \-number -Number the sections. -.TP -.B \-split_chapter -Split the output into several HTML files (one per main section: -chapter, appendix...). -.TP -.B \-split_node -Split the output into several HTML files (one per node). -.TP -.B \-usage -Print usage instructions, listing the current available command-line options. -.TP -.B \-verbose -Give a verbose output. Can be used with the -.B \-check -option. -.PP -.SH FILES -By default -.I texi2html -creates the following files (foo being the name of the Texinfo file): -.TP 16 -.B foo_toc.html -The table of contents. -.TP -.B foo.html -The document's contents. -.TP -.B foo_foot.html -The footnotes (if any). -.PP -When used with the -.B \-split -option, it creates several files (one per chapter or node), named -.B foo_n.html -(n being the indice of the chapter or node), instead of the single -.B foo.html -file. -.PP -When used with the -.B \-monolithic -option, it creates only one file: -.B foo.html -.SH VARIABLES -.I texi2html -predefines the following variables: \fBhtml\fP, \fBtexi2html\fP. -.SH ADDITIONAL COMMANDS -.I texi2html -implements the following non-Texinfo commands (maybe they are in Texinfo now...): -.TP 16 -.B @ifhtml -This indicates the start of an HTML section, this section will passed through -without any modification. -.TP -.B @end ifhtml -This indicates the end of an HTML section. -.SH VERSION -This is \fItexi2html\fP version 1.56k, 1999-02-20. -.PP -The latest version of \fItexi2html\fP can be found in WWW, cf. URLs -http://wwwinfo.cern.ch/dis/texi2html/ -.br -http://texinfo.org/texi2html/ -.SH AUTHOR -The main author is Lionel Cons, CERN IT/DIS/OSE, Lionel.Cons@cern.ch. -Many other people around the net contributed to this program. -.SH COPYRIGHT -This program is the intellectual property of the European -Laboratory for Particle Physics (known as CERN). No guarantee whatsoever is -provided by CERN. No liability whatsoever is accepted for any loss or damage -of any kind resulting from any defect or inaccuracy in this information or -code. -.PP -CERN, 1211 Geneva 23, Switzerland -.SH "SEE ALSO" -GNU Texinfo Documentation Format, -HyperText Markup Language (HTML), -World Wide Web (WWW). -.SH BUGS -This program does not understand all Texinfo commands (yet). -.PP -TeX specific commands (normally enclosed in @iftex) will be -passed unmodified. -.ex From 3da78d203713a153b7f44059c98b78c8a84c0ed5 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 2 Dec 2017 16:06:31 +0100 Subject: [PATCH 167/279] support/unix_connect: mimic XCB behavior Fallback to TCP when implicit Unix socket connection fails. --- Xlib/protocol/display.py | 4 +- Xlib/support/connect.py | 19 ++-- Xlib/support/unix_connect.py | 55 ++++++----- Xlib/support/vms_connect.py | 6 +- dev-requirements.txt | 1 + test/test_unix_connect.py | 187 ++++++++++++++++++++++++++--------- 6 files changed, 190 insertions(+), 82 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 9c816516..4f431e99 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -82,12 +82,12 @@ class Display(object): event_classes = event.event_class.copy() def __init__(self, display = None): - name, host, displayno, screenno = connect.get_display(display) + name, protocol, host, displayno, screenno = connect.get_display(display) self.display_name = name self.default_screen = screenno - self.socket = connect.get_socket(name, host, displayno) + self.socket = connect.get_socket(name, protocol, host, displayno) auth_name, auth_data = connect.get_auth(self.socket, name, host, displayno) diff --git a/Xlib/support/connect.py b/Xlib/support/connect.py index af42d620..93b26c0e 100644 --- a/Xlib/support/connect.py +++ b/Xlib/support/connect.py @@ -56,15 +56,16 @@ def _relative_import(modname): def get_display(display): - """dname, host, dno, screen = get_display(display) + """dname, protocol, host, dno, screen = get_display(display) Parse DISPLAY into its components. If DISPLAY is None, use the default display. The return values are: - DNAME -- the full display name (string) - HOST -- the host name (string, possibly empty) - DNO -- display number (integer) - SCREEN -- default screen number (integer) + DNAME -- the full display name (string) + PROTOCOL -- the protocol to use (None if automatic) + HOST -- the host name (string, possibly empty) + DNO -- display number (integer) + SCREEN -- default screen number (integer) """ modname = _display_mods.get(platform, _default_display_mod) @@ -72,10 +73,10 @@ def get_display(display): return mod.get_display(display) -def get_socket(dname, host, dno): - """socket = get_socket(dname, host, dno) +def get_socket(dname, protocol, host, dno): + """socket = get_socket(dname, protocol, host, dno) - Connect to the display specified by DNAME, HOST and DNO, which + Connect to the display specified by DNAME, PROTOCOL, HOST and DNO, which are the corresponding values from a previous call to get_display(). Return SOCKET, a new socket object connected to the X server. @@ -83,7 +84,7 @@ def get_socket(dname, host, dno): modname = _socket_mods.get(platform, _default_socket_mod) mod = _relative_import(modname) - return mod.get_socket(dname, host, dno) + return mod.get_socket(dname, protocol, host, dno) def get_auth(sock, dname, host, dno): diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index 3b16d5dc..25a8f3ac 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -62,50 +62,57 @@ def get_display(display): name = display protocol, host, dno, screen = m.group('proto', 'host', 'dno', 'screen') - if protocol == 'tcp': + if protocol == 'tcp' and not host: # Host is mandatory when protocol is TCP. - if not host: - raise error.DisplayNameError(display) - elif protocol == 'unix': - # Clear host to force Unix socket connection. - host = '' - else: - # Special case: `unix:0.0` is equivalent to `:0.0`. - if host == 'unix': - host = '' + raise error.DisplayNameError(display) dno = int(dno) if screen: screen = int(screen) else: screen = 0 - return name, host, dno, screen + return name, protocol, host, dno, screen + +def _get_tcp_socket(host, dno): + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.connect((host, 6000 + dno)) + return s + +def _get_unix_socket(address): + s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + s.connect(address) + return s -def get_socket(dname, host, dno): +def get_socket(dname, protocol, host, dno): + assert protocol in (None, 'tcp', 'unix') try: - # Darwin funky socket - if (uname[0] == 'Darwin') and host and host.startswith('/private/tmp/'): - s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - s.connect(dname) + # Darwin funky socket. + if uname[0] == 'Darwin' and host and host.startswith('/private/tmp/'): + s = _get_unix_socket(dname) - # If hostname (or IP) is provided, use TCP socket - elif host: - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.connect((host, 6000 + dno)) + # TCP socket, note the special case: `unix:0.0` is equivalent to `:0.0`. + elif (not protocol or protocol != 'unix') and host and host != 'unix': + s = _get_tcp_socket(host, dno) - # Else use Unix socket + # Unix socket. else: address = '/tmp/.X11-unix/X%d' % dno if not os.path.exists(address): # Use abstract address. address = '\0' + address - s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - s.connect(address) + try: + s = _get_unix_socket(address) + except socket.error: + if not protocol and not host: + # If no protocol/host was specified, fallback to TCP. + s = _get_tcp_socket(host, dno) + else: + raise except socket.error as val: raise error.DisplayConnectionError(dname, str(val)) - # Make sure that the connection isn't inherited in child processes + # Make sure that the connection isn't inherited in child processes. fcntl.fcntl(s.fileno(), F_SETFD, FD_CLOEXEC) return s diff --git a/Xlib/support/vms_connect.py b/Xlib/support/vms_connect.py index 394077b7..3c53695f 100644 --- a/Xlib/support/vms_connect.py +++ b/Xlib/support/vms_connect.py @@ -32,7 +32,7 @@ def get_display(display): # check DECW$DISPLAY instead, but that has to wait if display is None: - return ':0.0', 'localhost', 0, 0 + return ':0.0', None, 'localhost', 0, 0 m = display_re.match(display) if not m: @@ -52,10 +52,10 @@ def get_display(display): else: screen = 0 - return name, host, dno, screen + return name, None, host, dno, screen -def get_socket(dname, host, dno): +def get_socket(dname, protocol, host, dno): try: # Always use TCP/IP sockets. Later it would be nice to # be able to use DECNET och LOCAL connections. diff --git a/dev-requirements.txt b/dev-requirements.txt index 22fc7108..b2f5288c 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,5 @@ coverage codecov +mock nose setuptools-scm diff --git a/test/test_unix_connect.py b/test/test_unix_connect.py index 8c325da9..7680ba5b 100644 --- a/test/test_unix_connect.py +++ b/test/test_unix_connect.py @@ -1,59 +1,158 @@ #!/usr/bin/env python # -*- coding: utf-8 -* +from functools import partial +import socket import sys import unittest +from mock import patch + from Xlib.support import unix_connect -from Xlib.error import DisplayNameError +from Xlib.error import DisplayConnectionError, DisplayNameError @unittest.skipUnless(sys.platform.startswith('linux'), 'Linux specific tests') class TestUnixConnect(unittest.TestCase): - def test_get_display(self): - # Valid cases. - for display, expected in ( - # Implicit Unix socket connections. - (':0.1', ('', 0, 1)), - (':4', ('', 4, 0)), - # Implicit TCP connections. - ('foo:1.2', ('foo', 1, 2)), - ('bar:5', ('bar', 5, 0)), - # Explicit Unix socket connections. - ('unix/foo:4.3', ('', 4, 3)), - ('unix/:66', ('', 66, 0)), - # Explicit TCP connections. - ('tcp/foo:11.1', ('foo', 11, 1)), - ('tcp/bar:66.6', ('bar', 66, 6)), - ('tcp/unix:54.3', ('unix', 54, 3)), - # Special case: `unix:0.0` is equivalent to `:0.0`. - ('unix:99.5', ('', 99, 5)), - ('unix:42', ('', 42, 0)), - ): - result = unix_connect.get_display(display) - self.assertEqual(result, (display,) + expected) - # Invalid cases. - for display in ( - # No display number. - '', - ':', - 'foo', - 'bar:', - # Bad screen number. - ':48.', - ':47.f', - # Bad hostname. - u'fòó:0', - u'tcp/bàr:1', - u'unix/fòóbàr:2', - # Bad protocol. - 'udp/foo:0' - # With explicit TCP connections, hostname must be set. - 'tcp/:0', - ): - with self.assertRaises(DisplayNameError): - unix_connect.get_display(display) + def test_get_display(self): + # Valid cases. + for display, expected in ( + # Implicit Unix socket connections. + (':0.1', (None, '', 0, 1)), + (':4', (None, '', 4, 0)), + # Implicit TCP connections. + ('foo:1.2', (None, 'foo', 1, 2)), + ('bar:5', (None, 'bar', 5, 0)), + # Explicit Unix socket connections. + ('unix/foo:4.3', ('unix', 'foo', 4, 3)), + ('unix/:66', ('unix', '', 66, 0)), + # Explicit TCP connections. + ('tcp/foo:11.1', ('tcp', 'foo', 11, 1)), + ('tcp/bar:66.6', ('tcp', 'bar', 66, 6)), + ('tcp/unix:54.3', ('tcp', 'unix', 54, 3)), + # Special case: `unix:0.0` is equivalent to `:0.0`. + ('unix:99.5', (None, 'unix', 99, 5)), + ('unix:42', (None, 'unix', 42, 0)), + ): + result = unix_connect.get_display(display) + self.assertEqual(result, (display,) + expected) + # Invalid cases. + for display in ( + # No display number. + '', + ':', + 'foo', + 'bar:', + # Bad screen number. + ':48.', + ':47.f', + # Bad hostname. + u'fòó:0', + u'tcp/bàr:1', + u'unix/fòóbàr:2', + # Bad protocol. + 'udp/foo:0' + # With explicit TCP connections, hostname must be set. + 'tcp/:0', + ): + with self.assertRaises(DisplayNameError): + unix_connect.get_display(display) + + def test_get_socket(self): + class FakeSocket(object): + def fileno(self): + return 42 + calls = [] + def _get_socket(socket_type, raises, *params): + calls.append(('_get_%s_socket' % socket_type,) + params) + if raises: + raise socket.error() + return FakeSocket() + def path_exists(returns, path): + calls.append(('os.path.exists', path)) + return returns + def fcntl(*args): + calls.append(('fcntl',) + args) + for params, allow_unix, unix_addr_exists, allow_tcp, expect_connection_error, expected_calls in ( + # Successful explicit TCP socket connection. + (('tcp/host:6', None, 'host', 6), False, False, True, False, [ + ('_get_tcp_socket', 'host', 6), + ]), + # Failed explicit TCP socket connection. + (('tcp/host:6', None, 'host', 6), False, False, False, True, [ + ('_get_tcp_socket', 'host', 6), + ]), + # Successful implicit TCP socket connection. + (('host:5', None, 'host', 5), False, False, True, False, [ + ('_get_tcp_socket', 'host', 5), + ]), + # Failed implicit TCP socket connection. + (('host:5', None, 'host', 5), False, False, False, True, [ + ('_get_tcp_socket', 'host', 5), + ]), + # Successful explicit Unix socket connection. + (('unix/name:0', 'unix', 'name', 0), True, True, False, False, [ + ('os.path.exists', '/tmp/.X11-unix/X0'), + ('_get_unix_socket', '/tmp/.X11-unix/X0'), + ]), + # Failed explicit Unix socket connection. + (('unix/name:0', 'unix', 'name', 0), False, True, False, True, [ + ('os.path.exists', '/tmp/.X11-unix/X0'), + ('_get_unix_socket', '/tmp/.X11-unix/X0'), + ]), + # Successful explicit Unix socket connection, variant. + (('unix:0', None, 'unix', 0), True, True, False, False, [ + ('os.path.exists', '/tmp/.X11-unix/X0'), + ('_get_unix_socket', '/tmp/.X11-unix/X0'), + ]), + # Failed explicit Unix socket connection, variant. + (('unix:0', None, 'unix', 0), False, True, False, True, [ + ('os.path.exists', '/tmp/.X11-unix/X0'), + ('_get_unix_socket', '/tmp/.X11-unix/X0'), + ]), + # Successful implicit Unix socket connection. + ((':4', None, '', 4), True, True, False, False, [ + ('os.path.exists', '/tmp/.X11-unix/X4'), + ('_get_unix_socket', '/tmp/.X11-unix/X4'), + ]), + # Successful implicit Unix socket connection, abstract address. + ((':3', None, '', 3), True, False, False, False, [ + ('os.path.exists', '/tmp/.X11-unix/X3'), + ('_get_unix_socket', '\0/tmp/.X11-unix/X3'), + ]), + # Failed implicit Unix socket connection, successful fallback on TCP. + ((':2', None, '', 2), False, False, True, False, [ + ('os.path.exists', '/tmp/.X11-unix/X2'), + ('_get_unix_socket', '\0/tmp/.X11-unix/X2'), + ('_get_tcp_socket', '', 2), + ]), + # Failed implicit Unix socket connection, failed fallback on TCP. + ((':1', None, '', 1), False, False, False, True, [ + ('os.path.exists', '/tmp/.X11-unix/X1'), + ('_get_unix_socket', '\0/tmp/.X11-unix/X1'), + ('_get_tcp_socket', '', 1), + ]), + ): + with \ + patch('Xlib.support.unix_connect._get_unix_socket', + partial(_get_socket, 'unix', not allow_unix)), \ + patch('Xlib.support.unix_connect._get_tcp_socket', + partial(_get_socket, 'tcp', not allow_tcp)), \ + patch('os.path.exists', + partial(path_exists, unix_addr_exists)), \ + patch('fcntl.fcntl', fcntl): + del calls[:] + if expect_connection_error: + with self.assertRaises(DisplayConnectionError): + unix_connect.get_socket(*params) + else: + s = unix_connect.get_socket(*params) + self.assertIsInstance(s, FakeSocket) + expected_calls.append(('fcntl', 42, + unix_connect.F_SETFD, + unix_connect.FD_CLOEXEC)) + self.assertEqual(calls, expected_calls) if __name__ == '__main__': From f9119b8d073a418042b11684c91bcf4fcd39e1e2 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 3 Dec 2017 16:03:57 +0100 Subject: [PATCH 168/279] update news --- NEWS | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/NEWS b/NEWS index fdda9820..0483c58f 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,20 @@ NEWS for Python X Library +* Version 0.21 + +** Bug Fixes + +- fix use under Windows Subsystem for Linux: when DISPLAY does not + specify a protocol, and the implicit Unix socket connection fails, + fallback to TCP (mimicking XCB's behavior). + +** Misc + +- don't bundle a copy of texi2html to build the HTML documentation, + but use the currently installed version instead. + + * Version 0.20 ** Bug Fixes From 22a8e1929ad58b8168bcf5d931e8f6067ebdec0a Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 4 Dec 2017 17:46:50 +0100 Subject: [PATCH 169/279] fixup metadata - use `setup.cfg` - tweak `README.rst` - mark Python 3.6 as supported - convert `NEWS` to `CHANGELOG.md` - set long description to the contents of `README.rst` --- CHANGELOG.md | 389 +++++++++++++++++++++++++++++++++++++++++++++++++++ NEWS | 340 -------------------------------------------- README.rst | 38 ++--- setup.cfg | 35 +++++ setup.py | 32 ----- 5 files changed, 439 insertions(+), 395 deletions(-) create mode 100644 CHANGELOG.md delete mode 100644 NEWS diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..a33f8fdb --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,389 @@ +NEWS for Python X Library + +Version 0.21 +============ + +Bug Fixes +--------- + +- fix use under Windows Subsystem for Linux: when DISPLAY does not + specify a protocol, and the implicit Unix socket connection fails, + fallback to TCP (mimicking XCB's behavior). + +Misc +---- + +- don't bundle a copy of texi2html to build the HTML documentation, + but use the currently installed version instead. + +--- +Version 0.20 +============ + +Bug Fixes +--------- + +- fix unclosed file in Xauth implementation +- fix support for `Window.set_wm_transient_for` +- fix support for `Drawable.put_image` / `Drawable.get_image` +- use ASCII for decoding strings in Python 3 (same as Python 2) +- fix Python 3 warnings about `array.tostring()` (deprecated) + +Misc +---- + +Improve response processing performance: reduce the number of +`socket.recv` calls needed to receive a full response. + +--- +Version 0.19 +============ + +Bug Fixes +--------- + +- don't throw an exception if `$XAUTHFILE` / `~/.Xauthority` is missing +- fix authentication work-around for SSH forwarding under Python 3 +- improve `$DISPLAY` handling: support optional protocol prefix, and + correctly handle `unix:0.0` as `:0.0` + +--- +Version 0.18 +============ + +Bug Fixes +--------- + +- fix Python 3 buffer abstraction +- fix interrupted select handling for Python 3.3/3.4 +- fix Unix socket support when only an abstract address is available + +--- +Version 0.17 +============ + +Bug Fixes +--------- + +- fix Xauth handling when using Python 2 and DISPLAY contains a remote IP +- fix String16 request field handling when using Python 3 +- fix RECORD extension and example when using Python 3 +- fix handling of properties: use byte strings for all X11 8-bits + strings, as not all of them are text properties (the window + getters/setters for `wm_name`, `wm_icon_name`, `wm_class`, and + `wm_client_machine` still return/expect Unicode strings) + +API Changes +----------- + +Core: + +- new window getter/setter for text properties: `get_full_text_property` + and `change_text_property`; with automatic conversion to/from Unicode + when the property type encoding is supported (`STRING` and + `UTF8_STRING`) + +Composite extension: + +- support for `GetOverlayWindow` request + +--- +Version 0.16 +============ + +Licensing +--------- + +The project is now licensed under the GNU Lesser General Public License +v2.1 or later (see the LICENSE file for details). + +Compatibility +------------- + +Support for Python versions older than 2.7 has been dropped. Support for +Python 3 (3.3, 3.4 and 3.5) has been added. Note that Python-Xlib now +depends on the six package (>=1.10) for combined Python 2 / 3 support. + +API Changes +----------- + +With the change of license, and no way to contact the original author of +the SHAPE extension, the code had to be rewritten from scratch. This +resulted in a few minor API changes (see [examples/shapewin.py](examples/shapewin.py)). + +Partial support for the SECURITY. XInput, and XFIXES extensions has been +added. + +Bug Fixes +--------- + +- fix RECORD extension +- fixed OS X socket path +- fix handling of generic events +- fix handling of KeymapNotify events +- several fixes for the RandR extension + +--- +Version 0.15rc1 - 14 Nov 2009 +============================= + +Improved support for newer versions of Mac OS X, a couple of new +extensions, and several bugfixes. + +Composite extension +------------------- + +Support for the composite extension, used to implement a composition +manager (added for plcm work in plwm). + +By itself this extension is not very useful, it is intended to be used +together with the DAMAGE and XFIXES extensions. Typically you would also +need RENDER or glX or some similar method of creating fancy graphics. + +XF86 special function keysyms +----------------------------- + +Keysym definitions for special function keys found on modern keyboards, +e.g. raise and lower volume, start specific applications, etc. Have a +look in [Xlib/keysymdef/xf86.py](Xlib/keysymdef/xf86.py) to see what +there are and experiment with xev to see what your keyboard generates. +These definitions aren't brought in by default, so you must do this +after importing `Xlib.XK`: + +```python +Xlib.XK.load_keysym_group('xf86') +``` + +RANDR extension +--------------- + +The RANDR extension complements XINERAMA as a way of getting data about +the physical screens making up a virtual screen in X. An example of +usage can be found in [examples/xrandr.py](examples/xrandr.py). + +--- +Version 0.14 - 1 Oct 2007 (trialed as 0.14rc1 on 10 Jun 2007) +============================================================= + +A couple of new extensions, a Python 2.5 fix and a couple of aliases +(`Display.get_atom()` now uses the internal cache and added +`Window.raise_window()`). Tabs converted to spaces (SF id: 1559082). + +RECORD extension (SF id: 1538663) +--------------------------------- + +Alex Badea contributed a RECORD extension module, allowing Python Xlib +programs to capture mouse and keyboard events (or all other core or +extension events) easily. A demo is in the examples directory. See + for more +information. + +XINERAMA extension +------------------ + +Mike Meyer contributed a Xinerama extension module, allowing Python Xlib +programs to interrogate the X server about positions and sizes of +multiple screens. Specifications are a bit tricky to find - + has some older specs and the +source code of the xorg project (libs & server code) has "definitive" +information. + +Python 2.5 fix (SF id: 1623900) +------------------------------- + +Bugfix to correct handling of XAuthority file parsing under Python 2.5 +causing failed authentication. + +--- +Version 0.13 - 6 Aug 2006 (trialed as 0.13pre1 on 22 Jul 2006) +============================================================== + +A small release to incorporate a number of minor corrections and bug +fixes, including small changes to keysym handling, `.Xauthority` +parsing, several fixes to sending/receiving/flushing data, addition of +`WithdrawnState` to `WMHints`. petli completed documentation for +`Display` objects. + +--- +Version 0.12 - 29 Mar 2002 +========================== + +SHAPE extension +--------------- + +Jeffrey Boser contributed a SHAPE extension module, allowing Python Xlib +programs to use shaped windows. Take a look at examples/shapewin.py for +ideas on how to use it. For more information on shaped windows, see + + +Python 2.2 fix +-------------- + +In Python 2.2 `FCNTL.FD_CLOEXEC` has disappeared and `FCNTL` on the whole +is deprecated, so that had to be dealt with to make the Xlib work with +that version. + +--- +Version 0.11 - 23 Feb 2002 +========================== + +Regression tests for the protocol definition +-------------------------------------------- + +Regressions tests have been created for all requests, replies and +events. The tests use PyUnit, and the old resource database test has +been updated to use it too. + +A lot of protocol bugfixes +-------------------------- + +The bugs discovered by the regression tests have been fixed. +Additionally, a subtle bug in the core engine which could cause a +"can't happen"-error has also been found and fixed. + +--- +Version 0.10 - 16 Dec 2001 +========================== + +Event bugfix +------------ + +The xlib failed to parse the type code of events sent from other clients +using `SendEvent`. This has been fixed, adding the field `send_event' to +all event objects. + +Event documentation +------------------- + +The section "Event Types" in the manual has been written, detailing +all event types in the core protocol. The manual is now ten pages +thicker. + +Basic support for GetImage/PutImage +----------------------------------- + +The Drawable methods `put_image()` and `get_image()` have been +implemented, but handling image data is still up to the user. There is +however, thanks to Ilpo Nyyssönen, a trivial method `put_pil_image()` +that will work on some combinations of image and drawable depth. It's +not perfect, but it's a start. + +--- +Version 0.9 - 4 Dec 2001 +======================== + +Documentation improved +---------------------- + +The documentation has been augmented with a chapter about event +handling, and a chapter listing all X objects and their methods provided +by the library. They are not described in any detail, though. + +Keysym handling improved +------------------------ + +The module `Xlib.XK`, which listed all keysyms, have been split up into +several sub-modules providing different sets of keysyms. By importing +`Xlib.XK` only the miscellany and latin1 sets are loaded, thus removing +some unnecessary clutter. + +`Xlib.display.Display` has two new methods (`lookup_string()` and +`rebind_string()`) for translating keysyms into characters. + +Small changes to library interface +---------------------------------- + +The order of the `Xlib.display.Display` method `send_event()` parameters +`event_mask` and propagate has changed. + +Some of the class names in `Xlib.protocol.event` have changed, to have +the same name as the corresponding event type constant. + +A few bugfixes +-------------- + +If a display has more than one screen, the default screen was always set +to the highest numbered one, irrespective of what the user specified in +`$DISPLAY`. + +Some response attributes in `Xlib.protocol.request` accidentally included +a comma. + +--- +Version 0.8 - 12 Jan 2001 +========================= + +Uses distutils +-------------- + +Python Xlib now uses distutils to make installation and distribution +building easier. + +Tested with Python 2.0 +---------------------- + +A few incompatibilities with Python 2.0 has been fixed. + +--- +Version 0.7 - 8 Jan 2001 +======================== + +Fixed the 64-bit platform fix. +------------------------------ + +As it turns out, the attempted fix for 64-bit platforms in v0.6 didn't +really work. Close study of structmodules.c gave the answer why, and now +it really should work. Yeah. + +Optimizations of core protocol engine +------------------------------------- + +Python Xlib is now at least 25% faster after the core of the protocol +engine has been rewritten. This is some quite cute code: tailor-made +methods are generated for all structures, resulting in a 650% speed-up +in generating binary data, and a 75% speed-up in parsing binary data. + +Interested Python hackers are recommended to take a look at the Struct +class in `Xlib/protocol/rq.py`. + +--- +Version 0.6 - 29 Dec 2000 +========================= + +Fix to make python-xlib work on 64-bytes architectures. +------------------------------------------------------- + +The struct and array modules uses `sizeof(long)` to determine the number +of bytes used when representing the type code 'l'. On Intel and VAX, +this is 32 bits as expected. On Alpha, it's 64 bits. python-xlib now +probes how large each type code is to avoid this problem. + +--- +Version 0.5 - 28 Dec 2000 +========================= + +- Functions implemented to get and set all ICCCM WM properties on Window + objects. + +- Keymap cache implemented, with external `Xlib.display.Display` methods + `keycode_to_keysym`, `keysym_to_keycode`, `keysym_to_keycodes` and + `refresh_keyboard_mapping`. + +- Two utils for debugging X traffic implemented. `utils/tcpbug.py` + forwards a TCP connection and outputs the communication between the + client and the server. This output can then be fed into + `utils/parsexbug.py`, which will output all requests, responses, + errors and events in a readable format. + +--- +Version 0.4 - 4 Oct 2000 +======================== + +- Thread support completed, but not really stress-tested yet. + +- A framework for handling different platforms has been implemented, + together with generic Unix code and some simple VMS code. + +- Some documentation has been written. + +- The usual bunch of bugfixes. diff --git a/NEWS b/NEWS deleted file mode 100644 index 0483c58f..00000000 --- a/NEWS +++ /dev/null @@ -1,340 +0,0 @@ --*-outline-*- - - NEWS for Python X Library - -* Version 0.21 - -** Bug Fixes - -- fix use under Windows Subsystem for Linux: when DISPLAY does not - specify a protocol, and the implicit Unix socket connection fails, - fallback to TCP (mimicking XCB's behavior). - -** Misc - -- don't bundle a copy of texi2html to build the HTML documentation, - but use the currently installed version instead. - - -* Version 0.20 - -** Bug Fixes - -- fix unclosed file in Xauth implementation -- fix support for `Window.set_wm_transient_for` -- fix support for `Drawable.put_image` / `Drawable.get_image` -- use ASCII for decoding strings in Python 3 (same as Python 2) -- fix Python 3 warnings about `array.tostring()` (deprecated) - -** Misc - -Improve response processing performance: reduce the number of `socket.recv` -calls needed to receive a full response. - - -* Version 0.19 - -** Bug Fixes - -- don't throw an exception if $XAUTHFILE / ~/.Xauthority is missing -- fix authentication work-around for SSH forwarding under Python 3 -- improve $DISPLAY handling: support optional protocol prefix, and - correctly handle `unix:0.0` as `:0.0` - - -* Version 0.18 - -** Bug Fixes - -- fix Python 3 buffer abstraction -- fix interrupted select handling for Python 3.3/3.4 -- fix Unix socket support when only an abstract address is available - - -* Version 0.17 - -** Bug Fixes - -- fix Xauth handling when using Python 2 and DISPLAY contains a remote IP -- fix String16 request field handling when using Python 3 -- fix RECORD extension and example when using Python 3 -- fix handling of properties: use byte strings for all X11 8-bits - strings, as not all of them are text properties (the window - getters/setters for wm_name, wm_icon_name, wm_class, and - wm_client_machine still return/expect Unicode strings) - -** API Changes - -Core: - -- new window getter/setter for text properties: get_full_text_property - and change_text_property; with automatic conversion to/from Unicode - when the property type encoding is supported (STRING and UTF8_STRING) - -Composite extension: - -- support for GetOverlayWindow request - - -* Version 0.16 - -** Licensing - -The project is now licensed under the GNU Lesser General Public License -v2.1 or later (see the LICENSE file for details). - -** Compatibility - -Support for Python versions older than 2.7 has been dropped. Support for -Python 3 (3.3, 3.4 and 3.5) has been added. Note that Python-Xlib now -depends on the six package (>=1.10) for combined Python 2 / 3 support. - -** API Changes - -With the change of license, and no way to contact the original author of -the SHAPE extension, the code had to be rewritten from scratch. This -resulted in a few minor API changes (see examples/shapewin.py). - -Partial support for the SECURITY. XInput, and XFIXES extensions has been -added. - -** Bug Fixes - -- fix RECORD extension -- fixed OS X socket path -- fix handling of generic events -- fix handling of KeymapNotify events -- several fixes for the RandR extension - -* Version 0.15rc1 - 14 Nov 2009 - -Improved support for newer versions of Mac OS X, a couple of new -extensions, and several bugfixes. - -** Composite extension - -Support for the composite extension, used to implement a composition -manager (added for plcm work in plwm). - -By itself this extension is not very useful, it is intended to be used -together with the DAMAGE and XFIXES extensions. Typically you would -also need RENDER or glX or some similar method of creating fancy -graphics. - -** XF86 special function keysyms - -Keysym definitions for special function keys found on modern -keyboards, e.g. raise and lower volume, start specific applications, -etc. Have a look in Xlib/keysymdef/xf86.py to see what there are and -experiment with xev to see what your keyboard generates. These -definitions aren't brought in by default, so you must do this after -importing Xlib.XK: - -Xlib.XK.load_keysym_group('xf86') - -** RANDR extension - -The RANDR extension complements XINERAMA as a way of getting data about the -physical screens making up a virtual screen in X. An example of usage can -be found in examples/xrandr.py. - - -* Version 0.14 - 1 Oct 2007 (trialed as 0.14rc1 on 10 Jun 2007) - -A couple of new extensions, a Python 2.5 fix and a couple of aliases -(Display.get_atom() now uses the internal cache and added -Window.raise_window()). Tabs converted to spaces (SF id: 1559082). - -** RECORD extension (SF id: 1538663) - -Alex Badea contributed a RECORD extension module, allowing Python Xlib -programs to capture mouse and keyboard events (or all other core or -extension events) easily. A demo is in the examples directory. See -http://refspecs.freestandards.org/X11/recordlib.pdf for more information. - -** XINERAMA extension - -Mike Meyer contributed a Xinerama extension module, allowing Python Xlib -programs to interrogate the X server about positions and sizes of -multiple screens. Specifications are a bit tricky to find - -http://sourceforge.net/projects/xinerama/ has some older specs and the -source code of the xorg project (libs & server code) has "definitive" -information. - -** Python 2.5 fix (SF id: 1623900) - -Bugfix to correct handling of XAuthority file parsing under Python 2.5 -causing failed authentication. - - -* Version 0.13 - 6 Aug 2006 (trialed as 0.13pre1 on 22 Jul 2006) - -A small release to incorporate a number of minor corrections and bug -fixes, including small changes to keysym handling, .Xauthority parsing, -several fixes to sending/receiving/flushing data, addition of -WithdrawnState to WMHints. petli completed documentation for Display -objects. - - -* Version 0.12 - 29 Mar 2002 - -** SHAPE extension - -Jeffrey Boser contributed a SHAPE extension module, allowing Python -Xlib programs to use shaped windows. Take a look at -examples/shapewin.py for ideas on how to use it. For more information -on shaped windows, see -http://ftp.x.org/pub/R6.6/xc/doc/hardcopy/Xext/shape.PS.gz - -** Python 2.2 fix - -In Python 2.2 FCNTL.FD_CLOEXEC has disappeared and FCNTL on the whole -is deprecated, so that had to be dealt with to make the Xlib work with -that version. - - -* Version 0.11 - 23 Feb 2002 - -** Regression tests for the protocol definition - -Regressions tests have been created for all requests, replies and -events. The tests use PyUnit, and the old resource database test has -been updated to use it too. - -** A lot of protocol bugfixes - -The bugs discovered by the regression tests have been fixed. -Additionally, a subtle bug in the core engine which could cause a -"can't happen"-error has also been found and fixed. - - -* Version 0.10 - 16 Dec 2001 - -** Event bugfix - -The xlib failed to parse the type code of events sent from other -clients using SendEvent. This has been fixed, adding the field -`send_event' to all event objects. - -** Event documentation - -The section "Event Types" in the manual has been written, detailing -all event types in the core protocol. The manual is now ten pages -thicker. - -** Basic support for GetImage/PutImage - -The Drawable methods put_image() and get_image() have been -implemented, but handling image data is still up to the user. There -is however, thanks to Ilpo Nyyssönen, a trivial method put_pil_image() -that will work on some combinations of image and drawable depth. It's -not perfect, but it's a start. - - -* Version 0.9 - 4 Dec 2001 - -** Documentation improved - -The documentation has been augmented with a chapter about event -handling, and a chapter listing all X objects and their methods -provided by the library. They are not described in any detail, -though. - -** Keysym handling improved - -The module Xlib.XK, which listed all keysyms, have been split up into -several sub-modules providing different sets of keysyms. By importing -Xlib.XK only the miscellany and latin1 sets are loaded, thus removing -some unnecessary clutter. - -Xlib.display.Display has two new methods (lookup_string() and -rebind_string()) for translating keysyms into characters. - -** Small changes to library interface - -The order of the Xlib.display.Display method send_event() parameters -event_mask and propagate has changed. - -Some of the class names in Xlib.protocol.event have changed, to have -the same namse as the corresponding. event type constant. - -** A few bugfixes - -If a display has more than one screen, the default screen was always -set to the highest numbered one, irrespective of what the user -specified in $DISPLAY. - -Some response attributes in Xlib.protocol.request accidentally -included a comma. - - - -* Version 0.8 - 12 Jan 2001 - -** Uses distutils - -Python Xlib now uses distutils to make installation and distribution -building easier. - -** Tested with Python 2.0 - -A few incompatibilities with Python 2.0 has been fixed. - - -* Version 0.7 - 8 Jan 2001 - -** Fixed the 64-bit platform fix. - -As it turns out, the attempted fix for 64-bit platforms in v0.6 didn't -really work. Close study of structmodules.c gave the answer why, and -now it really should work. Yeah. - -** Optimizations of core protocol engine - -Python Xlib is now at least 25% faster after the core of the protocol -engine has been rewritten. This is some quite cute code: tailor-made -methods are generated for all structures, resulting in a 650% speed-up -in generating binary data, and a 75% speed-up in parsing binary data. - -Interested Python hackers are recommended to take a look at the Struct -class in Xlib/protocol/rq.py. - - - -* Version 0.6 - 29 Dec 2000 - -** Fix to make python-xlib work on 64-bytes architectures. - -The struct and array modules uses sizeof(long) to determine the number -of bytes used when representing the type code 'l'. On Intel and VAX, -this is 32 bits as expected. On Alpha, it's 64 bits. python-xlib now -probes how large each type code is to avoid this problem. - - -* Version 0.5 - 28 Dec 2000 - -** Functions implemented to get and set all ICCCM WM properties on -Window objects. - -** Keymap cache implemented, with external Xlib.display.Display -methods keycode_to_keysym, keysym_to_keycode, keysym_to_keycodes and -refresh_keyboard_mapping. - -** Two utils for debugging X traffic implemented. -utils/tcpbug.py forwards a TCP connection and outputs the -communication between the client and the server. This output can then -be fed into utils/parsexbug.py, which will output all requests, -responses, errors and events in a readable format. - - -* Version 0.4 - 4 Oct 2000 - -** Thread support completed, but not really stresstested yet. - -** A framework for handling different platforms has been implemented, -together with generic Unix code and some simple VMS code. - -** Some documentation has been written. - -** The usual bunch of bugfixes. - diff --git a/README.rst b/README.rst index f145f3da..e28f80cf 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,10 @@ -|Build Status| |codecov.io| |Code Health| - The Python X Library ==================== +|Build Status| |codecov.io| |Code Health| + +`Homepage`_ | `Releases`_ | `Changelog`_ + Copyright ~~~~~~~~~ @@ -12,8 +14,7 @@ The main part of the code is Copyright (C) 2000-2002 Peter Liljenberg -Some contributed code is copyrighted by `the -contributors `__, +Some contributed code is copyrighted by `the contributors `_, in these cases that is indicated in the source files in question. The Python X Library is released under LGPL v2.1 or later (since 2016), @@ -24,7 +25,7 @@ Requirements ~~~~~~~~~~~~ The Python X Library requires Python 2.7 or newer. It has been tested to -various extents with Python 2.7 and 3.3 through 3.5. +various extents with Python 2.7 and 3.3 through 3.6. Installation ~~~~~~~~~~~~ @@ -73,9 +74,11 @@ There are three advantages of implementing a pure Python library: Documentation ~~~~~~~~~~~~~ -The reference manual is not finished by far, but is probably still useful. It can be `browsed online `__. +The reference manual is not finished by far, but is probably still useful. It +can be `browsed online `__. -There are also some `example programs `__ and, of course, `the standard X11 documentation `__ applies. +There are also some `example programs `_ and, of course, +`the standard X11 documentation `__ applies. Project status @@ -104,22 +107,11 @@ http://www.rahul.net/kenton/xsites.html See the file TODO for a detailed list of what is missing, approximately ordered by importance. -Contact information -~~~~~~~~~~~~~~~~~~~ - -Author email: Peter Liljenberg petli@ctrl-c.liu.se - -Mailing list: http://sourceforge.net/mail/?group\_id=10350 - -The Python X Library is a SourceForged project (currently migrating to -GitHub). The project page is -http://sourceforge.net/projects/python-xlib/. Source is available from -that page as zip archive and from the `releases -list `__. - -There isn't any real web page yet, only a derivative of this file. It is -located at http://python-xlib.sourceforge.net/. It now also features the -documentation for downloading or browsing. +.. _Homepage: https://github.com/python-xlib/python-xlib +.. _Releases: https://github.com/python-xlib/python-xlib/releases +.. _Changelog: https://github.com/python-xlib/python-xlib/tree/master/CHANGELOG.md +.. _Contributors: https://github.com/python-xlib/python-xlib/graphs/contributors +.. _Examples: https://github.com/python-xlib/python-xlib/tree/master/examples .. |Build Status| image:: https://travis-ci.org/python-xlib/python-xlib.svg?branch=master :target: https://travis-ci.org/python-xlib/python-xlib diff --git a/setup.cfg b/setup.cfg index 2a9acf13..ba1f408a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,37 @@ +[metadata] +name = python-xlib +version = attr: Xlib.__version_string__ +description = Python X Library +long_description = file: README.rst +download_url = https://github.com/python-xlib/python-xlib/releases +url = https://github.com/python-xlib/python-xlib +license = LGPLv2+ +author = Peter Liljenberg +author_email = petli@ctrl-c.liu.se +keywords = + windows + x + x11 + xlib +classifiers = + Development Status :: 5 - Production/Stable + Environment :: X11 Applications + Intended Audience :: Developers + License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+) + Operating System :: OS Independent + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.3 + Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.5 + Programming Language :: Python :: 3.5 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: Implementation :: CPython + Topic :: Software Development :: Libraries :: Python Modules + Topic :: Software Development :: Libraries + Topic :: Software Development :: User Interfaces + [bdist_wheel] universal = 1 + +# vim: list diff --git a/setup.py b/setup.py index b425618f..9b4a47e2 100644 --- a/setup.py +++ b/setup.py @@ -2,24 +2,10 @@ from setuptools import setup -import Xlib - setup( - name='python-xlib', - version=Xlib.__version_string__, - - description='Python X Library', - download_url='https://github.com/python-xlib/python-xlib/releases', - url='https://github.com/python-xlib/python-xlib', - license='LGPLv2+', - - author='Peter Liljenberg', - author_email='petli@ctrl-c.liu.se', - install_requires=['six>=1.10.0'], setup_requires=['setuptools-scm'], - packages=[ 'Xlib', 'Xlib.ext', @@ -28,22 +14,4 @@ 'Xlib.support', 'Xlib.xobject' ], - - keywords='xlib x11 x windows', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: X11 Applications', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: Implementation :: CPython', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Software Development :: Libraries', - 'Topic :: Software Development :: User Interfaces', - ], ) From b9f72dbd83585183af542430dbce897641d21d8f Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 5 Dec 2017 15:58:03 +0100 Subject: [PATCH 170/279] release 0.21 --- Xlib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 95a3c733..f5551eca 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 20) +__version__ = (0, 21) __version_extra__ = '' From fc4ba3c6f06a4d90c7c3cf740ca6872e8072b303 Mon Sep 17 00:00:00 2001 From: Tomek Date: Sun, 11 Feb 2018 17:23:42 +0100 Subject: [PATCH 171/279] Corrected missing last letter in variable name. --- Xlib/display.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/display.py b/Xlib/display.py index d5fd3faa..88d3ac97 100644 --- a/Xlib/display.py +++ b/Xlib/display.py @@ -814,7 +814,7 @@ def change_pointer_control(self, accel = None, threshold = None, onerror = None) request.ChangePointerControl(display = self.display, onerror = onerror, do_accel = do_accel, - do_thres = do_threshold, + do_thresh = do_threshold, accel_num = accel_num, accel_denum = accel_denum, threshold = threshold) From acaea4ae623e114b22fec06c53e66146999e2ab8 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 9 Feb 2018 15:36:53 +0100 Subject: [PATCH 172/279] travis: drop eggs from releases --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d5fb8fca..c54c9650 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,6 @@ before_deploy: # Note: only do this with Python 3.5 because the contents # of the distribution are the same for all versions. - case "$TRAVIS_PYTHON_VERSION" in 3.5) python setup.py sdist --formats=bztar;; esac - # Generate egg distribution. - - python setup.py bdist_egg # Generate wheel distribution. # Note: only do this once, since we create a universal wheel. - case "$TRAVIS_PYTHON_VERSION" in 3.5) python setup.py bdist_wheel;; esac @@ -37,7 +35,6 @@ deploy: file_glob: true file: - dist/*.tar.* - - dist/*.egg - dist/*.whl on: tags: true From 3febd497e6cda5f925d177df152c80d51238f41e Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 14 Mar 2018 23:07:26 +0100 Subject: [PATCH 173/279] xobject/drawable: fix `put_pil_image` implementation The deprecated `Image.tostring` method has been removed in Pillow>=3.0. --- Xlib/xobject/drawable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/xobject/drawable.py b/Xlib/xobject/drawable.py index 71576f8c..2f688c88 100644 --- a/Xlib/xobject/drawable.py +++ b/Xlib/xobject/drawable.py @@ -249,7 +249,7 @@ def put_pil_image(self, gc, x, y, image, onerror = None): else: subimage = image w, h = subimage.size - data = subimage.tostring("raw", rawmode, stride, 0) + data = subimage.tobytes("raw", rawmode, stride, 0) self.put_image(gc, x, y, w, h, format, depth, 0, data) y1 = y1 + h y = y + h From 376b4739cedc4eee32e60e7b158d20ed18dfddc1 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 14 Mar 2018 22:57:30 +0100 Subject: [PATCH 174/279] setup: check setuptools is recent enough to support `setup.cfg` --- setup.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9b4a47e2..71bdb085 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,12 @@ # Distutils script for python-xlib -from setuptools import setup +from pkg_resources import parse_requirements +from setuptools import (__version__ as setuptools_version, setup) + + +# Check setuptools is recent enough to support `setup.cfg`. +setuptools_require = next(parse_requirements('setuptools>=30.3.0')) +assert setuptools_version in setuptools_require, '{} is required'.format(setuptools_require) setup( From d4b4796b9f79105aa7c508bcd43c18d3ebc21b5b Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 16 Mar 2018 20:05:07 +0100 Subject: [PATCH 175/279] update news --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a33f8fdb..9429eb34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ NEWS for Python X Library +Version 0.22 +============ + +Bug Fixes +--------- + +- fix `Display.change_pointer_control` implementation +- fix `Drawable.put_pil_image` implementation + +--- Version 0.21 ============ From 402730bb736e24bb51922881e29cce28560a4200 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 16 Mar 2018 20:53:22 +0100 Subject: [PATCH 176/279] release 0.22 --- Xlib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/__init__.py b/Xlib/__init__.py index f5551eca..14a4b71d 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 21) +__version__ = (0, 22) __version_extra__ = '' From 31e6abf842c9307f9158efa393c813643789d11e Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 16 Mar 2018 22:12:15 +0100 Subject: [PATCH 177/279] protocol/rq: fix string decoding As it turns out, character strings should be decoded using Latin-1, see for example: https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#requests:InternAtom --- Xlib/protocol/rq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 4f5f16a6..296e44c1 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -35,7 +35,7 @@ def decode_string(bs): - return bs.decode('ascii') + return bs.decode('latin1') if PY3: def encode_array(a): From e0adefc3e30e3015686e578d4f2b6626eb1fb99d Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 20 Mar 2018 20:42:38 +0100 Subject: [PATCH 178/279] update news --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9429eb34..d8d4db6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ NEWS for Python X Library +Version 0.23 +============ + +Bug Fixes +--------- + +- fix strings decoding: use Latin-1 + +--- Version 0.22 ============ From a2537ebe704de0fe7b77c79a67763b6415c74e6e Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Fri, 23 Mar 2018 22:12:37 +0100 Subject: [PATCH 179/279] release 0.23 --- Xlib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 14a4b71d..042f1df0 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 22) +__version__ = (0, 23) __version_extra__ = '' From 3c8812e3b6bd29f35d06cdc8296d01f1bfe89798 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 6 Jun 2018 14:41:39 +0200 Subject: [PATCH 180/279] support/unix_connect: fix protocol handling - fix support for explicit unix connections - fix macOS support --- Xlib/protocol/display.py | 4 ++-- Xlib/support/connect.py | 8 +++---- Xlib/support/unix_connect.py | 45 ++++++++++++++++++++++++------------ 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 4f431e99..6453b49d 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -89,8 +89,8 @@ def __init__(self, display = None): self.socket = connect.get_socket(name, protocol, host, displayno) - auth_name, auth_data = connect.get_auth(self.socket, - name, host, displayno) + auth_name, auth_data = connect.get_auth(self.socket, name, + protocol, host, displayno) # Internal structures for communication, grouped # by their function and locks diff --git a/Xlib/support/connect.py b/Xlib/support/connect.py index 93b26c0e..4db4c2f4 100644 --- a/Xlib/support/connect.py +++ b/Xlib/support/connect.py @@ -87,11 +87,11 @@ def get_socket(dname, protocol, host, dno): return mod.get_socket(dname, protocol, host, dno) -def get_auth(sock, dname, host, dno): - """auth_name, auth_data = get_auth(sock, dname, host, dno) +def get_auth(sock, dname, protocol, host, dno): + """auth_name, auth_data = get_auth(sock, dname, protocol, host, dno) Return authentication data for the display on the other side of - SOCK, which was opened with DNAME, HOST and DNO. + SOCK, which was opened with DNAME, HOST and DNO, using PROTOCOL. Return AUTH_NAME and AUTH_DATA, two strings to be used in the connection setup request. @@ -99,4 +99,4 @@ def get_auth(sock, dname, host, dno): modname = _auth_mods.get(platform, _default_auth_mod) mod = _relative_import(modname) - return mod.get_auth(sock, dname, host, dno) + return mod.get_auth(sock, dname, protocol, host, dno) diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index 25a8f3ac..c2261dae 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -42,36 +42,50 @@ from Xlib import error, xauth + +SUPPORTED_PROTOCOLS = (None, 'tcp', 'unix') + +# Darwin funky socket. uname = platform.uname() if (uname[0] == 'Darwin') and ([int(x) for x in uname[2].split('.')] >= [9, 0]): + SUPPORTED_PROTOCOLS += ('darwin',) + DARWIN_DISPLAY_RE = re.compile(r'^/private/tmp/[-:a-zA-Z0-9._]*:(?P[0-9]+)(\.(?P[0-9]+))?$') - display_re = re.compile(r'^(?P)(?P[-:a-zA-Z0-9._/]*):(?P[0-9]+)(\.(?P[0-9]+))?$') - -else: +DISPLAY_RE = re.compile(r'^((?Ptcp|unix)/)?(?P[-:a-zA-Z0-9._]*):(?P[0-9]+)(\.(?P[0-9]+))?$') - display_re = re.compile(r'^((?Ptcp|unix)/)?(?P[-:a-zA-Z0-9._]*):(?P[0-9]+)(\.(?P[0-9]+))?$') def get_display(display): # Use $DISPLAY if display isn't provided if display is None: display = os.environ.get('DISPLAY', '') - m = display_re.match(display) - if not m: + re_list = [(DISPLAY_RE, {})] + + if 'darwin' in SUPPORTED_PROTOCOLS: + re_list.insert(0, (DARWIN_DISPLAY_RE, {'protocol': 'darwin'})) + + for re, defaults in re_list: + m = re.match(display) + if m is not None: + protocol, host, dno, screen = [ + m.groupdict().get(field, defaults.get(field)) + for field in ('proto', 'host', 'dno', 'screen') + ] + break + else: raise error.DisplayNameError(display) - name = display - protocol, host, dno, screen = m.group('proto', 'host', 'dno', 'screen') if protocol == 'tcp' and not host: # Host is mandatory when protocol is TCP. raise error.DisplayNameError(display) + dno = int(dno) if screen: screen = int(screen) else: screen = 0 - return name, protocol, host, dno, screen + return display, protocol, host, dno, screen def _get_tcp_socket(host, dno): @@ -85,14 +99,14 @@ def _get_unix_socket(address): return s def get_socket(dname, protocol, host, dno): - assert protocol in (None, 'tcp', 'unix') + assert protocol in SUPPORTED_PROTOCOLS try: # Darwin funky socket. - if uname[0] == 'Darwin' and host and host.startswith('/private/tmp/'): + if protocol == 'darwin': s = _get_unix_socket(dname) # TCP socket, note the special case: `unix:0.0` is equivalent to `:0.0`. - elif (not protocol or protocol != 'unix') and host and host != 'unix': + elif (protocol is None or protocol != 'unix') and host and host != 'unix': s = _get_tcp_socket(host, dno) # Unix socket. @@ -118,13 +132,14 @@ def get_socket(dname, protocol, host, dno): return s -def new_get_auth(sock, dname, host, dno): +def new_get_auth(sock, dname, protocol, host, dno): + assert protocol in SUPPORTED_PROTOCOLS # Translate socket address into the xauth domain - if (uname[0] == 'Darwin') and host and host.startswith('/private/tmp/'): + if protocol == 'darwin': family = xauth.FamilyLocal addr = socket.gethostname() - elif host: + elif protocol == 'tcp': family = xauth.FamilyInternet # Convert the prettyprinted IP number into 4-octet string. From a953c932a865c15552a91290ef7f113ad6e21c73 Mon Sep 17 00:00:00 2001 From: Joseph Kogut Date: Tue, 17 Jul 2018 14:02:39 -0700 Subject: [PATCH 181/279] fix parse_event_response subcode decoding When using python3, the subcode received from the response is already an int, triggering a TypeError when attempting to decode it using ord(). This patch checks the subcode type before attempting to decode it. Fixes #119 --- Xlib/protocol/display.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 6453b49d..6964c555 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -822,8 +822,14 @@ def parse_event_response(self, etype): estruct = self.event_classes.get(etype, event.AnyEvent) if type(estruct) == dict: + subcode = self.data_recv[1] + + # Python2 compatibility + if type(subcode) == str: + subcode = ord(subcode) + # this etype refers to a set of sub-events with individual subcodes - estruct = estruct[ord(self.data_recv[1])] + estruct = estruct[subcode] e = estruct(display = self, binarydata = self.data_recv[:length]) From 3bb44923ac37b8b2ddb0602e8d4473746d5bd4df Mon Sep 17 00:00:00 2001 From: Piotr Kasprzyk Date: Fri, 20 Jul 2018 12:00:02 +0200 Subject: [PATCH 182/279] Fix in comments: receiving Signed-off-by: Piotr Kasprzyk --- Xlib/protocol/display.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 6964c555..82d14a79 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -485,7 +485,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) # There's no thread doing what we need to do. Find out exactly # what to do - # There must always be some thread recieving data, but it must not + # There must always be some thread receiving data, but it must not # necessarily be us if not self.recv_active: @@ -497,7 +497,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) flush_bytes = None sending = 0 - # Loop, recieving and sending data. + # Loop, receiving and sending data. while 1: # We might want to start sending data @@ -542,9 +542,9 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) try: # We're only checking for the socket to be writable # if we're the sending thread. We always check for it - # to become readable: either we are the recieving thread - # and should take care of the data, or the recieving thread - # might finish recieving after having read the data + # to become readable: either we are the receiving thread + # and should take care of the data, or the receiving thread + # might finish receiving after having read the data if sending: writeset = [self.socket] @@ -594,7 +594,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) gotreq = 0 if rs: - # We're the recieving thread, parse the data + # We're the receiving thread, parse the data if recieving: try: count = self.recv_packet_len - len(self.data_recv) From 909990e869cb104fc2415f3d50bcd974a8d48cdc Mon Sep 17 00:00:00 2001 From: Piotr Kasprzyk Date: Fri, 20 Jul 2018 12:01:45 +0200 Subject: [PATCH 183/279] Fix variable name: receiving Signed-off-by: Piotr Kasprzyk --- Xlib/protocol/display.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 82d14a79..258ecc84 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -489,10 +489,10 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) # necessarily be us if not self.recv_active: - recieving = 1 + receiving = 1 self.recv_active = 1 else: - recieving = 0 + receiving = 0 flush_bytes = None sending = 0 @@ -529,7 +529,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) self.send_recv_lock.release() # There's no longer anything useful we can do here. - if not (sending or recieving): + if not (sending or receiving): break # If we're flushing, figure out how many bytes we @@ -595,7 +595,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) if rs: # We're the receiving thread, parse the data - if recieving: + if receiving: try: count = self.recv_packet_len - len(self.data_recv) count = max(self.recv_buffer_size, count) @@ -661,7 +661,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) if sending: self.send_active = 0 - if recieving: + if receiving: self.recv_active = 0 if self.event_waiting: From 6b5df2f490cd9623a0313c7cc27e7215bdb8cbc2 Mon Sep 17 00:00:00 2001 From: Piotr Kasprzyk Date: Fri, 20 Jul 2018 12:18:06 +0200 Subject: [PATCH 184/279] There is StaticGray in Xlib/X.py Signed-off-by: Piotr Kasprzyk --- doc/src/objects.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/objects.texi b/doc/src/objects.texi index 16d4adbe..f970c370 100644 --- a/doc/src/objects.texi +++ b/doc/src/objects.texi @@ -205,7 +205,7 @@ list items have the following attributes: The ID of this visual. @item visual_class -One of @code{X.StaticGrey}, @code{X.StaticColor}, @code{X.TrueColor}, +One of @code{X.StaticGray}, @code{X.StaticColor}, @code{X.TrueColor}, @code{X.GrayScale}, @code{X.PseudoColor}, or @code{X.DirectColor}. @item bits_per_rgb_value From 044debee6dcab2b754bb75890f1e01a435f427f4 Mon Sep 17 00:00:00 2001 From: Piotr Kasprzyk Date: Fri, 20 Jul 2018 13:00:21 +0200 Subject: [PATCH 185/279] Fix many misspellings Signed-off-by: Piotr Kasprzyk --- Xlib/display.py | 4 ++-- Xlib/ext/xinerama.py | 2 +- Xlib/protocol/display.py | 24 ++++++++++++------------ Xlib/protocol/rq.py | 2 +- Xlib/rdb.py | 2 +- debian/rules | 2 +- doc/src/errors.texi | 2 +- doc/src/events.texi | 4 ++-- doc/src/objects.texi | 2 +- examples/get_selection.py | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Xlib/display.py b/Xlib/display.py index 88d3ac97..622e0a2a 100644 --- a/Xlib/display.py +++ b/Xlib/display.py @@ -517,7 +517,7 @@ def send_event(self, destination, event, event_mask = 0, propagate = 0, event = event) def ungrab_pointer(self, time, onerror = None): - """elease a grabbed pointer and any queued events. See + """Release a grabbed pointer and any queued events. See XUngrabPointer(3X11).""" request.UngrabPointer(display = self.display, onerror = onerror, @@ -661,7 +661,7 @@ def list_fonts_with_info(self, pattern, max_names): font_ascent font_descent replies_hint - See the descripton of XFontStruct in XGetFontProperty(3X11) + See the description of XFontStruct in XGetFontProperty(3X11) for details on these values. properties A list of properties. Each entry has two attributes: diff --git a/Xlib/ext/xinerama.py b/Xlib/ext/xinerama.py index 12d2f0e0..f0546707 100644 --- a/Xlib/ext/xinerama.py +++ b/Xlib/ext/xinerama.py @@ -30,7 +30,7 @@ this is untested because I don't have a server that implements it. The functions loosely follow the libXineram functions. Mostly, they -return an rq.Struct in lieue of passing in pointers that get data from +return an rq.Struct in lieu of passing in pointers that get data from the rq.Struct crammed into them. The exception is isActive, which returns the state information - because that's what libXinerama does.""" diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 258ecc84..ce0413cd 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -110,7 +110,7 @@ def __init__(self, display = None): self.request_serial = 1 self.request_queue = [] - # Send-and-recieve loop, see function send_and_recive + # Send-and-receive loop, see function send_and_receive # for a detailed explanation self.send_recv_lock = lock.allocate_lock() self.send_active = 0 @@ -127,7 +127,7 @@ def __init__(self, display = None): buffer_size = math.pow(2, math.floor(math.log(buffer_size, 2))) self.recv_buffer_size = int(buffer_size) - # Data used by the send-and-recieve loop + # Data used by the send-and-receive loop self.sent_requests = [] self.recv_packet_len = 0 self.data_send = b'' @@ -146,7 +146,7 @@ def __init__(self, display = None): # Right, now we're all set up for the connection setup # request with the server. - # Figure out which endianess the hardware uses + # Figure out which endianness the hardware uses self.big_endian = struct.unpack('BB', struct.pack('H', 0x0100))[0] if self.big_endian: @@ -204,7 +204,7 @@ def next_event(self): while not self.event_queue: - # Lock send_recv so no send_and_recieve + # Lock send_recv so no send_and_receive # can start or stop while we're checking # whether there are one active. self.send_recv_lock.acquire() @@ -400,7 +400,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) be true. Will return immediately if another thread is already doing send_and_recv. - To wait for an event to be recieved, event should be true. + To wait for an event to be received, event should be true. To wait for a response to a certain request (either an error or a response), request should be set the that request's @@ -561,7 +561,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) rs, ws, es = select.select([self.socket], writeset, [], timeout) - # Ignore errors caused by a signal recieved while blocking. + # Ignore errors caused by a signal received while blocking. # All other errors are re-raised. except select.error as err: if isinstance(err, OSError): @@ -627,7 +627,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) # There are three different end of send-recv-loop conditions. # However, we don't leave the loop immediately, instead we - # try to send and recieve any data that might be left. We + # try to send and receive any data that might be left. We # do this by giving a timeout of 0 to select to poll # the socket. @@ -643,7 +643,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) if request is not None and gotreq: break - # Always break if we just want to recieve as much as possible + # Always break if we just want to receive as much as possible if recv: break @@ -678,9 +678,9 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) def parse_response(self, request): """Internal method. - Parse data recieved from server. If REQUEST is not None + Parse data received from server. If REQUEST is not None true is returned if the request with that serial number - was recieved, otherwise false is returned. + was received, otherwise false is returned. If REQUEST is -1, we're parsing the server connection setup response. @@ -711,11 +711,11 @@ def parse_response(self, request): raise AssertionError(rtype) # Every response is at least 32 bytes long, so don't bother - # until we have recieved that much + # until we have received that much if len(self.data_recv) < 32: return gotreq - # Error resposne + # Error response if rtype == 0: gotreq = self.parse_error_response(request) or gotreq diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 296e44c1..f4c1399d 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -1058,7 +1058,7 @@ def to_binary(self, *varargs, **keys): pack_items.append(field_args[f.name]) # Multivalue field. Handled like single valuefield, - # but the value are tuple unpacked into seperate arguments + # but the value are tuple unpacked into separate arguments # which are appended to pack_items else: if f.check_value is not None: diff --git a/Xlib/rdb.py b/Xlib/rdb.py index 21ef5622..03b06e2a 100644 --- a/Xlib/rdb.py +++ b/Xlib/rdb.py @@ -699,7 +699,7 @@ def get_display_opts(options, argv = sys.argv): # the resource object. # Example: Inserting "foo.bar*gazonk: yep" into an otherwise empty -# resource database would give the folliwing structure: +# resource database would give the following structure: # { 'foo': ( { 'bar': ( { }, # { 'gazonk': ( { }, diff --git a/debian/rules b/debian/rules index 9bc7713d..dd820f18 100644 --- a/debian/rules +++ b/debian/rules @@ -7,7 +7,7 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -# This is the debhelper compatability version to use. +# This is the debhelper compatibility version to use. export DH_COMPAT=1 build: build-stamp diff --git a/doc/src/errors.texi b/doc/src/errors.texi index 2a9a700d..a76ce316 100644 --- a/doc/src/errors.texi +++ b/doc/src/errors.texi @@ -142,7 +142,7 @@ Forget any caught error. Since the X protocol is mostly asynchronous any error we're watching for -might not have been recieved when we call @code{get_error}. To make +might not have been received when we call @code{get_error}. To make sure that the request has been processed by the server and any error generated has been received by the Xlib, we must synchronize with the server. diff --git a/doc/src/events.texi b/doc/src/events.texi index 035a5220..ba678ffd 100644 --- a/doc/src/events.texi +++ b/doc/src/events.texi @@ -22,7 +22,7 @@ typically by doing one or more X requests. @section Getting Events Events can be sent at any time, not necessarily when the client is ready -to recieve an event. Therefore they must be stored temporarily from that +to receive an event. Therefore they must be stored temporarily from that they are read from the network until the client is ready to handle them. Read but unhandled events are stored on an event queue in the Display object. There are two functions to access this queue: @@ -72,7 +72,7 @@ while 1: if not readable: handle_timeout() - # if display is readable, handle as many events as have been recieved + # if display is readable, handle as many events as have been received elif disp in readable: i = disp.pending_events() while i > 0: diff --git a/doc/src/objects.texi b/doc/src/objects.texi index f970c370..6d47137a 100644 --- a/doc/src/objects.texi +++ b/doc/src/objects.texi @@ -475,7 +475,7 @@ The name of the font. @itemx font_ascent @itemx font_descent @itemx replies_hint -See the descripton of XFontStruct in XGetFontProperty(3X11) for details +See the description of XFontStruct in XGetFontProperty(3X11) for details on these values. @item properties diff --git a/examples/get_selection.py b/examples/get_selection.py index 79ea739f..b249c027 100755 --- a/examples/get_selection.py +++ b/examples/get_selection.py @@ -83,7 +83,7 @@ def main(): # since we don't have an event here we have to. w.convert_selection(sel_atom, target_atom, data_atom, X.CurrentTime) - # Wait for the notificiaton that we got the selection + # Wait for the notification that we got the selection while True: e = d.next_event() if e.type == X.SelectionNotify: From afc5bb3c5aba0742275a27e57aaa962fec128873 Mon Sep 17 00:00:00 2001 From: hbregalad Date: Sat, 11 Aug 2018 09:02:20 -0400 Subject: [PATCH 186/279] Update xfixes.py xfixes_hide_cursor() called twice, changed second call to xfixes_show_cursor() --- examples/xfixes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/xfixes.py b/examples/xfixes.py index a7fc06ba..53c37146 100755 --- a/examples/xfixes.py +++ b/examples/xfixes.py @@ -58,7 +58,7 @@ def main(argv): time.sleep(5) print('Showing cursor ...', file=sys.stderr) - screen.root.xfixes_hide_cursor() + screen.root.xfixes_show_cursor() display.sync() From 859f50d4933dc0c96742dc5db4994be7a842b216 Mon Sep 17 00:00:00 2001 From: Joseph Kogut Date: Fri, 5 Oct 2018 08:42:06 -0700 Subject: [PATCH 187/279] ext: composite: set default client version --- Xlib/ext/composite.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Xlib/ext/composite.py b/Xlib/ext/composite.py index be1fac76..464ddd9c 100644 --- a/Xlib/ext/composite.py +++ b/Xlib/ext/composite.py @@ -65,6 +65,8 @@ def query_version(self): return QueryVersion( display = self.display, opcode = self.display.get_extension_major(extname), + major_version=0, + minor_version=4 ) From 0aa0acde181667cc7e3b40d8d0ebc9202ed686f7 Mon Sep 17 00:00:00 2001 From: Joseph Kogut Date: Tue, 9 Oct 2018 09:37:12 -0700 Subject: [PATCH 188/279] ext: composite: add error handlers --- Xlib/ext/composite.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Xlib/ext/composite.py b/Xlib/ext/composite.py index be1fac76..1533d36b 100644 --- a/Xlib/ext/composite.py +++ b/Xlib/ext/composite.py @@ -78,11 +78,12 @@ class RedirectWindow(rq.Request): rq.Pad(3), ) -def redirect_window(self, update): +def redirect_window(self, update, onerror = None): """Redirect the hierarchy starting at this window to off-screen storage. """ RedirectWindow(display = self.display, + onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, @@ -99,11 +100,12 @@ class RedirectSubwindows(rq.Request): rq.Pad(3), ) -def redirect_subwindows(self, update): +def redirect_subwindows(self, update, onerror = None): """Redirect the hierarchies starting at all current and future children to this window to off-screen storage. """ RedirectSubwindows(display = self.display, + onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, @@ -120,10 +122,11 @@ class UnredirectWindow(rq.Request): rq.Pad(3), ) -def unredirect_window(self, update): +def unredirect_window(self, update, onerror = None): """Stop redirecting this window hierarchy. """ UnredirectWindow(display = self.display, + onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, @@ -140,10 +143,11 @@ class UnredirectSubindows(rq.Request): rq.Pad(3), ) -def unredirect_subwindows(self, update): +def unredirect_subwindows(self, update, onerror = None): """Stop redirecting the hierarchies of children to this window. """ RedirectWindow(display = self.display, + onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, @@ -159,7 +163,7 @@ class CreateRegionFromBorderClip(rq.Request): rq.Window('window'), ) -def create_region_from_border_clip(self): +def create_region_from_border_clip(self, onerror = None): """Create a region of the border clip of the window, i.e. the area that is not clipped by the parent and any sibling windows. """ @@ -167,6 +171,7 @@ def create_region_from_border_clip(self): rid = self.display.allocate_resource_id() CreateRegionFromBorderClip( display = self.display, + onerror = onerror, opcode = self.display.get_extension_major(extname), region = rid, window = self, @@ -185,7 +190,7 @@ class NameWindowPixmap(rq.Request): rq.Pixmap('pixmap'), ) -def name_window_pixmap(self): +def name_window_pixmap(self, onerror = None): """Create a new pixmap that refers to the off-screen storage of the window, including its border. @@ -198,6 +203,7 @@ def name_window_pixmap(self): pid = self.display.allocate_resource_id() NameWindowPixmap(display = self.display, + onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, pixmap = pid, From cfaf9ede7455aa75a152ac74c24ff1738b318c89 Mon Sep 17 00:00:00 2001 From: Joseph Kogut Date: Fri, 5 Oct 2018 08:42:35 -0700 Subject: [PATCH 189/279] ext: create damage client extension --- Xlib/ext/__init__.py | 1 + Xlib/ext/damage.py | 186 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 Xlib/ext/damage.py diff --git a/Xlib/ext/__init__.py b/Xlib/ext/__init__.py index 4ba62f8e..15193d7e 100644 --- a/Xlib/ext/__init__.py +++ b/Xlib/ext/__init__.py @@ -36,6 +36,7 @@ ('XFIXES', 'xfixes'), ('SECURITY', 'security'), ('XInputExtension', 'xinput'), + ('DAMAGE', 'damage'), ] __all__ = map(lambda x: x[1], __extensions__) diff --git a/Xlib/ext/damage.py b/Xlib/ext/damage.py new file mode 100644 index 00000000..eeb7340b --- /dev/null +++ b/Xlib/ext/damage.py @@ -0,0 +1,186 @@ +# Xlib.ext.damage -- DAMAGE extension module +# +# Copyright (C) 2018 Joseph Kogut +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA + + +from Xlib import X +from Xlib.protocol import rq, structs +from Xlib.xobject import resource +from Xlib.error import XError + +extname = 'DAMAGE' + +# Event codes # +DamageNotifyCode = 0 + +# Error codes # +BadDamageCode = 0 + +class BadDamageError(XError): + pass + +# DamageReportLevel options +DamageReportRawRectangles = 0 +DamageReportDeltaRectangles = 1 +DamageReportBoundingBox = 2 +DamageReportNonEmpty = 3 + +DamageReportLevel = ( + DamageReportRawRectangles, + DamageReportDeltaRectangles, + DamageReportBoundingBox, + DamageReportNonEmpty, +) + +DAMAGE = rq.Card32 + +# Methods + +class QueryVersion(rq.ReplyRequest): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(0), + rq.RequestLength(), + rq.Card32('major_version'), + rq.Card32('minor_version'), + ) + + _reply = rq.Struct(rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('major_version'), + rq.Card32('minor_version'), + rq.Pad(16), + ) + +def query_version(self): + return QueryVersion(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + +class DamageCreate(rq.Request): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(1), + rq.RequestLength(), + DAMAGE('damage'), + rq.Drawable('drawable'), + rq.Set('level', 1, DamageReportLevel), + rq.Pad(3), + ) + +def damage_create(self, level): + did = self.display.allocate_resource_id() + DamageCreate(display=self.display, + opcode=self.display.get_extension_major(extname), + damage=did, + drawable=self.id, + level=level, + ) + print('damage create') + return did + +class DamageDestroy(rq.Request): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(2), + rq.RequestLength(), + DAMAGE('damage') + ) + +def damage_destroy(self, damage): + DamageDestroy(display=self.display, + opcode=self.display.get_extension_major(extname), + damage=damage, + ) + + self.display.free_resource_id(damage) + print('damage destroy') + +class DamageSubtract(rq.Request): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(3), + rq.RequestLength(), + DAMAGE('damage'), + rq.Card32('repair'), + rq.Card32('parts') + ) + +def damage_subtract(self, damage, repair=X.NONE, parts=X.NONE): + DamageSubtract(display=self.display, + opcode=self.display.get_extension_major(extname), + damage=damage, + repair=repair, + parts=parts) + print('damage subtract') + +class DamageAdd(rq.Request): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(4), + rq.RequestLength(), + rq.Card32('repair'), + rq.Card32('parts'), + ) + +def damage_add(self, repair, parts): + DamageAdd(display=self.display, + opcode=self.display.get_extension_major(extname), + repair=repair, + parts=parts) + print('damage add') + +# Events # + +class DamageNotify(rq.Event): + _code = None + _fields = rq.Struct( + rq.Card8('type'), + rq.Card8('level'), + rq.Card16('sequence_number'), + rq.Drawable('drawable'), + DAMAGE('damage'), + rq.Card32('timestamp'), + rq.Object('area', structs.Rectangle), + rq.Object('drawable_geometry', structs.Rectangle) + ) + +def init(disp, info): + disp.extension_add_method('display', + 'damage_query_version', + query_version) + + disp.extension_add_method('drawable', + 'damage_create', + damage_create) + + disp.extension_add_method('display', + 'damage_destroy', + damage_destroy) + + disp.extension_add_method('display', + 'damage_subtract', + damage_subtract) + + disp.extension_add_method('drawable', + 'damage_add', + damage_add) + + disp.extension_add_event(info.first_event + DamageNotifyCode, DamageNotify) + + disp.add_extension_error(code=BadDamageCode, err=BadDamageError) From a7553472c10839eaa50fa9505bfc447789d16de1 Mon Sep 17 00:00:00 2001 From: gpatel-fr <44170243+gpatel-fr@users.noreply.github.com> Date: Sat, 1 Dec 2018 15:47:05 +0100 Subject: [PATCH 190/279] fix python3 crash with sample at http://rosettacode.org/wiki/Window_creation/X11#Xlib_2 --- Xlib/protocol/rq.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index f4c1399d..24042176 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -1221,7 +1221,7 @@ def pack_value(self, value): for v in value: # Let values be simple strings, meaning a delta of 0 - if type(v) is bytes: + if type(v) in (str, bytes): v = (0, v) # A tuple, it should be (delta, string) @@ -1230,19 +1230,19 @@ def pack_value(self, value): if isinstance(v, (tuple, dict, DictWrapper)): if isinstance(v, tuple): - delta, str = v + delta, m_str = v else: delta = v['delta'] - str = v['string'] + m_str = v['string'] - while delta or str: + while delta or m_str: args['delta'] = delta - args['string'] = str[:254] + args['string'] = m_str[:254] data = data + self.string_textitem.to_binary(*(), **args) delta = 0 - str = str[254:] + m_str = m_str[254:] # Else an integer, i.e. a font change else: From 919cdc1960266f0ed87967601aadf83cd34910b0 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 27 Jan 2019 14:33:49 +0100 Subject: [PATCH 191/279] update news --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8d4db6c..9fae403f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ NEWS for Python X Library +Version 0.24 +============ + +Bug Fixes +--------- + +- fix protocol handling: correctly support explicit Unix + connections and fix support fox macOS +- improve Python 3 support: fix events sub-code handling + and possible crashes when unpacking text data +- add support for error handlers to the Composite extension + +Misc +---- + +- fix `xfixes` example +- fix a bunch of typos in the code / documentation + +--- Version 0.23 ============ From a8df10702393fd055432f00aa433def71597f655 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 27 Jan 2019 17:06:10 +0100 Subject: [PATCH 192/279] release 0.24 --- Xlib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 042f1df0..c290d9ad 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 23) +__version__ = (0, 24) __version_extra__ = '' From 85ecd6bb759b1cabcb6e5132b7fb62f0df80daef Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 19:21:43 +0100 Subject: [PATCH 193/279] NV-CONTROL: query/set integer plus query string --- Xlib/ext/__init__.py | 1 + Xlib/ext/nvcontrol.py | 5188 +++++++++++++++++++++++++++++++++++++++++ examples/nvcontrol.py | 91 + 3 files changed, 5280 insertions(+) create mode 100644 Xlib/ext/nvcontrol.py create mode 100755 examples/nvcontrol.py diff --git a/Xlib/ext/__init__.py b/Xlib/ext/__init__.py index 4ba62f8e..e9fb0ee0 100644 --- a/Xlib/ext/__init__.py +++ b/Xlib/ext/__init__.py @@ -36,6 +36,7 @@ ('XFIXES', 'xfixes'), ('SECURITY', 'security'), ('XInputExtension', 'xinput'), + ('NV-CONTROL', 'nvcontrol'), ] __all__ = map(lambda x: x[1], __extensions__) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py new file mode 100644 index 00000000..9f8d45cc --- /dev/null +++ b/Xlib/ext/nvcontrol.py @@ -0,0 +1,5188 @@ +# Xlib.ext.nvcontrol -- NV-CONTROL extension module +# +# Copyright (C) 2019 Roberto Leinardi +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA + + +"""NV-CONTROL - provide access to the NV-CONTROL extension information.""" + +from Xlib.protocol import rq + +extname = 'NV-CONTROL' + + +def query_int_attribute(self, target, displays, attr): + """return the value of an integer attribute""" + display_mask = _displays2mask(displays) + reply = NVCtrlQueryAttributeRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_id=target.id(), + target_type=target.type(), + display_mask=display_mask, + attr=attr) + if not reply._data.get('flags'): + return None + return int(reply._data.get('value')) + + +def set_int_attribute(self, target, displays, attr, value): + """return the value of an integer attribute""" + display_mask = _displays2mask(displays) + reply = NVCtrlSetAttributeAndGetStatusRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_id=target.id(), + target_type=target.type(), + display_mask=display_mask, + attr=attr, + value=value) + return reply._data.get('flags') + + +def set_cooler_manual_control_enabled(self, target, enabled): + return set_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL, 1 if enabled else 0) == 1 + + +def query_string_attribute(self, target, displays, attr): + """return the value of an integer attribute""" + display_mask = _displays2mask(displays) + reply = NVCtrlQueryStringAttributeRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_id=target.id(), + target_type=target.type(), + display_mask=display_mask, + attr=attr) + if not reply._data.get('flags'): + return None + return str(reply._data.get('string')).strip('\0') + + +def get_name(self, target): + """the GPU product name on which the specified X screen is running""" + return query_string_attribute(self, target, [], NV_CTRL_STRING_PRODUCT_NAME) + + +def get_driver_version(self, target): + """the NVIDIA (kernel level) driver version for the specified screen or GPU""" + return query_string_attribute(self, target, [], NV_CTRL_STRING_NVIDIA_DRIVER_VERSION) + + +def get_vbios_version(self, target): + """the version of the VBIOS for the specified screen or GPU""" + return query_string_attribute(self, target, [], NV_CTRL_STRING_VBIOS_VERSION) + + +def get_gpu_uuid(self, target): + return query_string_attribute(self, target, [], NV_CTRL_STRING_GPU_UUID) + + +def get_gpu_utilization(self, target): + return query_string_attribute(self, target, [], NV_CTRL_STRING_GPU_UTILIZATION) + + +def get_performance_modes(self, target): + return query_string_attribute(self, target, [], NV_CTRL_STRING_PERFORMANCE_MODES) + + +def get_vram(self, target): + return query_int_attribute(self, target, [], NV_CTRL_VIDEO_RAM) + + +def get_irq(self, target): + """Return the interrupt request line used by the GPU driving the screen""" + return query_int_attribute(self, target, [], NV_CTRL_IRQ) + + +def supports_framelock(self, target): + """returns whether the underlying GPU supports Frame Lock. All of the + other frame lock attributes are only applicable if this returns True.""" + return query_int_attribute(self, target, [], NV_CTRL_FRAMELOCK) == 1 + + +def gvo_supported(self, screen): + """returns whether this X screen supports GVO; if this screen does not + support GVO output, then all other GVO attributes are unavailable.""" + return query_int_attribute(self, screen, [], NV_CTRL_GVO_SUPPORTED) + + +def get_core_temp(self, target): + """return the current core temperature of the GPU driving the X screen.""" + return query_int_attribute(self, target, [], NV_CTRL_GPU_CORE_TEMPERATURE) + + +def get_core_threshold(self, target): + """return the current GPU core slowdown threshold temperature. It + reflects the temperature at which the GPU is throttled to prevent + overheating.""" + return query_int_attribute(self, target, [], NV_CTRL_GPU_CORE_THRESHOLD) + + +def get_default_core_threshold(self, target): + """return the default core threshold temperature.""" + return query_int_attribute(self, target, [], NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD) + + +def get_max_core_threshold(self, target): + """return the maximum core threshold temperature.""" + return query_int_attribute(self, target, [], NV_CTRL_GPU_MAX_CORE_THRESHOLD) + + +def get_ambient_temp(self, target): + """return the current temperature in the immediate neighbourhood of + the GPU driving the X screen.""" + return query_int_attribute(self, target, [], NV_CTRL_AMBIENT_TEMPERATURE) + + +def get_cuda_cores(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_CORES) + + +def get_memory_bus_width(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_MEMORY_BUS_WIDTH) + + +def get_total_dedicated_gpu_memory(self, target): + return query_int_attribute(self, target, [], NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY) + + +def get_used_dedicated_gpu_memory(self, target): + return query_int_attribute(self, target, [], NV_CTRL_USED_DEDICATED_GPU_MEMORY) + + +def get_pcie_current_link_width(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH) + + +def get_pcie_max_link_width(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH) + + +def get_pcie_generation(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_PCIE_GENERATION) + + +def get_video_encoder_utilization(self, target): + return query_int_attribute(self, target, [], NV_CTRL_VIDEO_ENCODER_UTILIZATION) + + +def get_video_decoder_utilization(self, target): + return query_int_attribute(self, target, [], NV_CTRL_VIDEO_DECODER_UTILIZATION) + + +def get_current_performance_level(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL) + + +def get_gpu_nvclock_offset(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_NVCLOCK_OFFSET) + + +def get_mem_transfer_rate_offset(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) + + +def get_cooler_manual_control_enabled(self, target): + return query_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL) == 1 + + +def get_fan_duty(self, target): + return query_int_attribute(self, target, [], NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL) + + +def get_fan_rpm(self, target): + return query_int_attribute(self, target, [], NV_CTRL_THERMAL_COOLER_SPEED) + + +def get_max_displays(self, target): + """return the maximum number of display devices that can be driven + simultaneously on a GPU (e.g., that can be used in a MetaMode at once). + Note that this does not indicate the maximum number of bits that can be + set in NV_CTRL_CONNECTED_DISPLAYS, because more display devices can be + connected than are actively in use.""" + return query_int_attribute(self, target, [], NV_CTRL_MAX_DISPLAYS) + + +# def get_connected_displays(self, target): +# """Return an array with connected display numbers""" +# return query_int_attribute(self, target, [], NV_CTRL_CONNECTED_DISPLAYS) +# +# +# def get_enabled_displays(self, target): +# """returns an array of displays that are enabled on the specified X +# screen or GPU.""" +# return query_int_attribute(self, target, [], NV_CTRL_ENABLED_DISPLAYS) + +# def get_current_clocks(self, target): +# """return the current (GPU, memory) clocks of the graphics device +# driving the X screen.""" +# return query_int_attribute(self, target, [], NV_CTRL_GPU_CURRENT_CLOCK_FREQS) + +def _displaystr2num(st): + """return a display number from a string""" + num = None + for s, n in [('DFP-', 16), ('TV-', 8), ('CRT-', 0)]: + if st.startswith(s): + try: + curnum = int(st[len(s):]) + if 0 <= curnum <= 7: + num = n + curnum + break + except Exception: + pass + if num is not None: + return num + else: + raise ValueError('Unrecognised display name: ' + st) + + +def _displays2mask(displays): + """return a display mask from an array of display numbers.""" + mask = 0 + for d in displays: + mask += (1 << _displaystr2num(d)) + return mask + + +def init(disp, info): + disp.extension_add_method('display', 'nvcontrol_query_int_attribute', query_int_attribute) + disp.extension_add_method('display', 'nvcontrol_query_string_attribute', query_string_attribute) + disp.extension_add_method('display', 'nvcontrol_get_vram', get_vram) + disp.extension_add_method('display', 'nvcontrol_get_irq', get_irq) + disp.extension_add_method('display', 'nvcontrol_supports_framelock', supports_framelock) + disp.extension_add_method('display', 'nvcontrol_get_core_temp', get_core_temp) + disp.extension_add_method('display', 'nvcontrol_get_core_threshold', get_core_threshold) + disp.extension_add_method('display', 'nvcontrol_get_default_core_threshold', get_default_core_threshold) + disp.extension_add_method('display', 'nvcontrol_get_max_core_threshold', get_max_core_threshold) + disp.extension_add_method('display', 'nvcontrol_get_ambient_temp', get_ambient_temp) + disp.extension_add_method('display', 'nvcontrol_get_cuda_cores', get_cuda_cores) + disp.extension_add_method('display', 'nvcontrol_get_memory_bus_width', get_memory_bus_width) + disp.extension_add_method('display', 'nvcontrol_get_total_dedicated_gpu_memory', get_total_dedicated_gpu_memory) + disp.extension_add_method('display', 'nvcontrol_get_used_dedicated_gpu_memory', get_used_dedicated_gpu_memory) + disp.extension_add_method('display', 'nvcontrol_get_pcie_current_link_width', get_pcie_current_link_width) + disp.extension_add_method('display', 'nvcontrol_get_pcie_max_link_width', get_pcie_max_link_width) + disp.extension_add_method('display', 'nvcontrol_get_pcie_generation', get_pcie_generation) + disp.extension_add_method('display', 'nvcontrol_get_video_encoder_utilization', get_video_encoder_utilization) + disp.extension_add_method('display', 'nvcontrol_get_video_decoder_utilization', get_video_decoder_utilization) + disp.extension_add_method('display', 'nvcontrol_get_current_performance_level', get_current_performance_level) + disp.extension_add_method('display', 'nvcontrol_get_gpu_nvclock_offset', get_gpu_nvclock_offset) + disp.extension_add_method('display', 'nvcontrol_get_mem_transfer_rate_offset', get_mem_transfer_rate_offset) + disp.extension_add_method('display', 'nvcontrol_get_cooler_manual_control_enabled', + get_cooler_manual_control_enabled) + disp.extension_add_method('display', 'nvcontrol_get_fan_duty', get_fan_duty) + disp.extension_add_method('display', 'nvcontrol_get_fan_rpm', get_fan_rpm) + disp.extension_add_method('display', 'nvcontrol_get_max_displays', get_max_displays) + disp.extension_add_method('display', 'nvcontrol_get_name', get_name) + disp.extension_add_method('display', 'nvcontrol_get_driver_version', get_driver_version) + disp.extension_add_method('display', 'nvcontrol_get_vbios_version', get_vbios_version) + disp.extension_add_method('display', 'nvcontrol_get_gpu_uuid', get_gpu_uuid) + disp.extension_add_method('display', 'nvcontrol_get_gpu_utilization', get_gpu_utilization) + disp.extension_add_method('display', 'nvcontrol_get_performance_modes', get_performance_modes) + disp.extension_add_method('display', 'nvcontrol_set_cooler_manual_control_enabled', + set_cooler_manual_control_enabled) + + +############################################################################ +# +# Attributes +# +# Some attributes may only be read; some may require a display_mask +# argument and others may be valid only for specific target types. +# This information is encoded in the "permission" comment after each +# attribute #define, and can be queried at run time with +# XNVCTRLQueryValidAttributeValues() and/or +# XNVCTRLQueryValidTargetAttributeValues() +# +# Key to Integer Attribute "Permissions": +# +# R: The attribute is readable (in general, all attributes will be +# readable) +# +# W: The attribute is writable (attributes may not be writable for +# various reasons: they represent static system information, they +# can only be changed by changing an XF86Config option, etc). +# +# D: The attribute requires the display mask argument. The +# attributes NV_CTRL_CONNECTED_DISPLAYS and NV_CTRL_ENABLED_DISPLAYS +# will be a bitmask of what display devices are connected and what +# display devices are enabled for use in X, respectively. Each bit +# in the bitmask represents a display device; it is these bits which +# should be used as the display_mask when dealing with attributes +# designated with "D" below. For attributes that do not require the +# display mask, the argument is ignored. +# +# Alternatively, NV-CONTROL versions 1.27 and greater allow these +# attributes to be accessed via display target types, in which case +# the display_mask is ignored. +# +# G: The attribute may be queried using an NV_CTRL_TARGET_TYPE_GPU +# target type via XNVCTRLQueryTargetAttribute(). +# +# F: The attribute may be queried using an NV_CTRL_TARGET_TYPE_FRAMELOCK +# target type via XNVCTRLQueryTargetAttribute(). +# +# X: When Xinerama is enabled, this attribute is kept consistent across +# all Physical X Screens; assignment of this attribute will be +# broadcast by the NVIDIA X Driver to all X Screens. +# +# V: The attribute may be queried using an NV_CTRL_TARGET_TYPE_VCSC +# target type via XNVCTRLQueryTargetAttribute(). +# +# I: The attribute may be queried using an NV_CTRL_TARGET_TYPE_GVI target type +# via XNVCTRLQueryTargetAttribute(). +# +# Q: The attribute is a 64-bit integer attribute; use the 64-bit versions +# of the appropriate query interfaces. +# +# C: The attribute may be queried using an NV_CTRL_TARGET_TYPE_COOLER target +# type via XNVCTRLQueryTargetAttribute(). +# +# S: The attribute may be queried using an NV_CTRL_TARGET_TYPE_THERMAL_SENSOR +# target type via XNVCTRLQueryTargetAttribute(). +# +# T: The attribute may be queried using an +# NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER target type +# via XNVCTRLQueryTargetAttribute(). +# +# NOTE: Unless mentioned otherwise, all attributes may be queried using +# an NV_CTRL_TARGET_TYPE_X_SCREEN target type via +# XNVCTRLQueryTargetAttribute(). +# + + +############################################################################ + +# +# Integer attributes: +# +# Integer attributes can be queried through the XNVCTRLQueryAttribute() and +# XNVCTRLQueryTargetAttribute() function calls. +# +# Integer attributes can be set through the XNVCTRLSetAttribute() and +# XNVCTRLSetTargetAttribute() function calls. +# +# Unless otherwise noted, all integer attributes can be queried/set +# using an NV_CTRL_TARGET_TYPE_X_SCREEN target. Attributes that cannot +# take an NV_CTRL_TARGET_TYPE_X_SCREEN also cannot be queried/set through +# XNVCTRLQueryAttribute()/XNVCTRLSetAttribute() (Since these assume +# an X Screen target). +# + + +# +# NV_CTRL_FLATPANEL_SCALING - not supported +# + +NV_CTRL_FLATPANEL_SCALING = 2 # not supported +NV_CTRL_FLATPANEL_SCALING_DEFAULT = 0 # not supported +NV_CTRL_FLATPANEL_SCALING_NATIVE = 1 # not supported +NV_CTRL_FLATPANEL_SCALING_SCALED = 2 # not supported +NV_CTRL_FLATPANEL_SCALING_CENTERED = 3 # not supported +NV_CTRL_FLATPANEL_SCALING_ASPECT_SCALED = 4 # not supported + +# +# NV_CTRL_FLATPANEL_DITHERING - not supported +# +# NV_CTRL_DITHERING should be used instead. +# + +NV_CTRL_FLATPANEL_DITHERING = 3 # not supported +NV_CTRL_FLATPANEL_DITHERING_DEFAULT = 0 # not supported +NV_CTRL_FLATPANEL_DITHERING_ENABLED = 1 # not supported +NV_CTRL_FLATPANEL_DITHERING_DISABLED = 2 # not supported + +# +# NV_CTRL_DITHERING - the requested dithering configuration; +# possible values are: +# +# 0: auto (the driver will decide when to dither) +# 1: enabled (the driver will always dither when possible) +# 2: disabled (the driver will never dither) +# + +NV_CTRL_DITHERING = 3 # RWDG +NV_CTRL_DITHERING_AUTO = 0 +NV_CTRL_DITHERING_ENABLED = 1 +NV_CTRL_DITHERING_DISABLED = 2 + +# +# NV_CTRL_DIGITAL_VIBRANCE - sets the digital vibrance level for the +# specified display device. +# + +NV_CTRL_DIGITAL_VIBRANCE = 4 # RWDG + +# +# NV_CTRL_BUS_TYPE - returns the bus type through which the specified device +# is connected to the computer. +# When this attribute is queried on an X screen target, the bus type of the +# GPU driving the X screen is returned. +# + +NV_CTRL_BUS_TYPE = 5 # R--GI +NV_CTRL_BUS_TYPE_AGP = 0 +NV_CTRL_BUS_TYPE_PCI = 1 +NV_CTRL_BUS_TYPE_PCI_EXPRESS = 2 +NV_CTRL_BUS_TYPE_INTEGRATED = 3 + +# +# NV_CTRL_TOTAL_GPU_MEMORY - returns the total amount of memory available +# to the specified GPU (or the GPU driving the specified X +# screen). Note: if the GPU supports TurboCache(TM), the value +# reported may exceed the amount of video memory installed on the +# GPU. The value reported for integrated GPUs may likewise exceed +# the amount of dedicated system memory set aside by the system +# BIOS for use by the integrated GPU. +# + +NV_CTRL_TOTAL_GPU_MEMORY = 6 # R--G +NV_CTRL_VIDEO_RAM = NV_CTRL_TOTAL_GPU_MEMORY + +# +# NV_CTRL_IRQ - returns the interrupt request line used by the specified +# device. +# When this attribute is queried on an X screen target, the IRQ of the GPU +# driving the X screen is returned. +# + +NV_CTRL_IRQ = 7 # R--GI + +# +# NV_CTRL_OPERATING_SYSTEM - returns the operating system on which +# the X server is running. +# + +NV_CTRL_OPERATING_SYSTEM = 8 # R--G +NV_CTRL_OPERATING_SYSTEM_LINUX = 0 +NV_CTRL_OPERATING_SYSTEM_FREEBSD = 1 +NV_CTRL_OPERATING_SYSTEM_SUNOS = 2 + +# +# NV_CTRL_SYNC_TO_VBLANK - enables sync to vblank for OpenGL clients. +# This setting is only applied to OpenGL clients that are started +# after this setting is applied. +# + +NV_CTRL_SYNC_TO_VBLANK = 9 # RW-X +NV_CTRL_SYNC_TO_VBLANK_OFF = 0 +NV_CTRL_SYNC_TO_VBLANK_ON = 1 + +# +# NV_CTRL_LOG_ANISO - enables anisotropic filtering for OpenGL +# clients; on some NVIDIA hardware, this can only be enabled or +# disabled; on other hardware different levels of anisotropic +# filtering can be specified. This setting is only applied to OpenGL +# clients that are started after this setting is applied. +# + +NV_CTRL_LOG_ANISO = 10 # RW-X + +# +# NV_CTRL_FSAA_MODE - the FSAA setting for OpenGL clients; possible +# FSAA modes: +# +# NV_CTRL_FSAA_MODE_2x "2x Bilinear Multisampling" +# NV_CTRL_FSAA_MODE_2x_5t "2x Quincunx Multisampling" +# NV_CTRL_FSAA_MODE_15x15 "1.5 x 1.5 Supersampling" +# NV_CTRL_FSAA_MODE_2x2 "2 x 2 Supersampling" +# NV_CTRL_FSAA_MODE_4x "4x Bilinear Multisampling" +# NV_CTRL_FSAA_MODE_4x_9t "4x Gaussian Multisampling" +# NV_CTRL_FSAA_MODE_8x "2x Bilinear Multisampling by 4x Supersampling" +# NV_CTRL_FSAA_MODE_16x "4x Bilinear Multisampling by 4x Supersampling" +# NV_CTRL_FSAA_MODE_8xS "4x Multisampling by 2x Supersampling" +# +# This setting is only applied to OpenGL clients that are started +# after this setting is applied. +# + +NV_CTRL_FSAA_MODE = 11 # RW-X +NV_CTRL_FSAA_MODE_NONE = 0 +NV_CTRL_FSAA_MODE_2x = 1 +NV_CTRL_FSAA_MODE_2x_5t = 2 +NV_CTRL_FSAA_MODE_15x15 = 3 +NV_CTRL_FSAA_MODE_2x2 = 4 +NV_CTRL_FSAA_MODE_4x = 5 +NV_CTRL_FSAA_MODE_4x_9t = 6 +NV_CTRL_FSAA_MODE_8x = 7 +NV_CTRL_FSAA_MODE_16x = 8 +NV_CTRL_FSAA_MODE_8xS = 9 +NV_CTRL_FSAA_MODE_8xQ = 10 +NV_CTRL_FSAA_MODE_16xS = 11 +NV_CTRL_FSAA_MODE_16xQ = 12 +NV_CTRL_FSAA_MODE_32xS = 13 +NV_CTRL_FSAA_MODE_32x = 14 +NV_CTRL_FSAA_MODE_64xS = 15 +NV_CTRL_FSAA_MODE_MAX = NV_CTRL_FSAA_MODE_64xS + +# +# NV_CTRL_UBB - returns whether UBB is enabled for the specified X +# screen. +# + +NV_CTRL_UBB = 13 # R-- +NV_CTRL_UBB_OFF = 0 +NV_CTRL_UBB_ON = 1 + +# +# NV_CTRL_OVERLAY - returns whether the RGB overlay is enabled for +# the specified X screen. +# + +NV_CTRL_OVERLAY = 14 # R-- +NV_CTRL_OVERLAY_OFF = 0 +NV_CTRL_OVERLAY_ON = 1 + +# +# NV_CTRL_STEREO - returns whether stereo (and what type) is enabled +# for the specified X screen. +# + +NV_CTRL_STEREO = 16 # R-- +NV_CTRL_STEREO_OFF = 0 +NV_CTRL_STEREO_DDC = 1 +NV_CTRL_STEREO_BLUELINE = 2 +NV_CTRL_STEREO_DIN = 3 +NV_CTRL_STEREO_PASSIVE_EYE_PER_DPY = 4 +NV_CTRL_STEREO_VERTICAL_INTERLACED = 5 +NV_CTRL_STEREO_COLOR_INTERLACED = 6 +NV_CTRL_STEREO_HORIZONTAL_INTERLACED = 7 +NV_CTRL_STEREO_CHECKERBOARD_PATTERN = 8 +NV_CTRL_STEREO_INVERSE_CHECKERBOARD_PATTERN = 9 +NV_CTRL_STEREO_3D_VISION = 10 +NV_CTRL_STEREO_3D_VISION_PRO = 11 +NV_CTRL_STEREO_HDMI_3D = 12 +NV_CTRL_STEREO_TRIDELITY_SL = 13 +NV_CTRL_STEREO_INBAND_STEREO_SIGNALING = 14 +NV_CTRL_STEREO_MAX = NV_CTRL_STEREO_INBAND_STEREO_SIGNALING + +# +# NV_CTRL_EMULATE - not supported +# + +NV_CTRL_EMULATE = 17 # not supported +NV_CTRL_EMULATE_NONE = 0 # not supported + +# +# NV_CTRL_TWINVIEW - returns whether TwinView is enabled for the +# specified X screen. +# + +NV_CTRL_TWINVIEW = 18 # R-- +NV_CTRL_TWINVIEW_NOT_ENABLED = 0 +NV_CTRL_TWINVIEW_ENABLED = 1 + +# +# NV_CTRL_CONNECTED_DISPLAYS - deprecated +# +# NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU and +# NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN should be used instead. +# + +NV_CTRL_CONNECTED_DISPLAYS = 19 # deprecated + +# +# NV_CTRL_ENABLED_DISPLAYS - Event that notifies when one or more display +# devices are enabled or disabled on a GPU and/or X screen. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# +# Note: Querying this value has been deprecated. +# NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU, +# NV_CTRL_DISPLAY_ENABLED, and +# NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN should be used +# instead to obtain the list of enabled displays. +# + +NV_CTRL_ENABLED_DISPLAYS = 20 # ---G + +############################################################################ +# +# Integer attributes specific to configuring Frame Lock on boards that +# support it. +# + + +# +# NV_CTRL_FRAMELOCK - returns whether the underlying GPU supports +# Frame Lock. All of the other frame lock attributes are only +# applicable if NV_CTRL_FRAMELOCK is _SUPPORTED. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_FRAMELOCK = 21 # R--G +NV_CTRL_FRAMELOCK_NOT_SUPPORTED = 0 +NV_CTRL_FRAMELOCK_SUPPORTED = 1 + +# +# NV_CTRL_FRAMELOCK_MASTER - deprecated +# +# NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead. +# + +NV_CTRL_FRAMELOCK_MASTER = 22 # deprecated +NV_CTRL_FRAMELOCK_MASTER_FALSE = 0 # deprecated +NV_CTRL_FRAMELOCK_MASTER_TRUE = 1 # deprecated + +# +# NV_CTRL_FRAMELOCK_POLARITY - sync either to the rising edge of the +# frame lock pulse, the falling edge of the frame lock pulse or both. +# +# On Quadro Sync II, this attribute is ignored when +# NV_CTRL_USE_HOUSE_SYNC is OUTPUT. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_FRAMELOCK_POLARITY = 23 # RW-F +NV_CTRL_FRAMELOCK_POLARITY_RISING_EDGE = 0x1 +NV_CTRL_FRAMELOCK_POLARITY_FALLING_EDGE = 0x2 +NV_CTRL_FRAMELOCK_POLARITY_BOTH_EDGES = 0x3 + +# +# NV_CTRL_FRAMELOCK_SYNC_DELAY - delay between the frame lock pulse +# and the GPU sync. This value must be multiplied by +# NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION to determine the sync delay in +# nanoseconds. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# +# USAGE NOTE: NV_CTRL_FRAMELOCK_SYNC_DELAY_MAX and +# NV_CTRL_FRAMELOCK_SYNC_DELAY_FACTOR are deprecated. +# The Sync Delay _MAX and _FACTOR are different for different +# Quadro Sync products and so, to be correct, the valid values for +# NV_CTRL_FRAMELOCK_SYNC_DELAY must be queried to get the range +# of acceptable sync delay values, and +# NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION must be queried to +# obtain the correct factor. +# + +NV_CTRL_FRAMELOCK_SYNC_DELAY = 24 # RW-F +NV_CTRL_FRAMELOCK_SYNC_DELAY_MAX = 2047 # deprecated +NV_CTRL_FRAMELOCK_SYNC_DELAY_FACTOR = 7.81 # deprecated + +# +# NV_CTRL_FRAMELOCK_SYNC_INTERVAL - how many house sync pulses +# between the frame lock sync generation (0 == sync every house sync); +# this only applies to the master when receiving house sync. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_FRAMELOCK_SYNC_INTERVAL = 25 # RW-F + +# +# NV_CTRL_FRAMELOCK_PORT0_STATUS - status of the rj45 port0. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_FRAMELOCK_PORT0_STATUS = 26 # R--F +NV_CTRL_FRAMELOCK_PORT0_STATUS_INPUT = 0 +NV_CTRL_FRAMELOCK_PORT0_STATUS_OUTPUT = 1 + +# +# NV_CTRL_FRAMELOCK_PORT1_STATUS - status of the rj45 port1. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_FRAMELOCK_PORT1_STATUS = 27 # R--F +NV_CTRL_FRAMELOCK_PORT1_STATUS_INPUT = 0 +NV_CTRL_FRAMELOCK_PORT1_STATUS_OUTPUT = 1 + +# +# NV_CTRL_FRAMELOCK_HOUSE_STATUS - returns whether or not the house +# sync input signal was detected on the BNC connector of the frame lock +# board. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_FRAMELOCK_HOUSE_STATUS = 28 # R--F +NV_CTRL_FRAMELOCK_HOUSE_STATUS_NOT_DETECTED = 0 +NV_CTRL_FRAMELOCK_HOUSE_STATUS_DETECTED = 1 + +# +# NV_CTRL_FRAMELOCK_SYNC - enable/disable the syncing of display +# devices to the frame lock pulse as specified by previous calls to +# NV_CTRL_FRAMELOCK_DISPLAY_CONFIG. +# +# This attribute can only be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN. +# + +NV_CTRL_FRAMELOCK_SYNC = 29 # RW-G +NV_CTRL_FRAMELOCK_SYNC_DISABLE = 0 +NV_CTRL_FRAMELOCK_SYNC_ENABLE = 1 + +# +# NV_CTRL_FRAMELOCK_SYNC_READY - reports whether a frame lock +# board is receiving sync (regardless of whether or not any display +# devices are using the sync). +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_FRAMELOCK_SYNC_READY = 30 # R--F +NV_CTRL_FRAMELOCK_SYNC_READY_FALSE = 0 +NV_CTRL_FRAMELOCK_SYNC_READY_TRUE = 1 + +# +# NV_CTRL_FRAMELOCK_STEREO_SYNC - this indicates that the GPU stereo +# signal is in sync with the frame lock stereo signal. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_FRAMELOCK_STEREO_SYNC = 31 # R--G +NV_CTRL_FRAMELOCK_STEREO_SYNC_FALSE = 0 +NV_CTRL_FRAMELOCK_STEREO_SYNC_TRUE = 1 + +# +# NV_CTRL_FRAMELOCK_TEST_SIGNAL - to test the connections in the sync +# group, tell the master to enable a test signal, then query port[01] +# status and sync_ready on all slaves. When done, tell the master to +# disable the test signal. Test signal should only be manipulated +# while NV_CTRL_FRAMELOCK_SYNC is enabled. +# +# The TEST_SIGNAL is also used to reset the Universal Frame Count (as +# returned by the glXQueryFrameCountNV() function in the +# GLX_NV_swap_group extension). Note: for best accuracy of the +# Universal Frame Count, it is recommended to toggle the TEST_SIGNAL +# on and off after enabling frame lock. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_FRAMELOCK_TEST_SIGNAL = 32 # RW-G +NV_CTRL_FRAMELOCK_TEST_SIGNAL_DISABLE = 0 +NV_CTRL_FRAMELOCK_TEST_SIGNAL_ENABLE = 1 + +# +# NV_CTRL_FRAMELOCK_ETHERNET_DETECTED - The frame lock boards are +# cabled together using regular cat5 cable, connecting to rj45 ports +# on the backplane of the card. There is some concern that users may +# think these are ethernet ports and connect them to a +# router/hub/etc. The hardware can detect this and will shut off to +# prevent damage (either to itself or to the router). +# NV_CTRL_FRAMELOCK_ETHERNET_DETECTED may be called to find out if +# ethernet is connected to one of the rj45 ports. An appropriate +# error message should then be displayed. The _PORT0 and _PORT1 +# values may be or'ed together. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_FRAMELOCK_ETHERNET_DETECTED = 33 # R--F +NV_CTRL_FRAMELOCK_ETHERNET_DETECTED_NONE = 0 +NV_CTRL_FRAMELOCK_ETHERNET_DETECTED_PORT0 = 0x1 +NV_CTRL_FRAMELOCK_ETHERNET_DETECTED_PORT1 = 0x2 + +# +# NV_CTRL_FRAMELOCK_VIDEO_MODE - get/set what video mode is used +# to interperate the house sync signal. This should only be set +# on the master. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_FRAMELOCK_VIDEO_MODE = 34 # RW-F +NV_CTRL_FRAMELOCK_VIDEO_MODE_NONE = 0 +NV_CTRL_FRAMELOCK_VIDEO_MODE_TTL = 1 +NV_CTRL_FRAMELOCK_VIDEO_MODE_NTSCPALSECAM = 2 +NV_CTRL_FRAMELOCK_VIDEO_MODE_HDTV = 3 + +# +# During FRAMELOCK bring-up, the above values were redefined to +# these: +# + +NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_AUTO = 0 +NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_BI_LEVEL = 2 +NV_CTRL_FRAMELOCK_VIDEO_MODE_COMPOSITE_TRI_LEVEL = 3 + +# +# NV_CTRL_FRAMELOCK_SYNC_RATE - this is the refresh rate that the +# frame lock board is sending to the GPU, in milliHz. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_FRAMELOCK_SYNC_RATE = 35 # R--F + +############################################################################ + +# +# NV_CTRL_FORCE_GENERIC_CPU - not supported +# + +NV_CTRL_FORCE_GENERIC_CPU = 37 # not supported +NV_CTRL_FORCE_GENERIC_CPU_DISABLE = 0 # not supported +NV_CTRL_FORCE_GENERIC_CPU_ENABLE = 1 # not supported + +# +# NV_CTRL_OPENGL_AA_LINE_GAMMA - for OpenGL clients, allow +# Gamma-corrected antialiased lines to consider variances in the +# color display capabilities of output devices when rendering smooth +# lines. Only available on recent Quadro GPUs. This setting is only +# applied to OpenGL clients that are started after this setting is +# applied. +# + +NV_CTRL_OPENGL_AA_LINE_GAMMA = 38 # RW-X +NV_CTRL_OPENGL_AA_LINE_GAMMA_DISABLE = 0 +NV_CTRL_OPENGL_AA_LINE_GAMMA_ENABLE = 1 + +# +# NV_CTRL_FRAMELOCK_TIMING - this is TRUE when the gpu is both receiving +# and locked to an input timing signal. Timing information may come from +# the following places: Another frame lock device that is set to master, +# the house sync signal, or the GPU's internal timing from a display +# device. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_FRAMELOCK_TIMING = 39 # R--G +NV_CTRL_FRAMELOCK_TIMING_FALSE = 0 +NV_CTRL_FRAMELOCK_TIMING_TRUE = 1 + +# +# NV_CTRL_FLIPPING_ALLOWED - when TRUE, OpenGL will swap by flipping +# when possible; when FALSE, OpenGL will always swap by blitting. +# + +NV_CTRL_FLIPPING_ALLOWED = 40 # RW-X +NV_CTRL_FLIPPING_ALLOWED_FALSE = 0 +NV_CTRL_FLIPPING_ALLOWED_TRUE = 1 + +# +# NV_CTRL_ARCHITECTURE - returns the architecture on which the X server is +# running. +# + +NV_CTRL_ARCHITECTURE = 41 # R-- +NV_CTRL_ARCHITECTURE_X86 = 0 +NV_CTRL_ARCHITECTURE_X86_64 = 1 +NV_CTRL_ARCHITECTURE_IA64 = 2 +NV_CTRL_ARCHITECTURE_ARM = 3 +NV_CTRL_ARCHITECTURE_AARCH64 = 4 +NV_CTRL_ARCHITECTURE_PPC64LE = 5 + +# +# NV_CTRL_TEXTURE_CLAMPING - texture clamping mode in OpenGL. By +# default, _SPEC is used, which forces OpenGL texture clamping to +# conform with the OpenGL specification. _EDGE forces NVIDIA's +# OpenGL implementation to remap GL_CLAMP to GL_CLAMP_TO_EDGE, +# which is not strictly conformant, but some applications rely on +# the non-conformant behavior. +# + +NV_CTRL_TEXTURE_CLAMPING = 42 # RW-X +NV_CTRL_TEXTURE_CLAMPING_EDGE = 0 +NV_CTRL_TEXTURE_CLAMPING_SPEC = 1 + +# +# The NV_CTRL_CURSOR_SHADOW - not supported +# +# use an ARGB cursor instead. +# + +NV_CTRL_CURSOR_SHADOW = 43 # not supported +NV_CTRL_CURSOR_SHADOW_DISABLE = 0 # not supported +NV_CTRL_CURSOR_SHADOW_ENABLE = 1 # not supported + +NV_CTRL_CURSOR_SHADOW_ALPHA = 44 # not supported +NV_CTRL_CURSOR_SHADOW_RED = 45 # not supported +NV_CTRL_CURSOR_SHADOW_GREEN = 46 # not supported +NV_CTRL_CURSOR_SHADOW_BLUE = 47 # not supported + +NV_CTRL_CURSOR_SHADOW_X_OFFSET = 48 # not supported +NV_CTRL_CURSOR_SHADOW_Y_OFFSET = 49 # not supported + +# +# When Application Control for FSAA is enabled, then what the +# application requests is used, and NV_CTRL_FSAA_MODE is ignored. If +# this is disabled, then any application setting is overridden with +# NV_CTRL_FSAA_MODE +# + +NV_CTRL_FSAA_APPLICATION_CONTROLLED = 50 # RW-X +NV_CTRL_FSAA_APPLICATION_CONTROLLED_ENABLED = 1 +NV_CTRL_FSAA_APPLICATION_CONTROLLED_DISABLED = 0 + +# +# When Application Control for LogAniso is enabled, then what the +# application requests is used, and NV_CTRL_LOG_ANISO is ignored. If +# this is disabled, then any application setting is overridden with +# NV_CTRL_LOG_ANISO +# + +NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED = 51 # RW-X +NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED_ENABLED = 1 +NV_CTRL_LOG_ANISO_APPLICATION_CONTROLLED_DISABLED = 0 + +# +# IMAGE_SHARPENING adjusts the sharpness of the display's image +# quality by amplifying high frequency content. Valid values will +# normally be in the range [0,32). Only available on GeForceFX or +# newer. +# + +NV_CTRL_IMAGE_SHARPENING = 52 # RWDG + +# +# NV_CTRL_TV_OVERSCAN - not supported +# + +NV_CTRL_TV_OVERSCAN = 53 # not supported + +# +# NV_CTRL_TV_FLICKER_FILTER - not supported +# + +NV_CTRL_TV_FLICKER_FILTER = 54 # not supported + +# +# NV_CTRL_TV_BRIGHTNESS - not supported +# + +NV_CTRL_TV_BRIGHTNESS = 55 # not supported + +# +# NV_CTRL_TV_HUE - not supported +# + +NV_CTRL_TV_HUE = 56 # not supported + +# +# NV_CTRL_TV_CONTRAST - not suppoerted +# + +NV_CTRL_TV_CONTRAST = 57 # not supported + +# +# NV_CTRL_TV_SATURATION - not supported +# + +NV_CTRL_TV_SATURATION = 58 # not supported + +# +# NV_CTRL_TV_RESET_SETTINGS - not supported +# + +NV_CTRL_TV_RESET_SETTINGS = 59 # not supported + +# +# NV_CTRL_GPU_CORE_TEMPERATURE reports the current core temperature +# of the GPU driving the X screen. +# + +NV_CTRL_GPU_CORE_TEMPERATURE = 60 # R--G + +# +# NV_CTRL_GPU_CORE_THRESHOLD reports the current GPU core slowdown +# threshold temperature, NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD and +# NV_CTRL_GPU_MAX_CORE_THRESHOLD report the default and MAX core +# slowdown threshold temperatures. +# +# NV_CTRL_GPU_CORE_THRESHOLD reflects the temperature at which the +# GPU is throttled to prevent overheating. +# + +NV_CTRL_GPU_CORE_THRESHOLD = 61 # R--G +NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD = 62 # R--G +NV_CTRL_GPU_MAX_CORE_THRESHOLD = 63 # R--G + +# +# NV_CTRL_AMBIENT_TEMPERATURE reports the current temperature in the +# immediate neighbourhood of the GPU driving the X screen. +# + +NV_CTRL_AMBIENT_TEMPERATURE = 64 # R--G + +# +# NV_CTRL_PBUFFER_SCANOUT_SUPPORTED - returns whether this X screen +# supports scanout of FP pbuffers; +# +# if this screen does not support PBUFFER_SCANOUT, then all other +# PBUFFER_SCANOUT attributes are unavailable. +# +# PBUFFER_SCANOUT is supported if and only if: +# - Twinview is configured with clone mode. The secondary screen is used to +# scanout the pbuffer. +# - The desktop is running in with 16 bits per pixel. +# +NV_CTRL_PBUFFER_SCANOUT_SUPPORTED = 65 # not supported +NV_CTRL_PBUFFER_SCANOUT_FALSE = 0 +NV_CTRL_PBUFFER_SCANOUT_TRUE = 1 + +# +# NV_CTRL_PBUFFER_SCANOUT_XID indicates the XID of the pbuffer used for +# scanout. +# +NV_CTRL_PBUFFER_SCANOUT_XID = 66 # not supported + +############################################################################ +# +# The NV_CTRL_GVO_* integer attributes are used to configure GVO +# (Graphics to Video Out). This functionality is available, for +# example, on the Quadro SDI Output card. +# +# The following is a typical usage pattern for the GVO attributes: +# +# - query NV_CTRL_GVO_SUPPORTED to determine if the X screen supports GV0. +# +# - specify NV_CTRL_GVO_SYNC_MODE (one of FREE_RUNNING, GENLOCK, or +# FRAMELOCK); if you specify GENLOCK or FRAMELOCK, you should also +# specify NV_CTRL_GVO_SYNC_SOURCE. +# +# - Use NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED and +# NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED to detect what input syncs are +# present. +# +# (If no analog sync is detected but it is known that a valid +# bi-level or tri-level sync is connected set +# NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE appropriately and +# retest with NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED). +# +# - if syncing to input sync, query the +# NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT attribute; note that Input video +# format can only be queried after SYNC_SOURCE is specified. +# +# - specify the NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT +# +# - specify the NV_CTRL_GVO_DATA_FORMAT +# +# - specify any custom Color Space Conversion (CSC) matrix, offset, +# and scale with XNVCTRLSetGvoColorConversion(). +# +# - if using the GLX_NV_video_out extension to display one or more +# pbuffers, call glXGetVideoDeviceNV() to lock the GVO output for use +# by the GLX client; then bind the pbuffer(s) to the GVO output with +# glXBindVideoImageNV() and send pbuffers to the GVO output with +# glXSendPbufferToVideoNV(); see the GLX_NV_video_out spec for more +# details. +# +# - if using the GLX_NV_present_video extension, call +# glXBindVideoDeviceNV() to bind the GVO video device to current +# OpenGL context. +# +# Note that setting most GVO attributes only causes the value to be +# cached in the X server. The values will be flushed to the hardware +# either when the next MetaMode is set that uses the GVO display +# device, or when a GLX pbuffer is bound to the GVO output (with +# glXBindVideoImageNV()). +# +# Note that GLX_NV_video_out/GLX_NV_present_video and X screen use +# are mutually exclusive. If a MetaMode is currently using the GVO +# device, then glXGetVideoDeviceNV and glXBindVideoImageNV() will +# fail. Similarly, if a GLX client has locked the GVO output (via +# glXGetVideoDeviceNV or glXBindVideoImageNV), then setting a +# MetaMode that uses the GVO device will fail. The +# NV_CTRL_GVO_GLX_LOCKED event will be sent when a GLX client locks +# the GVO output. +# +# + + +# +# NV_CTRL_GVO_SUPPORTED - returns whether this X screen supports GVO; +# if this screen does not support GVO output, then all other GVO +# attributes are unavailable. +# + +NV_CTRL_GVO_SUPPORTED = 67 # R-- +NV_CTRL_GVO_SUPPORTED_FALSE = 0 +NV_CTRL_GVO_SUPPORTED_TRUE = 1 + +# +# NV_CTRL_GVO_SYNC_MODE - selects the GVO sync mode; possible values +# are: +# +# FREE_RUNNING - GVO does not sync to any external signal +# +# GENLOCK - the GVO output is genlocked to an incoming sync signal; +# genlocking locks at hsync. This requires that the output video +# format exactly match the incoming sync video format. +# +# FRAMELOCK - the GVO output is frame locked to an incoming sync +# signal; frame locking locks at vsync. This requires that the output +# video format have the same refresh rate as the incoming sync video +# format. +# + +NV_CTRL_GVO_SYNC_MODE = 68 # RW- +NV_CTRL_GVO_SYNC_MODE_FREE_RUNNING = 0 +NV_CTRL_GVO_SYNC_MODE_GENLOCK = 1 +NV_CTRL_GVO_SYNC_MODE_FRAMELOCK = 2 + +# +# NV_CTRL_GVO_SYNC_SOURCE - if NV_CTRL_GVO_SYNC_MODE is set to either +# GENLOCK or FRAMELOCK, this controls which sync source is used as +# the incoming sync signal (either Composite or SDI). If +# NV_CTRL_GVO_SYNC_MODE is FREE_RUNNING, this attribute has no +# effect. +# + +NV_CTRL_GVO_SYNC_SOURCE = 69 # RW- +NV_CTRL_GVO_SYNC_SOURCE_COMPOSITE = 0 +NV_CTRL_GVO_SYNC_SOURCE_SDI = 1 + +# +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT - specifies the desired output video +# format for GVO devices or the desired input video format for GVI devices. +# +# Note that for GVO, the valid video formats may vary depending on +# the NV_CTRL_GVO_SYNC_MODE and the incoming sync video format. See +# the definition of NV_CTRL_GVO_SYNC_MODE. +# +# Note that when querying the ValidValues for this data type, the +# values are reported as bits within a bitmask +# (ATTRIBUTE_TYPE_INT_BITS); unfortunately, there are more valid +# value bits than will fit in a single 32-bit value. To solve this, +# query the ValidValues for NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT to +# check which of the first 31 VIDEO_FORMATS are valid, query the +# ValidValues for NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 to check which +# of the 32-63 VIDEO_FORMATS are valid, and query the ValidValues of +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3 to check which of the 64-95 +# VIDEO_FORMATS are valid. +# +# Note: Setting this attribute on a GVI device may also result in the +# following NV-CONTROL attributes being reset on that device (to +# ensure the configuration remains valid): +# NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT +# NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING +# + +NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT = 70 # RW--I + +NV_CTRL_GVIO_VIDEO_FORMAT_NONE = 0 +NV_CTRL_GVIO_VIDEO_FORMAT_487I_59_94_SMPTE259_NTSC = 1 +NV_CTRL_GVIO_VIDEO_FORMAT_576I_50_00_SMPTE259_PAL = 2 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_59_94_SMPTE296 = 3 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_60_00_SMPTE296 = 4 +NV_CTRL_GVIO_VIDEO_FORMAT_1035I_59_94_SMPTE260 = 5 +NV_CTRL_GVIO_VIDEO_FORMAT_1035I_60_00_SMPTE260 = 6 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_50_00_SMPTE295 = 7 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_50_00_SMPTE274 = 8 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_59_94_SMPTE274 = 9 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_60_00_SMPTE274 = 10 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_23_976_SMPTE274 = 11 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_24_00_SMPTE274 = 12 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_25_00_SMPTE274 = 13 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_29_97_SMPTE274 = 14 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_30_00_SMPTE274 = 15 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_50_00_SMPTE296 = 16 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_48_00_SMPTE274 = 17 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_47_96_SMPTE274 = 18 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_30_00_SMPTE296 = 19 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_29_97_SMPTE296 = 20 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_25_00_SMPTE296 = 21 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_24_00_SMPTE296 = 22 +NV_CTRL_GVIO_VIDEO_FORMAT_720P_23_98_SMPTE296 = 23 +NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_25_00_SMPTE274 = 24 +NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_29_97_SMPTE274 = 25 +NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_30_00_SMPTE274 = 26 +NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_24_00_SMPTE274 = 27 +NV_CTRL_GVIO_VIDEO_FORMAT_1080PSF_23_98_SMPTE274 = 28 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_30_00_SMPTE372 = 29 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_29_97_SMPTE372 = 30 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_60_00_SMPTE372 = 31 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_59_94_SMPTE372 = 32 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_25_00_SMPTE372 = 33 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_50_00_SMPTE372 = 34 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_24_00_SMPTE372 = 35 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_23_98_SMPTE372 = 36 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_48_00_SMPTE372 = 37 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_47_96_SMPTE372 = 38 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_50_00_3G_LEVEL_A_SMPTE274 = 39 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_59_94_3G_LEVEL_A_SMPTE274 = 40 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_60_00_3G_LEVEL_A_SMPTE274 = 41 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_60_00_3G_LEVEL_B_SMPTE274 = 42 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_60_00_3G_LEVEL_B_SMPTE274 = 43 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_60_00_3G_LEVEL_B_SMPTE372 = 44 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_50_00_3G_LEVEL_B_SMPTE274 = 45 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_50_00_3G_LEVEL_B_SMPTE274 = 46 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_50_00_3G_LEVEL_B_SMPTE372 = 47 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_30_00_3G_LEVEL_B_SMPTE274 = 48 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_30_00_3G_LEVEL_B_SMPTE372 = 49 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_25_00_3G_LEVEL_B_SMPTE274 = 50 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_25_00_3G_LEVEL_B_SMPTE372 = 51 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_24_00_3G_LEVEL_B_SMPTE274 = 52 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_24_00_3G_LEVEL_B_SMPTE372 = 53 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_48_00_3G_LEVEL_B_SMPTE274 = 54 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_48_00_3G_LEVEL_B_SMPTE372 = 55 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_59_94_3G_LEVEL_B_SMPTE274 = 56 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_59_94_3G_LEVEL_B_SMPTE274 = 57 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_59_94_3G_LEVEL_B_SMPTE372 = 58 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_29_97_3G_LEVEL_B_SMPTE274 = 59 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_29_97_3G_LEVEL_B_SMPTE372 = 60 +NV_CTRL_GVIO_VIDEO_FORMAT_1080P_23_98_3G_LEVEL_B_SMPTE274 = 61 +NV_CTRL_GVIO_VIDEO_FORMAT_2048P_23_98_3G_LEVEL_B_SMPTE372 = 62 +NV_CTRL_GVIO_VIDEO_FORMAT_1080I_47_96_3G_LEVEL_B_SMPTE274 = 63 +NV_CTRL_GVIO_VIDEO_FORMAT_2048I_47_96_3G_LEVEL_B_SMPTE372 = 64 + +# +# The following have been renamed; NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT and the +# corresponding NV_CTRL_GVIO_* formats should be used instead. +# +NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT = 70 # renamed + +NV_CTRL_GVO_VIDEO_FORMAT_NONE = 0 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_487I_59_94_SMPTE259_NTSC = 1 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_576I_50_00_SMPTE259_PAL = 2 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_59_94_SMPTE296 = 3 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_60_00_SMPTE296 = 4 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1035I_59_94_SMPTE260 = 5 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1035I_60_00_SMPTE260 = 6 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080I_50_00_SMPTE295 = 7 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080I_50_00_SMPTE274 = 8 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080I_59_94_SMPTE274 = 9 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080I_60_00_SMPTE274 = 10 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080P_23_976_SMPTE274 = 11 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080P_24_00_SMPTE274 = 12 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080P_25_00_SMPTE274 = 13 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080P_29_97_SMPTE274 = 14 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080P_30_00_SMPTE274 = 15 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_50_00_SMPTE296 = 16 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080I_48_00_SMPTE274 = 17 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080I_47_96_SMPTE274 = 18 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_30_00_SMPTE296 = 19 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_29_97_SMPTE296 = 20 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_25_00_SMPTE296 = 21 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_24_00_SMPTE296 = 22 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_720P_23_98_SMPTE296 = 23 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_25_00_SMPTE274 = 24 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_29_97_SMPTE274 = 25 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_30_00_SMPTE274 = 26 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_24_00_SMPTE274 = 27 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_1080PSF_23_98_SMPTE274 = 28 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048P_30_00_SMPTE372 = 29 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048P_29_97_SMPTE372 = 30 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048I_60_00_SMPTE372 = 31 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048I_59_94_SMPTE372 = 32 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048P_25_00_SMPTE372 = 33 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048I_50_00_SMPTE372 = 34 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048P_24_00_SMPTE372 = 35 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048P_23_98_SMPTE372 = 36 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048I_48_00_SMPTE372 = 37 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_2048I_47_96_SMPTE372 = 38 # renamed + +# +# NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT - indicates the input video format +# detected for GVO or GVI devices; the possible values are the +# NV_CTRL_GVIO_VIDEO_FORMAT constants. +# +# For GVI devices, the jack number should be specified in the lower +# 16 bits of the "display_mask" parameter, while the channel number should be +# specified in the upper 16 bits. +# + +NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT = 71 # R--I + +# +# NV_CTRL_GVO_INPUT_VIDEO_FORMAT - renamed +# +# NV_CTRL_GVIO_DETECTED_VIDEO_FORMAT should be used instead. +# + +NV_CTRL_GVO_INPUT_VIDEO_FORMAT = 71 # renamed + +# +# NV_CTRL_GVO_DATA_FORMAT - This controls how the data in the source +# (either the X screen or the GLX pbuffer) is interpretted and +# displayed. +# +# Note: some of the below DATA_FORMATS have been renamed. For +# example, R8G8B8_TO_RGB444 has been renamed to X8X8X8_444_PASSTHRU. +# This is to more accurately reflect DATA_FORMATS where the +# per-channel data could be either RGB or YCrCb -- the point is that +# the driver and GVO hardware do not perform any implicit color space +# conversion on the data; it is passed through to the SDI out. +# + +NV_CTRL_GVO_DATA_FORMAT = 72 # RW- +NV_CTRL_GVO_DATA_FORMAT_R8G8B8_TO_YCRCB444 = 0 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8A8_TO_YCRCBA4444 = 1 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8Z10_TO_YCRCBZ4444 = 2 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8_TO_YCRCB422 = 3 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8A8_TO_YCRCBA4224 = 4 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8Z10_TO_YCRCBZ4224 = 5 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8_TO_RGB444 = 6 # renamed +NV_CTRL_GVO_DATA_FORMAT_X8X8X8_444_PASSTHRU = 6 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8A8_TO_RGBA4444 = 7 # renamed +NV_CTRL_GVO_DATA_FORMAT_X8X8X8A8_4444_PASSTHRU = 7 +NV_CTRL_GVO_DATA_FORMAT_R8G8B8Z10_TO_RGBZ4444 = 8 # renamed +NV_CTRL_GVO_DATA_FORMAT_X8X8X8Z8_4444_PASSTHRU = 8 +NV_CTRL_GVO_DATA_FORMAT_Y10CR10CB10_TO_YCRCB444 = 9 # renamed +NV_CTRL_GVO_DATA_FORMAT_X10X10X10_444_PASSTHRU = 9 +NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8_TO_YCRCB444 = 10 # renamed +NV_CTRL_GVO_DATA_FORMAT_X10X8X8_444_PASSTHRU = 10 +NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8A10_TO_YCRCBA4444 = 11 # renamed +NV_CTRL_GVO_DATA_FORMAT_X10X8X8A10_4444_PASSTHRU = 11 +NV_CTRL_GVO_DATA_FORMAT_Y10CR8CB8Z10_TO_YCRCBZ4444 = 12 # renamed +NV_CTRL_GVO_DATA_FORMAT_X10X8X8Z10_4444_PASSTHRU = 12 +NV_CTRL_GVO_DATA_FORMAT_DUAL_R8G8B8_TO_DUAL_YCRCB422 = 13 +NV_CTRL_GVO_DATA_FORMAT_DUAL_Y8CR8CB8_TO_DUAL_YCRCB422 = 14 # renamed +NV_CTRL_GVO_DATA_FORMAT_DUAL_X8X8X8_TO_DUAL_422_PASSTHRU = 14 +NV_CTRL_GVO_DATA_FORMAT_R10G10B10_TO_YCRCB422 = 15 +NV_CTRL_GVO_DATA_FORMAT_R10G10B10_TO_YCRCB444 = 16 +NV_CTRL_GVO_DATA_FORMAT_Y12CR12CB12_TO_YCRCB444 = 17 # renamed +NV_CTRL_GVO_DATA_FORMAT_X12X12X12_444_PASSTHRU = 17 +NV_CTRL_GVO_DATA_FORMAT_R12G12B12_TO_YCRCB444 = 18 +NV_CTRL_GVO_DATA_FORMAT_X8X8X8_422_PASSTHRU = 19 +NV_CTRL_GVO_DATA_FORMAT_X8X8X8A8_4224_PASSTHRU = 20 +NV_CTRL_GVO_DATA_FORMAT_X8X8X8Z8_4224_PASSTHRU = 21 +NV_CTRL_GVO_DATA_FORMAT_X10X10X10_422_PASSTHRU = 22 +NV_CTRL_GVO_DATA_FORMAT_X10X8X8_422_PASSTHRU = 23 +NV_CTRL_GVO_DATA_FORMAT_X10X8X8A10_4224_PASSTHRU = 24 +NV_CTRL_GVO_DATA_FORMAT_X10X8X8Z10_4224_PASSTHRU = 25 +NV_CTRL_GVO_DATA_FORMAT_X12X12X12_422_PASSTHRU = 26 +NV_CTRL_GVO_DATA_FORMAT_R12G12B12_TO_YCRCB422 = 27 + +# +# NV_CTRL_GVO_DISPLAY_X_SCREEN - not supported +# + +NV_CTRL_GVO_DISPLAY_X_SCREEN = 73 # not supported +NV_CTRL_GVO_DISPLAY_X_SCREEN_ENABLE = 1 # not supported +NV_CTRL_GVO_DISPLAY_X_SCREEN_DISABLE = 0 # not supported + +# +# NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED - indicates whether +# Composite Sync input is detected. +# + +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED = 74 # R-- +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED_FALSE = 0 +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECTED_TRUE = 1 + +# +# NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE - get/set the +# Composite Sync input detect mode. +# + +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE = 75 # RW- +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE_AUTO = 0 +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE_BI_LEVEL = 1 +NV_CTRL_GVO_COMPOSITE_SYNC_INPUT_DETECT_MODE_TRI_LEVEL = 2 + +# +# NV_CTRL_GVO_SYNC_INPUT_DETECTED - indicates whether SDI Sync input +# is detected, and what type. +# + +NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED = 76 # R-- +NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_NONE = 0 +NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_HD = 1 +NV_CTRL_GVO_SDI_SYNC_INPUT_DETECTED_SD = 2 + +# +# NV_CTRL_GVO_VIDEO_OUTPUTS - indicates which GVO video output +# connectors are currently outputing data. +# + +NV_CTRL_GVO_VIDEO_OUTPUTS = 77 # R-- +NV_CTRL_GVO_VIDEO_OUTPUTS_NONE = 0 +NV_CTRL_GVO_VIDEO_OUTPUTS_VIDEO1 = 1 +NV_CTRL_GVO_VIDEO_OUTPUTS_VIDEO2 = 2 +NV_CTRL_GVO_VIDEO_OUTPUTS_VIDEO_BOTH = 3 + +# +# NV_CTRL_GVO_FIRMWARE_VERSION - deprecated +# +# NV_CTRL_STRING_GVIO_FIRMWARE_VERSION should be used instead. +# + +NV_CTRL_GVO_FIRMWARE_VERSION = 78 # deprecated + +# +# NV_CTRL_GVO_SYNC_DELAY_PIXELS - controls the delay between the +# input sync and the output sync in numbers of pixels from hsync; +# this is a 12 bit value. +# +# If the NV_CTRL_GVO_CAPABILITIES_ADVANCE_SYNC_SKEW bit is set, +# then setting this value will set an advance instead of a delay. +# + +NV_CTRL_GVO_SYNC_DELAY_PIXELS = 79 # RW- + +# +# NV_CTRL_GVO_SYNC_DELAY_LINES - controls the delay between the input +# sync and the output sync in numbers of lines from vsync; this is a +# 12 bit value. +# +# If the NV_CTRL_GVO_CAPABILITIES_ADVANCE_SYNC_SKEW bit is set, +# then setting this value will set an advance instead of a delay. +# + +NV_CTRL_GVO_SYNC_DELAY_LINES = 80 # RW- + +# +# NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE - must be set for a period +# of about 2 seconds for the new InputVideoFormat to be properly +# locked to. In nvidia-settings, we do a reacquire whenever genlock +# or frame lock mode is entered into, when the user clicks the +# "detect" button. This value can be written, but always reads back +# _FALSE. +# + +NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE = 81 # -W- +NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE_FALSE = 0 +NV_CTRL_GVO_INPUT_VIDEO_FORMAT_REACQUIRE_TRUE = 1 + +# +# NV_CTRL_GVO_GLX_LOCKED - deprecated +# +# NV_CTRL_GVO_LOCK_OWNER should be used instead. +# + +NV_CTRL_GVO_GLX_LOCKED = 82 # deprecated +NV_CTRL_GVO_GLX_LOCKED_FALSE = 0 # deprecated +NV_CTRL_GVO_GLX_LOCKED_TRUE = 1 # deprecated + +# +# NV_CTRL_GVIO_VIDEO_FORMAT_{WIDTH,HEIGHT,REFRESH_RATE} - query the +# width, height, and refresh rate for the specified +# NV_CTRL_GVIO_VIDEO_FORMAT_*. So that this can be queried with +# existing interfaces, XNVCTRLQueryAttribute() should be used, and +# the video format specified in the display_mask field; eg: +# +# XNVCTRLQueryAttribute (dpy, +# screen, +# NV_CTRL_GVIO_VIDEO_FORMAT_487I_59_94_SMPTE259_NTSC, +# NV_CTRL_GVIO_VIDEO_FORMAT_WIDTH, +# &value); +# +# Note that Refresh Rate is in milliHertz values +# + +NV_CTRL_GVIO_VIDEO_FORMAT_WIDTH = 83 # R--I +NV_CTRL_GVIO_VIDEO_FORMAT_HEIGHT = 84 # R--I +NV_CTRL_GVIO_VIDEO_FORMAT_REFRESH_RATE = 85 # R--I + +# The following have been renamed; use the NV_CTRL_GVIO_* versions, instead +NV_CTRL_GVO_VIDEO_FORMAT_WIDTH = 83 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_HEIGHT = 84 # renamed +NV_CTRL_GVO_VIDEO_FORMAT_REFRESH_RATE = 85 # renamed + +# +# NV_CTRL_GVO_X_SCREEN_PAN_[XY] - not supported +# + +NV_CTRL_GVO_X_SCREEN_PAN_X = 86 # not supported +NV_CTRL_GVO_X_SCREEN_PAN_Y = 87 # not supported + +# +# NV_CTRL_GPU_OVERCLOCKING_STATE - not supported +# + +NV_CTRL_GPU_OVERCLOCKING_STATE = 88 # not supported +NV_CTRL_GPU_OVERCLOCKING_STATE_NONE = 0 # not supported +NV_CTRL_GPU_OVERCLOCKING_STATE_MANUAL = 1 # not supported + +# +# NV_CTRL_GPU_{2,3}D_CLOCK_FREQS - not supported +# + +NV_CTRL_GPU_2D_CLOCK_FREQS = 89 # not supported +NV_CTRL_GPU_3D_CLOCK_FREQS = 90 # not supported + +# +# NV_CTRL_GPU_DEFAULT_{2,3}D_CLOCK_FREQS - not supported +# + +NV_CTRL_GPU_DEFAULT_2D_CLOCK_FREQS = 91 # not supported +NV_CTRL_GPU_DEFAULT_3D_CLOCK_FREQS = 92 # not supported + +# +# NV_CTRL_GPU_CURRENT_CLOCK_FREQS - query the current GPU and memory +# clocks of the graphics device driving the X screen. +# +# NV_CTRL_GPU_CURRENT_CLOCK_FREQS is a "packed" integer attribute; +# the GPU clock is stored in the upper 16 bits of the integer, and +# the memory clock is stored in the lower 16 bits of the integer. +# All clock values are in MHz. All clock values are in MHz. +# + +NV_CTRL_GPU_CURRENT_CLOCK_FREQS = 93 # R--G + +# +# NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS - not supported +# + +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS = 94 # not supported +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_INVALID = 0 # not supported + +# +# NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION - not supported +# + +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION = 95 # not supported +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_START = 0 # not supported +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_CANCEL = 1 # not supported + +# +# NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE - not supported +# + +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE = 96 # not supported +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_IDLE = 0 # not supported +NV_CTRL_GPU_OPTIMAL_CLOCK_FREQS_DETECTION_STATE_BUSY = 1 # not supported + +# +# NV_CTRL_FLATPANEL_CHIP_LOCATION - for the specified display device, +# report whether the flat panel is driven by the on-chip controller, +# or a separate controller chip elsewhere on the graphics board. +# This attribute is only available for flat panels. +# + +NV_CTRL_FLATPANEL_CHIP_LOCATION = 215 # R-DG +NV_CTRL_FLATPANEL_CHIP_LOCATION_INTERNAL = 0 +NV_CTRL_FLATPANEL_CHIP_LOCATION_EXTERNAL = 1 + +# +# NV_CTRL_FLATPANEL_LINK - report the number of links for a DVI connection, or +# the main link's active lane count for DisplayPort. +# This attribute is only available for flat panels. +# + +NV_CTRL_FLATPANEL_LINK = 216 # R-DG +NV_CTRL_FLATPANEL_LINK_SINGLE = 0 +NV_CTRL_FLATPANEL_LINK_DUAL = 1 +NV_CTRL_FLATPANEL_LINK_QUAD = 3 + +# +# NV_CTRL_FLATPANEL_SIGNAL - for the specified display device, report +# whether the flat panel is driven by an LVDS, TMDS, or DisplayPort signal. +# This attribute is only available for flat panels. +# + +NV_CTRL_FLATPANEL_SIGNAL = 217 # R-DG +NV_CTRL_FLATPANEL_SIGNAL_LVDS = 0 +NV_CTRL_FLATPANEL_SIGNAL_TMDS = 1 +NV_CTRL_FLATPANEL_SIGNAL_DISPLAYPORT = 2 + +# +# NV_CTRL_USE_HOUSE_SYNC - when INPUT, the server (master) frame lock +# device will propagate the incoming house sync signal as the outgoing +# frame lock sync signal. If the frame lock device cannot detect a +# frame lock sync signal, it will default to using the internal timings +# from the GPU connected to the primary connector. +# +# When set to OUTPUT, the server (master) frame lock device will +# generate a house sync signal from its internal timing and output +# this signal over the BNC connector on the frame lock device. This +# is only allowed on a Quadro Sync II device. If an incoming house +# sync signal is present on the BNC connector, this setting will +# have no effect. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_USE_HOUSE_SYNC = 218 # RW-F +NV_CTRL_USE_HOUSE_SYNC_DISABLED = 0 # aliases with FALSE +NV_CTRL_USE_HOUSE_SYNC_INPUT = 1 # aliases with TRUE +NV_CTRL_USE_HOUSE_SYNC_OUTPUT = 2 +NV_CTRL_USE_HOUSE_SYNC_FALSE = 0 +NV_CTRL_USE_HOUSE_SYNC_TRUE = 1 + +# +# NV_CTRL_EDID_AVAILABLE - report if an EDID is available for the +# specified display device. +# +# This attribute may also be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# + +NV_CTRL_EDID_AVAILABLE = 219 # R-DG +NV_CTRL_EDID_AVAILABLE_FALSE = 0 +NV_CTRL_EDID_AVAILABLE_TRUE = 1 + +# +# NV_CTRL_FORCE_STEREO - when TRUE, OpenGL will force stereo flipping +# even when no stereo drawables are visible (if the device is configured +# to support it, see the "Stereo" X config option). +# When false, fall back to the default behavior of only flipping when a +# stereo drawable is visible. +# + +NV_CTRL_FORCE_STEREO = 220 # RW- +NV_CTRL_FORCE_STEREO_FALSE = 0 +NV_CTRL_FORCE_STEREO_TRUE = 1 + +# +# NV_CTRL_IMAGE_SETTINGS - the image quality setting for OpenGL clients. +# +# This setting is only applied to OpenGL clients that are started +# after this setting is applied. +# + +NV_CTRL_IMAGE_SETTINGS = 221 # RW-X +NV_CTRL_IMAGE_SETTINGS_HIGH_QUALITY = 0 +NV_CTRL_IMAGE_SETTINGS_QUALITY = 1 +NV_CTRL_IMAGE_SETTINGS_PERFORMANCE = 2 +NV_CTRL_IMAGE_SETTINGS_HIGH_PERFORMANCE = 3 + +# +# NV_CTRL_XINERAMA - return whether xinerama is enabled +# + +NV_CTRL_XINERAMA = 222 # R--G +NV_CTRL_XINERAMA_OFF = 0 +NV_CTRL_XINERAMA_ON = 1 + +# +# NV_CTRL_XINERAMA_STEREO - when TRUE, OpenGL will allow stereo flipping +# on multiple X screens configured with Xinerama. +# When FALSE, flipping is allowed only on one X screen at a time. +# + +NV_CTRL_XINERAMA_STEREO = 223 # RW- +NV_CTRL_XINERAMA_STEREO_FALSE = 0 +NV_CTRL_XINERAMA_STEREO_TRUE = 1 + +# +# NV_CTRL_BUS_RATE - if the bus type of the specified device is AGP, then +# NV_CTRL_BUS_RATE returns the configured AGP transfer rate. If the bus type +# is PCI Express, then this attribute returns the maximum link width. +# When this attribute is queried on an X screen target, the bus rate of the +# GPU driving the X screen is returned. +# + +NV_CTRL_BUS_RATE = 224 # R--GI + +# +# NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH - returns the maximum +# PCIe link width, in number of lanes. +# +NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH = NV_CTRL_BUS_RATE +# +# NV_CTRL_SHOW_SLI_VISUAL_INDICATOR - when TRUE, OpenGL will draw information +# about the current SLI mode. +# + +NV_CTRL_SHOW_SLI_VISUAL_INDICATOR = 225 # RW-X +NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_FALSE = 0 +NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_TRUE = 1 + +# +# NV_CTRL_SHOW_SLI_HUD - when TRUE, OpenGL will draw information about the +# current SLI mode. +# Renamed this attribute to NV_CTRL_SHOW_SLI_VISUAL_INDICATOR +# + +NV_CTRL_SHOW_SLI_HUD = NV_CTRL_SHOW_SLI_VISUAL_INDICATOR +NV_CTRL_SHOW_SLI_HUD_FALSE = NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_FALSE +NV_CTRL_SHOW_SLI_HUD_TRUE = NV_CTRL_SHOW_SLI_VISUAL_INDICATOR_TRUE + +# +# NV_CTRL_XV_SYNC_TO_DISPLAY - deprecated +# +# NV_CTRL_XV_SYNC_TO_DISPLAY_ID should be used instead. +# + +NV_CTRL_XV_SYNC_TO_DISPLAY = 226 # deprecated + +# +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 - this attribute is only +# intended to be used to query the ValidValues for +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT for VIDEO_FORMAT values between +# 31 and 63. See NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT for details. +# + +NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 = 227 # ---GI + +# +# NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT2 - renamed +# +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT2 should be used instead. +# +NV_CTRL_GVO_OUTPUT_VIDEO_FORMAT2 = 227 # renamed + +# +# NV_CTRL_GVO_OVERRIDE_HW_CSC - Override the SDI hardware's Color Space +# Conversion with the values controlled through +# XNVCTRLSetGvoColorConversion() and XNVCTRLGetGvoColorConversion(). If +# this attribute is FALSE, then the values specified through +# XNVCTRLSetGvoColorConversion() are ignored. +# + +NV_CTRL_GVO_OVERRIDE_HW_CSC = 228 # RW- +NV_CTRL_GVO_OVERRIDE_HW_CSC_FALSE = 0 +NV_CTRL_GVO_OVERRIDE_HW_CSC_TRUE = 1 + +# +# NV_CTRL_GVO_CAPABILITIES - this read-only attribute describes GVO +# capabilities that differ between NVIDIA SDI products. This value +# is a bitmask where each bit indicates whether that capability is +# available. +# +# APPLY_CSC_IMMEDIATELY - whether the CSC matrix, offset, and scale +# specified through XNVCTRLSetGvoColorConversion() will take affect +# immediately, or only after SDI output is disabled and enabled +# again. +# +# APPLY_CSC_TO_X_SCREEN - whether the CSC matrix, offset, and scale +# specified through XNVCTRLSetGvoColorConversion() will also apply +# to GVO output of an X screen, or only to OpenGL GVO output, as +# enabled through the GLX_NV_video_out extension. +# +# COMPOSITE_TERMINATION - whether the 75 ohm termination of the +# SDI composite input signal can be programmed through the +# NV_CTRL_GVO_COMPOSITE_TERMINATION attribute. +# +# SHARED_SYNC_BNC - whether the SDI device has a single BNC +# connector used for both (SDI & Composite) incoming signals. +# +# MULTIRATE_SYNC - whether the SDI device supports synchronization +# of input and output video modes that match in being odd or even +# modes (ie, AA.00 Hz modes can be synched to other BB.00 Hz modes and +# AA.XX Hz can match to BB.YY Hz where .XX and .YY are not .00) +# + +NV_CTRL_GVO_CAPABILITIES = 229 # R-- +NV_CTRL_GVO_CAPABILITIES_APPLY_CSC_IMMEDIATELY = 0x00000001 +NV_CTRL_GVO_CAPABILITIES_APPLY_CSC_TO_X_SCREEN = 0x00000002 +NV_CTRL_GVO_CAPABILITIES_COMPOSITE_TERMINATION = 0x00000004 +NV_CTRL_GVO_CAPABILITIES_SHARED_SYNC_BNC = 0x00000008 +NV_CTRL_GVO_CAPABILITIES_MULTIRATE_SYNC = 0x00000010 +NV_CTRL_GVO_CAPABILITIES_ADVANCE_SYNC_SKEW = 0x00000020 + +# +# NV_CTRL_GVO_COMPOSITE_TERMINATION - enable or disable 75 ohm +# termination of the SDI composite input signal. +# + +NV_CTRL_GVO_COMPOSITE_TERMINATION = 230 # RW- +NV_CTRL_GVO_COMPOSITE_TERMINATION_ENABLE = 1 +NV_CTRL_GVO_COMPOSITE_TERMINATION_DISABLE = 0 + +# +# NV_CTRL_ASSOCIATED_DISPLAY_DEVICES - deprecated +# +# NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN should be used instead. +# + +NV_CTRL_ASSOCIATED_DISPLAY_DEVICES = 231 # deprecated + +# +# NV_CTRL_FRAMELOCK_SLAVES - deprecated +# +# NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead. +# + +NV_CTRL_FRAMELOCK_SLAVES = 232 # deprecated + +# +# NV_CTRL_FRAMELOCK_MASTERABLE - deprecated +# +# NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead. +# + +NV_CTRL_FRAMELOCK_MASTERABLE = 233 # deprecated + +# +# NV_CTRL_PROBE_DISPLAYS - re-probes the hardware to detect what +# display devices are connected to the GPU or GPU driving the +# specified X screen. The return value is deprecated and should not be used. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_PROBE_DISPLAYS = 234 # R--G + +# +# NV_CTRL_REFRESH_RATE - Returns the refresh rate of the specified +# display device in 100# Hz (ie. to get the refresh rate in Hz, divide +# the returned value by 100.) +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_REFRESH_RATE = 235 # R-DG + +# +# NV_CTRL_GVO_FLIP_QUEUE_SIZE - The Graphics to Video Out interface +# exposed through NV-CONTROL and the GLX_NV_video_out extension uses +# an internal flip queue when pbuffers are sent to the video device +# (via glXSendPbufferToVideoNV()). The NV_CTRL_GVO_FLIP_QUEUE_SIZE +# can be used to query and assign the flip queue size. This +# attribute is applied to GLX when glXGetVideoDeviceNV() is called by +# the application. +# + +NV_CTRL_GVO_FLIP_QUEUE_SIZE = 236 # RW- + +# +# NV_CTRL_CURRENT_SCANLINE - query the current scanline for the +# specified display device. +# + +NV_CTRL_CURRENT_SCANLINE = 237 # R-DG + +# +# NV_CTRL_INITIAL_PIXMAP_PLACEMENT - Controls where X pixmaps are initially +# created. +# +# NV_CTRL_INITIAL_PIXMAP_PLACEMENT_FORCE_SYSMEM causes pixmaps to stay in +# system memory. These pixmaps can't be accelerated by the NVIDIA driver; this +# will cause blank windows if used with an OpenGL compositing manager. +# NV_CTRL_INITIAL_PIXMAP_PLACEMENT_SYSMEM creates pixmaps in system memory +# initially, but allows them to migrate to video memory. +# NV_CTRL_INITIAL_PIXMAP_PLACEMENT_VIDMEM creates pixmaps in video memory +# when enough resources are available. +# NV_CTRL_INITIAL_PIXMAP_PLACEMENT_RESERVED is currently reserved for future +# use. Behavior is undefined. +# NV_CTRL_INITIAL_PIXMAP_PLACEMENT_GPU_SYSMEM creates pixmaps in GPU accessible +# system memory when enough resources are available. +# + +NV_CTRL_INITIAL_PIXMAP_PLACEMENT = 238 # RW- +NV_CTRL_INITIAL_PIXMAP_PLACEMENT_FORCE_SYSMEM = 0 +NV_CTRL_INITIAL_PIXMAP_PLACEMENT_SYSMEM = 1 +NV_CTRL_INITIAL_PIXMAP_PLACEMENT_VIDMEM = 2 +NV_CTRL_INITIAL_PIXMAP_PLACEMENT_RESERVED = 3 +NV_CTRL_INITIAL_PIXMAP_PLACEMENT_GPU_SYSMEM = 4 + +# +# NV_CTRL_PCI_BUS - Returns the PCI bus number the specified device is using. +# + +NV_CTRL_PCI_BUS = 239 # R--GI + +# +# NV_CTRL_PCI_DEVICE - Returns the PCI device number the specified device is +# using. +# + +NV_CTRL_PCI_DEVICE = 240 # R--GI + +# +# NV_CTRL_PCI_FUNCTION - Returns the PCI function number the specified device +# is using. +# + +NV_CTRL_PCI_FUNCTION = 241 # R--GI + +# +# NV_CTRL_FRAMELOCK_FPGA_REVISION - Queries the FPGA revision of the +# Frame Lock device. +# +# This attribute must be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK target. +# + +NV_CTRL_FRAMELOCK_FPGA_REVISION = 242 # R--F + +# +# NV_CTRL_MAX_SCREEN_{WIDTH,HEIGHT} - the maximum allowable size, in +# pixels, of either the specified X screen (if the target_type of the +# query is an X screen), or any X screen on the specified GPU (if the +# target_type of the query is a GPU). +# + +NV_CTRL_MAX_SCREEN_WIDTH = 243 # R--G +NV_CTRL_MAX_SCREEN_HEIGHT = 244 # R--G + +# +# NV_CTRL_MAX_DISPLAYS - The maximum number of display devices that +# can be driven simultaneously on a GPU (e.g., that can be used in a +# MetaMode at once). Note that this does not indicate the maximum +# number of displays that are listed in NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU +# and NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU because more display +# devices can be connected than are actively in use. +# + +NV_CTRL_MAX_DISPLAYS = 245 # R--G + +# +# NV_CTRL_DYNAMIC_TWINVIEW - Returns whether or not the screen +# supports dynamic twinview. +# + +NV_CTRL_DYNAMIC_TWINVIEW = 246 # R-- + +# +# NV_CTRL_MULTIGPU_DISPLAY_OWNER - Returns the (NV-CONTROL) GPU ID of +# the GPU that has the display device(s) used for showing the X Screen. +# + +NV_CTRL_MULTIGPU_DISPLAY_OWNER = 247 # R-- + +# +# NV_CTRL_GPU_SCALING - not supported +# + +NV_CTRL_GPU_SCALING = 248 # not supported + +NV_CTRL_GPU_SCALING_TARGET_INVALID = 0 # not supported +NV_CTRL_GPU_SCALING_TARGET_FLATPANEL_BEST_FIT = 1 # not supported +NV_CTRL_GPU_SCALING_TARGET_FLATPANEL_NATIVE = 2 # not supported + +NV_CTRL_GPU_SCALING_METHOD_INVALID = 0 # not supported +NV_CTRL_GPU_SCALING_METHOD_STRETCHED = 1 # not supported +NV_CTRL_GPU_SCALING_METHOD_CENTERED = 2 # not supported +NV_CTRL_GPU_SCALING_METHOD_ASPECT_SCALED = 3 # not supported + +# +# NV_CTRL_FRONTEND_RESOLUTION - not supported +# + +NV_CTRL_FRONTEND_RESOLUTION = 249 # not supported + +# +# NV_CTRL_BACKEND_RESOLUTION - not supported +# + +NV_CTRL_BACKEND_RESOLUTION = 250 # not supported + +# +# NV_CTRL_FLATPANEL_NATIVE_RESOLUTION - not supported +# + +NV_CTRL_FLATPANEL_NATIVE_RESOLUTION = 251 # not supported + +# +# NV_CTRL_FLATPANEL_BEST_FIT_RESOLUTION - not supported +# + +NV_CTRL_FLATPANEL_BEST_FIT_RESOLUTION = 252 # not supported + +# +# NV_CTRL_GPU_SCALING_ACTIVE - not supported +# + +NV_CTRL_GPU_SCALING_ACTIVE = 253 # not supported + +# +# NV_CTRL_DFP_SCALING_ACTIVE - not supported +# + +NV_CTRL_DFP_SCALING_ACTIVE = 254 # not supported + +# +# NV_CTRL_FSAA_APPLICATION_ENHANCED - Controls how the NV_CTRL_FSAA_MODE +# is applied when NV_CTRL_FSAA_APPLICATION_CONTROLLED is set to +# NV_CTRL_APPLICATION_CONTROLLED_DISABLED. When +# NV_CTRL_FSAA_APPLICATION_ENHANCED is _DISABLED, OpenGL applications will +# be forced to use the FSAA mode specified by NV_CTRL_FSAA_MODE. when set +# to _ENABLED, only those applications that have selected a multisample +# FBConfig will be made to use the NV_CTRL_FSAA_MODE specified. +# +# This attribute is ignored when NV_CTRL_FSAA_APPLICATION_CONTROLLED is +# set to NV_CTRL_FSAA_APPLICATION_CONTROLLED_ENABLED. +# + +NV_CTRL_FSAA_APPLICATION_ENHANCED = 255 # RW-X +NV_CTRL_FSAA_APPLICATION_ENHANCED_ENABLED = 1 +NV_CTRL_FSAA_APPLICATION_ENHANCED_DISABLED = 0 + +# +# NV_CTRL_FRAMELOCK_SYNC_RATE_4 - This is the refresh rate that the +# frame lock board is sending to the GPU with 4 digits of precision. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK. +# + +NV_CTRL_FRAMELOCK_SYNC_RATE_4 = 256 # R--F + +# +# NV_CTRL_GVO_LOCK_OWNER - indicates that the GVO device is available +# or in use (by GLX or an X screen). +# +# The GVO device is locked by GLX when either glXGetVideoDeviceNV +# (part of GLX_NV_video_out) or glXBindVideoDeviceNV (part of +# GLX_NV_present_video) is called. All GVO output resources are +# locked until released by the GLX_NV_video_out/GLX_NV_present_video +# client. +# +# The GVO device is locked/unlocked by an X screen, when the GVO device is +# used in a MetaMode on an X screen. +# +# When the GVO device is locked, setting of the following GVO NV-CONTROL +# attributes will not happen immediately and will instead be cached. The +# GVO resource will need to be disabled/released and re-enabled/claimed for +# the values to be flushed. These attributes are: +# +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT +# NV_CTRL_GVO_DATA_FORMAT +# NV_CTRL_GVO_FLIP_QUEUE_SIZE +# + +NV_CTRL_GVO_LOCK_OWNER = 257 # R-- +NV_CTRL_GVO_LOCK_OWNER_NONE = 0 +NV_CTRL_GVO_LOCK_OWNER_GLX = 1 +NV_CTRL_GVO_LOCK_OWNER_CLONE = 2 # not supported +NV_CTRL_GVO_LOCK_OWNER_X_SCREEN = 3 + +# +# NV_CTRL_HWOVERLAY - when a workstation overlay is in use, reports +# whether the hardware overlay is used, or if the overlay is emulated. +# + +NV_CTRL_HWOVERLAY = 258 # R-- +NV_CTRL_HWOVERLAY_FALSE = 0 +NV_CTRL_HWOVERLAY_TRUE = 1 + +# +# NV_CTRL_NUM_GPU_ERRORS_RECOVERED - Returns the number of GPU errors +# occured. This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_NUM_GPU_ERRORS_RECOVERED = 259 # R--- + +# +# NV_CTRL_REFRESH_RATE_3 - Returns the refresh rate of the specified +# display device in 1000# Hz (ie. to get the refresh rate in Hz, divide +# the returned value by 1000.) +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_REFRESH_RATE_3 = 260 # R-DG + +# +# NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS - not supported +# + +NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS = 261 # not supported +NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS_OFF = 0 # not supported +NV_CTRL_ONDEMAND_VBLANK_INTERRUPTS_ON = 1 # not supported + +# +# NV_CTRL_GPU_POWER_SOURCE reports the type of power source +# of the GPU driving the X screen. +# + +NV_CTRL_GPU_POWER_SOURCE = 262 # R--G +NV_CTRL_GPU_POWER_SOURCE_AC = 0 +NV_CTRL_GPU_POWER_SOURCE_BATTERY = 1 + +# +# NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE - not supported +# + +NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE = 263 # not supported +NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE_DESKTOP = 0 # not supported +NV_CTRL_GPU_CURRENT_PERFORMANCE_MODE_MAXPERF = 1 # not supported + +# NV_CTRL_GLYPH_CACHE - Enables RENDER Glyph Caching to VRAM + +NV_CTRL_GLYPH_CACHE = 264 # RW- +NV_CTRL_GLYPH_CACHE_DISABLED = 0 +NV_CTRL_GLYPH_CACHE_ENABLED = 1 + +# +# NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL reports the current +# Performance level of the GPU driving the X screen. Each +# Performance level has associated NVClock and Mem Clock values. +# + +NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL = 265 # R--G + +# +# NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE reports if Adaptive Clocking +# is Enabled on the GPU driving the X screen. +# + +NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE = 266 # R--G +NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE_DISABLED = 0 +NV_CTRL_GPU_ADAPTIVE_CLOCK_STATE_ENABLED = 1 + +# +# NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED - Returns whether or not the GVO output +# video is locked to the GPU. +# + +NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED = 267 # R--- +NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED_FALSE = 0 +NV_CTRL_GVO_OUTPUT_VIDEO_LOCKED_TRUE = 1 + +# +# NV_CTRL_GVO_SYNC_LOCK_STATUS - Returns whether or not the GVO device +# is locked to the input ref signal. If the sync mode is set to +# NV_CTRL_GVO_SYNC_MODE_GENLOCK, then this returns the genlock +# sync status, and if the sync mode is set to NV_CTRL_GVO_SYNC_MODE_FRAMELOCK, +# then this reports the frame lock status. +# + +NV_CTRL_GVO_SYNC_LOCK_STATUS = 268 # R--- +NV_CTRL_GVO_SYNC_LOCK_STATUS_UNLOCKED = 0 +NV_CTRL_GVO_SYNC_LOCK_STATUS_LOCKED = 1 + +# +# NV_CTRL_GVO_ANC_TIME_CODE_GENERATION - Allows SDI device to generate +# time codes in the ANC region of the SDI video output stream. +# + +NV_CTRL_GVO_ANC_TIME_CODE_GENERATION = 269 # RW-- +NV_CTRL_GVO_ANC_TIME_CODE_GENERATION_DISABLE = 0 +NV_CTRL_GVO_ANC_TIME_CODE_GENERATION_ENABLE = 1 + +# +# NV_CTRL_GVO_COMPOSITE - Enables/Disables SDI compositing. This attribute +# is only available when an SDI input source is detected and is in genlock +# mode. +# + +NV_CTRL_GVO_COMPOSITE = 270 # RW-- +NV_CTRL_GVO_COMPOSITE_DISABLE = 0 +NV_CTRL_GVO_COMPOSITE_ENABLE = 1 + +# +# NV_CTRL_GVO_COMPOSITE_ALPHA_KEY - When compositing is enabled, this +# enables/disables alpha blending. +# + +NV_CTRL_GVO_COMPOSITE_ALPHA_KEY = 271 # RW-- +NV_CTRL_GVO_COMPOSITE_ALPHA_KEY_DISABLE = 0 +NV_CTRL_GVO_COMPOSITE_ALPHA_KEY_ENABLE = 1 + +# +# NV_CTRL_GVO_COMPOSITE_LUMA_KEY_RANGE - Set the values of a luma +# channel range. This is a packed int that has the following format +# (in order of high-bits to low bits): +# +# Range # (11 bits), (Enabled 1 bit), min value (10 bits), max value (10 bits) +# +# To query the current values, pass the range # throught the display_mask +# variable. +# + +NV_CTRL_GVO_COMPOSITE_LUMA_KEY_RANGE = 272 # RW-- + +# +# NV_CTRL_GVO_COMPOSITE_CR_KEY_RANGE - Set the values of a CR +# channel range. This is a packed int that has the following format +# (in order of high-bits to low bits): +# +# Range # (11 bits), (Enabled 1 bit), min value (10 bits), max value (10 bits) +# +# To query the current values, pass the range # throught he display_mask +# variable. +# + +NV_CTRL_GVO_COMPOSITE_CR_KEY_RANGE = 273 # RW-- + +# +# NV_CTRL_GVO_COMPOSITE_CB_KEY_RANGE - Set the values of a CB +# channel range. This is a packed int that has the following format +# (in order of high-bits to low bits): +# +# Range # (11 bits), (Enabled 1 bit), min value (10 bits), max value (10 bits) +# +# To query the current values, pass the range # throught he display_mask +# variable. +# + +NV_CTRL_GVO_COMPOSITE_CB_KEY_RANGE = 274 # RW-- + +# +# NV_CTRL_GVO_COMPOSITE_NUM_KEY_RANGES - Returns the number of ranges +# available for each channel (Y/Luma, Cr, and Cb.) +# + +NV_CTRL_GVO_COMPOSITE_NUM_KEY_RANGES = 275 # R--- + +# +# NV_CTRL_SWITCH_TO_DISPLAYS - not supported +# + +NV_CTRL_SWITCH_TO_DISPLAYS = 276 # not supported + +# +# NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT - not supported +# + +NV_CTRL_NOTEBOOK_DISPLAY_CHANGE_LID_EVENT = 277 # not supported + +# +# NV_CTRL_NOTEBOOK_INTERNAL_LCD - deprecated +# + +NV_CTRL_NOTEBOOK_INTERNAL_LCD = 278 # deprecated + +# +# NV_CTRL_DEPTH_30_ALLOWED - returns whether the NVIDIA X driver supports +# depth 30 on the specified X screen or GPU. +# + +NV_CTRL_DEPTH_30_ALLOWED = 279 # R--G + +# +# NV_CTRL_MODE_SET_EVENT This attribute is sent as an event +# when hotkey, ctrl-alt-+/- or randr event occurs. Note that +# This attribute cannot be set or queried and is meant to +# be received by clients that wish to be notified of when +# mode set events occur. +# + +NV_CTRL_MODE_SET_EVENT = 280 # --- + +# +# NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE - the gamma value used by +# OpenGL when NV_CTRL_OPENGL_AA_LINE_GAMMA is enabled +# + +NV_CTRL_OPENGL_AA_LINE_GAMMA_VALUE = 281 # RW-X + +# +# NV_CTRL_VCSC_HIGH_PERF_MODE - deprecated +# +# Is used to both query High Performance Mode status on the Visual Computing +# System, and also to enable or disable High Performance Mode. +# + +NV_CTRL_VCSC_HIGH_PERF_MODE = 282 # RW-V +NV_CTRL_VCSC_HIGH_PERF_MODE_DISABLE = 0 +NV_CTRL_VCSC_HIGH_PERF_MODE_ENABLE = 1 + +# +# NV_CTRL_DISPLAYPORT_LINK_RATE - returns the negotiated lane bandwidth of the +# DisplayPort main link. The numerical value of this attribute is the link +# rate in bps divided by 27000000. +# This attribute is only available for DisplayPort flat panels. +# + +NV_CTRL_DISPLAYPORT_LINK_RATE = 291 # R-DG +NV_CTRL_DISPLAYPORT_LINK_RATE_DISABLED = 0x0 +NV_CTRL_DISPLAYPORT_LINK_RATE_1_62GBPS = 0x6 # deprecated +NV_CTRL_DISPLAYPORT_LINK_RATE_2_70GBPS = 0xA # deprecated + +# +# NV_CTRL_STEREO_EYES_EXCHANGE - Controls whether or not the left and right +# eyes of a stereo image are flipped. +# + +NV_CTRL_STEREO_EYES_EXCHANGE = 292 # RW-X +NV_CTRL_STEREO_EYES_EXCHANGE_OFF = 0 +NV_CTRL_STEREO_EYES_EXCHANGE_ON = 1 + +# +# NV_CTRL_NO_SCANOUT - returns whether the special "NoScanout" mode is +# enabled on the specified X screen or GPU; for details on this mode, +# see the description of the "none" value for the "UseDisplayDevice" +# X configuration option in the NVIDIA driver README. +# + +NV_CTRL_NO_SCANOUT = 293 # R--G +NV_CTRL_NO_SCANOUT_DISABLED = 0 +NV_CTRL_NO_SCANOUT_ENABLED = 1 + +# +# NV_CTRL_GVO_CSC_CHANGED_EVENT This attribute is sent as an event +# when the color space conversion matrix has been altered by another +# client. +# + +NV_CTRL_GVO_CSC_CHANGED_EVENT = 294 # --- + +# +# NV_CTRL_FRAMELOCK_SLAVEABLE - deprecated +# +# NV_CTRL_FRAMELOCK_DISPLAY_CONFIG should be used instead. +# + +NV_CTRL_FRAMELOCK_SLAVEABLE = 295 # deprecated + +# +# NV_CTRL_GVO_SYNC_TO_DISPLAY This attribute controls whether or not +# the non-SDI display device will be sync'ed to the SDI display device +# (when configured in TwinView, Clone Mode or when using the SDI device +# with OpenGL). +# + +NV_CTRL_GVO_SYNC_TO_DISPLAY = 296 # --- +NV_CTRL_GVO_SYNC_TO_DISPLAY_DISABLE = 0 +NV_CTRL_GVO_SYNC_TO_DISPLAY_ENABLE = 1 + +# +# NV_CTRL_X_SERVER_UNIQUE_ID - returns a pseudo-unique identifier for this +# X server. Intended for use in cases where an NV-CONTROL client communicates +# with multiple X servers, and wants some level of confidence that two +# X Display connections correspond to the same or different X servers. +# + +NV_CTRL_X_SERVER_UNIQUE_ID = 297 # R--- + +# +# NV_CTRL_PIXMAP_CACHE - This attribute controls whether the driver attempts to +# store video memory pixmaps in a cache. The cache speeds up allocation and +# deallocation of pixmaps, but could use more memory than when the cache is +# disabled. +# + +NV_CTRL_PIXMAP_CACHE = 298 # RW-X +NV_CTRL_PIXMAP_CACHE_DISABLE = 0 +NV_CTRL_PIXMAP_CACHE_ENABLE = 1 + +# +# NV_CTRL_PIXMAP_CACHE_ROUNDING_SIZE_KB - When the pixmap cache is enabled and +# there is not enough free space in the cache to fit a new pixmap, the driver +# will round up to the next multiple of this number of kilobytes when +# allocating more memory for the cache. +# + +NV_CTRL_PIXMAP_CACHE_ROUNDING_SIZE_KB = 299 # RW-X + +# +# NV_CTRL_IS_GVO_DISPLAY - returns whether or not a given display is an +# SDI device. +# + +NV_CTRL_IS_GVO_DISPLAY = 300 # R-D +NV_CTRL_IS_GVO_DISPLAY_FALSE = 0 +NV_CTRL_IS_GVO_DISPLAY_TRUE = 1 + +# +# NV_CTRL_PCI_ID - Returns the PCI vendor and device ID of the specified +# device. +# +# NV_CTRL_PCI_ID is a "packed" integer attribute; the PCI vendor ID is stored +# in the upper 16 bits of the integer, and the PCI device ID is stored in the +# lower 16 bits of the integer. +# + +NV_CTRL_PCI_ID = 301 # R--GI + +# +# NV_CTRL_GVO_FULL_RANGE_COLOR - Allow full range color data [4-1019] +# without clamping to [64-940]. +# + +NV_CTRL_GVO_FULL_RANGE_COLOR = 302 # RW- +NV_CTRL_GVO_FULL_RANGE_COLOR_DISABLED = 0 +NV_CTRL_GVO_FULL_RANGE_COLOR_ENABLED = 1 + +# +# NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE - Returns whether or not +# SLI Mosaic Mode supported. +# + +NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE = 303 # R-- +NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE_FALSE = 0 +NV_CTRL_SLI_MOSAIC_MODE_AVAILABLE_TRUE = 1 + +# +# NV_CTRL_GVO_ENABLE_RGB_DATA - Allows clients to specify when +# the GVO board should process colors as RGB when the output data +# format is one of the NV_CTRL_GVO_DATA_FORMAT_???_PASSTRHU modes. +# + +NV_CTRL_GVO_ENABLE_RGB_DATA = 304 # RW- +NV_CTRL_GVO_ENABLE_RGB_DATA_DISABLE = 0 +NV_CTRL_GVO_ENABLE_RGB_DATA_ENABLE = 1 + +# +# NV_CTRL_IMAGE_SHARPENING_DEFAULT - Returns default value of +# Image Sharpening. +# + +NV_CTRL_IMAGE_SHARPENING_DEFAULT = 305 # R-- + +# +# NV_CTRL_PCI_DOMAIN - Returns the PCI domain number the specified device is +# using. +# + +NV_CTRL_PCI_DOMAIN = 306 # R--GI + +# +# NV_CTRL_GVI_NUM_JACKS - Returns the number of input BNC jacks available +# on a GVI device. +# + +NV_CTRL_GVI_NUM_JACKS = 307 # R--I + +# +# NV_CTRL_GVI_MAX_LINKS_PER_STREAM - Returns the maximum supported number of +# links that can be tied to one stream. +# + +NV_CTRL_GVI_MAX_LINKS_PER_STREAM = 308 # R--I + +# +# NV_CTRL_GVI_DETECTED_CHANNEL_BITS_PER_COMPONENT - Returns the detected +# number of bits per component (BPC) of data on the given input jack+ +# channel. +# +# The jack number should be specified in the lower 16 bits of the +# "display_mask" parameter, while the channel number should be specified in +# the upper 16 bits. +# + +NV_CTRL_GVI_DETECTED_CHANNEL_BITS_PER_COMPONENT = 309 # R--I +NV_CTRL_GVI_BITS_PER_COMPONENT_UNKNOWN = 0 +NV_CTRL_GVI_BITS_PER_COMPONENT_8 = 1 +NV_CTRL_GVI_BITS_PER_COMPONENT_10 = 2 +NV_CTRL_GVI_BITS_PER_COMPONENT_12 = 3 + +# +# NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT - Specify the number of +# bits per component (BPC) of data for the captured stream. +# The stream number should be specified in the "display_mask" parameter. +# +# Note: Setting this attribute may also result in the following +# NV-CONTROL attributes being reset on the GVI device (to ensure +# the configuration remains valid): +# NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING +# + +NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT = 310 # RW-I + +# +# NV_CTRL_GVI_DETECTED_CHANNEL_COMPONENT_SAMPLING - Returns the detected +# sampling format for the input jack+channel. +# +# The jack number should be specified in the lower 16 bits of the +# "display_mask" parameter, while the channel number should be specified in +# the upper 16 bits. +# + +NV_CTRL_GVI_DETECTED_CHANNEL_COMPONENT_SAMPLING = 311 # R--I +NV_CTRL_GVI_COMPONENT_SAMPLING_UNKNOWN = 0 +NV_CTRL_GVI_COMPONENT_SAMPLING_4444 = 1 +NV_CTRL_GVI_COMPONENT_SAMPLING_4224 = 2 +NV_CTRL_GVI_COMPONENT_SAMPLING_444 = 3 +NV_CTRL_GVI_COMPONENT_SAMPLING_422 = 4 +NV_CTRL_GVI_COMPONENT_SAMPLING_420 = 5 + +# +# NV_CTRL_GVI_REQUESTED_COMPONENT_SAMPLING - Specify the sampling format for +# the captured stream. +# The possible values are the NV_CTRL_GVI_DETECTED_COMPONENT_SAMPLING +# constants. +# The stream number should be specified in the "display_mask" parameter. +# + +NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING = 312 # RW-I + +# +# NV_CTRL_GVI_CHROMA_EXPAND - Enable or disable 4:2:2 -> 4:4:4 chroma +# expansion for the captured stream. This value is ignored when a +# COMPONENT_SAMPLING format is selected that does not use chroma subsampling, +# or if a BITS_PER_COMPONENT value is selected that is not supported. +# The stream number should be specified in the "display_mask" parameter. +# + +NV_CTRL_GVI_REQUESTED_STREAM_CHROMA_EXPAND = 313 # RW-I +NV_CTRL_GVI_CHROMA_EXPAND_FALSE = 0 +NV_CTRL_GVI_CHROMA_EXPAND_TRUE = 1 + +# +# NV_CTRL_GVI_DETECTED_CHANNEL_COLOR_SPACE - Returns the detected color space +# of the input jack+channel. +# +# The jack number should be specified in the lower 16 bits of the +# "display_mask" parameter, while the channel number should be specified in +# the upper 16 bits. +# + +NV_CTRL_GVI_DETECTED_CHANNEL_COLOR_SPACE = 314 # R--I +NV_CTRL_GVI_COLOR_SPACE_UNKNOWN = 0 +NV_CTRL_GVI_COLOR_SPACE_GBR = 1 +NV_CTRL_GVI_COLOR_SPACE_GBRA = 2 +NV_CTRL_GVI_COLOR_SPACE_GBRD = 3 +NV_CTRL_GVI_COLOR_SPACE_YCBCR = 4 +NV_CTRL_GVI_COLOR_SPACE_YCBCRA = 5 +NV_CTRL_GVI_COLOR_SPACE_YCBCRD = 6 + +# +# NV_CTRL_GVI_DETECTED_CHANNEL_LINK_ID - Returns the detected link identifier +# for the given input jack+channel. +# +# The jack number should be specified in the lower 16 bits of the +# "display_mask" parameter, while the channel number should be specified in +# the upper 16 bits. +# + +NV_CTRL_GVI_DETECTED_CHANNEL_LINK_ID = 315 # R--I +NV_CTRL_GVI_LINK_ID_UNKNOWN = 0xFFFF + +# +# NV_CTRL_GVI_DETECTED_CHANNEL_SMPTE352_IDENTIFIER - Returns the 4-byte +# SMPTE 352 identifier from the given input jack+channel. +# +# The jack number should be specified in the lower 16 bits of the +# "display_mask" parameter, while the channel number should be specified in +# the upper 16 bits. +# + +NV_CTRL_GVI_DETECTED_CHANNEL_SMPTE352_IDENTIFIER = 316 # R--I + +# +# NV_CTRL_GVI_GLOBAL_IDENTIFIER - Returns a global identifier for the +# GVI device. This identifier can be used to relate GVI devices named +# in NV-CONTROL with those enumerated in OpenGL. +# + +NV_CTRL_GVI_GLOBAL_IDENTIFIER = 317 # R--I + +# +# NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION - Returns the number of nanoseconds +# that one unit of NV_CTRL_FRAMELOCK_SYNC_DELAY corresponds to. +# +NV_CTRL_FRAMELOCK_SYNC_DELAY_RESOLUTION = 318 # R-- + +# +# NV_CTRL_GPU_COOLER_MANUAL_CONTROL - Query the current or set a new +# cooler control state; the value of this attribute controls the +# availability of additional cooler control attributes (see below). +# +# Note: this attribute is unavailable unless cooler control support +# has been enabled in the X server (by the user). +# + +NV_CTRL_GPU_COOLER_MANUAL_CONTROL = 319 # RW-G +NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE = 0 +NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE = 1 + +# +# NV_CTRL_THERMAL_COOLER_LEVEL - The cooler's target level. +# Normally, the driver dynamically adjusts the cooler based on +# the needs of the GPU. But when NV_CTRL_GPU_COOLER_MANUAL_CONTROL=TRUE, +# the driver will attempt to make the cooler achieve the setting in +# NV_CTRL_THERMAL_COOLER_LEVEL. The actual current level of the cooler +# is reported in NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL. +# + +NV_CTRL_THERMAL_COOLER_LEVEL = 320 # RW-C + +# NV_CTRL_THERMAL_COOLER_LEVEL_SET_DEFAULT - Sets default values of +# cooler. +# + +NV_CTRL_THERMAL_COOLER_LEVEL_SET_DEFAULT = 321 # -W-C + +# +# NV_CTRL_THERMAL_COOLER_CONTROL_TYPE - +# Returns a cooler's control signal characteristics. +# The possible types are restricted, Variable and Toggle. +# + +NV_CTRL_THERMAL_COOLER_CONTROL_TYPE = 322 # R--C +NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_NONE = 0 +NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_TOGGLE = 1 +NV_CTRL_THERMAL_COOLER_CONTROL_TYPE_VARIABLE = 2 + +# +# NV_CTRL_THERMAL_COOLER_TARGET - Returns objects that cooler cools. +# Targets may be GPU, Memory, Power Supply or All of these. +# GPU_RELATED = GPU | MEMORY | POWER_SUPPLY +# +# + +NV_CTRL_THERMAL_COOLER_TARGET = 323 # R--C +NV_CTRL_THERMAL_COOLER_TARGET_NONE = 0 +NV_CTRL_THERMAL_COOLER_TARGET_GPU = 1 +NV_CTRL_THERMAL_COOLER_TARGET_MEMORY = 2 +NV_CTRL_THERMAL_COOLER_TARGET_POWER_SUPPLY = 4 +NV_CTRL_THERMAL_COOLER_TARGET_GPU_RELATED = NV_CTRL_THERMAL_COOLER_TARGET_GPU | NV_CTRL_THERMAL_COOLER_TARGET_MEMORY | NV_CTRL_THERMAL_COOLER_TARGET_POWER_SUPPLY + +# +# NV_CTRL_GPU_ECC_SUPPORTED - Reports whether ECC is supported by the +# targeted GPU. +# +NV_CTRL_GPU_ECC_SUPPORTED = 324 # R--G +NV_CTRL_GPU_ECC_SUPPORTED_FALSE = 0 +NV_CTRL_GPU_ECC_SUPPORTED_TRUE = 1 + +# +# NV_CTRL_GPU_ECC_STATUS - Returns the current hardware ECC setting +# for the targeted GPU. +# +NV_CTRL_GPU_ECC_STATUS = 325 # R--G +NV_CTRL_GPU_ECC_STATUS_DISABLED = 0 +NV_CTRL_GPU_ECC_STATUS_ENABLED = 1 + +# +# NV_CTRL_GPU_ECC_CONFIGURATION - Reports whether ECC can be configured +# dynamically for the GPU in question. +# +NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED = 326 # R--G +NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED_FALSE = 0 +NV_CTRL_GPU_ECC_CONFIGURATION_SUPPORTED_TRUE = 1 + +# +# NV_CTRL_GPU_ECC_CONFIGURATION_SETTING - Returns the current ECC +# configuration setting or specifies new settings. New settings do not +# take effect until the next POST. +# +NV_CTRL_GPU_ECC_CONFIGURATION = 327 # RW-G +NV_CTRL_GPU_ECC_CONFIGURATION_DISABLED = 0 +NV_CTRL_GPU_ECC_CONFIGURATION_ENABLED = 1 + +# +# NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION_SETTING - Returns the default +# ECC configuration setting. +# +NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION = 328 # R--G +NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION_DISABLED = 0 +NV_CTRL_GPU_ECC_DEFAULT_CONFIGURATION_ENABLED = 1 + +# +# NV_CTRL_GPU_ECC_SINGLE_BIT_ERRORS - Returns the number of single-bit +# ECC errors detected by the targeted GPU since the last POST. +# Note: this attribute is a 64-bit integer attribute. +# +NV_CTRL_GPU_ECC_SINGLE_BIT_ERRORS = 329 # R--GQ + +# +# NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS - Returns the number of double-bit +# ECC errors detected by the targeted GPU since the last POST. +# Note: this attribute is a 64-bit integer attribute. +# +NV_CTRL_GPU_ECC_DOUBLE_BIT_ERRORS = 330 # R--GQ + +# +# NV_CTRL_GPU_ECC_AGGREGATE_SINGLE_BIT_ERRORS - Returns the number of +# single-bit ECC errors detected by the targeted GPU since the +# last counter reset. +# Note: this attribute is a 64-bit integer attribute. +# +NV_CTRL_GPU_ECC_AGGREGATE_SINGLE_BIT_ERRORS = 331 # R--GQ + +# +# NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS - Returns the number of +# double-bit ECC errors detected by the targeted GPU since the +# last counter reset. +# Note: this attribute is a 64-bit integer attribute. +# +NV_CTRL_GPU_ECC_AGGREGATE_DOUBLE_BIT_ERRORS = 332 # R--GQ + +# +# NV_CTRL_GPU_ECC_RESET_ERROR_STATUS - Resets the volatile/aggregate +# single-bit and double-bit error counters. This attribute is a +# bitmask attribute. +# +NV_CTRL_GPU_ECC_RESET_ERROR_STATUS = 333 # -W-G +NV_CTRL_GPU_ECC_RESET_ERROR_STATUS_VOLATILE = 0x00000001 +NV_CTRL_GPU_ECC_RESET_ERROR_STATUS_AGGREGATE = 0x00000002 + +# +# NV_CTRL_GPU_POWER_MIZER_MODE - Provides a hint to the driver +# as to how to manage the performance of the GPU. +# +# ADAPTIVE - adjust GPU clocks based on GPU +# utilization +# PREFER_MAXIMUM_PERFORMANCE - raise GPU clocks to favor +# maximum performance, to the extent +# that thermal and other constraints +# allow +# AUTO - let the driver choose the performance +# policy +# PREFER_CONSISTENT_PERFORMANCE - lock to GPU base clocks +# +NV_CTRL_GPU_POWER_MIZER_MODE = 334 # RW-G +NV_CTRL_GPU_POWER_MIZER_MODE_ADAPTIVE = 0 +NV_CTRL_GPU_POWER_MIZER_MODE_PREFER_MAXIMUM_PERFORMANCE = 1 +NV_CTRL_GPU_POWER_MIZER_MODE_AUTO = 2 +NV_CTRL_GPU_POWER_MIZER_MODE_PREFER_CONSISTENT_PERFORMANCE = 3 + +# +# NV_CTRL_GVI_SYNC_OUTPUT_FORMAT - Returns the output sync signal +# from the GVI device. +# + +NV_CTRL_GVI_SYNC_OUTPUT_FORMAT = 335 # R--I + +# +# NV_CTRL_GVI_MAX_CHANNELS_PER_JACK - Returns the maximum +# supported number of (logical) channels within a single physical jack of +# a GVI device. For most SDI video formats, there is only one channel +# (channel 0). But for 3G video formats (as specified in SMPTE 425), +# as an example, there are two channels (channel 0 and channel 1) per +# physical jack. +# + +NV_CTRL_GVI_MAX_CHANNELS_PER_JACK = 336 # R--I + +# +# NV_CTRL_GVI_MAX_STREAMS - Returns the maximum number of streams +# that can be configured on the GVI device. +# + +NV_CTRL_GVI_MAX_STREAMS = 337 # R--I + +# +# NV_CTRL_GVI_NUM_CAPTURE_SURFACES - The GVI interface exposed through +# NV-CONTROL and the GLX_NV_video_input extension uses internal capture +# surfaces when frames are read from the GVI device. The +# NV_CTRL_GVI_NUM_CAPTURE_SURFACES can be used to query and assign the +# number of capture surfaces. This attribute is applied when +# glXBindVideoCaptureDeviceNV() is called by the application. +# +# A lower number of capture surfaces will mean less video memory is used, +# but can result in frames being dropped if the application cannot keep up +# with the capture device. A higher number will prevent frames from being +# dropped, making capture more reliable but will consume move video memory. +# +NV_CTRL_GVI_NUM_CAPTURE_SURFACES = 338 # RW-I + +# +# NV_CTRL_OVERSCAN_COMPENSATION - not supported +# +NV_CTRL_OVERSCAN_COMPENSATION = 339 # not supported + +# +# NV_CTRL_GPU_PCIE_GENERATION - Reports the current PCIe generation. +# +NV_CTRL_GPU_PCIE_GENERATION = 341 # R--GI +NV_CTRL_GPU_PCIE_GENERATION1 = 0x00000001 +NV_CTRL_GPU_PCIE_GENERATION2 = 0x00000002 +NV_CTRL_GPU_PCIE_GENERATION3 = 0x00000003 + +# +# NV_CTRL_GVI_BOUND_GPU - Returns the NV_CTRL_TARGET_TYPE_GPU target_id of +# the GPU currently bound to the GVI device. Returns -1 if no GPU is +# currently bound to the GVI device. +# +NV_CTRL_GVI_BOUND_GPU = 342 # R--I + +# +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3 - this attribute is only +# intended to be used to query the ValidValues for +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT for VIDEO_FORMAT values between +# 64 and 95. See NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT for details. +# + +NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT3 = 343 # ---GI + +# +# NV_CTRL_ACCELERATE_TRAPEZOIDS - Toggles RENDER Trapezoid acceleration +# + +NV_CTRL_ACCELERATE_TRAPEZOIDS = 344 # RW- +NV_CTRL_ACCELERATE_TRAPEZOIDS_DISABLE = 0 +NV_CTRL_ACCELERATE_TRAPEZOIDS_ENABLE = 1 + +# +# NV_CTRL_GPU_CORES - Returns number of GPU cores supported by the graphics +# pipeline. +# + +NV_CTRL_GPU_CORES = 345 # R--G + +# +# NV_CTRL_GPU_MEMORY_BUS_WIDTH - Returns memory bus bandwidth on the associated +# subdevice. +# + +NV_CTRL_GPU_MEMORY_BUS_WIDTH = 346 # R--G + +# +# NV_CTRL_GVI_TEST_MODE - This attribute controls the GVI test mode. When +# enabled, the GVI device will generate fake data as quickly as possible. All +# GVI settings are still valid when this is enabled (e.g., the requested video +# format is honored and sets the video size). +# This may be used to test the pipeline. +# + +NV_CTRL_GVI_TEST_MODE = 347 # R--I +NV_CTRL_GVI_TEST_MODE_DISABLE = 0 +NV_CTRL_GVI_TEST_MODE_ENABLE = 1 + +# +# NV_CTRL_COLOR_SPACE - This option controls the preferred color space of the +# video signal. This may not match the current color space depending on the +# current mode on this display. +# +# NV_CTRL_CURRENT_COLOR_SPACE will reflect the actual color space in use. +# +NV_CTRL_COLOR_SPACE = 348 # RWDG +NV_CTRL_COLOR_SPACE_RGB = 0 +NV_CTRL_COLOR_SPACE_YCbCr422 = 1 +NV_CTRL_COLOR_SPACE_YCbCr444 = 2 + +# +# NV_CTRL_COLOR_RANGE - This option controls the preferred color range of the +# video signal. +# +# If the current color space requires it, the actual color range will be +# limited. +# +# NV_CTRL_CURRENT_COLOR_RANGE will reflect the actual color range in use. +# +NV_CTRL_COLOR_RANGE = 349 # RWDG +NV_CTRL_COLOR_RANGE_FULL = 0 +NV_CTRL_COLOR_RANGE_LIMITED = 1 + +# +# NV_CTRL_GPU_SCALING_DEFAULT_TARGET - not supported +# + +NV_CTRL_GPU_SCALING_DEFAULT_TARGET = 350 # not supported + +# +# NV_CTRL_GPU_SCALING_DEFAULT_METHOD - not supported +# + +NV_CTRL_GPU_SCALING_DEFAULT_METHOD = 351 # not supported + +# +# NV_CTRL_DITHERING_MODE - Controls the dithering mode, when +# NV_CTRL_CURRENT_DITHERING is Enabled. +# +# AUTO: allow the driver to choose the dithering mode automatically. +# +# DYNAMIC_2X2: use a 2x2 matrix to dither from the GPU's pixel +# pipeline to the bit depth of the flat panel. The matrix values +# are changed from frame to frame. +# +# STATIC_2X2: use a 2x2 matrix to dither from the GPU's pixel +# pipeline to the bit depth of the flat panel. The matrix values +# do not change from frame to frame. +# +# TEMPORAL: use a pseudorandom value from a uniform distribution calculated at +# every pixel to achieve stochastic dithering. This method produces a better +# visual result than 2x2 matrix approaches. +# +NV_CTRL_DITHERING_MODE = 352 # RWDG +NV_CTRL_DITHERING_MODE_AUTO = 0 +NV_CTRL_DITHERING_MODE_DYNAMIC_2X2 = 1 +NV_CTRL_DITHERING_MODE_STATIC_2X2 = 2 +NV_CTRL_DITHERING_MODE_TEMPORAL = 3 + +# +# NV_CTRL_CURRENT_DITHERING - Returns the current dithering state. +# +NV_CTRL_CURRENT_DITHERING = 353 # R-DG +NV_CTRL_CURRENT_DITHERING_DISABLED = 0 +NV_CTRL_CURRENT_DITHERING_ENABLED = 1 + +# +# NV_CTRL_CURRENT_DITHERING_MODE - Returns the current dithering +# mode. +# +NV_CTRL_CURRENT_DITHERING_MODE = 354 # R-DG +NV_CTRL_CURRENT_DITHERING_MODE_NONE = 0 +NV_CTRL_CURRENT_DITHERING_MODE_DYNAMIC_2X2 = 1 +NV_CTRL_CURRENT_DITHERING_MODE_STATIC_2X2 = 2 +NV_CTRL_CURRENT_DITHERING_MODE_TEMPORAL = 3 + +# +# NV_CTRL_THERMAL_SENSOR_READING - Returns the thermal sensor's current +# reading. +# +NV_CTRL_THERMAL_SENSOR_READING = 355 # R--S + +# +# NV_CTRL_THERMAL_SENSOR_PROVIDER - Returns the hardware device that +# provides the thermal sensor. +# +NV_CTRL_THERMAL_SENSOR_PROVIDER = 356 # R--S +NV_CTRL_THERMAL_SENSOR_PROVIDER_NONE = 0 +NV_CTRL_THERMAL_SENSOR_PROVIDER_GPU_INTERNAL = 1 +NV_CTRL_THERMAL_SENSOR_PROVIDER_ADM1032 = 2 +NV_CTRL_THERMAL_SENSOR_PROVIDER_ADT7461 = 3 +NV_CTRL_THERMAL_SENSOR_PROVIDER_MAX6649 = 4 +NV_CTRL_THERMAL_SENSOR_PROVIDER_MAX1617 = 5 +NV_CTRL_THERMAL_SENSOR_PROVIDER_LM99 = 6 +NV_CTRL_THERMAL_SENSOR_PROVIDER_LM89 = 7 +NV_CTRL_THERMAL_SENSOR_PROVIDER_LM64 = 8 +NV_CTRL_THERMAL_SENSOR_PROVIDER_G781 = 9 +NV_CTRL_THERMAL_SENSOR_PROVIDER_ADT7473 = 10 +NV_CTRL_THERMAL_SENSOR_PROVIDER_SBMAX6649 = 11 +NV_CTRL_THERMAL_SENSOR_PROVIDER_VBIOSEVT = 12 +NV_CTRL_THERMAL_SENSOR_PROVIDER_OS = 13 +NV_CTRL_THERMAL_SENSOR_PROVIDER_UNKNOWN = 0xFFFFFFFF + +# +# NV_CTRL_THERMAL_SENSOR_TARGET - Returns what hardware component +# the thermal sensor is measuring. +# +NV_CTRL_THERMAL_SENSOR_TARGET = 357 # R--S +NV_CTRL_THERMAL_SENSOR_TARGET_NONE = 0 +NV_CTRL_THERMAL_SENSOR_TARGET_GPU = 1 +NV_CTRL_THERMAL_SENSOR_TARGET_MEMORY = 2 +NV_CTRL_THERMAL_SENSOR_TARGET_POWER_SUPPLY = 4 +NV_CTRL_THERMAL_SENSOR_TARGET_BOARD = 8 +NV_CTRL_THERMAL_SENSOR_TARGET_UNKNOWN = 0xFFFFFFFF + +# +# NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR - when TRUE, OpenGL will +# draw information about the current MULTIGPU mode. +# +NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR = 358 # RW-X +NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR_FALSE = 0 +NV_CTRL_SHOW_MULTIGPU_VISUAL_INDICATOR_TRUE = 1 + +# +# NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS - Returns GPU's processor +# clock freqs. +# +NV_CTRL_GPU_CURRENT_PROCESSOR_CLOCK_FREQS = 359 # RW-G + +# +# NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS - query the flags (various information +# for the specified NV_CTRL_GVIO_VIDEO_FORMAT_*. So that this can be +# queried with existing interfaces, the video format should be specified +# in the display_mask field; eg: +# +# XNVCTRLQueryTargetAttribute(dpy, +# NV_CTRL_TARGET_TYPE_GVI, +# gvi, +# NV_CTRL_GVIO_VIDEO_FORMAT_720P_60_00_SMPTE296, +# NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS, +# &flags); +# +# Note: The NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_1080P_NO_12BPC flag is set +# for those 1080P 3G modes (level A and B) that do not support +# 12 bits per component (when configuring a GVI stream.) +# + +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS = 360 # R--I +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_NONE = 0x00000000 +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_INTERLACED = 0x00000001 +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_PROGRESSIVE = 0x00000002 +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_PSF = 0x00000004 +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_LEVEL_A = 0x00000008 +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_LEVEL_B = 0x00000010 +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G = NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_LEVEL_A | NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_LEVEL_B +NV_CTRL_GVIO_VIDEO_FORMAT_FLAGS_3G_1080P_NO_12BPC = 0x00000020 + +# +# NV_CTRL_GPU_PCIE_MAX_LINK_SPEED - returns maximum PCIe link speed, +# in gigatransfers per second (GT/s). +# + +NV_CTRL_GPU_PCIE_MAX_LINK_SPEED = 361 # R--GI + +# +# NV_CTRL_3D_VISION_PRO_RESET_TRANSCEIVER_TO_FACTORY_SETTINGS - Resets the +# 3D Vision Pro transceiver to its factory settings. +# +NV_CTRL_3D_VISION_PRO_RESET_TRANSCEIVER_TO_FACTORY_SETTINGS = 363 # -W-T + +# +# NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL - Controls the channel that is +# currently used by the 3D Vision Pro transceiver. +# +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL = 364 # RW-T + +# +# NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE - Controls the mode in which the +# 3D Vision Pro transceiver operates. +# NV_CTRL_3D_VISION_PRO_TM_LOW_RANGE is bidirectional +# NV_CTRL_3D_VISION_PRO_TM_MEDIUM_RANGE is bidirectional +# NV_CTRL_3D_VISION_PRO_TM_HIGH_RANGE may be bidirectional just up to a +# given range, and unidirectional beyond it +# NV_CTRL_3D_VISION_PRO_TM_COUNT is the total number of +# 3D Vision Pro transceiver modes +# +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE = 365 # RW-T +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_INVALID = 0 +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_LOW_RANGE = 1 +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_MEDIUM_RANGE = 2 +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_HIGH_RANGE = 3 +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_MODE_COUNT = 4 + +# +# NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES - controls whether updates to the color +# lookup table (LUT) are synchronous with respect to X rendering. For example, +# if an X client sends XStoreColors followed by XFillRectangle, the driver will +# guarantee that the FillRectangle request is not processed until after the +# updated LUT colors are actually visible on the screen if +# NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES is enabled. Otherwise, the rendering may +# occur first. +# +# This makes a difference for applications that use the LUT to animate, such as +# XPilot. If you experience flickering in applications that use LUT +# animations, try enabling this attribute. +# +# When synchronous updates are enabled, XStoreColors requests will be processed +# at your screen's refresh rate. +# + +NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES = 367 # RWDG +NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES_DISABLE = 0 +NV_CTRL_SYNCHRONOUS_PALETTE_UPDATES_ENABLE = 1 + +# +# NV_CTRL_DITHERING_DEPTH - Controls the dithering depth when +# NV_CTRL_CURRENT_DITHERING is ENABLED. Some displays connected +# to the GPU via the DVI or LVDS interfaces cannot display the +# full color range of ten bits per channel, so the GPU will +# dither to either 6 or 8 bits per channel. +# +NV_CTRL_DITHERING_DEPTH = 368 # RWDG +NV_CTRL_DITHERING_DEPTH_AUTO = 0 +NV_CTRL_DITHERING_DEPTH_6_BITS = 1 +NV_CTRL_DITHERING_DEPTH_8_BITS = 2 + +# +# NV_CTRL_CURRENT_DITHERING_DEPTH - Returns the current dithering +# depth value. +# +NV_CTRL_CURRENT_DITHERING_DEPTH = 369 # R-DG +NV_CTRL_CURRENT_DITHERING_DEPTH_NONE = 0 +NV_CTRL_CURRENT_DITHERING_DEPTH_6_BITS = 1 +NV_CTRL_CURRENT_DITHERING_DEPTH_8_BITS = 2 + +# +# NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_FREQUENCY - Returns the +# frequency of the channel(in kHz) of the 3D Vision Pro transceiver. +# Use the display_mask parameter to specify the channel number. +# +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_FREQUENCY = 370 # R--T + +# +# NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY - Returns the +# quality of the channel(in percentage) of the 3D Vision Pro transceiver. +# Use the display_mask parameter to specify the channel number. +# +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_QUALITY = 371 # R--T + +# +# NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_COUNT - Returns the number of +# channels on the 3D Vision Pro transceiver. +# +NV_CTRL_3D_VISION_PRO_TRANSCEIVER_CHANNEL_COUNT = 372 # R--T + +# +# NV_CTRL_3D_VISION_PRO_PAIR_GLASSES - Puts the 3D Vision Pro +# transceiver into pairing mode to gather additional glasses. +# NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_STOP - stops any pairing +# NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_BEACON - starts continuous +# pairing via beacon mode +# Any other value, N - Puts the 3D Vision Pro transceiver into +# authenticated pairing mode for N seconds. +# +NV_CTRL_3D_VISION_PRO_PAIR_GLASSES = 373 # -W-T +NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_STOP = 0 +NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_BEACON = 0xFFFFFFFF + +# +# NV_CTRL_3D_VISION_PRO_UNPAIR_GLASSES - Tells a specific pair +# of glasses to unpair. The glasses will "forget" the address +# of the 3D Vision Pro transceiver to which they have been paired. +# To unpair all the currently paired glasses, specify +# the glasses id as 0. +# +NV_CTRL_3D_VISION_PRO_UNPAIR_GLASSES = 374 # -W-T + +# +# NV_CTRL_3D_VISION_PRO_DISCOVER_GLASSES - Tells the 3D Vision Pro +# transceiver about the glasses that have been paired using +# NV_CTRL_3D_VISION_PRO_PAIR_GLASSES_BEACON. Unless this is done, +# the 3D Vision Pro transceiver will not know about glasses paired in +# beacon mode. +# +NV_CTRL_3D_VISION_PRO_DISCOVER_GLASSES = 375 # -W-T + +# +# NV_CTRL_3D_VISION_PRO_IDENTIFY_GLASSES - Causes glasses LEDs to +# flash for a short period of time. +# +NV_CTRL_3D_VISION_PRO_IDENTIFY_GLASSES = 376 # -W-T + +# +# NV_CTRL_3D_VISION_PRO_GLASSES_SYNC_CYCLE - Controls the +# sync cycle duration(in milliseconds) of the glasses. +# Use the display_mask parameter to specify the glasses id. +# +NV_CTRL_3D_VISION_PRO_GLASSES_SYNC_CYCLE = 378 # RW-T + +# +# NV_CTRL_3D_VISION_PRO_GLASSES_MISSED_SYNC_CYCLES - Returns the +# number of state sync cycles recently missed by the glasses. +# Use the display_mask parameter to specify the glasses id. +# +NV_CTRL_3D_VISION_PRO_GLASSES_MISSED_SYNC_CYCLES = 379 # R--T + +# +# NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL - Returns the +# battery level(in percentage) of the glasses. +# Use the display_mask parameter to specify the glasses id. +# +NV_CTRL_3D_VISION_PRO_GLASSES_BATTERY_LEVEL = 380 # R--T + +# +# NV_CTRL_GVO_ANC_PARITY_COMPUTATION - Controls the SDI device's computation +# of the parity bit (bit 8) for ANC data words. +# + +NV_CTRL_GVO_ANC_PARITY_COMPUTATION = 381 # RW--- +NV_CTRL_GVO_ANC_PARITY_COMPUTATION_AUTO = 0 +NV_CTRL_GVO_ANC_PARITY_COMPUTATION_ON = 1 +NV_CTRL_GVO_ANC_PARITY_COMPUTATION_OFF = 2 + +# +# NV_CTRL_3D_VISION_PRO_GLASSES_PAIR_EVENT - This attribute is sent +# as an event when glasses get paired in response to pair command +# from any of the clients. +# +NV_CTRL_3D_VISION_PRO_GLASSES_PAIR_EVENT = 382 # ---T + +# +# NV_CTRL_3D_VISION_PRO_GLASSES_UNPAIR_EVENT - This attribute is sent +# as an event when glasses get unpaired in response to unpair command +# from any of the clients. +# +NV_CTRL_3D_VISION_PRO_GLASSES_UNPAIR_EVENT = 383 # ---T + +# +# NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH - returns the current +# PCIe link width, in number of lanes. +# +NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH = 384 # R--GI + +# +# NV_CTRL_GPU_PCIE_CURRENT_LINK_SPEED - returns the current +# PCIe link speed, in megatransfers per second (GT/s). +# +NV_CTRL_GPU_PCIE_CURRENT_LINK_SPEED = 385 # R--GI + +# +# NV_CTRL_GVO_AUDIO_BLANKING - specifies whether the GVO device should delete +# audio ancillary data packets when frames are repeated. +# +# When a new frame is not ready in time, the current frame, including all +# ancillary data packets, is repeated. When this data includes audio packets, +# this can result in stutters or clicks. When this option is enabled, the GVO +# device will detect when frames are repeated, identify audio ancillary data +# packets, and mark them for deletion. +# +# This option is applied when the GVO device is bound. +# +NV_CTRL_GVO_AUDIO_BLANKING = 386 # RW- +NV_CTRL_GVO_AUDIO_BLANKING_DISABLE = 0 +NV_CTRL_GVO_AUDIO_BLANKING_ENABLE = 1 + +# +# NV_CTRL_CURRENT_METAMODE_ID - switch modes to the MetaMode with +# the specified ID. +# +NV_CTRL_CURRENT_METAMODE_ID = 387 # RW- + +# +# NV_CTRL_DISPLAY_ENABLED - Returns whether or not the display device +# is currently enabled. +# +NV_CTRL_DISPLAY_ENABLED = 388 # R-D +NV_CTRL_DISPLAY_ENABLED_TRUE = 1 +NV_CTRL_DISPLAY_ENABLED_FALSE = 0 + +# +# NV_CTRL_FRAMELOCK_INCOMING_HOUSE_SYNC_RATE: this is the rate +# of an incomming house sync signal to the frame lock board, in milliHz. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK or NV_CTRL_TARGET_TYPE_X_SCREEN +# target. +# +NV_CTRL_FRAMELOCK_INCOMING_HOUSE_SYNC_RATE = 389 # R--F + +# +# NV_CTRL_FXAA - enables FXAA. A pixel shader based anti- +# aliasing method. +# +NV_CTRL_FXAA = 390 # RW-X +NV_CTRL_FXAA_DISABLE = 0 +NV_CTRL_FXAA_ENABLE = 1 + +# +# NV_CTRL_DISPLAY_RANDR_OUTPUT_ID - the RandR Output ID (type RROutput) +# that corresponds to the specified Display Device target. If a new +# enough version of RandR is not available in the X server, +# DISPLAY_RANDR_OUTPUT_ID will be 0. +# +NV_CTRL_DISPLAY_RANDR_OUTPUT_ID = 391 # R-D- + +# +# NV_CTRL_FRAMELOCK_DISPLAY_CONFIG - Configures whether the display device +# should listen, ignore or drive the framelock sync signal. +# +# Note that whether or not a display device may be set as a client/server +# depends on the current configuration. For example, only one server may be +# set per Quadro Sync device, and displays can only be configured as a client +# if their refresh rate sufficiently matches the refresh rate of the server +# device. +# +# Note that when querying the ValidValues for this data type, the values are +# reported as bits within a bitmask (ATTRIBUTE_TYPE_INT_BITS); +# +NV_CTRL_FRAMELOCK_DISPLAY_CONFIG = 392 # RWD +NV_CTRL_FRAMELOCK_DISPLAY_CONFIG_DISABLED = 0 +NV_CTRL_FRAMELOCK_DISPLAY_CONFIG_CLIENT = 1 +NV_CTRL_FRAMELOCK_DISPLAY_CONFIG_SERVER = 2 + +# +# NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY - Returns the total amount of dedicated +# GPU video memory, in MB, on the specified GPU. This excludes any TurboCache +# padding included in the value returned by NV_CTRL_TOTAL_GPU_MEMORY. +# +NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY = 393 # R--G + +# +# NV_CTRL_USED_DEDICATED_GPU_MEMORY- Returns the amount of video memory +# currently used on the graphics card in MB. +# +NV_CTRL_USED_DEDICATED_GPU_MEMORY = 394 # R--G + +# +# NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE +# Some GPUs can make a tradeoff between double-precision floating-point +# performance and clock speed. Enabling double-precision floating point +# performance may benefit CUDA or OpenGL applications that require high +# bandwidth double-precision performance. Disabling this feature may benefit +# graphics applications that require higher clock speeds. +# +# This attribute is only available when toggling double precision boost +# can be done immediately (without need for a rebooot). +# +NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE = 395 # RW-G +NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE_DISABLED = 0 +NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_IMMEDIATE_ENABLED = 1 + +# +# NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT +# Some GPUs can make a tradeoff between double-precision floating-point +# performance and clock speed. Enabling double-precision floating point +# performance may benefit CUDA or OpenGL applications that require high +# bandwidth double-precision performance. Disabling this feature may benefit +# graphics applications that require higher clock speeds. +# +# This attribute is only available when toggling double precision boost +# requires a reboot. +# + +NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT = 396 # RW-G +NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT_DISABLED = 0 +NV_CTRL_GPU_DOUBLE_PRECISION_BOOST_REBOOT_ENALED = 1 + +# +# NV_CTRL_DPY_HDMI_3D - Returns whether the specified display device is +# currently using HDMI 3D Frame Packed Stereo mode. Clients may use this +# to help interpret the refresh rate returned by NV_CTRL_REFRESH_RATE or +# NV_CTRL_REFRESH_RATE_3, which will be doubled when using HDMI 3D mode. +# +# This attribute may be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU target. +# + +NV_CTRL_DPY_HDMI_3D = 397 # R-DG +NV_CTRL_DPY_HDMI_3D_DISABLED = 0 +NV_CTRL_DPY_HDMI_3D_ENABLED = 1 + +# +# NV_CTRL_BASE_MOSAIC - Returns whether Base Mosaic is currently enabled on the +# given GPU. Querying the valid values of this attribute returns capabilities. +# + +NV_CTRL_BASE_MOSAIC = 398 # R--G +NV_CTRL_BASE_MOSAIC_DISABLED = 0 +NV_CTRL_BASE_MOSAIC_FULL = 1 +NV_CTRL_BASE_MOSAIC_LIMITED = 2 + +# +# NV_CTRL_MULTIGPU_MASTER_POSSIBLE - Returns whether the GPU can be configured +# as the master GPU in a Multi GPU configuration (SLI, SLI Mosaic, +# Base Mosaic). +# + +NV_CTRL_MULTIGPU_MASTER_POSSIBLE = 399 # R--G +NV_CTRL_MULTIGPU_MASTER_POSSIBLE_FALSE = 0 +NV_CTRL_MULTIGPU_MASTER_POSSIBLE_TRUE = 1 + +# +# NV_CTRL_GPU_POWER_MIZER_DEFAULT_MODE - Returns the default PowerMizer mode +# for the given GPU. +# +NV_CTRL_GPU_POWER_MIZER_DEFAULT_MODE = 400 # R--G + +# +# NV_CTRL_XV_SYNC_TO_DISPLAY_ID - When XVideo Sync To VBlank is enabled, this +# controls which display device will be synched to if the display is enabled. +# Returns NV_CTRL_XV_SYNC_TO_DISPLAY_ID_AUTO if no display has been +# selected. +# +NV_CTRL_XV_SYNC_TO_DISPLAY_ID = 401 # RW- +NV_CTRL_XV_SYNC_TO_DISPLAY_ID_AUTO = 0xFFFFFFFF + +# +# NV_CTRL_BACKLIGHT_BRIGHTNESS - The backlight brightness of an internal panel. +# +NV_CTRL_BACKLIGHT_BRIGHTNESS = 402 # RWD- + +# +# NV_CTRL_GPU_LOGO_BRIGHTNESS - Controls brightness +# of the logo on the GPU, if any. The value is variable from 0% - 100%. +# +NV_CTRL_GPU_LOGO_BRIGHTNESS = 403 # RW-G + +# +# NV_CTRL_GPU_SLI_LOGO_BRIGHTNESS - Controls brightness of the logo +# on the SLI bridge, if any. The value is variable from 0% - 100%. +# +NV_CTRL_GPU_SLI_LOGO_BRIGHTNESS = 404 # RW-G + +# +# NV_CTRL_THERMAL_COOLER_SPEED - Returns cooler's current operating speed in +# rotations per minute (RPM). +# + +NV_CTRL_THERMAL_COOLER_SPEED = 405 # R--C + +# +# NV_CTRL_PALETTE_UPDATE_EVENT - The Color Palette has been changed and the +# color correction info needs to be updated. +# + +NV_CTRL_PALETTE_UPDATE_EVENT = 406 # --- + +# +# NV_CTRL_VIDEO_ENCODER_UTILIZATION - Returns the video encoder engine +# utilization as a percentage. +# +NV_CTRL_VIDEO_ENCODER_UTILIZATION = 407 # R--G + +# +# NV_CTRL_GSYNC_ALLOWED - when TRUE, OpenGL will enable G-SYNC when possible; +# when FALSE, OpenGL will always use a fixed monitor refresh rate. +# + +NV_CTRL_GSYNC_ALLOWED = 408 # RW-X +NV_CTRL_GSYNC_ALLOWED_FALSE = 0 +NV_CTRL_GSYNC_ALLOWED_TRUE = 1 + +# +# NV_CTRL_GPU_NVCLOCK_OFFSET - This attribute controls the GPU clock offsets +# (in MHz) used for overclocking per performance level. +# Use the display_mask parameter to specify the performance level. +# +# Note: To enable overclocking support, set the X configuration +# option "Coolbits" to value "8". +# +# This offset can have any integer value between +# NVCTRLAttributeValidValues.u.range.min and +# NVCTRLAttributeValidValues.u.range.max (inclusive). +# +# This attribute is available on GeForce GTX 400 series and later +# Geforce GPUs. +# +NV_CTRL_GPU_NVCLOCK_OFFSET = 409 # RW-G + +# +# NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET - This attribute controls +# the memory transfer rate offsets (in MHz) used for overclocking +# per performance level. +# Use the display_mask parameter to specify the performance level. +# +# Note: To enable overclocking support, set the X configuration +# option "Coolbits" to value "8". +# +# This offset can have any integer value between +# NVCTRLAttributeValidValues.u.range.min and +# NVCTRLAttributeValidValues.u.range.max (inclusive). +# +# This attribute is available on GeForce GTX 400 series and later +# Geforce GPUs. +# +NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET = 410 # RW-G + +# +# NV_CTRL_VIDEO_DECODER_UTILIZATION - Returns the video decoder engine +# utilization as a percentage. +# +NV_CTRL_VIDEO_DECODER_UTILIZATION = 411 # R--G + +# +# NV_CTRL_GPU_OVER_VOLTAGE_OFFSET - This attribute controls +# the overvoltage offset in microvolts (uV). +# +# Note: To enable overvoltage support, set the X configuration +# option "Coolbits" to value "16". +# +# This offset can have any integer value between +# NVCTRLAttributeValidValues.u.range.min and +# NVCTRLAttributeValidValues.u.range.max (inclusive). +# +# This attribute is available on GeForce GTX 400 series and later +# Geforce GPUs. +# + +NV_CTRL_GPU_OVER_VOLTAGE_OFFSET = 412 # RW-G + +# +# NV_CTRL_GPU_CURRENT_CORE_VOLTAGE - This attribute returns the +# GPU's current operating voltage in microvolts (uV). +# +# This attribute is available on GPUs that support +# NV_CTRL_GPU_OVER_VOLTAGE_OFFSET. +# +NV_CTRL_GPU_CURRENT_CORE_VOLTAGE = 413 # R--G + +# +# NV_CTRL_CURRENT_COLOR_SPACE - Returns the current color space of the video +# signal. +# +# This will match NV_CTRL_COLOR_SPACE unless the current mode on this display +# device is an HDMI 2.0 4K@60Hz mode and the display device or GPU does not +# support driving this mode in RGB, in which case YCbCr420 will be returned. +# +NV_CTRL_CURRENT_COLOR_SPACE = 414 # R-DG +NV_CTRL_CURRENT_COLOR_SPACE_RGB = 0 +NV_CTRL_CURRENT_COLOR_SPACE_YCbCr422 = 1 +NV_CTRL_CURRENT_COLOR_SPACE_YCbCr444 = 2 +NV_CTRL_CURRENT_COLOR_SPACE_YCbCr420 = 3 + +# +# NV_CTRL_CURRENT_COLOR_RANGE - Returns the current color range of the video +# signal. +# +NV_CTRL_CURRENT_COLOR_RANGE = 415 # R-DG +NV_CTRL_CURRENT_COLOR_RANGE_FULL = 0 +NV_CTRL_CURRENT_COLOR_RANGE_LIMITED = 1 + +# +# NV_CTRL_SHOW_GSYNC_VISUAL_INDICATOR - when TRUE, OpenGL will indicate when +# G-SYNC is in use for full-screen applications. +# + +NV_CTRL_SHOW_GSYNC_VISUAL_INDICATOR = 416 # RW-X +NV_CTRL_SHOW_GSYNC_VISUAL_INDICATOR_FALSE = 0 +NV_CTRL_SHOW_GSYNC_VISUAL_INDICATOR_TRUE = 1 + +# +# NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL - Returns cooler's current +# operating level. This may fluctuate dynamically. When +# NV_CTRL_GPU_COOLER_MANUAL_CONTROL=TRUE, the driver attempts +# to make this match NV_CTRL_THERMAL_COOLER_LEVEL. When +# NV_CTRL_GPU_COOLER_MANUAL_CONTROL=FALSE, the driver adjusts the +# current level based on the needs of the GPU. +# + +NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL = 417 # R--C + +# +# NV_CTRL_STEREO_SWAP_MODE - This attribute controls the swap mode when +# Quad-Buffered stereo is used. +# NV_CTRL_STEREO_SWAP_MODE_APPLICATION_CONTROL : Stereo swap mode is derived +# from the value of swap interval. +# If it's odd, the per eye swap mode is used. +# If it's even, the per eye pair swap mode is used. +# NV_CTRL_STEREO_SWAP_MODE_PER_EYE : The driver swaps each eye as it is ready. +# NV_CTRL_STEREO_SWAP_MODE_PER_EYE_PAIR : The driver waits for both eyes to +# complete rendering before swapping. +# + +NV_CTRL_STEREO_SWAP_MODE = 418 # RW-X +NV_CTRL_STEREO_SWAP_MODE_APPLICATION_CONTROL = 0 +NV_CTRL_STEREO_SWAP_MODE_PER_EYE = 1 +NV_CTRL_STEREO_SWAP_MODE_PER_EYE_PAIR = 2 + +# +# NV_CTRL_CURRENT_XV_SYNC_TO_DISPLAY_ID - When XVideo Sync To VBlank is +# enabled, this returns the display id of the device currently synched to. +# Returns NV_CTRL_XV_SYNC_TO_DISPLAY_ID_AUTO if no display is currently +# set. +# + +NV_CTRL_CURRENT_XV_SYNC_TO_DISPLAY_ID = 419 # R-- + +# +# NV_CTRL_GPU_FRAMELOCK_FIRMWARE_UNSUPPORTED - Returns true if the +# Quadro Sync card connected to this GPU has a firmware version incompatible +# with this GPU. +# + +NV_CTRL_GPU_FRAMELOCK_FIRMWARE_UNSUPPORTED = 420 # R--G +NV_CTRL_GPU_FRAMELOCK_FIRMWARE_UNSUPPORTED_FALSE = 0 +NV_CTRL_GPU_FRAMELOCK_FIRMWARE_UNSUPPORTED_TRUE = 1 + +# +# NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE - Returns the connector type used by +# a DisplayPort display. +# + +NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE = 421 # R-DG +NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_UNKNOWN = 0 +NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_DISPLAYPORT = 1 +NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_HDMI = 2 +NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_DVI = 3 +NV_CTRL_DISPLAYPORT_CONNECTOR_TYPE_VGA = 4 + +# +# NV_CTRL_DISPLAYPORT_IS_MULTISTREAM - Returns multi-stream support for +# DisplayPort displays. +# +NV_CTRL_DISPLAYPORT_IS_MULTISTREAM = 422 # R-DG + +# +# NV_CTRL_DISPLAYPORT_SINK_IS_AUDIO_CAPABLE - Returns whether a DisplayPort +# device supports audio. +# +NV_CTRL_DISPLAYPORT_SINK_IS_AUDIO_CAPABLE = 423 # R-DG + +# +# NV_CTRL_GPU_NVCLOCK_OFFSET_ALL_PERFORMANCE_LEVELS - This attribute +# controls the GPU clock offsets (in MHz) used for overclocking. +# The offset is applied to all performance levels. +# +# Note: To enable overclocking support, set the X configuration +# option "Coolbits" to value "8". +# +# This offset can have any integer value between +# NVCTRLAttributeValidValues.u.range.min and +# NVCTRLAttributeValidValues.u.range.max (inclusive). +# +# This attribute is available on GeForce GTX 1000 series and later +# Geforce GPUs. +# +NV_CTRL_GPU_NVCLOCK_OFFSET_ALL_PERFORMANCE_LEVELS = 424 # RW-G + +# +# NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET_ALL_PERFORMANCE_LEVELS - This +# attribute controls the memory transfer rate offsets (in MHz) used +# for overclocking. The offset is applied to all performance levels. +# +# Note: To enable overclocking support, set the X configuration +# option "Coolbits" to value "8". +# +# This offset can have any integer value between +# NVCTRLAttributeValidValues.u.range.min and +# NVCTRLAttributeValidValues.u.range.max (inclusive). +# +# This attribute is available on GeForce GTX 1000 series and later +# Geforce GPUs. +# +NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET_ALL_PERFORMANCE_LEVELS = 425 # RW-G + +# +# NV_CTRL_FRAMELOCK_FIRMWARE_VERSION - Queries the firmware major version of +# the Frame Lock device. +# +# This attribute must be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK target. +# + +NV_CTRL_FRAMELOCK_FIRMWARE_VERSION = 426 # R--F + +# +# NV_CTRL_FRAMELOCK_FIRMWARE_MINOR_VERSION - Queries the firmware minor +# version of the Frame Lock device. +# +# This attribute must be queried through XNVCTRLQueryTargetAttribute() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK target. +# + +NV_CTRL_FRAMELOCK_FIRMWARE_MINOR_VERSION = 427 # R--F + +# +# NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR - when TRUE, graphics APIs will +# indicate various runtime information such as flip/blit, vsync status, API +# in use. +# + +NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR = 428 # RW-X +NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR_FALSE = 0 +NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR_TRUE = 1 + +NV_CTRL_LAST_ATTRIBUTE = NV_CTRL_SHOW_GRAPHICS_VISUAL_INDICATOR + +############################################################################ + +# +# String Attributes: +# +# String attributes can be queryied through the XNVCTRLQueryStringAttribute() +# and XNVCTRLQueryTargetStringAttribute() function calls. +# +# String attributes can be set through the XNVCTRLSetStringAttribute() +# function call. (There are currently no string attributes that can be +# set on non-X Screen targets.) +# +# Unless otherwise noted, all string attributes can be queried/set using an +# NV_CTRL_TARGET_TYPE_X_SCREEN target. Attributes that cannot take an +# NV_CTRL_TARGET_TYPE_X_SCREEN target also cannot be queried/set through +# XNVCTRLQueryStringAttribute()/XNVCTRLSetStringAttribute() (Since +# these assume an X Screen target). +# + + +# +# NV_CTRL_STRING_PRODUCT_NAME - the product name on which the +# specified X screen is running, or the product name of the specified +# Frame Lock device. +# +# This attribute may be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target to +# return the product name of the GPU, or a NV_CTRL_TARGET_TYPE_FRAMELOCK to +# return the product name of the Frame Lock device. +# + +NV_CTRL_STRING_PRODUCT_NAME = 0 # R--GF + +# +# NV_CTRL_STRING_VBIOS_VERSION - the video bios version on the GPU on +# which the specified X screen is running. +# + +NV_CTRL_STRING_VBIOS_VERSION = 1 # R--G + +# +# NV_CTRL_STRING_NVIDIA_DRIVER_VERSION - string representation of the +# NVIDIA driver version number for the NVIDIA X driver in use. +# + +NV_CTRL_STRING_NVIDIA_DRIVER_VERSION = 3 # R--G + +# +# NV_CTRL_STRING_DISPLAY_DEVICE_NAME - name of the display device +# specified in the display_mask argument. +# +# This attribute may be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_STRING_DISPLAY_DEVICE_NAME = 4 # R-DG + +# +# NV_CTRL_STRING_TV_ENCODER_NAME - not supported +# + +NV_CTRL_STRING_TV_ENCODER_NAME = 5 # not supported + +# +# NV_CTRL_STRING_GVIO_FIRMWARE_VERSION - indicates the version of the +# Firmware on the GVIO device. +# + +NV_CTRL_STRING_GVIO_FIRMWARE_VERSION = 8 # R--I + +# +# NV_CTRL_STRING_GVO_FIRMWARE_VERSION - renamed +# +# NV_CTRL_STRING_GVIO_FIRMWARE_VERSION should be used instead. +# +NV_CTRL_STRING_GVO_FIRMWARE_VERSION = 8 # renamed + +# +# NV_CTRL_STRING_CURRENT_MODELINE - Return the ModeLine currently +# being used by the specified display device. +# +# This attribute may be queried through XNVCTRLQueryTargetStringAttribute() +# using an NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# +# The ModeLine string may be prepended with a comma-separated list of +# "token=value" pairs, separated from the ModeLine string by "::". +# This "token=value" syntax is the same as that used in +# NV_CTRL_BINARY_DATA_MODELINES +# + +NV_CTRL_STRING_CURRENT_MODELINE = 9 # R-DG + +# +# NV_CTRL_STRING_ADD_MODELINE - Adds a ModeLine to the specified +# display device. The ModeLine is not added if validation fails. +# +# The ModeLine string should have the same syntax as a ModeLine in +# the X configuration file; e.g., +# +# "1600x1200" 229.5 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync +# + +NV_CTRL_STRING_ADD_MODELINE = 10 # -WDG + +# +# NV_CTRL_STRING_DELETE_MODELINE - Deletes an existing ModeLine +# from the specified display device. The currently selected +# ModeLine cannot be deleted. (This also means you cannot delete +# the last ModeLine.) +# +# The ModeLine string should have the same syntax as a ModeLine in +# the X configuration file; e.g., +# +# "1600x1200" 229.5 1600 1664 1856 2160 1200 1201 1204 1250 +HSync +VSync +# + +NV_CTRL_STRING_DELETE_MODELINE = 11 # -WDG + +# +# NV_CTRL_STRING_CURRENT_METAMODE - Returns the metamode currently +# being used by the specified X screen. The MetaMode string has the +# same syntax as the MetaMode X configuration option, as documented +# in the NVIDIA driver README. +# +# The returned string may be prepended with a comma-separated list of +# "token=value" pairs, separated from the MetaMode string by "::". +# This "token=value" syntax is the same as that used in +# NV_CTRL_BINARY_DATA_METAMODES. +# + +NV_CTRL_STRING_CURRENT_METAMODE = 12 # RW-- +NV_CTRL_STRING_CURRENT_METAMODE_VERSION_1 = NV_CTRL_STRING_CURRENT_METAMODE + +# +# NV_CTRL_STRING_ADD_METAMODE - Adds a MetaMode to the specified +# X Screen. +# +# It is recommended to not use this attribute, but instead use +# NV_CTRL_STRING_OPERATION_ADD_METAMODE. +# + +NV_CTRL_STRING_ADD_METAMODE = 13 # -W-- + +# +# NV_CTRL_STRING_DELETE_METAMODE - Deletes an existing MetaMode from +# the specified X Screen. The currently selected MetaMode cannot be +# deleted. (This also means you cannot delete the last MetaMode). +# The MetaMode string should have the same syntax as the MetaMode X +# configuration option, as documented in the NVIDIA driver README. +# + +NV_CTRL_STRING_DELETE_METAMODE = 14 # -WD-- + +# +# NV_CTRL_STRING_VCSC_PRODUCT_NAME - deprecated +# +# Queries the product name of the VCSC device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_PRODUCT_NAME = 15 # R---V + +# +# NV_CTRL_STRING_VCSC_PRODUCT_ID - deprecated +# +# Queries the product ID of the VCSC device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_PRODUCT_ID = 16 # R---V + +# +# NV_CTRL_STRING_VCSC_SERIAL_NUMBER - deprecated +# +# Queries the unique serial number of the VCS device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_SERIAL_NUMBER = 17 # R---V + +# +# NV_CTRL_STRING_VCSC_BUILD_DATE - deprecated +# +# Queries the date of the VCS device. the returned string is in the following +# format: "Week.Year" +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_BUILD_DATE = 18 # R---V + +# +# NV_CTRL_STRING_VCSC_FIRMWARE_VERSION - deprecated +# +# Queries the firmware version of the VCS device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_FIRMWARE_VERSION = 19 # R---V + +# +# NV_CTRL_STRING_VCSC_FIRMWARE_REVISION - deprecated +# +# Queries the firmware revision of the VCS device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCS target. +# + +NV_CTRL_STRING_VCSC_FIRMWARE_REVISION = 20 # R---V + +# +# NV_CTRL_STRING_VCSC_HARDWARE_VERSION - deprecated +# +# Queries the hardware version of the VCS device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_HARDWARE_VERSION = 21 # R---V + +# +# NV_CTRL_STRING_VCSC_HARDWARE_REVISION - deprecated +# +# Queries the hardware revision of the VCS device. +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# + +NV_CTRL_STRING_VCSC_HARDWARE_REVISION = 22 # R---V + +# +# NV_CTRL_STRING_MOVE_METAMODE - Moves a MetaMode to the specified +# index location. The MetaMode must already exist in the X Screen's +# list of MetaModes (as returned by the NV_CTRL_BINARY_DATA_METAMODES +# attribute). If the index is larger than the number of MetaModes in +# the list, the MetaMode is moved to the end of the list. The +# MetaMode string should have the same syntax as the MetaMode X +# configuration option, as documented in the NVIDIA driver README. + +# The MetaMode string must be prepended with a comma-separated list +# of "token=value" pairs, separated from the MetaMode string by "::". +# Currently, the only valid token is "index", which indicates where +# in the MetaMode list the MetaMode should be moved to. +# +# Other tokens may be added in the future. +# +# E.g., +# "index=5 :: CRT-0: 1024x768 @1024x768 +0+0" +# + +NV_CTRL_STRING_MOVE_METAMODE = 23 # -W-- + +# +# NV_CTRL_STRING_VALID_HORIZ_SYNC_RANGES - returns the valid +# horizontal sync ranges used to perform mode validation for the +# specified display device. The ranges are in the same format as the +# "HorizSync" X config option: +# +# "horizsync-range may be a comma separated list of either discrete +# values or ranges of values. A range of values is two values +# separated by a dash." +# +# The values are in kHz. +# +# Additionally, the string may be prepended with a comma-separated +# list of "token=value" pairs, separated from the HorizSync string by +# "::". Valid tokens: +# +# Token Value +# "source" "edid" - HorizSync is from the display device's EDID +# "xconfig" - HorizSync is from the "HorizSync" entry in +# the Monitor section of the X config file +# "option" - HorizSync is from the "HorizSync" NVIDIA X +# config option +# "builtin" - HorizSync is from NVIDIA X driver builtin +# default values +# +# Additional tokens and/or values may be added in the future. +# +# Example: "source=edid :: 30.000-62.000" +# + +NV_CTRL_STRING_VALID_HORIZ_SYNC_RANGES = 24 # R-DG + +# +# NV_CTRL_STRING_VALID_VERT_REFRESH_RANGES - returns the valid +# vertical refresh ranges used to perform mode validation for the +# specified display device. The ranges are in the same format as the +# "VertRefresh" X config option: +# +# "vertrefresh-range may be a comma separated list of either discrete +# values or ranges of values. A range of values is two values +# separated by a dash." +# +# The values are in Hz. +# +# Additionally, the string may be prepended with a comma-separated +# list of "token=value" pairs, separated from the VertRefresh string by +# "::". Valid tokens: +# +# Token Value +# "source" "edid" - VertRefresh is from the display device's EDID +# "xconfig" - VertRefresh is from the "VertRefresh" entry in +# the Monitor section of the X config file +# "option" - VertRefresh is from the "VertRefresh" NVIDIA X +# config option +# "builtin" - VertRefresh is from NVIDIA X driver builtin +# default values +# +# Additional tokens and/or values may be added in the future. +# +# Example: "source=edid :: 50.000-75.000" +# + +NV_CTRL_STRING_VALID_VERT_REFRESH_RANGES = 25 # R-DG + +# +# NV_CTRL_STRING_SCREEN_RECTANGLE - returns the physical X Screen's +# initial position and size (in absolute coordinates) within the +# desktop as the "token=value" string: "x=#, y=#, width=#, height=#" +# +# Querying this attribute returns success only when Xinerama is enabled +# or the X server ABI is greater than equal to 12. +# + +NV_CTRL_STRING_SCREEN_RECTANGLE = 26 # R--- + +# +# NV_CTRL_STRING_XINERAMA_SCREEN_INFO - renamed +# +# NV_CTRL_STRING_SCREEN_RECTANGLE should be used instead. +# + +NV_CTRL_STRING_XINERAMA_SCREEN_INFO = 26 # renamed + +# +# NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER - used to specify the +# order that display devices will be returned via Xinerama when +# nvidiaXineramaInfo is enabled. Follows the same syntax as the +# nvidiaXineramaInfoOrder X config option. +# + +NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER = 27 # RW-- + +NV_CTRL_STRING_TWINVIEW_XINERAMA_INFO_ORDER = NV_CTRL_STRING_NVIDIA_XINERAMA_INFO_ORDER # for backwards compatibility: + +# +# NV_CTRL_STRING_SLI_MODE - returns a string describing the current +# SLI mode, if any, or FALSE if SLI is not currently enabled. +# +# This string should be used for informational purposes only, and +# should not be used to distinguish between SLI modes, other than to +# recognize when SLI is disabled (FALSE is returned) or +# enabled (the returned string is non-NULL and describes the current +# SLI configuration). +# + +NV_CTRL_STRING_SLI_MODE = 28 # R---*/ + +# +# NV_CTRL_STRING_PERFORMANCE_MODES - returns a string with all the +# performance modes defined for this GPU along with their associated +# NV Clock and Memory Clock values. +# Not all tokens will be reported on all GPUs, and additional tokens +# may be added in the future. +# For backwards compatibility we still provide nvclock, memclock, and +# processorclock those are the same as nvclockmin, memclockmin and +# processorclockmin. +# +# Note: These clock values take into account the offset +# set by clients through NV_CTRL_GPU_NVCLOCK_OFFSET and +# NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET. +# +# Each performance modes are returned as a comma-separated list of +# "token=value" pairs. Each set of performance mode tokens are separated +# by a ";". Valid tokens: +# +# Token Value +# "perf" integer - the Performance level +# "nvclock" integer - the GPU clocks (in MHz) for the perf level +# "nvclockmin" integer - the GPU clocks min (in MHz) for the perf level +# "nvclockmax" integer - the GPU clocks max (in MHz) for the perf level +# "nvclockeditable" integer - if the GPU clock domain is editable +# for the perf level +# "memclock" integer - the memory clocks (in MHz) for the perf level +# "memclockmin" integer - the memory clocks min (in MHz) for the perf level +# "memclockmax" integer - the memory clocks max (in MHz) for the perf level +# "memclockeditable" integer - if the memory clock domain is editable +# for the perf level +# "memtransferrate" integer - the memory transfer rate (in MHz) +# for the perf level +# "memtransferratemin" integer - the memory transfer rate min (in MHz) +# for the perf level +# "memtransferratemax" integer - the memory transfer rate max (in MHz) +# for the perf level +# "memtransferrateeditable" integer - if the memory transfer rate is editable +# for the perf level +# "processorclock" integer - the processor clocks (in MHz) +# for the perf level +# "processorclockmin" integer - the processor clocks min (in MHz) +# for the perf level +# "processorclockmax" integer - the processor clocks max (in MHz) +# for the perf level +# "processorclockeditable" integer - if the processor clock domain is editable +# for the perf level +# +# Example: +# +# perf=0, nvclock=324, nvclockmin=324, nvclockmax=324, nvclockeditable=0, +# memclock=324, memclockmin=324, memclockmax=324, memclockeditable=0, +# memtransferrate=648, memtransferratemin=648, memtransferratemax=648, +# memtransferrateeditable=0 ; +# perf=1, nvclock=324, nvclockmin=324, nvclockmax=640, nvclockeditable=0, +# memclock=810, memclockmin=810, memclockmax=810, memclockeditable=0, +# memtransferrate=1620, memtransferrate=1620, memtransferrate=1620, +# memtransferrateeditable=0 ; +# +# This attribute may be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_STRING_PERFORMANCE_MODES = 29 # R--G + +# +# NV_CTRL_STRING_VCSC_FAN_STATUS - deprecated +# +# Returns a string with status of all the fans in the Visual Computing System, +# if such a query is supported. Fan information is reported along with its +# tachometer reading (in RPM) and a flag indicating whether the fan has failed +# or not. +# +# Valid tokens: +# +# Token Value +# "fan" integer - the Fan index +# "speed" integer - the tachometer reading of the fan in rpm +# "fail" integer - flag to indicate whether the fan has failed +# +# Example: +# +# fan=0, speed=694, fail=0 ; fan=1, speed=693, fail=0 +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# +# + +NV_CTRL_STRING_VCSC_FAN_STATUS = 30 # R---V + +# +# NV_CTRL_STRING_VCSC_TEMPERATURES - Deprecated +# +# Returns a string with all Temperature readings in the Visual Computing +# System, if such a query is supported. Intake, Exhaust and Board Temperature +# values are reported in Celcius. +# +# Valid tokens: +# +# Token Value +# "intake" integer - the intake temperature for the VCS +# "exhaust" integer - the exhaust temperature for the VCS +# "board" integer - the board temperature of the VCS +# +# Example: +# +# intake=29, exhaust=46, board=41 +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# +# + +NV_CTRL_STRING_VCSC_TEMPERATURES = 31 # R---V + +# +# NV_CTRL_STRING_VCSC_PSU_INFO - Deprecated +# +# Returns a string with all Power Supply Unit related readings in the Visual +# Computing System, if such a query is supported. Current in amperes, Power +# in watts, Voltage in volts and PSU state may be reported. Not all PSU types +# support all of these values, and therefore some readings may be unknown. +# +# Valid tokens: +# +# Token Value +# "current" integer - the current drawn in amperes by the VCS +# "power" integer - the power drawn in watts by the VCS +# "voltage" integer - the voltage reading of the VCS +# "state" integer - flag to indicate whether PSU is operating normally +# +# Example: +# +# current=10, power=15, voltage=unknown, state=normal +# +# This attribute must be queried through XNVCTRLQueryTargetStringAttribute() +# using a NV_CTRL_TARGET_TYPE_VCSC target. +# +# + + +NV_CTRL_STRING_VCSC_PSU_INFO = 32 # R---V + +# +# NV_CTRL_STRING_GVIO_VIDEO_FORMAT_NAME - query the name for the specified +# NV_CTRL_GVIO_VIDEO_FORMAT_*. So that this can be queried with existing +# interfaces, XNVCTRLQueryStringAttribute() should be used, and the video +# format specified in the display_mask field; eg: +# +# XNVCTRLQueryStringAttribute(dpy, +# screen, +# NV_CTRL_GVIO_VIDEO_FORMAT_720P_60_00_SMPTE296, +# NV_CTRL_GVIO_VIDEO_FORMAT_NAME, +# &name); +# + +NV_CTRL_STRING_GVIO_VIDEO_FORMAT_NAME = 33 # R--GI + +# +# NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME - renamed +# +# NV_CTRL_STRING_GVIO_VIDEO_FORMAT_NAME should be used instead. +# +NV_CTRL_STRING_GVO_VIDEO_FORMAT_NAME = 33 # renamed + +# +# NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS - returns a string with the +# associated NV Clock, Memory Clock and Processor Clock values. +# +# Current valid tokens are "nvclock", "nvclockmin", "nvclockmax", +# "memclock", "memclockmin", "memclockmax", "processorclock", +# "processorclockmin" and "processorclockmax". +# Not all tokens will be reported on all GPUs, and additional tokens +# may be added in the future. +# +# Note: These clock values take into account the offset +# set by clients through NV_CTRL_GPU_NVCLOCK_OFFSET and +# NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET. +# +# Clock values are returned as a comma-separated list of +# "token=value" pairs. +# Valid tokens: +# +# Token Value +# "nvclock" integer - the GPU clocks (in MHz) for the perf level +# "nvclockmin" integer - the GPU clocks min (in MHz) for the perf level +# "nvclockmax" integer - the GPU clocks max (in MHz) for the perf level +# "nvclockeditable" integer - if the GPU clock domain is editable +# for the perf level +# "memclock" integer - the memory clocks (in MHz) for the perf level +# "memclockmin" integer - the memory clocks min (in MHz) for the perf level +# "memclockmax" integer - the memory clocks (max in MHz) for the perf level +# "memclockeditable" integer - if the memory clock domain is editable +# for the perf level +# "memtransferrate" integer - the memory transfer rate (in MHz) +# for the perf level +# "memtransferratemin" integer - the memory transfer rate min (in MHz) +# for the perf level +# "memtransferratemax" integer - the memory transfer rate max (in MHz) +# for the perf level +# "memtransferrateeditable" integer - if the memory transfer rate is editable +# for the perf level +# "processorclock" integer - the processor clocks (in MHz) +# for the perf level +# "processorclockmin" integer - the processor clocks min (in MHz) +# for the perf level +# "processorclockmax" integer - the processor clocks max (in MHz) +# for the perf level +# "processorclockeditable" integer - if the processor clock domain is editable +# for the perf level +# +# Example: +# +# nvclock=324, nvclockmin=324, nvclockmax=324, nvclockeditable=0 +# memclock=324, memclockmin=324, memclockmax=324, memclockeditable=0 +# memtrasferrate=628 +# +# This attribute may be queried through XNVCTRLQueryTargetStringAttribute() +# using an NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS = 34 # RW-G + +# +# NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_HARDWARE_REVISION - Returns the +# hardware revision of the 3D Vision Pro transceiver. +# +NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_HARDWARE_REVISION = 35 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_A - Returns the +# firmware version of chip A of the 3D Vision Pro transceiver. +# +NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_A = 36 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_A - Returns the +# date of the firmware of chip A of the 3D Vision Pro transceiver. +# +NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_A = 37 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_B - Returns the +# firmware version of chip B of the 3D Vision Pro transceiver. +# +NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_VERSION_B = 38 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_B - Returns the +# date of the firmware of chip B of the 3D Vision Pro transceiver. +# +NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_FIRMWARE_DATE_B = 39 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_ADDRESS - Returns the RF address +# of the 3D Vision Pro transceiver. +# +NV_CTRL_STRING_3D_VISION_PRO_TRANSCEIVER_ADDRESS = 40 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_VERSION_A - Returns the +# firmware version of chip A of the glasses. +# Use the display_mask parameter to specify the glasses id. +# +NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_VERSION_A = 41 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_DATE_A - Returns the +# date of the firmware of chip A of the glasses. +# Use the display_mask parameter to specify the glasses id. +# +NV_CTRL_STRING_3D_VISION_PRO_GLASSES_FIRMWARE_DATE_A = 42 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_GLASSES_ADDRESS - Returns the RF address +# of the glasses. +# Use the display_mask parameter to specify the glasses id. +# +NV_CTRL_STRING_3D_VISION_PRO_GLASSES_ADDRESS = 43 # R--T + +# +# NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME - Controls the name the +# glasses should use. +# Use the display_mask parameter to specify the glasses id. +# Glasses' name should start and end with an alpha-numeric character. +# +NV_CTRL_STRING_3D_VISION_PRO_GLASSES_NAME = 44 # RW-T + +# +# NV_CTRL_STRING_CURRENT_METAMODE_VERSION_2 - Returns the metamode currently +# being used by the specified X screen. The MetaMode string has the same +# syntax as the MetaMode X configuration option, as documented in the NVIDIA +# driver README. Also, see NV_CTRL_BINARY_DATA_METAMODES_VERSION_2 for more +# details on the base syntax. +# +# The returned string may also be prepended with a comma-separated list of +# "token=value" pairs, separated from the MetaMode string by "::". +# +NV_CTRL_STRING_CURRENT_METAMODE_VERSION_2 = 45 # RW-- + +# +# NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME - Returns a type name for the +# display device ("CRT", "DFP", or "TV"). However, note that the determination +# of the name is based on the protocol through which the X driver communicates +# to the display device. E.g., if the driver communicates using VGA ,then the +# basename is "CRT"; if the driver communicates using TMDS, LVDS, or DP, then +# the name is "DFP". +# +NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME = 46 # R-D- + +# +# NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID - Returns the type-based name + ID for +# the display device, e.g. "CRT-0", "DFP-1", "TV-2". If this device is a +# DisplayPort multistream device, then this name will also be prepended with the +# device's port address like so: "DFP-1.0.1.2.3". See +# NV_CTRL_STRING_DISPLAY_NAME_TYPE_BASENAME for more information about the +# construction of type-based names. +# +NV_CTRL_STRING_DISPLAY_NAME_TYPE_ID = 47 # R-D- + +# +# NV_CTRL_STRING_DISPLAY_NAME_DP_GUID - Returns the GUID of the DisplayPort +# display device. e.g. "DP-GUID-f16a5bde-79f3-11e1-b2ae-8b5a8969ba9c" +# +# The display device must be a DisplayPort 1.2 device. +# +NV_CTRL_STRING_DISPLAY_NAME_DP_GUID = 48 # R-D- + +# +# NV_CTRL_STRING_DISPLAY_NAME_EDID_HASH - Returns the SHA-1 hash of the +# display device's EDID in 8-4-4-4-12 UID format. e.g. +# "DPY-EDID-f16a5bde-79f3-11e1-b2ae-8b5a8969ba9c" +# +# The display device must have a valid EDID. +# +NV_CTRL_STRING_DISPLAY_NAME_EDID_HASH = 49 # R-D- + +# +# NV_CTRL_STRING_DISPLAY_NAME_TARGET_INDEX - Returns the current NV-CONTROL +# target ID (name) of the display device. e.g. "DPY-1", "DPY-4" +# +# This name for the display device is not guarenteed to be the same between +# different runs of the X server. +# +NV_CTRL_STRING_DISPLAY_NAME_TARGET_INDEX = 50 # R-D- + +# +# NV_CTRL_STRING_DISPLAY_NAME_RANDR - Returns the RandR output name for the +# display device. e.g. "VGA-1", "DVI-I-0", "DVI-D-3", "LVDS-1", "DP-2", +# "HDMI-3", "eDP-6". This name should match If this device is a DisplayPort +# 1.2 device, then this name will also be prepended with the device's port +# address like so: "DVI-I-3.0.1.2.3" +# +NV_CTRL_STRING_DISPLAY_NAME_RANDR = 51 # R-D- + +# +# NV_CTRL_STRING_GPU_UUID - Returns the UUID of the given GPU. +# +NV_CTRL_STRING_GPU_UUID = 52 # R--G + +# +# NV_CTRL_STRING_GPU_UTILIZATION - Returns the current percentage usage +# of the various components of the GPU. +# +# Current valid tokens are "graphics", "memory", "video" and "PCIe". +# Not all tokens will be reported on all GPUs, and additional tokens +# may be added in the future. +# +# Utilization values are returned as a comma-separated list of +# "token=value" pairs. +# Valid tokens: +# +# Token Value +# "graphics" integer - the percentage usage of graphics engine. +# "memory" integer - the percentage usage of FB. +# "video" integer - the percentage usage of video engine. +# "PCIe" integer - the percentage usage of PCIe bandwidth. +# +# +# Example: +# +# graphics=45, memory=6, video=0, PCIe=0 +# +# This attribute may be queried through XNVCTRLQueryTargetStringAttribute() +# using an NV_CTRL_TARGET_TYPE_GPU. +# +NV_CTRL_STRING_GPU_UTILIZATION = 53 # R--G + +# +# NV_CTRL_STRING_MULTIGPU_MODE - returns a string describing the current +# MULTIGPU mode, if any, or FALSE if MULTIGPU is not currently enabled. +# +NV_CTRL_STRING_MULTIGPU_MODE = 54 # R--- + +# +# NV_CTRL_STRING_PRIME_OUTPUTS_DATA - returns a semicolon delimited list of +# strings that describe all PRIME configured displays. +# +# ex. "xpos=1920, ypos=0, width=1280, height=1024, screen=0;xpos=3200, +# ypos=0, width=800, height=600, screen=0;" +# +NV_CTRL_STRING_PRIME_OUTPUTS_DATA = 55 # R--- + +NV_CTRL_STRING_LAST_ATTRIBUTE = NV_CTRL_STRING_PRIME_OUTPUTS_DATA + +############################################################################ + +# +# Binary Data Attributes: +# +# Binary data attributes can be queryied through the XNVCTRLQueryBinaryData() +# and XNVCTRLQueryTargetBinaryData() function calls. +# +# There are currently no binary data attributes that can be set. +# +# Unless otherwise noted, all Binary data attributes can be queried +# using an NV_CTRL_TARGET_TYPE_X_SCREEN target. Attributes that cannot take +# an NV_CTRL_TARGET_TYPE_X_SCREEN target also cannot be queried through +# XNVCTRLQueryBinaryData() (Since an X Screen target is assumed). +# + + +# +# NV_CTRL_BINARY_DATA_EDID - Returns a display device's EDID information +# data. +# +# This attribute may be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_BINARY_DATA_EDID = 0 # R-DG + +# +# NV_CTRL_BINARY_DATA_MODELINES - Returns a display device's supported +# ModeLines. ModeLines are returned in a buffer, separated by a single +# '\0' and terminated by two consecutive '\0' s like so: +# +# "ModeLine 1\0ModeLine 2\0ModeLine 3\0Last ModeLine\0\0" +# +# This attribute may be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU or NV_CTRL_TARGET_TYPE_X_SCREEN target. +# +# Each ModeLine string may be prepended with a comma-separated list +# of "token=value" pairs, separated from the ModeLine string with a +# "::". Valid tokens: +# +# Token Value +# "source" "xserver" - the ModeLine is from the core X server +# "xconfig" - the ModeLine was specified in the X config file +# "builtin" - the NVIDIA driver provided this builtin ModeLine +# "vesa" - this is a VESA standard ModeLine +# "edid" - the ModeLine was in the display device's EDID +# "nv-control" - the ModeLine was specified via NV-CONTROL +# +# "xconfig-name" - for ModeLines that were specified in the X config +# file, this is the name the X config file +# gave for the ModeLine. +# +# Note that a ModeLine can have several sources; the "source" token +# can appear multiple times in the "token=value" pairs list. +# Additional source values may be specified in the future. +# +# Additional tokens may be added in the future, so it is recommended +# that any token parser processing the returned string from +# NV_CTRL_BINARY_DATA_MODELINES be implemented to gracefully ignore +# unrecognized tokens. +# +# E.g., +# +# "source=xserver, source=vesa, source=edid :: "1024x768_70" 75.0 1024 1048 1184 1328 768 771 777 806 -HSync -VSync" +# "source=xconfig, xconfig-name=1600x1200_60.00 :: "1600x1200_60_0" 161.0 1600 1704 1880 2160 1200 1201 1204 1242 -HSync +VSync" +# + +NV_CTRL_BINARY_DATA_MODELINES = 1 # R-DG + +# +# NV_CTRL_BINARY_DATA_METAMODES - Returns an X Screen's supported +# MetaModes. MetaModes are returned in a buffer separated by a +# single '\0' and terminated by two consecutive '\0' s like so: +# +# "MetaMode 1\0MetaMode 2\0MetaMode 3\0Last MetaMode\0\0" +# +# The MetaMode string should have the same syntax as the MetaMode X +# configuration option, as documented in the NVIDIA driver README. + +# Each MetaMode string may be prepended with a comma-separated list +# of "token=value" pairs, separated from the MetaMode string with +# "::". Currently, valid tokens are: +# +# Token Value +# "id" - the id of this MetaMode; this is stored in +# the Vertical Refresh field, as viewed +# by the XRandR and XF86VidMode X# +# extensions. +# +# "switchable" "yes"/"no" - whether this MetaMode may be switched to via +# ctrl-alt-+/-; Implicit MetaModes (see +# the "IncludeImplicitMetaModes" X +# config option), for example, are not +# normally made available through +# ctrl-alt-+/-. +# +# "source" "xconfig" - the MetaMode was specified in the X +# config file. +# "implicit" - the MetaMode was implicitly added; see the +# "IncludeImplicitMetaModes" X config option +# for details. +# "nv-control" - the MetaMode was added via the NV-CONTROL X +# extension to the currently running X server. +# "RandR" - the MetaMode was modified in response to an +# RandR RRSetCrtcConfig request. +# +# Additional tokens may be added in the future, so it is recommended +# that any token parser processing the returned string from +# NV_CTRL_BINARY_DATA_METAMODES be implemented to gracefully ignore +# unrecognized tokens. +# +# E.g., +# +# "id=50, switchable=yes, source=xconfig :: CRT-0: 1024x768 @1024x768 +0+0" +# + +NV_CTRL_BINARY_DATA_METAMODES = 2 # R-D- +NV_CTRL_BINARY_DATA_METAMODES_VERSION_1 = NV_CTRL_BINARY_DATA_METAMODES + +# +# NV_CTRL_BINARY_DATA_XSCREENS_USING_GPU - Returns the list of X +# screens currently driven by the given GPU. +# +# The format of the returned data is: +# +# 4 CARD32 number of screens +# 4# n CARD32 screen indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN. +# + +NV_CTRL_BINARY_DATA_XSCREENS_USING_GPU = 3 # R-DG + +# +# NV_CTRL_BINARY_DATA_GPUS_USED_BY_XSCREEN - Returns the list of GPUs +# currently in use by the given X screen. +# +# The format of the returned data is: +# +# 4 CARD32 number of GPUs +# 4# n CARD32 GPU indices +# + +NV_CTRL_BINARY_DATA_GPUS_USED_BY_XSCREEN = 4 # R--- + +# +# NV_CTRL_BINARY_DATA_GPUS_USING_FRAMELOCK - Returns the list of +# GPUs currently connected to the given frame lock board. +# +# The format of the returned data is: +# +# 4 CARD32 number of GPUs +# 4# n CARD32 GPU indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_FRAMELOCK target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN. +# + +NV_CTRL_BINARY_DATA_GPUS_USING_FRAMELOCK = 5 # R-DF + +# +# NV_CTRL_BINARY_DATA_DISPLAY_VIEWPORT - Returns the Display Device's +# viewport box into the given X Screen (in X Screen coordinates.) +# +# The format of the returned data is: +# +# 4 CARD32 Offset X +# 4 CARD32 Offset Y +# 4 CARD32 Width +# 4 CARD32 Height +# + +NV_CTRL_BINARY_DATA_DISPLAY_VIEWPORT = 6 # R-DG + +# +# NV_CTRL_BINARY_DATA_FRAMELOCKS_USED_BY_GPU - Returns the list of +# Framelock devices currently connected to the given GPU. +# +# The format of the returned data is: +# +# 4 CARD32 number of Framelocks +# 4# n CARD32 Framelock indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN. +# + +NV_CTRL_BINARY_DATA_FRAMELOCKS_USED_BY_GPU = 7 # R-DG + +# +# NV_CTRL_BINARY_DATA_GPUS_USING_VCSC - Deprecated +# +# Returns the list of GPU devices connected to the given VCS. +# +# The format of the returned data is: +# +# 4 CARD32 number of GPUs +# 4# n CARD32 GPU indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_VCSC target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN and cannot be queried using +# a NV_CTRL_TARGET_TYPE_X_GPU +# + +NV_CTRL_BINARY_DATA_GPUS_USING_VCSC = 8 # R-DV + +# +# NV_CTRL_BINARY_DATA_VCSCS_USED_BY_GPU - Deprecated +# +# Returns the VCSC device that is controlling the given GPU. +# +# The format of the returned data is: +# +# 4 CARD32 number of VCS (always 1) +# 4# n CARD32 VCS indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN +# + +NV_CTRL_BINARY_DATA_VCSCS_USED_BY_GPU = 9 # R-DG + +# +# NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU - Returns the coolers that +# are cooling the given GPU. +# +# The format of the returned data is: +# +# 4 CARD32 number of COOLER +# 4# n CARD32 COOLER indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN +# + +NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU = 10 # R-DG + +# +# NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN - Returns the list of +# GPUs currently driving the given X screen. If Xinerama is enabled, this +# will return all GPUs that are driving any X screen. +# +# The format of the returned data is: +# +# 4 CARD32 number of GPUs +# 4# n CARD32 GPU indices +# + +NV_CTRL_BINARY_DATA_GPUS_USED_BY_LOGICAL_XSCREEN = 11 # R--- + +# +# NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU - Returns the sensors that +# are attached to the given GPU. +# +# The format of the returned data is: +# +# 4 CARD32 number of SENSOR +# 4# n CARD32 SENSOR indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. This attribute cannot be +# queried using a NV_CTRL_TARGET_TYPE_X_SCREEN +# + +NV_CTRL_BINARY_DATA_THERMAL_SENSORS_USED_BY_GPU = 12 # R--G + +# +# NV_CTRL_BINARY_DATA_GLASSES_PAIRED_TO_3D_VISION_PRO_TRANSCEIVER - Returns +# the id of the glasses that are currently paired to the given +# 3D Vision Pro transceiver. +# +# The format of the returned data is: +# +# 4 CARD32 number of glasses +# 4# n CARD32 id of glasses +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER target. +# +NV_CTRL_BINARY_DATA_GLASSES_PAIRED_TO_3D_VISION_PRO_TRANSCEIVER = 13 # R--T + +# +# NV_CTRL_BINARY_DATA_DISPLAY_TARGETS - Returns all the display devices +# currently connected to any GPU on the X server. +# +# The format of the returned data is: +# +# 4 CARD32 number of display devices +# 4# n CARD32 display device indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData(). +# + +NV_CTRL_BINARY_DATA_DISPLAY_TARGETS = 14 # R--- + +# +# NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU - Returns the list of +# display devices that are connected to the GPU target. +# +# The format of the returned data is: +# +# 4 CARD32 number of display devices +# 4# n CARD32 display device indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. +# + +NV_CTRL_BINARY_DATA_DISPLAYS_CONNECTED_TO_GPU = 15 # R--G + +# +# NV_CTRL_BINARY_DATA_METAMODES_VERSION_2 - Returns values similar to +# NV_CTRL_BINARY_DATA_METAMODES(_VERSION_1) but also returns extended syntax +# information to indicate a specific display device, as well as other per- +# display deviceflags as "token=value" pairs. For example: +# +# "DPY-1: 1280x1024 {Stereo=PassiveLeft}, +# DPY-2: 1280x1024 {Stereo=PassiveRight}," +# +# The display device names have the form "DPY-%d", where the integer +# part of the name is the NV-CONTROL target ID for that display device +# for this instance of the X server. Note that display device NV-CONTROL +# target IDs are not guaranteed to be the same from one run of the X +# server to the next. +# + +NV_CTRL_BINARY_DATA_METAMODES_VERSION_2 = 16 # R-D- + +# +# NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN - Returns the list of +# display devices that are currently scanning out the X screen target. +# +# The format of the returned data is: +# +# 4 CARD32 number of display devices +# 4# n CARD32 display device indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_BINARY_DATA_DISPLAYS_ENABLED_ON_XSCREEN = 17 # R--- + +# +# NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN - Returns the list of +# display devices that are currently assigned the X screen target. +# +# The format of the returned data is: +# +# 4 CARD32 number of display devices +# 4# n CARD32 display device indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + +NV_CTRL_BINARY_DATA_DISPLAYS_ASSIGNED_TO_XSCREEN = 18 # R--- + +# +# NV_CTRL_BINARY_DATA_GPU_FLAGS - Returns a list of flags for the +# given GPU. A flag can, for instance, be a capability which enables +# or disables some features according to the GPU state. +# +# The format of the returned data is: +# +# 4 CARD32 number of GPU flags +# 4# n CARD32 GPU flag +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. +# +NV_CTRL_BINARY_DATA_GPU_FLAGS = 19 # R--- + +# Stereo and display composition transformations are mutually exclusive. +NV_CTRL_BINARY_DATA_GPU_FLAGS_STEREO_DISPLAY_TRANSFORM_EXCLUSIVE = 0 +# Overlay and display composition transformations are mutually exclusive. +NV_CTRL_BINARY_DATA_GPU_FLAGS_OVERLAY_DISPLAY_TRANSFORM_EXCLUSIVE = 1 +# Depth 8 and display composition transformations are mutually exclusive. +NV_CTRL_BINARY_DATA_GPU_FLAGS_DEPTH_8_DISPLAY_TRANSFORM_EXCLUSIVE = 2 + +# +# NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU - Returns the list of valid +# display devices that can be connected to the GPU target. +# +# The format of the returned data is: +# +# 4 CARD32 number of display devices +# 4# n CARD32 display device indices +# +# This attribute can only be queried through XNVCTRLQueryTargetBinaryData() +# using a NV_CTRL_TARGET_TYPE_GPU target. +# + +NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU = 20 # R--G + +NV_CTRL_BINARY_DATA_LAST_ATTRIBUTE = NV_CTRL_BINARY_DATA_DISPLAYS_ON_GPU + +############################################################################ + +# +# String Operation Attributes: +# +# These attributes are used with the XNVCTRLStringOperation() +# function; a string is specified as input, and a string is returned +# as output. +# +# Unless otherwise noted, all attributes can be operated upon using +# an NV_CTRL_TARGET_TYPE_X_SCREEN target. +# + + +# +# NV_CTRL_STRING_OPERATION_ADD_METAMODE - provide a MetaMode string +# as input, and returns a string containing comma-separated list of +# "token=value" pairs as output. Currently, the only output token is +# "id", which indicates the id that was assigned to the MetaMode. +# +# All ModeLines referenced in the MetaMode must already exist for +# each display device (as returned by the +# NV_CTRL_BINARY_DATA_MODELINES attribute). +# +# The MetaMode string should have the same syntax as the MetaMode X +# configuration option, as documented in the NVIDIA driver README. +# +# The input string can optionally be prepended with a string of +# comma-separated "token=value" pairs, separated from the MetaMode +# string by "::". Currently, the only valid token is "index" which +# indicates the insertion index for the MetaMode. +# +# E.g., +# +# Input: "index=5 :: 1600x1200+0+0, 1600x1200+1600+0" +# Output: "id=58" +# +# which causes the MetaMode to be inserted at position 5 in the +# MetaMode list (all entries after 5 will be shifted down one slot in +# the list), and the X server's containing mode stores 58 as the +# VRefresh, so that the MetaMode can be uniquely identifed through +# XRandR and XF86VidMode. +# + +NV_CTRL_STRING_OPERATION_ADD_METAMODE = 0 # ---- + +# +# NV_CTRL_STRING_OPERATION_GTF_MODELINE - provide as input a string +# of comma-separated "token=value" pairs, and returns a ModeLine +# string, computed using the GTF formula using the parameters from +# the input string. Valid tokens for the input string are "width", +# "height", and "refreshrate". +# +# E.g., +# +# Input: "width=1600, height=1200, refreshrate=60" +# Output: "160.96 1600 1704 1880 2160 1200 1201 1204 1242 -HSync +VSync" +# +# This operation does not have any impact on any display device's +# modePool, and the ModeLine is not validated; it is simply intended +# for generating ModeLines. +# + +NV_CTRL_STRING_OPERATION_GTF_MODELINE = 1 # --- + +# +# NV_CTRL_STRING_OPERATION_CVT_MODELINE - provide as input a string +# of comma-separated "token=value" pairs, and returns a ModeLine +# string, computed using the CVT formula using the parameters from +# the input string. Valid tokens for the input string are "width", +# "height", "refreshrate", and "reduced-blanking". The +# "reduced-blanking" argument can be "0" or "1", to enable or disable +# use of reduced blanking for the CVT formula. +# +# E.g., +# +# Input: "width=1600, height=1200, refreshrate=60, reduced-blanking=1" +# Output: "130.25 1600 1648 1680 1760 1200 1203 1207 1235 +HSync -VSync" +# +# This operation does not have any impact on any display device's +# modePool, and the ModeLine is not validated; it is simply intended +# for generating ModeLines. +# + +NV_CTRL_STRING_OPERATION_CVT_MODELINE = 2 # --- + +# +# NV_CTRL_STRING_OPERATION_BUILD_MODEPOOL - build a ModePool for the +# specified display device on the specified target (either an X +# screen or a GPU). This is typically used to generate a ModePool +# for a display device on a GPU on which no X screens are present. +# +# Currently, a display device's ModePool is static for the life of +# the X server, so XNVCTRLStringOperation will return FALSE if +# requested to build a ModePool on a display device that already has +# a ModePool. +# +# The string input to BUILD_MODEPOOL may be NULL. If it is not NULL, +# then it is interpreted as a double-colon ("::") separated list +# of "option=value" pairs, where the options and the syntax of their +# values are the X configuration options that impact the behavior of +# modePool construction; namely: +# +# "ModeValidation" +# "HorizSync" +# "VertRefresh" +# "FlatPanelProperties" +# "ExactModeTimingsDVI" +# "UseEdidFreqs" +# +# An example input string might look like: +# +# "ModeValidation=NoVesaModes :: HorizSync=50-110 :: VertRefresh=50-150" +# +# This request currently does not return a string. +# + +NV_CTRL_STRING_OPERATION_BUILD_MODEPOOL = 3 # DG + +# +# NV_CTRL_STRING_OPERATION_GVI_CONFIGURE_STREAMS - Configure the streams- +# to-jack+channel topology for a GVI (Graphics capture board). +# +# The string input to GVI_CONFIGURE_STREAMS may be NULL. If this is the +# case, then the current topology is returned. +# +# If the input string to GVI_CONFIGURE_STREAMS is not NULL, the string +# is interpreted as a semicolon (";") separated list of comma-separated +# lists of "option=value" pairs that define a stream's composition. The +# available options and their values are: +# +# "stream": Defines which stream this comma-separated list describes. +# Valid values are the integers between 0 and +# NV_CTRL_GVI_NUM_STREAMS-1 (inclusive). +# +# "linkN": Defines a jack+channel pair to use for the given link N. +# Valid options are the string "linkN", where N is an integer +# between 0 and NV_CTRL_GVI_MAX_LINKS_PER_STREAM-1 (inclusive). +# Valid values for these options are strings of the form +# "jackX" and/or "jackX.Y", where X is an integer between 0 and +# NV_CTRL_GVI_NUM_JACKS-1 (inclusive), and Y (optional) is an +# integer between 0 and NV_CTRL_GVI_MAX_CHANNELS_PER_JACK-1 +# (inclusive). +# +# An example input string might look like: +# +# "stream=0, link0=jack0, link1=jack1; stream=1, link0=jack2.1" +# +# This example specifies two streams, stream 0 and stream 1. Stream 0 +# is defined to capture link0 data from the first channel (channel 0) of +# BNC jack 0 and link1 data from the first channel of BNC jack 1. The +# second stream (Stream 1) is defined to capture link0 data from channel 1 +# (second channel) of BNC jack 2. +# +# This example shows a possible configuration for capturing 3G input: +# +# "stream=0, link0=jack0.0, link1=jack0.1" +# +# Applications should query the following attributes to determine +# possible combinations: +# +# NV_CTRL_GVI_MAX_STREAMS +# NV_CTRL_GVI_MAX_LINKS_PER_STREAM +# NV_CTRL_GVI_NUM_JACKS +# NV_CTRL_GVI_MAX_CHANNELS_PER_JACK +# +# Note: A jack+channel pair can only be tied to one link/stream. +# +# Upon successful configuration or querying of this attribute, a string +# representing the current topology for all known streams on the device +# will be returned. On failure, NULL is returned. +# +# Note: Setting this attribute may also result in the following +# NV-CONTROL attributes being reset on the GVI device (to ensure +# the configuration remains valid): +# NV_CTRL_GVIO_REQUESTED_VIDEO_FORMAT +# NV_CTRL_GVI_REQUESTED_STREAM_BITS_PER_COMPONENT +# NV_CTRL_GVI_REQUESTED_STREAM_COMPONENT_SAMPLING +# + +NV_CTRL_STRING_OPERATION_GVI_CONFIGURE_STREAMS = 4 # RW-I + +# +# NV_CTRL_STRING_OPERATION_PARSE_METAMODE - Parses the given MetaMode string +# and returns the validated MetaMode string - possibly re-calculating various +# values such as ViewPortIn. If the MetaMode matches an existing MetaMode, +# the details of the existing MetaMode are returned. If the MetaMode fails to +# be parsed, NULL is returned. +# +NV_CTRL_STRING_OPERATION_PARSE_METAMODE = 5 # R--- + +NV_CTRL_STRING_OPERATION_LAST_ATTRIBUTE = NV_CTRL_STRING_OPERATION_PARSE_METAMODE + +############################################################################### +# NV-CONTROL major op numbers. these constants identify the request type +# +X_nvCtrlQueryExtension = 0 +X_nvCtrlQueryAttribute = 2 +X_nvCtrlQueryStringAttribute = 4 +X_nvCtrlQueryValidAttributeValues = 5 +X_nvCtrlSetStringAttribute = 9 +X_nvCtrlSetAttributeAndGetStatus = 19 +X_nvCtrlQueryBinaryData = 20 +X_nvCtrlQueryTargetCount = 24 +X_nvCtrlStringOperation = 25 + +############################################################################### +# various lists that go with attrs, but are handled more compactly +# this way. these lists are indexed by the possible values of their attrs +# and are explained in NVCtrl.h +# + +ATTRIBUTE_TYPE_UNKNOWN = 0 +ATTRIBUTE_TYPE_INTEGER = 1 +ATTRIBUTE_TYPE_BITMASK = 2 +ATTRIBUTE_TYPE_BOOL = 3 +ATTRIBUTE_TYPE_RANGE = 4 +ATTRIBUTE_TYPE_INT_BITS = 5 + +ATTRIBUTE_TYPE_READ = 0x01 +ATTRIBUTE_TYPE_WRITE = 0x02 +ATTRIBUTE_TYPE_DISPLAY = 0x04 +ATTRIBUTE_TYPE_GPU = 0x08 +ATTRIBUTE_TYPE_FRAMELOCK = 0x10 +ATTRIBUTE_TYPE_X_SCREEN = 0x20 +ATTRIBUTE_TYPE_XINERAMA = 0x40 +ATTRIBUTE_TYPE_VCSC = 0x80 + +############################################################################ + +# +# Attribute Targets +# +# Targets define attribute groups. For example, some attributes are only +# valid to set on a GPU, others are only valid when talking about an +# X Screen. Target types are then what is used to identify the target +# group of the attribute you wish to set/query. +# +# Here are the supported target types: +# + +NV_CTRL_TARGET_TYPE_X_SCREEN = 0 +NV_CTRL_TARGET_TYPE_GPU = 1 +NV_CTRL_TARGET_TYPE_FRAMELOCK = 2 +# Visual Computing System - deprecated. To be removed along with all +# VCS-specific attributes in a later release. +NV_CTRL_TARGET_TYPE_VCSC = 3 +NV_CTRL_TARGET_TYPE_GVI = 4 +NV_CTRL_TARGET_TYPE_COOLER = 5 # e.g., fan +NV_CTRL_TARGET_TYPE_THERMAL_SENSOR = 6 +NV_CTRL_TARGET_TYPE_3D_VISION_PRO_TRANSCEIVER = 7 +NV_CTRL_TARGET_TYPE_DISPLAY = 8 + + +############################################################################### +# Targets, to indicate where a command should be executed. +# +class Target(object): + def __init__(self): + self._id = -1 + self._type = -1 + self._name = '' + + def id(self): + return self._id + + def type(self): + return self._type + + def __str__(self): + return '' % (self._name, self.id()) + + +class Gpu(Target): + def __init__(self, ngpu=0): + """Target a GPU""" + super(self.__class__, self).__init__() + self._id = ngpu + self._type = NV_CTRL_TARGET_TYPE_GPU + self._name = 'GPU' + + +class Screen(Target): + def __init__(self, nscr=0): + """Target an X screen""" + super(self.__class__, self).__init__() + self._id = nscr + self._type = NV_CTRL_TARGET_TYPE_X_SCREEN + self._name = 'X screen' + + +class Cooler(Target): + def __init__(self, nfan=0): + """Target a fann""" + super(self.__class__, self).__init__() + self._id = nfan + self._type = NV_CTRL_TARGET_TYPE_COOLER + self._name = 'Cooler' + + +class NVCtrlQueryAttributeRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlQueryAttribute), + rq.RequestLength(), + rq.Card16('target_id'), + rq.Card16('target_type'), + rq.Card32('display_mask'), + rq.Card32('attr'), + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('pad0'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('flags'), + rq.Int32('value'), + rq.Card32('pad4'), + rq.Card32('pad5'), + rq.Card32('pad6'), + rq.Card32('pad7'), + ) + + +class NVCtrlSetAttributeAndGetStatusRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlSetAttributeAndGetStatus), + rq.RequestLength(), + rq.Card16('target_id'), + rq.Card16('target_type'), + rq.Card32('display_mask'), + rq.Card32('attr'), + rq.Int32('value') + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('pad0'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('flags'), + rq.Card32('pad3'), + rq.Card32('pad4'), + rq.Card32('pad5'), + rq.Card32('pad6'), + rq.Card32('pad7'), + ) + + +class NVCtrlQueryStringAttributeRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlQueryStringAttribute), + rq.RequestLength(), + rq.Card16('target_id'), + rq.Card16('target_type'), + rq.Card32('display_mask'), + rq.Card32('attr'), + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('pad0'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('flags'), + rq.Card32('string', 4), + rq.Card32('pad4'), + rq.Card32('pad5'), + rq.Card32('pad6'), + rq.Card32('pad7'), + rq.String8('string'), + ) diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py new file mode 100755 index 00000000..b8d387a1 --- /dev/null +++ b/examples/nvcontrol.py @@ -0,0 +1,91 @@ +#!/usr/bin/python +# +# examples/nvcontrol.py -- demonstrate the NV-CONTROL extension +# +# Copyright (C) 2019 Roberto Leinardi +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA + + +# Python 2/3 compatibility. +from __future__ import print_function + +import sys +import os + +# Change path so we find Xlib +from pprint import pprint + +from Xlib.display import Display +from Xlib.ext.nvcontrol import Gpu, Cooler + +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +if __name__ == '__main__': + display = Display() + # Check for extension + if not display.has_extension('NV-CONTROL'): + sys.stderr.write('%s: server does not have the NV-CONTROL extension\n' + % sys.argv[0]) + print(display.query_extension('NV-CONTROL')) + sys.stderr.write("\n".join(display.list_extensions())) + if display.query_extension('NV-CONTROL') is None: + sys.exit(1) + + gpu = Gpu(0) + fan = Cooler(0) + + dic = {'get_vram': display.nvcontrol_get_vram(gpu), + 'get_irq': display.nvcontrol_get_irq(gpu), + 'supports_framelock': display.nvcontrol_supports_framelock(gpu), + 'get_core_temp': display.nvcontrol_get_core_temp(gpu), + 'get_core_threshold': display.nvcontrol_get_core_threshold(gpu), + 'get_default_core_threshold': display.nvcontrol_get_default_core_threshold(gpu), + 'get_max_core_threshold': display.nvcontrol_get_max_core_threshold(gpu), + 'get_ambient_temp': display.nvcontrol_get_ambient_temp(gpu), + 'get_cuda_cores': display.nvcontrol_get_cuda_cores(gpu), + 'get_memory_bus_width': display.nvcontrol_get_memory_bus_width(gpu), + 'get_total_dedicated_gpu_memory': display.nvcontrol_get_total_dedicated_gpu_memory(gpu), + 'get_used_dedicated_gpu_memory': display.nvcontrol_get_used_dedicated_gpu_memory(gpu), + 'get_pcie_current_link_width': display.nvcontrol_get_pcie_current_link_width(gpu), + 'get_pcie_max_link_width': display.nvcontrol_get_pcie_max_link_width(gpu), + 'get_pcie_generation': display.nvcontrol_get_pcie_generation(gpu), + 'get_video_encoder_utilization': display.nvcontrol_get_video_encoder_utilization(gpu), + 'get_video_decoder_utilization': display.nvcontrol_get_video_decoder_utilization(gpu), + 'get_current_performance_level': display.nvcontrol_get_current_performance_level(gpu), + 'get_gpu_nvclock_offset': display.nvcontrol_get_gpu_nvclock_offset(gpu), + 'get_mem_transfer_rate_offset': display.nvcontrol_get_mem_transfer_rate_offset(gpu), + 'get_cooler_manual_control_enabled': display.nvcontrol_get_cooler_manual_control_enabled(gpu), + 'get_fan_duty': display.nvcontrol_get_fan_duty(fan), + 'get_fan_rpm': display.nvcontrol_get_fan_rpm(fan), + 'get_max_displays': display.nvcontrol_get_max_displays(gpu), + 'get_name': display.nvcontrol_get_name(gpu), + 'get_driver_version': display.nvcontrol_get_driver_version(gpu), + 'get_vbios_version': display.nvcontrol_get_vbios_version(gpu), + 'get_gpu_uuid': display.nvcontrol_get_gpu_uuid(gpu), + 'get_gpu_utilization': display.nvcontrol_get_gpu_utilization(gpu), + 'get_performance_modes': display.nvcontrol_get_performance_modes(gpu)} + + pprint(dic) + + # display.nvcontrol_set_cooler_manual_control_enabled(gpu, True) + # print(str(display.nvcontrol_get_cooler_manual_control_enabled(gpu))) + # display.nvcontrol_set_cooler_manual_control_enabled(gpu, False) + # print(str(display.nvcontrol_get_cooler_manual_control_enabled(gpu))) + + display.close() From 98f45f03cc0436d4c70ab6c56592258075500514 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 20:38:28 +0100 Subject: [PATCH 194/279] Ignoring mypy cache --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 19d67036..ac3327fb 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,4 @@ target/ .idea/ +/.mypy_cache/ From aafedf44b88f5ce7fde2d4355a12e384d093bb44 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 20:39:53 +0100 Subject: [PATCH 195/279] NV-CONTROL: query target count --- Xlib/ext/nvcontrol.py | 44 +++++++++++++++++++++++++++--- examples/nvcontrol.py | 63 ++++++++++++++++++++++--------------------- 2 files changed, 73 insertions(+), 34 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 9f8d45cc..07ed55bf 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -27,6 +27,19 @@ extname = 'NV-CONTROL' +def query_target_count(self, target): + """return the target count""" + reply = NVCtrlQueryTargetCountRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_type=target.type()) + return int(reply._data.get('count')) + + +def get_gpu_count(self): + """Return the number of GPU's present in the system.""" + return int(query_target_count(self, Gpu())) + + def query_int_attribute(self, target, displays, attr): """return the value of an integer attribute""" display_mask = _displays2mask(displays) @@ -54,10 +67,6 @@ def set_int_attribute(self, target, displays, attr, value): return reply._data.get('flags') -def set_cooler_manual_control_enabled(self, target, enabled): - return set_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL, 1 if enabled else 0) == 1 - - def query_string_attribute(self, target, displays, attr): """return the value of an integer attribute""" display_mask = _displays2mask(displays) @@ -200,6 +209,10 @@ def get_cooler_manual_control_enabled(self, target): return query_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL) == 1 +def set_cooler_manual_control_enabled(self, target, enabled): + return set_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL, 1 if enabled else 0) == 1 + + def get_fan_duty(self, target): return query_int_attribute(self, target, [], NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL) @@ -259,8 +272,10 @@ def _displays2mask(displays): def init(disp, info): + disp.extension_add_method('display', 'nvcontrol_query_target_count', query_target_count) disp.extension_add_method('display', 'nvcontrol_query_int_attribute', query_int_attribute) disp.extension_add_method('display', 'nvcontrol_query_string_attribute', query_string_attribute) + disp.extension_add_method('display', 'nvcontrol_get_gpu_count', get_gpu_count) disp.extension_add_method('display', 'nvcontrol_get_vram', get_vram) disp.extension_add_method('display', 'nvcontrol_get_irq', get_irq) disp.extension_add_method('display', 'nvcontrol_supports_framelock', supports_framelock) @@ -5186,3 +5201,24 @@ class NVCtrlQueryStringAttributeRequest(rq.ReplyRequest): rq.Card32('pad7'), rq.String8('string'), ) + + +class NVCtrlQueryTargetCountRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlQueryTargetCount), + rq.RequestLength(), + rq.Card32('target_type'), + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('padb1'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('count'), + rq.Card32('pad4'), + rq.Card32('pad5'), + rq.Card32('pad6'), + rq.Card32('pad7'), + rq.Card32('pad8'), + ) diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index b8d387a1..dfd3f9bb 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -50,36 +50,39 @@ gpu = Gpu(0) fan = Cooler(0) - dic = {'get_vram': display.nvcontrol_get_vram(gpu), - 'get_irq': display.nvcontrol_get_irq(gpu), - 'supports_framelock': display.nvcontrol_supports_framelock(gpu), - 'get_core_temp': display.nvcontrol_get_core_temp(gpu), - 'get_core_threshold': display.nvcontrol_get_core_threshold(gpu), - 'get_default_core_threshold': display.nvcontrol_get_default_core_threshold(gpu), - 'get_max_core_threshold': display.nvcontrol_get_max_core_threshold(gpu), - 'get_ambient_temp': display.nvcontrol_get_ambient_temp(gpu), - 'get_cuda_cores': display.nvcontrol_get_cuda_cores(gpu), - 'get_memory_bus_width': display.nvcontrol_get_memory_bus_width(gpu), - 'get_total_dedicated_gpu_memory': display.nvcontrol_get_total_dedicated_gpu_memory(gpu), - 'get_used_dedicated_gpu_memory': display.nvcontrol_get_used_dedicated_gpu_memory(gpu), - 'get_pcie_current_link_width': display.nvcontrol_get_pcie_current_link_width(gpu), - 'get_pcie_max_link_width': display.nvcontrol_get_pcie_max_link_width(gpu), - 'get_pcie_generation': display.nvcontrol_get_pcie_generation(gpu), - 'get_video_encoder_utilization': display.nvcontrol_get_video_encoder_utilization(gpu), - 'get_video_decoder_utilization': display.nvcontrol_get_video_decoder_utilization(gpu), - 'get_current_performance_level': display.nvcontrol_get_current_performance_level(gpu), - 'get_gpu_nvclock_offset': display.nvcontrol_get_gpu_nvclock_offset(gpu), - 'get_mem_transfer_rate_offset': display.nvcontrol_get_mem_transfer_rate_offset(gpu), - 'get_cooler_manual_control_enabled': display.nvcontrol_get_cooler_manual_control_enabled(gpu), - 'get_fan_duty': display.nvcontrol_get_fan_duty(fan), - 'get_fan_rpm': display.nvcontrol_get_fan_rpm(fan), - 'get_max_displays': display.nvcontrol_get_max_displays(gpu), - 'get_name': display.nvcontrol_get_name(gpu), - 'get_driver_version': display.nvcontrol_get_driver_version(gpu), - 'get_vbios_version': display.nvcontrol_get_vbios_version(gpu), - 'get_gpu_uuid': display.nvcontrol_get_gpu_uuid(gpu), - 'get_gpu_utilization': display.nvcontrol_get_gpu_utilization(gpu), - 'get_performance_modes': display.nvcontrol_get_performance_modes(gpu)} + dic = { + 'get_gpu_count': display.nvcontrol_get_gpu_count(), + 'get_vram': display.nvcontrol_get_vram(gpu), + 'get_irq': display.nvcontrol_get_irq(gpu), + 'supports_framelock': display.nvcontrol_supports_framelock(gpu), + 'get_core_temp': display.nvcontrol_get_core_temp(gpu), + 'get_core_threshold': display.nvcontrol_get_core_threshold(gpu), + 'get_default_core_threshold': display.nvcontrol_get_default_core_threshold(gpu), + 'get_max_core_threshold': display.nvcontrol_get_max_core_threshold(gpu), + 'get_ambient_temp': display.nvcontrol_get_ambient_temp(gpu), + 'get_cuda_cores': display.nvcontrol_get_cuda_cores(gpu), + 'get_memory_bus_width': display.nvcontrol_get_memory_bus_width(gpu), + 'get_total_dedicated_gpu_memory': display.nvcontrol_get_total_dedicated_gpu_memory(gpu), + 'get_used_dedicated_gpu_memory': display.nvcontrol_get_used_dedicated_gpu_memory(gpu), + 'get_pcie_current_link_width': display.nvcontrol_get_pcie_current_link_width(gpu), + 'get_pcie_max_link_width': display.nvcontrol_get_pcie_max_link_width(gpu), + 'get_pcie_generation': display.nvcontrol_get_pcie_generation(gpu), + 'get_video_encoder_utilization': display.nvcontrol_get_video_encoder_utilization(gpu), + 'get_video_decoder_utilization': display.nvcontrol_get_video_decoder_utilization(gpu), + 'get_current_performance_level': display.nvcontrol_get_current_performance_level(gpu), + 'get_gpu_nvclock_offset': display.nvcontrol_get_gpu_nvclock_offset(gpu), + 'get_mem_transfer_rate_offset': display.nvcontrol_get_mem_transfer_rate_offset(gpu), + 'get_cooler_manual_control_enabled': display.nvcontrol_get_cooler_manual_control_enabled(gpu), + 'get_fan_duty': display.nvcontrol_get_fan_duty(fan), + 'get_fan_rpm': display.nvcontrol_get_fan_rpm(fan), + 'get_max_displays': display.nvcontrol_get_max_displays(gpu), + 'get_name': display.nvcontrol_get_name(gpu), + 'get_driver_version': display.nvcontrol_get_driver_version(gpu), + 'get_vbios_version': display.nvcontrol_get_vbios_version(gpu), + 'get_gpu_uuid': display.nvcontrol_get_gpu_uuid(gpu), + 'get_gpu_utilization': display.nvcontrol_get_gpu_utilization(gpu), + 'get_performance_modes': display.nvcontrol_get_performance_modes(gpu) + } pprint(dic) From 14ad974709daa3b9fb8687987a76386cdc39193c Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 20:58:52 +0100 Subject: [PATCH 196/279] NV-CONTROL: query valid attrs values --- Xlib/ext/nvcontrol.py | 102 +++++++++++++++++++++++++++++++----------- examples/nvcontrol.py | 4 +- 2 files changed, 79 insertions(+), 27 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 07ed55bf..81a72b3b 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -29,9 +29,9 @@ def query_target_count(self, target): """return the target count""" - reply = NVCtrlQueryTargetCountRequest(display=self.display, - opcode=self.display.get_extension_major(extname), - target_type=target.type()) + reply = NVCtrlQueryTargetCountReplyRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_type=target.type()) return int(reply._data.get('count')) @@ -43,12 +43,12 @@ def get_gpu_count(self): def query_int_attribute(self, target, displays, attr): """return the value of an integer attribute""" display_mask = _displays2mask(displays) - reply = NVCtrlQueryAttributeRequest(display=self.display, - opcode=self.display.get_extension_major(extname), - target_id=target.id(), - target_type=target.type(), - display_mask=display_mask, - attr=attr) + reply = NVCtrlQueryAttributeReplyRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_id=target.id(), + target_type=target.type(), + display_mask=display_mask, + attr=attr) if not reply._data.get('flags'): return None return int(reply._data.get('value')) @@ -57,30 +57,44 @@ def query_int_attribute(self, target, displays, attr): def set_int_attribute(self, target, displays, attr, value): """return the value of an integer attribute""" display_mask = _displays2mask(displays) - reply = NVCtrlSetAttributeAndGetStatusRequest(display=self.display, - opcode=self.display.get_extension_major(extname), - target_id=target.id(), - target_type=target.type(), - display_mask=display_mask, - attr=attr, - value=value) + reply = NVCtrlSetAttributeAndGetStatusReplyRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_id=target.id(), + target_type=target.type(), + display_mask=display_mask, + attr=attr, + value=value) return reply._data.get('flags') def query_string_attribute(self, target, displays, attr): """return the value of an integer attribute""" display_mask = _displays2mask(displays) - reply = NVCtrlQueryStringAttributeRequest(display=self.display, - opcode=self.display.get_extension_major(extname), - target_id=target.id(), - target_type=target.type(), - display_mask=display_mask, - attr=attr) + reply = NVCtrlQueryStringAttributeReplyRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_id=target.id(), + target_type=target.type(), + display_mask=display_mask, + attr=attr) if not reply._data.get('flags'): return None return str(reply._data.get('string')).strip('\0') +def query_valid_attr_values(self, target, displays, attr): + """return the value of an integer attribute""" + display_mask = _displays2mask(displays) + reply = NVCtrlQueryValidAttributeValuesReplyRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_id=target.id(), + target_type=target.type(), + display_mask=display_mask, + attr=attr) + if not reply._data.get('flags'): + return None + return int(reply._data.get('min')), int(reply._data.get('max')) + + def get_name(self, target): """the GPU product name on which the specified X screen is running""" return query_string_attribute(self, target, [], NV_CTRL_STRING_PRODUCT_NAME) @@ -201,10 +215,18 @@ def get_gpu_nvclock_offset(self, target): return query_int_attribute(self, target, [], NV_CTRL_GPU_NVCLOCK_OFFSET) +def get_gpu_nvclock_offset_range(self, target): + return query_valid_attr_values(self, target, [], NV_CTRL_GPU_NVCLOCK_OFFSET) + + def get_mem_transfer_rate_offset(self, target): return query_int_attribute(self, target, [], NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) +def get_mem_transfer_rate_offset_range(self, target): + return query_valid_attr_values(self, target, [], NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) + + def get_cooler_manual_control_enabled(self, target): return query_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL) == 1 @@ -309,6 +331,10 @@ def init(disp, info): disp.extension_add_method('display', 'nvcontrol_get_performance_modes', get_performance_modes) disp.extension_add_method('display', 'nvcontrol_set_cooler_manual_control_enabled', set_cooler_manual_control_enabled) + disp.extension_add_method('display', 'nvcontrol_get_gpu_nvclock_offset_range', + get_gpu_nvclock_offset_range) + disp.extension_add_method('display', 'nvcontrol_get_mem_transfer_rate_offset_range', + get_mem_transfer_rate_offset_range) ############################################################################ @@ -5129,7 +5155,7 @@ def __init__(self, nfan=0): self._name = 'Cooler' -class NVCtrlQueryAttributeRequest(rq.ReplyRequest): +class NVCtrlQueryAttributeReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlQueryAttribute), @@ -5153,7 +5179,7 @@ class NVCtrlQueryAttributeRequest(rq.ReplyRequest): ) -class NVCtrlSetAttributeAndGetStatusRequest(rq.ReplyRequest): +class NVCtrlSetAttributeAndGetStatusReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlSetAttributeAndGetStatus), @@ -5178,7 +5204,7 @@ class NVCtrlSetAttributeAndGetStatusRequest(rq.ReplyRequest): ) -class NVCtrlQueryStringAttributeRequest(rq.ReplyRequest): +class NVCtrlQueryStringAttributeReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlQueryStringAttribute), @@ -5203,7 +5229,7 @@ class NVCtrlQueryStringAttributeRequest(rq.ReplyRequest): ) -class NVCtrlQueryTargetCountRequest(rq.ReplyRequest): +class NVCtrlQueryTargetCountReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(X_nvCtrlQueryTargetCount), @@ -5222,3 +5248,27 @@ class NVCtrlQueryTargetCountRequest(rq.ReplyRequest): rq.Card32('pad7'), rq.Card32('pad8'), ) + + +class NVCtrlQueryValidAttributeValuesReplyRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlQueryValidAttributeValues), + rq.RequestLength(), + rq.Card16('target_id'), + rq.Card16('target_type'), + rq.Card32('display_mask'), + rq.Card32('attr'), + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('pad0'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('flags'), + rq.Int32('attr_type'), + rq.Int32('min'), + rq.Int32('max'), + rq.Card32('bits'), + rq.Card32('perms'), + ) diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index dfd3f9bb..bde1be31 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -81,7 +81,9 @@ 'get_vbios_version': display.nvcontrol_get_vbios_version(gpu), 'get_gpu_uuid': display.nvcontrol_get_gpu_uuid(gpu), 'get_gpu_utilization': display.nvcontrol_get_gpu_utilization(gpu), - 'get_performance_modes': display.nvcontrol_get_performance_modes(gpu) + 'get_performance_modes': display.nvcontrol_get_performance_modes(gpu), + 'get_gpu_nvclock_offset_range': display.nvcontrol_get_gpu_nvclock_offset_range(gpu), + 'get_mem_transfer_rate_offset_range': display.nvcontrol_get_mem_transfer_rate_offset_range(gpu) } pprint(dic) From fb47feb951b9acbdbe3820d28324b117ca38b87c Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 21:31:53 +0100 Subject: [PATCH 197/279] NV-CONTROL: query binary data and get coolers used by gpu --- Xlib/ext/nvcontrol.py | 120 +++++++++++++++++++++++++++++++++++------- examples/nvcontrol.py | 1 + 2 files changed, 101 insertions(+), 20 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 81a72b3b..368c266b 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -35,11 +35,6 @@ def query_target_count(self, target): return int(reply._data.get('count')) -def get_gpu_count(self): - """Return the number of GPU's present in the system.""" - return int(query_target_count(self, Gpu())) - - def query_int_attribute(self, target, displays, attr): """return the value of an integer attribute""" display_mask = _displays2mask(displays) @@ -55,7 +50,7 @@ def query_int_attribute(self, target, displays, attr): def set_int_attribute(self, target, displays, attr, value): - """return the value of an integer attribute""" + """set the value of an integer attribute""" display_mask = _displays2mask(displays) reply = NVCtrlSetAttributeAndGetStatusReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), @@ -68,7 +63,7 @@ def set_int_attribute(self, target, displays, attr, value): def query_string_attribute(self, target, displays, attr): - """return the value of an integer attribute""" + """return the value of a string attribute""" display_mask = _displays2mask(displays) reply = NVCtrlQueryStringAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), @@ -95,6 +90,38 @@ def query_valid_attr_values(self, target, displays, attr): return int(reply._data.get('min')), int(reply._data.get('max')) +def query_binary_data(self, target, displays, attr): + """return binary data""" + display_mask = _displays2mask(displays) + reply = NVCtrlQueryBinaryDataReplyRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_id=target.id(), + target_type=target.type(), + display_mask=display_mask, + attr=attr) + if not reply._data.get('flags'): + return None + return reply._data.get('data') + + +def get_coolers_used_by_gpu(self, target): + display_mask = _displays2mask([]) + reply = NVCtrlQueryListCard32ReplyRequest(display=self.display, + opcode=self.display.get_extension_major(extname), + target_id=target.id(), + target_type=target.type(), + display_mask=display_mask, + attr=NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU) + if not reply._data.get('flags'): + return None + return reply._data.get('list') + + +def get_gpu_count(self): + """Return the number of GPU's present in the system.""" + return int(query_target_count(self, Gpu())) + + def get_name(self, target): """the GPU product name on which the specified X screen is running""" return query_string_attribute(self, target, [], NV_CTRL_STRING_PRODUCT_NAME) @@ -297,6 +324,8 @@ def init(disp, info): disp.extension_add_method('display', 'nvcontrol_query_target_count', query_target_count) disp.extension_add_method('display', 'nvcontrol_query_int_attribute', query_int_attribute) disp.extension_add_method('display', 'nvcontrol_query_string_attribute', query_string_attribute) + disp.extension_add_method('display', 'nvcontrol_query_valid_attr_values', query_valid_attr_values) + disp.extension_add_method('display', 'nvcontrol_query_binary_data', query_binary_data) disp.extension_add_method('display', 'nvcontrol_get_gpu_count', get_gpu_count) disp.extension_add_method('display', 'nvcontrol_get_vram', get_vram) disp.extension_add_method('display', 'nvcontrol_get_irq', get_irq) @@ -322,6 +351,7 @@ def init(disp, info): get_cooler_manual_control_enabled) disp.extension_add_method('display', 'nvcontrol_get_fan_duty', get_fan_duty) disp.extension_add_method('display', 'nvcontrol_get_fan_rpm', get_fan_rpm) + disp.extension_add_method('display', 'nvcontrol_get_coolers_used_by_gpu', get_coolers_used_by_gpu) disp.extension_add_method('display', 'nvcontrol_get_max_displays', get_max_displays) disp.extension_add_method('display', 'nvcontrol_get_name', get_name) disp.extension_add_method('display', 'nvcontrol_get_driver_version', get_driver_version) @@ -5155,6 +5185,27 @@ def __init__(self, nfan=0): self._name = 'Cooler' +class NVCtrlQueryTargetCountReplyRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlQueryTargetCount), + rq.RequestLength(), + rq.Card32('target_type'), + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('padb1'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('count'), + rq.Card32('pad4'), + rq.Card32('pad5'), + rq.Card32('pad6'), + rq.Card32('pad7'), + rq.Card32('pad8'), + ) + + class NVCtrlQueryAttributeReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), @@ -5229,31 +5280,59 @@ class NVCtrlQueryStringAttributeReplyRequest(rq.ReplyRequest): ) -class NVCtrlQueryTargetCountReplyRequest(rq.ReplyRequest): +class NVCtrlQueryValidAttributeValuesReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), - rq.Opcode(X_nvCtrlQueryTargetCount), + rq.Opcode(X_nvCtrlQueryValidAttributeValues), rq.RequestLength(), - rq.Card32('target_type'), + rq.Card16('target_id'), + rq.Card16('target_type'), + rq.Card32('display_mask'), + rq.Card32('attr'), ) _reply = rq.Struct( rq.ReplyCode(), - rq.Card8('padb1'), + rq.Card8('pad0'), rq.Card16('sequence_number'), rq.ReplyLength(), - rq.Card32('count'), + rq.Card32('flags'), + rq.Int32('attr_type'), + rq.Int32('min'), + rq.Int32('max'), + rq.Card32('bits'), + rq.Card32('perms'), + ) + + +class NVCtrlQueryBinaryDataReplyRequest(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(X_nvCtrlQueryBinaryData), + rq.RequestLength(), + rq.Card16('target_id'), + rq.Card16('target_type'), + rq.Card32('display_mask'), + rq.Card32('attr'), + ) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('pad0'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('flags'), + rq.Card32('data', 4), rq.Card32('pad4'), rq.Card32('pad5'), rq.Card32('pad6'), rq.Card32('pad7'), - rq.Card32('pad8'), + rq.Binary('data'), ) -class NVCtrlQueryValidAttributeValuesReplyRequest(rq.ReplyRequest): +class NVCtrlQueryListCard32ReplyRequest(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), - rq.Opcode(X_nvCtrlQueryValidAttributeValues), + rq.Opcode(X_nvCtrlQueryBinaryData), rq.RequestLength(), rq.Card16('target_id'), rq.Card16('target_type'), @@ -5266,9 +5345,10 @@ class NVCtrlQueryValidAttributeValuesReplyRequest(rq.ReplyRequest): rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('flags'), - rq.Int32('attr_type'), - rq.Int32('min'), - rq.Int32('max'), - rq.Card32('bits'), - rq.Card32('perms'), + rq.Card32('list', 4), + rq.Card32('pad4'), + rq.Card32('pad5'), + rq.Card32('pad6'), + rq.Card32('pad7'), + rq.List('list', rq.Card32), ) diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index bde1be31..c9edaa91 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -75,6 +75,7 @@ 'get_cooler_manual_control_enabled': display.nvcontrol_get_cooler_manual_control_enabled(gpu), 'get_fan_duty': display.nvcontrol_get_fan_duty(fan), 'get_fan_rpm': display.nvcontrol_get_fan_rpm(fan), + 'get_coolers_used_by_gpu': display.nvcontrol_get_coolers_used_by_gpu(gpu), 'get_max_displays': display.nvcontrol_get_max_displays(gpu), 'get_name': display.nvcontrol_get_name(gpu), 'get_driver_version': display.nvcontrol_get_driver_version(gpu), From f9819f26fb40d6d98c1178e0a8729b5762871db6 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 21:38:48 +0100 Subject: [PATCH 198/279] NV-CONTROL: returning parsed data for gpu usage and perf modes --- Xlib/ext/nvcontrol.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 368c266b..f4070463 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -142,11 +142,26 @@ def get_gpu_uuid(self, target): def get_gpu_utilization(self, target): - return query_string_attribute(self, target, [], NV_CTRL_STRING_GPU_UTILIZATION) + string = query_string_attribute(self, target, [], NV_CTRL_STRING_GPU_UTILIZATION) + result = {} + if string is not None and string != '': + for line in string.split(','): + key_value = line.split('=') + result[key_value[0].strip()] = int(key_value[1]) if key_value[1].isdigit else key_value[1] + return result def get_performance_modes(self, target): - return query_string_attribute(self, target, [], NV_CTRL_STRING_PERFORMANCE_MODES) + string = query_string_attribute(self, target, [], NV_CTRL_STRING_PERFORMANCE_MODES) + result = [] + if string is not None and string != '': + for perf in string.split(';'): + perf_dict = {} + for line in perf.split(','): + key_value = line.split('=') + perf_dict[key_value[0].strip()] = int(key_value[1]) if key_value[1].isdigit else key_value[1] + result.append(perf_dict) + return result def get_vram(self, target): From 8799e4d384787fee2ea3a91936eaa6d024cb25f2 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 21:47:16 +0100 Subject: [PATCH 199/279] NV-CONTROL: removed commented code --- Xlib/ext/nvcontrol.py | 15 --------------- examples/nvcontrol.py | 5 ----- 2 files changed, 20 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index f4070463..ffd7f77a 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -294,21 +294,6 @@ def get_max_displays(self, target): return query_int_attribute(self, target, [], NV_CTRL_MAX_DISPLAYS) -# def get_connected_displays(self, target): -# """Return an array with connected display numbers""" -# return query_int_attribute(self, target, [], NV_CTRL_CONNECTED_DISPLAYS) -# -# -# def get_enabled_displays(self, target): -# """returns an array of displays that are enabled on the specified X -# screen or GPU.""" -# return query_int_attribute(self, target, [], NV_CTRL_ENABLED_DISPLAYS) - -# def get_current_clocks(self, target): -# """return the current (GPU, memory) clocks of the graphics device -# driving the X screen.""" -# return query_int_attribute(self, target, [], NV_CTRL_GPU_CURRENT_CLOCK_FREQS) - def _displaystr2num(st): """return a display number from a string""" num = None diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index c9edaa91..f8f9be7e 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -89,9 +89,4 @@ pprint(dic) - # display.nvcontrol_set_cooler_manual_control_enabled(gpu, True) - # print(str(display.nvcontrol_get_cooler_manual_control_enabled(gpu))) - # display.nvcontrol_set_cooler_manual_control_enabled(gpu, False) - # print(str(display.nvcontrol_get_cooler_manual_control_enabled(gpu))) - display.close() From 7753247eb97a6a224e9a1bfd94a2364bbf6ff282 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 27 Jan 2019 22:12:25 +0100 Subject: [PATCH 200/279] NV-CONTROL: set offset for gpu and memory clock --- Xlib/ext/nvcontrol.py | 100 ++++++++++++++++++++++-------------------- examples/nvcontrol.py | 6 ++- 2 files changed, 56 insertions(+), 50 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index ffd7f77a..5d3bccde 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -35,9 +35,8 @@ def query_target_count(self, target): return int(reply._data.get('count')) -def query_int_attribute(self, target, displays, attr): +def query_int_attribute(self, target, display_mask, attr): """return the value of an integer attribute""" - display_mask = _displays2mask(displays) reply = NVCtrlQueryAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -49,9 +48,8 @@ def query_int_attribute(self, target, displays, attr): return int(reply._data.get('value')) -def set_int_attribute(self, target, displays, attr, value): +def set_int_attribute(self, target, display_mask, attr, value): """set the value of an integer attribute""" - display_mask = _displays2mask(displays) reply = NVCtrlSetAttributeAndGetStatusReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -59,12 +57,11 @@ def set_int_attribute(self, target, displays, attr, value): display_mask=display_mask, attr=attr, value=value) - return reply._data.get('flags') + return reply._data.get('flags') != 0 -def query_string_attribute(self, target, displays, attr): +def query_string_attribute(self, target, display_mask, attr): """return the value of a string attribute""" - display_mask = _displays2mask(displays) reply = NVCtrlQueryStringAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -76,9 +73,8 @@ def query_string_attribute(self, target, displays, attr): return str(reply._data.get('string')).strip('\0') -def query_valid_attr_values(self, target, displays, attr): +def query_valid_attr_values(self, target, display_mask, attr): """return the value of an integer attribute""" - display_mask = _displays2mask(displays) reply = NVCtrlQueryValidAttributeValuesReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -90,9 +86,8 @@ def query_valid_attr_values(self, target, displays, attr): return int(reply._data.get('min')), int(reply._data.get('max')) -def query_binary_data(self, target, displays, attr): +def query_binary_data(self, target, display_mask, attr): """return binary data""" - display_mask = _displays2mask(displays) reply = NVCtrlQueryBinaryDataReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -105,12 +100,11 @@ def query_binary_data(self, target, displays, attr): def get_coolers_used_by_gpu(self, target): - display_mask = _displays2mask([]) reply = NVCtrlQueryListCard32ReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), target_type=target.type(), - display_mask=display_mask, + display_mask=0, attr=NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU) if not reply._data.get('flags'): return None @@ -124,25 +118,25 @@ def get_gpu_count(self): def get_name(self, target): """the GPU product name on which the specified X screen is running""" - return query_string_attribute(self, target, [], NV_CTRL_STRING_PRODUCT_NAME) + return query_string_attribute(self, target, 0, NV_CTRL_STRING_PRODUCT_NAME) def get_driver_version(self, target): """the NVIDIA (kernel level) driver version for the specified screen or GPU""" - return query_string_attribute(self, target, [], NV_CTRL_STRING_NVIDIA_DRIVER_VERSION) + return query_string_attribute(self, target, 0, NV_CTRL_STRING_NVIDIA_DRIVER_VERSION) def get_vbios_version(self, target): """the version of the VBIOS for the specified screen or GPU""" - return query_string_attribute(self, target, [], NV_CTRL_STRING_VBIOS_VERSION) + return query_string_attribute(self, target, 0, NV_CTRL_STRING_VBIOS_VERSION) def get_gpu_uuid(self, target): - return query_string_attribute(self, target, [], NV_CTRL_STRING_GPU_UUID) + return query_string_attribute(self, target, 0, NV_CTRL_STRING_GPU_UUID) def get_gpu_utilization(self, target): - string = query_string_attribute(self, target, [], NV_CTRL_STRING_GPU_UTILIZATION) + string = query_string_attribute(self, target, 0, NV_CTRL_STRING_GPU_UTILIZATION) result = {} if string is not None and string != '': for line in string.split(','): @@ -152,7 +146,7 @@ def get_gpu_utilization(self, target): def get_performance_modes(self, target): - string = query_string_attribute(self, target, [], NV_CTRL_STRING_PERFORMANCE_MODES) + string = query_string_attribute(self, target, 0, NV_CTRL_STRING_PERFORMANCE_MODES) result = [] if string is not None and string != '': for perf in string.split(';'): @@ -165,18 +159,18 @@ def get_performance_modes(self, target): def get_vram(self, target): - return query_int_attribute(self, target, [], NV_CTRL_VIDEO_RAM) + return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_RAM) def get_irq(self, target): """Return the interrupt request line used by the GPU driving the screen""" - return query_int_attribute(self, target, [], NV_CTRL_IRQ) + return query_int_attribute(self, target, 0, NV_CTRL_IRQ) def supports_framelock(self, target): """returns whether the underlying GPU supports Frame Lock. All of the other frame lock attributes are only applicable if this returns True.""" - return query_int_attribute(self, target, [], NV_CTRL_FRAMELOCK) == 1 + return query_int_attribute(self, target, 0, NV_CTRL_FRAMELOCK) == 1 def gvo_supported(self, screen): @@ -187,102 +181,110 @@ def gvo_supported(self, screen): def get_core_temp(self, target): """return the current core temperature of the GPU driving the X screen.""" - return query_int_attribute(self, target, [], NV_CTRL_GPU_CORE_TEMPERATURE) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORE_TEMPERATURE) def get_core_threshold(self, target): """return the current GPU core slowdown threshold temperature. It reflects the temperature at which the GPU is throttled to prevent overheating.""" - return query_int_attribute(self, target, [], NV_CTRL_GPU_CORE_THRESHOLD) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORE_THRESHOLD) def get_default_core_threshold(self, target): """return the default core threshold temperature.""" - return query_int_attribute(self, target, [], NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD) def get_max_core_threshold(self, target): """return the maximum core threshold temperature.""" - return query_int_attribute(self, target, [], NV_CTRL_GPU_MAX_CORE_THRESHOLD) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_MAX_CORE_THRESHOLD) def get_ambient_temp(self, target): """return the current temperature in the immediate neighbourhood of the GPU driving the X screen.""" - return query_int_attribute(self, target, [], NV_CTRL_AMBIENT_TEMPERATURE) + return query_int_attribute(self, target, 0, NV_CTRL_AMBIENT_TEMPERATURE) def get_cuda_cores(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_CORES) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORES) def get_memory_bus_width(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_MEMORY_BUS_WIDTH) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_MEMORY_BUS_WIDTH) def get_total_dedicated_gpu_memory(self, target): - return query_int_attribute(self, target, [], NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY) + return query_int_attribute(self, target, 0, NV_CTRL_TOTAL_DEDICATED_GPU_MEMORY) def get_used_dedicated_gpu_memory(self, target): - return query_int_attribute(self, target, [], NV_CTRL_USED_DEDICATED_GPU_MEMORY) + return query_int_attribute(self, target, 0, NV_CTRL_USED_DEDICATED_GPU_MEMORY) def get_pcie_current_link_width(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH) def get_pcie_max_link_width(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH) def get_pcie_generation(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_PCIE_GENERATION) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_GENERATION) def get_video_encoder_utilization(self, target): - return query_int_attribute(self, target, [], NV_CTRL_VIDEO_ENCODER_UTILIZATION) + return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_ENCODER_UTILIZATION) def get_video_decoder_utilization(self, target): - return query_int_attribute(self, target, [], NV_CTRL_VIDEO_DECODER_UTILIZATION) + return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_DECODER_UTILIZATION) def get_current_performance_level(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL) + return query_int_attribute(self, target, 0, NV_CTRL_GPU_CURRENT_PERFORMANCE_LEVEL) + + +def get_gpu_nvclock_offset(self, target, perf_level): + return query_int_attribute(self, target, perf_level, NV_CTRL_GPU_NVCLOCK_OFFSET) -def get_gpu_nvclock_offset(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_NVCLOCK_OFFSET) +def set_gpu_nvclock_offset(self, target, perf_level, offset): + return set_int_attribute(self, target, perf_level, NV_CTRL_GPU_NVCLOCK_OFFSET, offset) def get_gpu_nvclock_offset_range(self, target): - return query_valid_attr_values(self, target, [], NV_CTRL_GPU_NVCLOCK_OFFSET) + return query_valid_attr_values(self, target, 0, NV_CTRL_GPU_NVCLOCK_OFFSET) + + +def get_mem_transfer_rate_offset(self, target, perf_level): + return query_int_attribute(self, target, perf_level, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) -def get_mem_transfer_rate_offset(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) +def set_mem_transfer_rate_offset(self, target, perf_level, offset): + return set_int_attribute(self, target, perf_level, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET, offset) def get_mem_transfer_rate_offset_range(self, target): - return query_valid_attr_values(self, target, [], NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) + return query_valid_attr_values(self, target, 0, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) def get_cooler_manual_control_enabled(self, target): - return query_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL) == 1 + return query_int_attribute(self, target, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL) == 1 def set_cooler_manual_control_enabled(self, target, enabled): - return set_int_attribute(self, target, [], NV_CTRL_GPU_COOLER_MANUAL_CONTROL, 1 if enabled else 0) == 1 + return set_int_attribute(self, target, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, 1 if enabled else 0) == 1 def get_fan_duty(self, target): - return query_int_attribute(self, target, [], NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL) + return query_int_attribute(self, target, 0, NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL) def get_fan_rpm(self, target): - return query_int_attribute(self, target, [], NV_CTRL_THERMAL_COOLER_SPEED) + return query_int_attribute(self, target, 0, NV_CTRL_THERMAL_COOLER_SPEED) def get_max_displays(self, target): @@ -291,7 +293,7 @@ def get_max_displays(self, target): Note that this does not indicate the maximum number of bits that can be set in NV_CTRL_CONNECTED_DISPLAYS, because more display devices can be connected than are actively in use.""" - return query_int_attribute(self, target, [], NV_CTRL_MAX_DISPLAYS) + return query_int_attribute(self, target, 0, NV_CTRL_MAX_DISPLAYS) def _displaystr2num(st): @@ -346,7 +348,9 @@ def init(disp, info): disp.extension_add_method('display', 'nvcontrol_get_video_decoder_utilization', get_video_decoder_utilization) disp.extension_add_method('display', 'nvcontrol_get_current_performance_level', get_current_performance_level) disp.extension_add_method('display', 'nvcontrol_get_gpu_nvclock_offset', get_gpu_nvclock_offset) + disp.extension_add_method('display', 'nvcontrol_set_gpu_nvclock_offset', set_gpu_nvclock_offset) disp.extension_add_method('display', 'nvcontrol_get_mem_transfer_rate_offset', get_mem_transfer_rate_offset) + disp.extension_add_method('display', 'nvcontrol_set_mem_transfer_rate_offset', set_mem_transfer_rate_offset) disp.extension_add_method('display', 'nvcontrol_get_cooler_manual_control_enabled', get_cooler_manual_control_enabled) disp.extension_add_method('display', 'nvcontrol_get_fan_duty', get_fan_duty) diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index f8f9be7e..36b61cfd 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -50,6 +50,8 @@ gpu = Gpu(0) fan = Cooler(0) + perf_level = 3 + dic = { 'get_gpu_count': display.nvcontrol_get_gpu_count(), 'get_vram': display.nvcontrol_get_vram(gpu), @@ -70,8 +72,8 @@ 'get_video_encoder_utilization': display.nvcontrol_get_video_encoder_utilization(gpu), 'get_video_decoder_utilization': display.nvcontrol_get_video_decoder_utilization(gpu), 'get_current_performance_level': display.nvcontrol_get_current_performance_level(gpu), - 'get_gpu_nvclock_offset': display.nvcontrol_get_gpu_nvclock_offset(gpu), - 'get_mem_transfer_rate_offset': display.nvcontrol_get_mem_transfer_rate_offset(gpu), + 'get_gpu_nvclock_offset': display.nvcontrol_get_gpu_nvclock_offset(gpu, perf_level), + 'get_mem_transfer_rate_offset': display.nvcontrol_get_mem_transfer_rate_offset(gpu, perf_level), 'get_cooler_manual_control_enabled': display.nvcontrol_get_cooler_manual_control_enabled(gpu), 'get_fan_duty': display.nvcontrol_get_fan_duty(fan), 'get_fan_rpm': display.nvcontrol_get_fan_rpm(fan), From 166e05a7c69b99a5b6e9d9f57fd3cad28c7ac864 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Mon, 28 Jan 2019 19:39:03 +0100 Subject: [PATCH 201/279] NV-CONTROL: small code refactoring --- Xlib/ext/nvcontrol.py | 20 ++++++++++---------- examples/nvcontrol.py | 8 ++++---- examples/xinerama.py | 8 ++++---- examples/xrandr.py | 8 ++++---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 5d3bccde..6402214a 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -140,8 +140,8 @@ def get_gpu_utilization(self, target): result = {} if string is not None and string != '': for line in string.split(','): - key_value = line.split('=') - result[key_value[0].strip()] = int(key_value[1]) if key_value[1].isdigit else key_value[1] + [key, value] = line.split('=')[:2] + result[key.strip()] = int(value) if value.isdigit() else value return result @@ -152,8 +152,8 @@ def get_performance_modes(self, target): for perf in string.split(';'): perf_dict = {} for line in perf.split(','): - key_value = line.split('=') - perf_dict[key_value[0].strip()] = int(key_value[1]) if key_value[1].isdigit else key_value[1] + [key, value] = line.split('=')[:2] + perf_dict[key.strip()] = int(value) if value.isdigit() else value result.append(perf_dict) return result @@ -288,11 +288,11 @@ def get_fan_rpm(self, target): def get_max_displays(self, target): - """return the maximum number of display devices that can be driven - simultaneously on a GPU (e.g., that can be used in a MetaMode at once). - Note that this does not indicate the maximum number of bits that can be - set in NV_CTRL_CONNECTED_DISPLAYS, because more display devices can be - connected than are actively in use.""" + """return the maximum number of display devices that can be driven simultaneously on a GPU. + + Note that this does not indicate the maximum number of bits that can be set in + NV_CTRL_CONNECTED_DISPLAYS, because more display devices can be connected than are actively + in use.""" return query_int_attribute(self, target, 0, NV_CTRL_MAX_DISPLAYS) @@ -5159,7 +5159,7 @@ def type(self): return self._type def __str__(self): - return '' % (self._name, self.id()) + return ''.format(self._name, self.id()) class Gpu(Target): diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index 36b61cfd..d50d0ea7 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -40,11 +40,11 @@ display = Display() # Check for extension if not display.has_extension('NV-CONTROL'): - sys.stderr.write('%s: server does not have the NV-CONTROL extension\n' - % sys.argv[0]) - print(display.query_extension('NV-CONTROL')) + sys.stderr.write('{}: server does not have the NV-CONTROL extension\n'.format(sys.argv[0])) + ext = display.query_extension('NV-CONTROL') + print(ext) sys.stderr.write("\n".join(display.list_extensions())) - if display.query_extension('NV-CONTROL') is None: + if ext is None: sys.exit(1) gpu = Gpu(0) diff --git a/examples/xinerama.py b/examples/xinerama.py index d635cfd9..13419ba9 100755 --- a/examples/xinerama.py +++ b/examples/xinerama.py @@ -42,11 +42,11 @@ def __init__(self, display): # Check for extension if not self.d.has_extension('XINERAMA'): - sys.stderr.write('%s: server does not have the XINERAMA extension\n' - % sys.argv[0]) - print(self.d.query_extension('XINERAMA')) + sys.stderr.write('{}: server does not have the XINERAMA extension\n'.format(sys.argv[0])) + ext = self.d.query_extension('XINERAMA') + print(ext) sys.stderr.write("\n".join(self.d.list_extensions())) - if self.d.query_extension('XINERAMA') is None: + if ext is None: sys.exit(1) # print version diff --git a/examples/xrandr.py b/examples/xrandr.py index 30176b47..5a645340 100755 --- a/examples/xrandr.py +++ b/examples/xrandr.py @@ -42,11 +42,11 @@ def __init__(self, display): # Check for extension if not self.d.has_extension('RANDR'): - sys.stderr.write('%s: server does not have the RANDR extension\n' - % sys.argv[0]) - print(self.d.query_extension('RANDR')) + sys.stderr.write('{}: server does not have the RANDR extension\n'.format(sys.argv[0])) + ext = self.d.query_extension('RANDR') + print(ext) sys.stderr.write("\n".join(self.d.list_extensions())) - if self.d.query_extension('RANDR') is None: + if ext is None: sys.exit(1) # print(version) From fb511490f3b48ff652189d5d2589a530ad5f3cab Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sat, 2 Feb 2019 10:59:14 +0100 Subject: [PATCH 202/279] Making doc strings complaint with PEP-0257 --- Xlib/ext/nvcontrol.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 6402214a..dd9de6c4 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -168,14 +168,16 @@ def get_irq(self, target): def supports_framelock(self, target): - """returns whether the underlying GPU supports Frame Lock. All of the - other frame lock attributes are only applicable if this returns True.""" + """returns whether the underlying GPU supports Frame Lock. + + All of the other frame lock attributes are only applicable if this returns True.""" return query_int_attribute(self, target, 0, NV_CTRL_FRAMELOCK) == 1 def gvo_supported(self, screen): - """returns whether this X screen supports GVO; if this screen does not - support GVO output, then all other GVO attributes are unavailable.""" + """returns whether this X screen supports GVO + + If this screen does not support GVO output, then all other GVO attributes are unavailable.""" return query_int_attribute(self, screen, [], NV_CTRL_GVO_SUPPORTED) @@ -185,9 +187,9 @@ def get_core_temp(self, target): def get_core_threshold(self, target): - """return the current GPU core slowdown threshold temperature. It - reflects the temperature at which the GPU is throttled to prevent - overheating.""" + """return the current GPU core slowdown threshold temperature. + + Itreflects the temperature at which the GPU is throttled to prevent overheating.""" return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORE_THRESHOLD) @@ -202,8 +204,7 @@ def get_max_core_threshold(self, target): def get_ambient_temp(self, target): - """return the current temperature in the immediate neighbourhood of - the GPU driving the X screen.""" + """return the current temperature in the immediate neighbourhood of the GPU driving the X screen.""" return query_int_attribute(self, target, 0, NV_CTRL_AMBIENT_TEMPERATURE) From 1e230f395fc3d48d358760f3d9bc0d2f13c383ef Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sat, 2 Feb 2019 15:33:23 +0100 Subject: [PATCH 203/279] NV-CONTROL: Set fan duty --- Xlib/ext/nvcontrol.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index dd9de6c4..ec5c40fe 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -108,7 +108,11 @@ def get_coolers_used_by_gpu(self, target): attr=NV_CTRL_BINARY_DATA_COOLERS_USED_BY_GPU) if not reply._data.get('flags'): return None - return reply._data.get('list') + fans = reply._data.get('list') + if len(fans) > 1: + return fans[1:] + else: + return None def get_gpu_count(self): @@ -284,6 +288,10 @@ def get_fan_duty(self, target): return query_int_attribute(self, target, 0, NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL) +def set_fan_duty(self, cooler, speed): + return set_int_attribute(self, cooler, 0, NV_CTRL_THERMAL_COOLER_LEVEL, speed) + + def get_fan_rpm(self, target): return query_int_attribute(self, target, 0, NV_CTRL_THERMAL_COOLER_SPEED) @@ -355,6 +363,7 @@ def init(disp, info): disp.extension_add_method('display', 'nvcontrol_get_cooler_manual_control_enabled', get_cooler_manual_control_enabled) disp.extension_add_method('display', 'nvcontrol_get_fan_duty', get_fan_duty) + disp.extension_add_method('display', 'nvcontrol_set_fan_duty', set_fan_duty) disp.extension_add_method('display', 'nvcontrol_get_fan_rpm', get_fan_rpm) disp.extension_add_method('display', 'nvcontrol_get_coolers_used_by_gpu', get_coolers_used_by_gpu) disp.extension_add_method('display', 'nvcontrol_get_max_displays', get_max_displays) From 0c3f593a89b81b8fd87b3d5fcad424f528e5bb49 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 3 Feb 2019 17:26:46 +0300 Subject: [PATCH 204/279] Amend the rest of doc strings according to PEP-0257 --- Xlib/ext/nvcontrol.py | 50 +++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index ec5c40fe..f1bdd8ba 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -28,7 +28,7 @@ def query_target_count(self, target): - """return the target count""" + """Return the target count""" reply = NVCtrlQueryTargetCountReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_type=target.type()) @@ -36,7 +36,7 @@ def query_target_count(self, target): def query_int_attribute(self, target, display_mask, attr): - """return the value of an integer attribute""" + """Return the value of an integer attribute""" reply = NVCtrlQueryAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -49,7 +49,7 @@ def query_int_attribute(self, target, display_mask, attr): def set_int_attribute(self, target, display_mask, attr, value): - """set the value of an integer attribute""" + """Set the value of an integer attribute""" reply = NVCtrlSetAttributeAndGetStatusReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -61,7 +61,7 @@ def set_int_attribute(self, target, display_mask, attr, value): def query_string_attribute(self, target, display_mask, attr): - """return the value of a string attribute""" + """Return the value of a string attribute""" reply = NVCtrlQueryStringAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -74,7 +74,7 @@ def query_string_attribute(self, target, display_mask, attr): def query_valid_attr_values(self, target, display_mask, attr): - """return the value of an integer attribute""" + """Return the value of an integer attribute""" reply = NVCtrlQueryValidAttributeValuesReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -87,7 +87,7 @@ def query_valid_attr_values(self, target, display_mask, attr): def query_binary_data(self, target, display_mask, attr): - """return binary data""" + """Return binary data""" reply = NVCtrlQueryBinaryDataReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), @@ -121,17 +121,17 @@ def get_gpu_count(self): def get_name(self, target): - """the GPU product name on which the specified X screen is running""" + """Return the GPU product name on which the specified X screen is running""" return query_string_attribute(self, target, 0, NV_CTRL_STRING_PRODUCT_NAME) def get_driver_version(self, target): - """the NVIDIA (kernel level) driver version for the specified screen or GPU""" + """Return the NVIDIA (kernel level) driver version for the specified screen or GPU""" return query_string_attribute(self, target, 0, NV_CTRL_STRING_NVIDIA_DRIVER_VERSION) def get_vbios_version(self, target): - """the version of the VBIOS for the specified screen or GPU""" + """Return the version of the VBIOS for the specified screen or GPU""" return query_string_attribute(self, target, 0, NV_CTRL_STRING_VBIOS_VERSION) @@ -172,43 +172,46 @@ def get_irq(self, target): def supports_framelock(self, target): - """returns whether the underlying GPU supports Frame Lock. + """Return whether the underlying GPU supports Frame Lock. - All of the other frame lock attributes are only applicable if this returns True.""" + All of the other frame lock attributes are only applicable if this returns True. + """ return query_int_attribute(self, target, 0, NV_CTRL_FRAMELOCK) == 1 def gvo_supported(self, screen): - """returns whether this X screen supports GVO + """Return whether this X screen supports GVO - If this screen does not support GVO output, then all other GVO attributes are unavailable.""" + If this screen does not support GVO output, then all other GVO attributes are unavailable. + """ return query_int_attribute(self, screen, [], NV_CTRL_GVO_SUPPORTED) def get_core_temp(self, target): - """return the current core temperature of the GPU driving the X screen.""" + """Return the current core temperature of the GPU driving the X screen.""" return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORE_TEMPERATURE) def get_core_threshold(self, target): - """return the current GPU core slowdown threshold temperature. + """Return the current GPU core slowdown threshold temperature. - Itreflects the temperature at which the GPU is throttled to prevent overheating.""" + It reflects the temperature at which the GPU is throttled to prevent overheating. + """ return query_int_attribute(self, target, 0, NV_CTRL_GPU_CORE_THRESHOLD) def get_default_core_threshold(self, target): - """return the default core threshold temperature.""" + """Return the default core threshold temperature.""" return query_int_attribute(self, target, 0, NV_CTRL_GPU_DEFAULT_CORE_THRESHOLD) def get_max_core_threshold(self, target): - """return the maximum core threshold temperature.""" + """Return the maximum core threshold temperature.""" return query_int_attribute(self, target, 0, NV_CTRL_GPU_MAX_CORE_THRESHOLD) def get_ambient_temp(self, target): - """return the current temperature in the immediate neighbourhood of the GPU driving the X screen.""" + """Return the current temperature in the immediate neighbourhood of the GPU driving the X screen.""" return query_int_attribute(self, target, 0, NV_CTRL_AMBIENT_TEMPERATURE) @@ -297,16 +300,17 @@ def get_fan_rpm(self, target): def get_max_displays(self, target): - """return the maximum number of display devices that can be driven simultaneously on a GPU. + """Return the maximum number of display devices that can be driven simultaneously on a GPU. Note that this does not indicate the maximum number of bits that can be set in NV_CTRL_CONNECTED_DISPLAYS, because more display devices can be connected than are actively - in use.""" + in use. + """ return query_int_attribute(self, target, 0, NV_CTRL_MAX_DISPLAYS) def _displaystr2num(st): - """return a display number from a string""" + """Return a display number from a string""" num = None for s, n in [('DFP-', 16), ('TV-', 8), ('CRT-', 0)]: if st.startswith(s): @@ -324,7 +328,7 @@ def _displaystr2num(st): def _displays2mask(displays): - """return a display mask from an array of display numbers.""" + """Return a display mask from an array of display numbers.""" mask = 0 for d in displays: mask += (1 << _displaystr2num(d)) From c55dcac4e4bc22cd345c1598b6355ad1331e2f84 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 3 Feb 2019 18:09:12 +0100 Subject: [PATCH 205/279] fix increasing memory usage on display instantiation Move finalized classes for resource types at the instance level, to avoid creating recursive class hierarchies. --- CHANGELOG.md | 9 +++++++++ Xlib/display.py | 2 +- Xlib/protocol/display.py | 1 - 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fae403f..7c93b76e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ NEWS for Python X Library +In development +============== + +Bug Fixes +--------- + +- fix increasing memory usage on display instantiation + +--- Version 0.24 ============ diff --git a/Xlib/display.py b/Xlib/display.py index 622e0a2a..beaeaad6 100644 --- a/Xlib/display.py +++ b/Xlib/display.py @@ -62,12 +62,12 @@ } class _BaseDisplay(protocol_display.Display): - resource_classes = _resource_baseclasses.copy() # Implement a cache of atom names, used by Window objects when # dealing with some ICCCM properties not defined in Xlib.Xatom def __init__(self, *args, **keys): + self.resource_classes = _resource_baseclasses.copy() protocol_display.Display.__init__(self, *args, **keys) self._atom_cache = {} diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index ce0413cd..2f8a9e24 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -76,7 +76,6 @@ def bytesview(data, offset=0, size=None): class Display(object): - resource_classes = {} extension_major_opcodes = {} error_classes = error.xerror_class.copy() event_classes = event.event_class.copy() From 89abb403755fc9b835f8570799fcab133298693e Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 3 Feb 2019 23:32:21 +0300 Subject: [PATCH 206/279] Bump version, add NV-CONTROL extension to change log --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c93b76e..3a0b0e5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,13 @@ NEWS for Python X Library -In development +Version 0.25 ============== Bug Fixes --------- - fix increasing memory usage on display instantiation +- implement NV-CONTROL extension by Roberto Leinardi (@leinardi) --- Version 0.24 From 501e15c6515d4e0e1585c858689fb3876a2be753 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 3 Feb 2019 23:32:52 +0300 Subject: [PATCH 207/279] Cosmetic change --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a0b0e5c..17e875b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ NEWS for Python X Library Version 0.25 -============== +============ Bug Fixes --------- From a8f6c733068ca96aa0f262295eb2376e783b005d Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 3 Feb 2019 23:34:36 +0300 Subject: [PATCH 208/279] Move extension note to separate section --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17e875b8..6711de85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,11 @@ Bug Fixes --------- - fix increasing memory usage on display instantiation -- implement NV-CONTROL extension by Roberto Leinardi (@leinardi) + +NV-CONTROL extension +-------------------- + +- add first implementation by Roberto Leinardi (@leinardi) --- Version 0.24 From 3e98bd91079dde1482a845968ded9c80b011fce9 Mon Sep 17 00:00:00 2001 From: Vasily V Ryabov Date: Sun, 3 Feb 2019 23:57:56 +0300 Subject: [PATCH 209/279] Bump version in __init__.py --- Xlib/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/__init__.py b/Xlib/__init__.py index c290d9ad..f023f80b 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 24) +__version__ = (0, 25) __version_extra__ = '' From 10056bad2d44c10294596efe712739f1b17bed90 Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sat, 9 Feb 2019 11:00:48 +0100 Subject: [PATCH 210/279] NV-CONTROL: Returning None if Coolbit 4 is not set Previously it was not possible to know if the manual control was simply disabled or if the coolbit 4 was not set at all. Now the function returns None if the coolbit is not set at all or a boolean if is set. --- Xlib/ext/nvcontrol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index f1bdd8ba..30f9c345 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -280,7 +280,7 @@ def get_mem_transfer_rate_offset_range(self, target): def get_cooler_manual_control_enabled(self, target): - return query_int_attribute(self, target, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL) == 1 + return query_int_attribute(self, target, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL) def set_cooler_manual_control_enabled(self, target, enabled): From d5d0fab1a545425b12683376771f5171c8e8a1fb Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sun, 10 Feb 2019 16:45:53 +0100 Subject: [PATCH 211/279] NV-CONTROL: Allow to specify perf level for get offset range --- Xlib/ext/nvcontrol.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 30f9c345..c4120b66 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -263,8 +263,8 @@ def set_gpu_nvclock_offset(self, target, perf_level, offset): return set_int_attribute(self, target, perf_level, NV_CTRL_GPU_NVCLOCK_OFFSET, offset) -def get_gpu_nvclock_offset_range(self, target): - return query_valid_attr_values(self, target, 0, NV_CTRL_GPU_NVCLOCK_OFFSET) +def get_gpu_nvclock_offset_range(self, target, perf_level): + return query_valid_attr_values(self, target, perf_level, NV_CTRL_GPU_NVCLOCK_OFFSET) def get_mem_transfer_rate_offset(self, target, perf_level): @@ -275,8 +275,8 @@ def set_mem_transfer_rate_offset(self, target, perf_level, offset): return set_int_attribute(self, target, perf_level, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET, offset) -def get_mem_transfer_rate_offset_range(self, target): - return query_valid_attr_values(self, target, 0, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) +def get_mem_transfer_rate_offset_range(self, target, perf_level): + return query_valid_attr_values(self, target, perf_level, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) def get_cooler_manual_control_enabled(self, target): From 8fdbcc6307b71baeb6ee0e80879ac7f12c623f73 Mon Sep 17 00:00:00 2001 From: Mohit Garg Date: Mon, 11 Feb 2019 16:51:59 +0530 Subject: [PATCH 212/279] damage extension example --- examples/xdamage.py | 133 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 examples/xdamage.py diff --git a/examples/xdamage.py b/examples/xdamage.py new file mode 100644 index 00000000..eff4ba43 --- /dev/null +++ b/examples/xdamage.py @@ -0,0 +1,133 @@ +#!/usr/bin/python +# +# examples/xdamage.py -- demonstrate damage extension +# +# Copyright (C) 2002 Peter Liljenberg +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA + + +# Python 2/3 compatibility. +from __future__ import print_function + +import sys +import os + +# Change path so we find Xlib +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +from Xlib import display, X, threaded,Xutil +import time +import thread +from Xlib.ext import damage +from PIL import Image, ImageTk + +def redraw(win, gc): + # win.clear_area() + win.fill_rectangle(gc, 0, 0, 60, 60) + +def blink(display, win, gc, cols): + while 1: + time.sleep(2) + print('Changing color', cols[0]) + gc.change(foreground = cols[0]) + cols = (cols[1], cols[0]) + redraw(win, gc) + display.flush() + +def getImageFromWin(win,ptW,ptH,ptX=0,ptY=0): + try: + raw = win.get_image(ptX,ptY, ptW,ptH, X.ZPixmap, 0xffffffff) + image = Image.frombytes("RGB", (ptW, ptH), raw.data, "raw", "BGRX") + return image + + except Exception: + print("exception thrown in getImageFromWin") + +def checkExt(disp): + # Check for extension + if not disp.has_extension('DAMAGE'): + sys.stderr.write('server does not have the DAMAGE extension\n') + sys.stderr.write("\n".join(disp.list_extensions())) + + if disp.query_extension('DAMAGE') is None: + sys.exit(1) + else: + r = disp.damage_query_version() + print('DAMAGE version %d.%d' % (r.major_version, r.minor_version)) + +def main(): + d = display.Display() + root = d.screen().root + + checkExt(d) + colormap = d.screen().default_colormap + + red = colormap.alloc_named_color("red").pixel + blue = colormap.alloc_named_color("blue").pixel + background = colormap.alloc_named_color("white").pixel + + window1 = root.create_window(100, 100, 250, 100, 1, + X.CopyFromParent, X.InputOutput, + X.CopyFromParent, + background_pixel = background, + event_mask = X.StructureNotifyMask | X.ExposureMask) + window1.set_wm_name('Changing Window') + window1.map() + gc = window1.create_gc(foreground = red) + + thread.start_new_thread(blink, (d, window1, gc, (blue, red))) + + window1.damage_create(damage.DamageReportRawRectangles) + window1.set_wm_normal_hints( + flags=(Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), + min_width=50, + min_height=50 + ) + + window2 = root.create_window(100, 250, 250, 100, 1, + X.CopyFromParent, X.InputOutput, + X.CopyFromParent, + background_pixel = background, + event_mask = X.StructureNotifyMask | X.ExposureMask) + window2.set_wm_normal_hints( + flags=(Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), + min_width=50, + min_height=50 + ) + + window2.set_wm_name('Tracking Window') + window2.map() + + while 1: + event = d.next_event() + if event.type == X.Expose: + if event.count == 0: + redraw(window1, gc) + elif event.type == d.extension_event.DamageNotify: + image = getImageFromWin(window1, event.area.width, event.area.height, event.area.x, event.area.y) + bgpm = window2.create_pixmap(image.width,image.height,d.screen().root_depth) + bggc = window2.create_gc(foreground=0,background=0) + bgpm.put_pil_image(bggc, 0, 0, image) + window2.copy_area(bggc, bgpm, 0, 0, image.width, image.height, 0, 0) + # bggc.free() + elif event.type == X.DestroyNotify: + sys.exit(0) + +if __name__ == "__main__": + main() \ No newline at end of file From ba2ce85849ce9968c11152a14e692fe5f224844c Mon Sep 17 00:00:00 2001 From: mgarg1 Date: Thu, 14 Feb 2019 09:15:26 +0530 Subject: [PATCH 213/279] made the changes as suggested in the review --- examples/xdamage.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/xdamage.py b/examples/xdamage.py index eff4ba43..646aedf1 100644 --- a/examples/xdamage.py +++ b/examples/xdamage.py @@ -2,7 +2,7 @@ # # examples/xdamage.py -- demonstrate damage extension # -# Copyright (C) 2002 Peter Liljenberg +# Copyright (C) 2019 Mohit Garg # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License @@ -36,6 +36,7 @@ import thread from Xlib.ext import damage from PIL import Image, ImageTk +import traceback def redraw(win, gc): # win.clear_area() @@ -50,14 +51,14 @@ def blink(display, win, gc, cols): redraw(win, gc) display.flush() -def getImageFromWin(win,ptW,ptH,ptX=0,ptY=0): +def get_image_from_win(win, pt_w, pt_h, pt_x=0, pt_y=0): try: raw = win.get_image(ptX,ptY, ptW,ptH, X.ZPixmap, 0xffffffff) image = Image.frombytes("RGB", (ptW, ptH), raw.data, "raw", "BGRX") return image except Exception: - print("exception thrown in getImageFromWin") + traceback.print_exc() def checkExt(disp): # Check for extension @@ -69,7 +70,7 @@ def checkExt(disp): sys.exit(1) else: r = disp.damage_query_version() - print('DAMAGE version %d.%d' % (r.major_version, r.minor_version)) + print('DAMAGE version %d.%d'.format(r.major_version, r.minor_version)) def main(): d = display.Display() @@ -120,9 +121,9 @@ def main(): if event.count == 0: redraw(window1, gc) elif event.type == d.extension_event.DamageNotify: - image = getImageFromWin(window1, event.area.width, event.area.height, event.area.x, event.area.y) - bgpm = window2.create_pixmap(image.width,image.height,d.screen().root_depth) - bggc = window2.create_gc(foreground=0,background=0) + image = get_image_from_win(window1, event.area.width, event.area.height, event.area.x, event.area.y) + bgpm = window2.create_pixmap(image.width, image.height, d.screen().root_depth) + bggc = window2.create_gc(foreground=0, background=0) bgpm.put_pil_image(bggc, 0, 0, image) window2.copy_area(bggc, bgpm, 0, 0, image.width, image.height, 0, 0) # bggc.free() @@ -130,4 +131,4 @@ def main(): sys.exit(0) if __name__ == "__main__": - main() \ No newline at end of file + main() From e98474e7c735c699402cc59f8348c512dfe06efd Mon Sep 17 00:00:00 2001 From: mgarg1 Date: Thu, 14 Feb 2019 09:22:35 +0530 Subject: [PATCH 214/279] correcting the usage of string format command --- examples/xdamage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/xdamage.py b/examples/xdamage.py index 646aedf1..898c7a89 100644 --- a/examples/xdamage.py +++ b/examples/xdamage.py @@ -70,7 +70,7 @@ def checkExt(disp): sys.exit(1) else: r = disp.damage_query_version() - print('DAMAGE version %d.%d'.format(r.major_version, r.minor_version)) + print('DAMAGE version {}.{}'.format(r.major_version, r.minor_version)) def main(): d = display.Display() From 2392580cd71e69e9b7b3ba88ff10c50ab0a5e658 Mon Sep 17 00:00:00 2001 From: mgarg1 Date: Fri, 15 Feb 2019 16:38:56 +0530 Subject: [PATCH 215/279] function name checkExt->check_ext --- examples/xdamage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/xdamage.py b/examples/xdamage.py index 898c7a89..91161578 100644 --- a/examples/xdamage.py +++ b/examples/xdamage.py @@ -60,7 +60,7 @@ def get_image_from_win(win, pt_w, pt_h, pt_x=0, pt_y=0): except Exception: traceback.print_exc() -def checkExt(disp): +def check_ext(disp): # Check for extension if not disp.has_extension('DAMAGE'): sys.stderr.write('server does not have the DAMAGE extension\n') From 88c038d4afb6640aed797f2ef5da03dd813517b9 Mon Sep 17 00:00:00 2001 From: mgarg1 Date: Fri, 15 Feb 2019 22:11:22 +0530 Subject: [PATCH 216/279] Update xdamage.py --- examples/xdamage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/xdamage.py b/examples/xdamage.py index 91161578..5a57b386 100644 --- a/examples/xdamage.py +++ b/examples/xdamage.py @@ -76,7 +76,7 @@ def main(): d = display.Display() root = d.screen().root - checkExt(d) + check_ext(d) colormap = d.screen().default_colormap red = colormap.alloc_named_color("red").pixel From 865f26f07e5f224017a619907d1ed7831e312ee4 Mon Sep 17 00:00:00 2001 From: mgarg1 Date: Fri, 15 Feb 2019 23:49:25 +0530 Subject: [PATCH 217/279] removed all the debug print messages --- Xlib/ext/damage.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Xlib/ext/damage.py b/Xlib/ext/damage.py index eeb7340b..0cde5ed0 100644 --- a/Xlib/ext/damage.py +++ b/Xlib/ext/damage.py @@ -94,7 +94,6 @@ def damage_create(self, level): drawable=self.id, level=level, ) - print('damage create') return did class DamageDestroy(rq.Request): @@ -111,7 +110,6 @@ def damage_destroy(self, damage): ) self.display.free_resource_id(damage) - print('damage destroy') class DamageSubtract(rq.Request): _request = rq.Struct(rq.Card8('opcode'), @@ -128,7 +126,6 @@ def damage_subtract(self, damage, repair=X.NONE, parts=X.NONE): damage=damage, repair=repair, parts=parts) - print('damage subtract') class DamageAdd(rq.Request): _request = rq.Struct(rq.Card8('opcode'), @@ -143,7 +140,6 @@ def damage_add(self, repair, parts): opcode=self.display.get_extension_major(extname), repair=repair, parts=parts) - print('damage add') # Events # From 2dde795cc2192d905b4e18e4ccf96c82cd0c7e8f Mon Sep 17 00:00:00 2001 From: Roberto Leinardi Date: Sat, 16 Feb 2019 11:26:07 +0100 Subject: [PATCH 218/279] NV-CONTROL: add Clock info and aligned method names to NVML --- Xlib/ext/nvcontrol.py | 35 +++++++++++++++++++++++------------ examples/nvcontrol.py | 17 +++++++++-------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index c4120b66..3060d247 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -139,7 +139,7 @@ def get_gpu_uuid(self, target): return query_string_attribute(self, target, 0, NV_CTRL_STRING_GPU_UUID) -def get_gpu_utilization(self, target): +def get_utilization_rates(self, target): string = query_string_attribute(self, target, 0, NV_CTRL_STRING_GPU_UTILIZATION) result = {} if string is not None and string != '': @@ -162,6 +162,16 @@ def get_performance_modes(self, target): return result +def get_clock_info(self, target): + string = query_string_attribute(self, target, 0, NV_CTRL_STRING_GPU_CURRENT_CLOCK_FREQS) + result = {} + if string is not None and string != '': + for line in string.split(','): + [key, value] = line.split('=')[:2] + result[key.strip()] = int(value) if value.isdigit() else value + return result + + def get_vram(self, target): return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_RAM) @@ -231,23 +241,23 @@ def get_used_dedicated_gpu_memory(self, target): return query_int_attribute(self, target, 0, NV_CTRL_USED_DEDICATED_GPU_MEMORY) -def get_pcie_current_link_width(self, target): +def get_curr_pcie_link_width(self, target): return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_CURRENT_LINK_WIDTH) -def get_pcie_max_link_width(self, target): +def get_max_pcie_link_width(self, target): return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_MAX_LINK_WIDTH) -def get_pcie_generation(self, target): +def get_curr_pcie_link_generation(self, target): return query_int_attribute(self, target, 0, NV_CTRL_GPU_PCIE_GENERATION) -def get_video_encoder_utilization(self, target): +def get_encoder_utilization(self, target): return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_ENCODER_UTILIZATION) -def get_video_decoder_utilization(self, target): +def get_decoder_utilization(self, target): return query_int_attribute(self, target, 0, NV_CTRL_VIDEO_DECODER_UTILIZATION) @@ -354,11 +364,11 @@ def init(disp, info): disp.extension_add_method('display', 'nvcontrol_get_memory_bus_width', get_memory_bus_width) disp.extension_add_method('display', 'nvcontrol_get_total_dedicated_gpu_memory', get_total_dedicated_gpu_memory) disp.extension_add_method('display', 'nvcontrol_get_used_dedicated_gpu_memory', get_used_dedicated_gpu_memory) - disp.extension_add_method('display', 'nvcontrol_get_pcie_current_link_width', get_pcie_current_link_width) - disp.extension_add_method('display', 'nvcontrol_get_pcie_max_link_width', get_pcie_max_link_width) - disp.extension_add_method('display', 'nvcontrol_get_pcie_generation', get_pcie_generation) - disp.extension_add_method('display', 'nvcontrol_get_video_encoder_utilization', get_video_encoder_utilization) - disp.extension_add_method('display', 'nvcontrol_get_video_decoder_utilization', get_video_decoder_utilization) + disp.extension_add_method('display', 'nvcontrol_get_curr_pcie_link_width', get_curr_pcie_link_width) + disp.extension_add_method('display', 'nvcontrol_get_max_pcie_link_width', get_max_pcie_link_width) + disp.extension_add_method('display', 'nvcontrol_get_curr_pcie_link_generation', get_curr_pcie_link_generation) + disp.extension_add_method('display', 'nvcontrol_get_encoder_utilization', get_encoder_utilization) + disp.extension_add_method('display', 'nvcontrol_get_decoder_utilization', get_decoder_utilization) disp.extension_add_method('display', 'nvcontrol_get_current_performance_level', get_current_performance_level) disp.extension_add_method('display', 'nvcontrol_get_gpu_nvclock_offset', get_gpu_nvclock_offset) disp.extension_add_method('display', 'nvcontrol_set_gpu_nvclock_offset', set_gpu_nvclock_offset) @@ -375,8 +385,9 @@ def init(disp, info): disp.extension_add_method('display', 'nvcontrol_get_driver_version', get_driver_version) disp.extension_add_method('display', 'nvcontrol_get_vbios_version', get_vbios_version) disp.extension_add_method('display', 'nvcontrol_get_gpu_uuid', get_gpu_uuid) - disp.extension_add_method('display', 'nvcontrol_get_gpu_utilization', get_gpu_utilization) + disp.extension_add_method('display', 'nvcontrol_get_utilization_rates', get_utilization_rates) disp.extension_add_method('display', 'nvcontrol_get_performance_modes', get_performance_modes) + disp.extension_add_method('display', 'nvcontrol_get_clock_info', get_clock_info) disp.extension_add_method('display', 'nvcontrol_set_cooler_manual_control_enabled', set_cooler_manual_control_enabled) disp.extension_add_method('display', 'nvcontrol_get_gpu_nvclock_offset_range', diff --git a/examples/nvcontrol.py b/examples/nvcontrol.py index d50d0ea7..dece439f 100755 --- a/examples/nvcontrol.py +++ b/examples/nvcontrol.py @@ -66,11 +66,11 @@ 'get_memory_bus_width': display.nvcontrol_get_memory_bus_width(gpu), 'get_total_dedicated_gpu_memory': display.nvcontrol_get_total_dedicated_gpu_memory(gpu), 'get_used_dedicated_gpu_memory': display.nvcontrol_get_used_dedicated_gpu_memory(gpu), - 'get_pcie_current_link_width': display.nvcontrol_get_pcie_current_link_width(gpu), - 'get_pcie_max_link_width': display.nvcontrol_get_pcie_max_link_width(gpu), - 'get_pcie_generation': display.nvcontrol_get_pcie_generation(gpu), - 'get_video_encoder_utilization': display.nvcontrol_get_video_encoder_utilization(gpu), - 'get_video_decoder_utilization': display.nvcontrol_get_video_decoder_utilization(gpu), + 'get_curr_pcie_link_width': display.nvcontrol_get_curr_pcie_link_width(gpu), + 'get_max_pcie_link_width': display.nvcontrol_get_max_pcie_link_width(gpu), + 'get_curr_pcie_link_generation': display.nvcontrol_get_curr_pcie_link_generation(gpu), + 'get_encoder_utilization': display.nvcontrol_get_encoder_utilization(gpu), + 'get_decoder_utilization': display.nvcontrol_get_decoder_utilization(gpu), 'get_current_performance_level': display.nvcontrol_get_current_performance_level(gpu), 'get_gpu_nvclock_offset': display.nvcontrol_get_gpu_nvclock_offset(gpu, perf_level), 'get_mem_transfer_rate_offset': display.nvcontrol_get_mem_transfer_rate_offset(gpu, perf_level), @@ -83,10 +83,11 @@ 'get_driver_version': display.nvcontrol_get_driver_version(gpu), 'get_vbios_version': display.nvcontrol_get_vbios_version(gpu), 'get_gpu_uuid': display.nvcontrol_get_gpu_uuid(gpu), - 'get_gpu_utilization': display.nvcontrol_get_gpu_utilization(gpu), + 'get_utilization_rates': display.nvcontrol_get_utilization_rates(gpu), 'get_performance_modes': display.nvcontrol_get_performance_modes(gpu), - 'get_gpu_nvclock_offset_range': display.nvcontrol_get_gpu_nvclock_offset_range(gpu), - 'get_mem_transfer_rate_offset_range': display.nvcontrol_get_mem_transfer_rate_offset_range(gpu) + 'get_gpu_nvclock_offset_range': display.nvcontrol_get_gpu_nvclock_offset_range(gpu, perf_level), + 'get_mem_transfer_rate_offset_range': display.nvcontrol_get_mem_transfer_rate_offset_range(gpu, perf_level), + 'get_clock_info': display.nvcontrol_get_clock_info(gpu) } pprint(dic) From b8aa85cfae5c0b3c4b5a72b877727b9277649bcd Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sun, 19 May 2019 21:05:45 -0400 Subject: [PATCH 219/279] XFixes: add XFixesSelectionNotify events These events can be used to tell when the owner of the clipboard selection has changed. Add an example that demonstrates usage. --- Xlib/ext/xfixes.py | 57 +++++++++++++++++++- examples/xfixes-selection-notify.py | 82 +++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100755 examples/xfixes-selection-notify.py diff --git a/Xlib/ext/xfixes.py b/Xlib/ext/xfixes.py index 72feb6d4..5f2f6438 100644 --- a/Xlib/ext/xfixes.py +++ b/Xlib/ext/xfixes.py @@ -22,13 +22,22 @@ ''' A partial implementation of the XFIXES extension. Only the HideCursor and -ShowCursor requests are provided. +ShowCursor requests and SelectionNotify events are provided. ''' from Xlib.protocol import rq extname = 'XFIXES' +XFixesSelectionNotify = 0 + +XFixesSetSelectionOwnerNotifyMask = (1 << 0) +XFixesSelectionWindowDestroyNotifyMask = (1 << 1) +XFixesSelectionClientCloseNotifyMask = (1 << 2) + +XFixesSetSelectionOwnerNotify = 0 +XFixesSelectionWindowDestroyNotify = 1 +XFixesSelectionClientCloseNotify = 2 class QueryVersion(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), @@ -80,8 +89,54 @@ def show_cursor(self): opcode=self.display.get_extension_major(extname), window=self) +class SelectSelectionInput(rq.Request): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(2), + rq.RequestLength(), + rq.Window('window'), + rq.Card32('selection'), + rq.Card32('mask') + ) + +def select_selection_input(self, window, selection, mask): + return SelectSelectionInput(opcode=self.display.get_extension_major(extname), + display=self.display, + window=window, + selection=selection, + mask=mask) + + +class SelectionNotify(rq.Event): + _code = None + _fields = rq.Struct(rq.Card8('type'), + rq.Card8('sub_code'), + rq.Card16('sequence_number'), + rq.Window('window'), + rq.Window('owner'), + rq.Card32('selection'), + rq.Card32('timestamp'), + rq.Card32('selection_timestamp'), + rq.Pad(8)) + + +class SetSelectionOwnerNotify(SelectionNotify): + pass + + +class SelectionWindowDestroyNotify(SelectionNotify): + pass + + +class SelectionClientCloseNotify(SelectionNotify): + pass + def init(disp, info): + disp.extension_add_method('display', 'xfixes_select_selection_input', select_selection_input) disp.extension_add_method('display', 'xfixes_query_version', query_version) disp.extension_add_method('window', 'xfixes_hide_cursor', hide_cursor) disp.extension_add_method('window', 'xfixes_show_cursor', show_cursor) + + disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSetSelectionOwnerNotify, SetSelectionOwnerNotify) + disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionWindowDestroyNotify, SelectionWindowDestroyNotify) + disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionClientCloseNotify, SelectionClientCloseNotify) diff --git a/examples/xfixes-selection-notify.py b/examples/xfixes-selection-notify.py new file mode 100755 index 00000000..6fa3f118 --- /dev/null +++ b/examples/xfixes-selection-notify.py @@ -0,0 +1,82 @@ +#!/usr/bin/python3 +# +# examples/xfixes-selection-notify.py -- demonstrate the XFIXES extension +# SelectionNotify event. +# +# Copyright (C) 2019 +# Tony Crisci +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA + +# Python 2/3 compatibility. +from __future__ import print_function + +import sys +import os +import time + +# Change path so we find Xlib +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +from Xlib.display import Display +from Xlib.ext import xfixes + +def main(argv): + if len(sys.argv) < 2 or len(sys.argv) > 3: + sys.exit('usage: {0} SELECTION\n\n' + 'SELECTION is typically PRIMARY, SECONDARY or CLIPBOARD.\n' + .format(sys.argv[0])) + + display = Display() + + sel_name = sys.argv[1] + sel_atom = display.get_atom(sel_name) + + if not display.has_extension('XFIXES'): + if display.query_extension('XFIXES') is None: + print('XFIXES extension not supported', file=sys.stderr) + return 1 + + xfixes_version = display.xfixes_query_version() + print('Found XFIXES version %s.%s' % ( + xfixes_version.major_version, + xfixes_version.minor_version, + ), file=sys.stderr) + + screen = display.screen() + + mask = xfixes.XFixesSetSelectionOwnerNotifyMask | \ + xfixes.XFixesSelectionWindowDestroyNotifyMask | \ + xfixes.XFixesSelectionClientCloseNotifyMask + + display.xfixes_select_selection_input(screen.root, sel_atom, mask) + + while True: + e = display.next_event() + print(e) + + if (e.type, e.sub_code) == display.extension_event.SetSelectionOwnerNotify: + print('SetSelectionOwner: owner=0x{0:08x}'.format(e.owner.id)) + elif (e.type, e.sub_code) == display.extension_event.SelectionWindowDestroyNotify: + print('SelectionWindowDestroy: owner=0x{0:08x}'.format(e.owner.id)) + elif (e.type, e.sub_code) == display.extension_event.SelectionClientCloseNotify: + print('SelectionClientClose: owner=0x{0:08x}'.format(e.owner.id)) + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) From d1ca3c31a5443820803b821645b4315d6679054e Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Thu, 23 May 2019 08:15:17 -0400 Subject: [PATCH 220/279] XFixes: simpler arg validation in selection example --- examples/xfixes-selection-notify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/xfixes-selection-notify.py b/examples/xfixes-selection-notify.py index 6fa3f118..20728fbd 100755 --- a/examples/xfixes-selection-notify.py +++ b/examples/xfixes-selection-notify.py @@ -37,7 +37,7 @@ from Xlib.ext import xfixes def main(argv): - if len(sys.argv) < 2 or len(sys.argv) > 3: + if len(sys.argv) != 2: sys.exit('usage: {0} SELECTION\n\n' 'SELECTION is typically PRIMARY, SECONDARY or CLIPBOARD.\n' .format(sys.argv[0])) From 4cb340def4b5ceebbe7efe740363b7e5c1dd3f4e Mon Sep 17 00:00:00 2001 From: Joseph Kogut Date: Tue, 23 Jul 2019 14:25:35 -0700 Subject: [PATCH 221/279] examples: xdamage: fix NameErrors --- examples/xdamage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/xdamage.py b/examples/xdamage.py index 5a57b386..3248a1ef 100644 --- a/examples/xdamage.py +++ b/examples/xdamage.py @@ -53,8 +53,8 @@ def blink(display, win, gc, cols): def get_image_from_win(win, pt_w, pt_h, pt_x=0, pt_y=0): try: - raw = win.get_image(ptX,ptY, ptW,ptH, X.ZPixmap, 0xffffffff) - image = Image.frombytes("RGB", (ptW, ptH), raw.data, "raw", "BGRX") + raw = win.get_image(pt_x, pt_y, pt_w, pt_h, X.ZPixmap, 0xffffffff) + image = Image.frombytes("RGB", (pt_w, pt_h), raw.data, "raw", "BGRX") return image except Exception: From ff757bee512c15db7e03bb957339e5e1d5d7315b Mon Sep 17 00:00:00 2001 From: Joseph Kogut Date: Tue, 23 Jul 2019 14:25:53 -0700 Subject: [PATCH 222/279] examples: xdamage: fix Python3 compatibility --- examples/xdamage.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/xdamage.py b/examples/xdamage.py index 3248a1ef..46cbab9d 100644 --- a/examples/xdamage.py +++ b/examples/xdamage.py @@ -33,7 +33,12 @@ from Xlib import display, X, threaded,Xutil import time -import thread + +try: + import thread +except ModuleNotFoundError: + import _thread as thread + from Xlib.ext import damage from PIL import Image, ImageTk import traceback From f035a95370e3e231f8a60a08315fc4401e06a2c7 Mon Sep 17 00:00:00 2001 From: Gerardwx Date: Mon, 19 Aug 2019 15:35:20 -0400 Subject: [PATCH 223/279] Add check for older / non-compliant X servers --- Xlib/ext/xinput.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index 1c95b54b..fee0d93c 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -647,8 +647,8 @@ def init(disp, info): disp.extension_add_method('display', 'xinput_ungrab_device', ungrab_device) disp.extension_add_method('window', 'xinput_grab_keycode', grab_keycode) disp.extension_add_method('window', 'xinput_ungrab_keycode', ungrab_keycode) - - for device_event in (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion): - disp.ge_add_event_data(info.major_opcode, device_event, DeviceEventData) - disp.ge_add_event_data(info.major_opcode, DeviceChanged, DeviceEventData) - disp.ge_add_event_data(info.major_opcode, HierarchyChanged, HierarchyEventData) + if hasattr(disp,"ge_add_event_data"): + for device_event in (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion): + disp.ge_add_event_data(info.major_opcode, device_event, DeviceEventData) + disp.ge_add_event_data(info.major_opcode, DeviceChanged, DeviceEventData) + disp.ge_add_event_data(info.major_opcode, HierarchyChanged, HierarchyEventData) From e9d7fd34dc149e23312c0acdf4476842385d1daf Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 23 Oct 2019 05:24:30 +0200 Subject: [PATCH 224/279] Travis CI: Add Python 3.7 and 3.8 to the testing --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index c54c9650..12858c99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ python: - "3.4" - "3.5" - "3.6" + - "3.7" + - "3.8" # command to install dependencies install: From a48536e136639cc0415713100b8b96d85c69d176 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 23 Oct 2019 10:32:10 +0200 Subject: [PATCH 225/279] Drop EOL Python 3.3 https://devguide.python.org/#status-of-python-branches --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 12858c99..524f0998 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: python python: - "2.7" - - "3.3" - "3.4" - "3.5" - "3.6" From 0432dc2462bc4fde9794da5d9872e1e61766d89b Mon Sep 17 00:00:00 2001 From: Vasily V Ryabov Date: Sun, 8 Dec 2019 14:54:12 +0300 Subject: [PATCH 226/279] Add 0.26 release notes and bump version. --- CHANGELOG.md | 19 +++++++++++++++++++ Xlib/__init__.py | 2 +- setup.cfg | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6711de85..1cd9e2a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ NEWS for Python X Library +Version 0.26 +============ + +Bug Fixes +--------- + +- support legacy X servers like RealVNC's one (by @Gerardwx) + +Extensions +-------------------- + +- enrich XFixes extension with XFixesSelectionNotify events (by @acrisci) +- add example xfixes-selection-notify.py (by @acrisci) +- fix two issues in NV-CONTROL extension (by @leinardi) +- add method get_clock_info into NV-CONTROL extension (by @leinardi) +- add default client version into Composite extension (by @jakogut) +- add Damage extension with the example (by @mgarg1 and @jakogut) + +--- Version 0.25 ============ diff --git a/Xlib/__init__.py b/Xlib/__init__.py index f023f80b..6164e53a 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 25) +__version__ = (0, 26) __version_extra__ = '' diff --git a/setup.cfg b/setup.cfg index ba1f408a..29a11ad0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,6 +26,8 @@ classifiers = Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 Programming Language :: Python :: Implementation :: CPython Topic :: Software Development :: Libraries :: Python Modules Topic :: Software Development :: Libraries From 5665e46e6b9a17a8815f8ac45ed60249e3fd2b8c Mon Sep 17 00:00:00 2001 From: Sporif Date: Wed, 8 Jan 2020 21:14:53 +0000 Subject: [PATCH 227/279] NV-CONTROL: set offset for all perf levels --- Xlib/ext/nvcontrol.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Xlib/ext/nvcontrol.py b/Xlib/ext/nvcontrol.py index 3060d247..7a21826c 100644 --- a/Xlib/ext/nvcontrol.py +++ b/Xlib/ext/nvcontrol.py @@ -273,6 +273,10 @@ def set_gpu_nvclock_offset(self, target, perf_level, offset): return set_int_attribute(self, target, perf_level, NV_CTRL_GPU_NVCLOCK_OFFSET, offset) +def set_gpu_nvclock_offset_all_levels(self, target, offset): + return set_int_attribute(self, target, 0, NV_CTRL_GPU_NVCLOCK_OFFSET_ALL_PERFORMANCE_LEVELS, offset) + + def get_gpu_nvclock_offset_range(self, target, perf_level): return query_valid_attr_values(self, target, perf_level, NV_CTRL_GPU_NVCLOCK_OFFSET) @@ -285,6 +289,10 @@ def set_mem_transfer_rate_offset(self, target, perf_level, offset): return set_int_attribute(self, target, perf_level, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET, offset) +def set_mem_transfer_rate_offset_all_levels(self, target, offset): + return set_int_attribute(self, target, 0, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET_ALL_PERFORMANCE_LEVELS, offset) + + def get_mem_transfer_rate_offset_range(self, target, perf_level): return query_valid_attr_values(self, target, perf_level, NV_CTRL_GPU_MEM_TRANSFER_RATE_OFFSET) @@ -372,8 +380,10 @@ def init(disp, info): disp.extension_add_method('display', 'nvcontrol_get_current_performance_level', get_current_performance_level) disp.extension_add_method('display', 'nvcontrol_get_gpu_nvclock_offset', get_gpu_nvclock_offset) disp.extension_add_method('display', 'nvcontrol_set_gpu_nvclock_offset', set_gpu_nvclock_offset) + disp.extension_add_method('display', 'nvcontrol_set_gpu_nvclock_offset_all_levels', set_gpu_nvclock_offset_all_levels) disp.extension_add_method('display', 'nvcontrol_get_mem_transfer_rate_offset', get_mem_transfer_rate_offset) disp.extension_add_method('display', 'nvcontrol_set_mem_transfer_rate_offset', set_mem_transfer_rate_offset) + disp.extension_add_method('display', 'nvcontrol_set_mem_transfer_rate_offset_all_levels', set_mem_transfer_rate_offset_all_levels) disp.extension_add_method('display', 'nvcontrol_get_cooler_manual_control_enabled', get_cooler_manual_control_enabled) disp.extension_add_method('display', 'nvcontrol_get_fan_duty', get_fan_duty) From 1e5ff831b8be9ddf617a9a7ddb25e7928a533999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= Date: Sat, 21 Mar 2020 11:53:20 +0100 Subject: [PATCH 228/279] Fix TypeError in socket.error exception handling The socket.error, which is an alias to OSError since python 3.3, is not subscriptable (and its subclasses neither are). Hence, pass the entire exception message to close_internal(). In case of a socket.error in self.socket.send(), the former crashed with a TypeError. I strongly suspect that this closes issue #127. --- Xlib/protocol/display.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 2f8a9e24..56623c35 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -582,7 +582,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) try: i = self.socket.send(self.data_send) except socket.error as err: - self.close_internal('server: %s' % err[1]) + self.close_internal('server: %s' % err) raise self.socket_error self.data_send = self.data_send[i:] @@ -600,7 +600,7 @@ def send_and_recv(self, flush = None, event = None, request = None, recv = None) count = max(self.recv_buffer_size, count) bytes_recv = self.socket.recv(count) except socket.error as err: - self.close_internal('server: %s' % err[1]) + self.close_internal('server: %s' % err) raise self.socket_error if not bytes_recv: From 126ab5373ce9da61c26ad7e610b6c353a44ff900 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Tue, 7 Apr 2020 17:57:30 +0300 Subject: [PATCH 229/279] Prepare release 0.27. --- CHANGELOG.md | 14 ++++++++++++++ Xlib/__init__.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cd9e2a6..6ead7502 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ NEWS for Python X Library +Version 0.27 +============ + +Bug Fixes +--------- + +- fix TypeError in socket.error exception handling for Python 3.x (by @t-wissmann) + +Extensions +-------------------- + +- NV-CONTROL: set offset for all perf levels (by @Sporif) + +--- Version 0.26 ============ diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 6164e53a..f983e876 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 26) +__version__ = (0, 27) __version_extra__ = '' From 12101cc4a0bea2ea251d304562434d8d6b4627d9 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 10 Sep 2020 21:53:34 -0300 Subject: [PATCH 230/279] Add Xlib.ext.dpms Based on the documentation found here: https://www.x.org/releases/X11R7.7/doc/xextproto/dpms.html It basically works, however there are some known issues: - Any rq.Request call (dpms_enable(), dpms_set_timeouts(), dpms_force_level()) only works if you call another rq.ReplyRequest function (dpms_get_version(), for example) afterwards. I tried to change them to use rq.ReplyRequest, but since they don't return anything they got stucked waiting for a response from X11. - DPMSInfo doesn't work. I don't have a clue why, I receive the following error when trying to call dpms_info(): ``` $ cat playground.py from Xlib import display d = display.Display() print(d.dpms_info()) $ python3 playground.py Traceback (most recent call last): File "playground.py", line 4, in print(d.dpms_info()) File "Xlib/display.py", line 225, in __getattr__ return types.MethodType(function, self) TypeError: first argument must be callable ``` So I decided to comment this function for now. --- Xlib/ext/__init__.py | 1 + Xlib/ext/dpms.py | 234 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 Xlib/ext/dpms.py diff --git a/Xlib/ext/__init__.py b/Xlib/ext/__init__.py index fbcc8e64..0da2800c 100644 --- a/Xlib/ext/__init__.py +++ b/Xlib/ext/__init__.py @@ -38,6 +38,7 @@ ('XInputExtension', 'xinput'), ('NV-CONTROL', 'nvcontrol'), ('DAMAGE', 'damage'), + ('DPMS', 'dpms'), ] __all__ = map(lambda x: x[1], __extensions__) diff --git a/Xlib/ext/dpms.py b/Xlib/ext/dpms.py new file mode 100644 index 00000000..8420894f --- /dev/null +++ b/Xlib/ext/dpms.py @@ -0,0 +1,234 @@ +# Xlib.ext.dpms -- X Display Power Management Signaling +# +# Copyright (C) 2020 Thiago Kenji Okada +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA + +''' +This extension provides X Protocol control over the VESA Display +Power Management Signaling (DPMS) characteristics of video boards +under control of the X Window System. + +Documentation: https://www.x.org/releases/X11R7.7/doc/xextproto/dpms.html +''' + +from Xlib import X +from Xlib.protocol import rq + +extname = 'DPMS' + + +# DPMS Extension Power Levels +# 0 DPMSModeOn In use +# 1 DPMSModeStandby Blanked, low power +# 2 DPMSModeSuspend Blanked, lower power +# 3 DPMSModeOff Shut off, awaiting activity +DPMSModeOn = 0 +DPMSModeStandby = 1 +DPMSModeSuspend = 2 +DPMSModeOff = 3 + +DPMSPowerLevel = ( + DPMSModeOn, + DPMSModeStandby, + DPMSModeSuspend, + DPMSModeOff, +) + + +class DPMSGetVersion(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(0), + rq.RequestLength(), + rq.Card16('major_version'), + rq.Card16('minor_version'), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card16('major_version'), + rq.Card16('minor_version'), + rq.Pad(20), + ) + + +def get_version(self): + return DPMSGetVersion(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + + +class DPMSCapable(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(1), + rq.RequestLength(), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Bool('capable'), + rq.Pad(23), + ) + + +def capable(self): + return DPMSCapable(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + + +class DPMSGetTimeouts(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(2), + rq.RequestLength(), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card16('standby_timeout'), + rq.Card16('suspend_timeout'), + rq.Card16('off_timeout'), + rq.Pad(18), + ) + + +def get_timeouts(self): + return DPMSGetTimeouts(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + + +class DPMSSetTimeouts(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(3), + rq.RequestLength(), + rq.Card16('standby_timeout'), + rq.Card16('suspend_timeout'), + rq.Card16('off_timeout'), + rq.Pad(2) + ) + + +def set_timeouts(self, standby_timeout, suspend_timeout, off_timeout): + return DPMSSetTimeouts(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1, + standby_timeout=standby_timeout, + suspend_timeout=suspend_timeout, + off_timeout=off_timeout) + + +class DPMSEnable(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(4), + rq.RequestLength(), + ) + + +def enable(self): + return DPMSEnable(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + + +class DPMSDisable(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(5), + rq.RequestLength(), + ) + + +def disable(self): + return DPMSDisable(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + + +class DPMSForceLevel(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(6), + rq.RequestLength(), + rq.Resource('power_level', DPMSPowerLevel), + ) + + +def force_level(self, power_level): + return DPMSForceLevel(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1, + power_level=power_level) + + +class DPMSInfo(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(7), + rq.RequestLength(), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Resource('power_level', DPMSPowerLevel), + rq.Bool('state'), + rq.Pad(21), + ) + + +def info(self): + return DPMSInfo(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=1) + + +def init(disp, info): + disp.extension_add_method('display', 'dpms_get_version', get_version) + disp.extension_add_method('display', 'dpms_capable', capable) + disp.extension_add_method('display', 'dpms_get_timeouts', get_timeouts) + disp.extension_add_method('display', 'dpms_set_timeouts', set_timeouts) + disp.extension_add_method('display', 'dpms_enable', enable) + disp.extension_add_method('display', 'dpms_disable', disable) + disp.extension_add_method('display', 'dpms_force_level', force_level) + # TODO: Returns 'TypeError: first argument must be callable' on call + # disp.extension_add_method('display', 'dpms_info', info) From b484fc167ab664c4372e1e6f6063b8131b2782fa Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 10 Sep 2020 22:01:36 -0300 Subject: [PATCH 231/279] Add examples/dpms.py --- examples/dpms.py | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 examples/dpms.py diff --git a/examples/dpms.py b/examples/dpms.py new file mode 100644 index 00000000..5f93a068 --- /dev/null +++ b/examples/dpms.py @@ -0,0 +1,78 @@ +#!/usr/bin/python +# +# examples/dpms.py -- DPMS usage examples. +# +# Copyright (C) 2020 Thiago Kenji Okada +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA + +import time + +from Xlib import display +from Xlib.ext import dpms + + +class DPMSExamples(object): + def __init__(self): + self.d = display.Display() + # Making sure that DPMS is enabled + self.d.dpms_enable() + # For some reason, the call above needs another X11 call + # to actually trigger it + self.d.dpms_get_version() + + def dpms_info(self): + capable = self.d.dpms_capable() + timeouts = self.d.dpms_get_timeouts() + + return (capable, timeouts) + + def turn_off_display(self): + self.d.dpms_force_level(dpms.DPMSModeOff) + # For some reason, the call above needs another X11 call + # to actually trigger it + self.d.dpms_get_version() + + def turn_on_display(self): + self.d.dpms_force_level(dpms.DPMSModeOn) + # For some reason, the call above needs another X11 call + # to actually trigger it + self.d.dpms_get_version() + + +if __name__ == '__main__': + examples = DPMSExamples() + + capable, timeouts = examples.dpms_info() + + assert capable, 'DPMS is not supported in your system' + + print('Current DPMS timeouts:') + print('Standby: {}, Suspend: {}, Off: {}'.format( + timeouts.standby_timeout, + timeouts.suspend_timeout, + timeouts.off_timeout + )) + + print('\nThe next example will turn-off your screen, press Ctrl-C to cancel.') + time.sleep(2) + examples.turn_off_display() + + print('\nTurning it on again...') + time.sleep(2) + examples.turn_on_display() From 8a10823bbf9435d93a1d7a12791e9be8165fb580 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 11 Sep 2020 12:09:00 -0300 Subject: [PATCH 232/279] Enable and fix dpms_info() The problem was simple: info (function) was being shadowed by info (parameter of init()). Simple renaming the parameter works (and it is not used anyway). --- Xlib/ext/dpms.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Xlib/ext/dpms.py b/Xlib/ext/dpms.py index 8420894f..dc06a654 100644 --- a/Xlib/ext/dpms.py +++ b/Xlib/ext/dpms.py @@ -209,7 +209,7 @@ class DPMSInfo(rq.ReplyRequest): rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), - rq.Resource('power_level', DPMSPowerLevel), + rq.Card16('power_level'), rq.Bool('state'), rq.Pad(21), ) @@ -222,7 +222,7 @@ def info(self): minor_version=1) -def init(disp, info): +def init(disp, _info): disp.extension_add_method('display', 'dpms_get_version', get_version) disp.extension_add_method('display', 'dpms_capable', capable) disp.extension_add_method('display', 'dpms_get_timeouts', get_timeouts) @@ -230,5 +230,4 @@ def init(disp, info): disp.extension_add_method('display', 'dpms_enable', enable) disp.extension_add_method('display', 'dpms_disable', disable) disp.extension_add_method('display', 'dpms_force_level', force_level) - # TODO: Returns 'TypeError: first argument must be callable' on call - # disp.extension_add_method('display', 'dpms_info', info) + disp.extension_add_method('display', 'dpms_info', info) From 152a2510d6710ce1fa4b4c341750ee1c6d449987 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 11 Sep 2020 12:27:16 -0300 Subject: [PATCH 233/279] Update examples/dpms.py to call Display.sync() --- examples/dpms.py | 112 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 30 deletions(-) mode change 100644 => 100755 examples/dpms.py diff --git a/examples/dpms.py b/examples/dpms.py old mode 100644 new mode 100755 index 5f93a068..364c5472 --- a/examples/dpms.py +++ b/examples/dpms.py @@ -21,6 +21,7 @@ # Suite 330, # Boston, MA 02111-1307 USA +import random import time from Xlib import display @@ -30,49 +31,100 @@ class DPMSExamples(object): def __init__(self): self.d = display.Display() - # Making sure that DPMS is enabled - self.d.dpms_enable() - # For some reason, the call above needs another X11 call - # to actually trigger it - self.d.dpms_get_version() - def dpms_info(self): capable = self.d.dpms_capable() - timeouts = self.d.dpms_get_timeouts() + assert capable, 'DPMS is not supported in your system' + + self.initial_info = self.d.dpms_info() + self.initial_timeouts = self.d.dpms_get_timeouts() + + # Making sure that DPMS is enable for this examples + self.d.dpms_enable() + self.d.sync() + + def print_dpms(self): + current_info = self.d.dpms_info() + print('\nDPMS state: {}\nPower level: {}'.format(current_info.state, + current_info.power_level)) + current_timeouts = self.d.dpms_get_timeouts() + print('Standby: {}, Suspend: {}, Off: {}\n'.format(current_timeouts.standby_timeout, + current_timeouts.suspend_timeout, + current_timeouts.off_timeout)) + + def toggle_dpms(self): + current_info = self.d.dpms_info() + if current_info.state: + self.d.dpms_disable() + else: + self.d.dpms_enable() + + self.d.sync() + + def restore(self): + print('Restoring DPMS configuration') + self.d.dpms_set_timeouts(self.initial_timeouts.standby_timeout, + self.initial_timeouts.suspend_timeout, + self.initial_timeouts.off_timeout) + if self.initial_info.state: + self.d.dpms_enable() + else: + self.d.dpms_disable() - return (capable, timeouts) + self.d.sync() + + self.print_dpms() + + def set_random_timeouts(self): + # Can be any number greater than 0 + # Using 10 just to not turnoff the screen suddenly + standby_timeout = random.randint(10, 600) + # Shouldn't be smaller than standby_timeout + suspend_timeout = random.randint(standby_timeout, 600) + # Shouldn't be smaller than standby_timeout or suspend_timeout + off_timeout = random.randint(suspend_timeout, 600) + self.d.dpms_set_timeouts(standby_timeout, suspend_timeout, off_timeout) + self.d.sync() def turn_off_display(self): self.d.dpms_force_level(dpms.DPMSModeOff) - # For some reason, the call above needs another X11 call - # to actually trigger it - self.d.dpms_get_version() + self.d.sync() def turn_on_display(self): self.d.dpms_force_level(dpms.DPMSModeOn) - # For some reason, the call above needs another X11 call - # to actually trigger it - self.d.dpms_get_version() + self.d.sync() -if __name__ == '__main__': - examples = DPMSExamples() +def main(): + try: + examples = DPMSExamples() + + print('Initial state') + examples.print_dpms() - capable, timeouts = examples.dpms_info() + print('Setting random timeouts') + examples.set_random_timeouts() + examples.print_dpms() - assert capable, 'DPMS is not supported in your system' + print('The next example will turn-off your screen, press Ctrl-C to cancel.') + time.sleep(2) + examples.turn_off_display() - print('Current DPMS timeouts:') - print('Standby: {}, Suspend: {}, Off: {}'.format( - timeouts.standby_timeout, - timeouts.suspend_timeout, - timeouts.off_timeout - )) + print('Turning it on again...') + time.sleep(2) + examples.turn_on_display() - print('\nThe next example will turn-off your screen, press Ctrl-C to cancel.') - time.sleep(2) - examples.turn_off_display() + print() - print('\nTurning it on again...') - time.sleep(2) - examples.turn_on_display() + print('Toggle DPMS') + examples.toggle_dpms() + examples.print_dpms() + + print('Toggle it again') + examples.toggle_dpms() + examples.print_dpms() + finally: + examples.restore() + + +if __name__ == '__main__': + main() From 733556f8b40b2d2643830ac193a0ffdd6560dbfc Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Mon, 14 Sep 2020 14:34:32 -0300 Subject: [PATCH 234/279] Fix e-mail in DPMS extension --- Xlib/ext/dpms.py | 2 +- examples/dpms.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/ext/dpms.py b/Xlib/ext/dpms.py index dc06a654..3ff9a246 100644 --- a/Xlib/ext/dpms.py +++ b/Xlib/ext/dpms.py @@ -1,6 +1,6 @@ # Xlib.ext.dpms -- X Display Power Management Signaling # -# Copyright (C) 2020 Thiago Kenji Okada +# Copyright (C) 2020 Thiago Kenji Okada # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License diff --git a/examples/dpms.py b/examples/dpms.py index 364c5472..0a04be57 100755 --- a/examples/dpms.py +++ b/examples/dpms.py @@ -2,7 +2,7 @@ # # examples/dpms.py -- DPMS usage examples. # -# Copyright (C) 2020 Thiago Kenji Okada +# Copyright (C) 2020 Thiago Kenji Okada # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License From f0a846d8aa5bc18ee8e58339b11ae6d24dc4224c Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 17 Sep 2020 12:38:34 -0300 Subject: [PATCH 235/279] Update links in README --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index e28f80cf..189c431b 100644 --- a/README.rst +++ b/README.rst @@ -75,10 +75,10 @@ Documentation ~~~~~~~~~~~~~ The reference manual is not finished by far, but is probably still useful. It -can be `browsed online `__. +can be `browsed online `__. There are also some `example programs `_ and, of course, -`the standard X11 documentation `__ applies. +`the standard X11 documentation `__ applies. Project status From 16de6b30f2dd38d914022d983a7b90d43d46f1c3 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 17 Sep 2020 12:41:17 -0300 Subject: [PATCH 236/279] Remove trailing whitespace, add DPMS to README.rst --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 189c431b..f5a92b14 100644 --- a/README.rst +++ b/README.rst @@ -70,7 +70,7 @@ There are three advantages of implementing a pure Python library: - Maintainability: It is much easier to develop and debug native Python modules than modules written in C. - + Documentation ~~~~~~~~~~~~~ @@ -92,7 +92,7 @@ starting with version 2.0. There is a resource database implementation, ICCCM support and a framework for adding X extension code. Several extensions have been -implemented; (RECORD, SHAPE, Xinerama, Composite, RANDR, and XTEST) +implemented; (RECORD, SHAPE, Xinerama, Composite, RANDR, DPMS, and XTEST) patches for additions are very welcome. There are most likely still bugs, but the library is at least stable From c5768cf0b0411cf39e00cc72c97687420224053d Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sat, 19 Sep 2020 23:43:18 +0300 Subject: [PATCH 237/279] Update CHANGELOG, version and list of extensions in README. --- CHANGELOG.md | 9 +++++++++ README.rst | 3 ++- Xlib/__init__.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ead7502..128a892d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ NEWS for Python X Library +Version 0.28 +============ + +Extensions +-------------------- + +- DPMS: Display Power Management Signaling (by @thiagokokada) + +--- Version 0.27 ============ diff --git a/README.rst b/README.rst index f5a92b14..8c06870e 100644 --- a/README.rst +++ b/README.rst @@ -92,7 +92,8 @@ starting with version 2.0. There is a resource database implementation, ICCCM support and a framework for adding X extension code. Several extensions have been -implemented; (RECORD, SHAPE, Xinerama, Composite, RANDR, DPMS, and XTEST) +implemented (RECORD, SHAPE, Xinerama, Composite, RANDR, DAMAGE, +Generic Event, SECURITY, XFIXES, XInput, XTEST, NV-CONTROL and DPMS); patches for additions are very welcome. There are most likely still bugs, but the library is at least stable diff --git a/Xlib/__init__.py b/Xlib/__init__.py index f983e876..e38da5ea 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 27) +__version__ = (0, 28) __version_extra__ = '' From ecafb97693635e334d9837b69985ca22956f70df Mon Sep 17 00:00:00 2001 From: Adrian Room Date: Mon, 21 Sep 2020 14:51:25 +0100 Subject: [PATCH 238/279] Fix __repr__s Reprs should contain the name of the class not the class's whole string conversion. (args) -> SomeClass(args) --- Xlib/protocol/rq.py | 6 +++--- Xlib/xobject/resource.py | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 24042176..86cb2def 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -1320,7 +1320,7 @@ def __str__(self): return str(self._data) def __repr__(self): - return '%s(%s)' % (self.__class__, repr(self._data)) + return '%s(%s)' % (self.__class__.__name__, repr(self._data)) def __lt__(self, other): if isinstance(other, DictWrapper): @@ -1400,7 +1400,7 @@ def _set_error(self, error): return 1 def __repr__(self): - return '<%s serial = %s, data = %s, error = %s>' % (self.__class__, self._serial, self._data, self._error) + return '<%s serial = %s, data = %s, error = %s>' % (self.__class__.__name__, self._serial, self._data, self._error) class Event(GetAttrData): @@ -1434,7 +1434,7 @@ def __repr__(self): kwlist.append('%s = %s' % (kw, repr(val))) kws = ', '.join(kwlist) - return '%s(%s)' % (self.__class__, kws) + return '%s(%s)' % (self.__class__.__name__, kws) def __lt__(self, other): if isinstance(other, Event): diff --git a/Xlib/xobject/resource.py b/Xlib/xobject/resource.py index 0492ffec..ea256ca1 100644 --- a/Xlib/xobject/resource.py +++ b/Xlib/xobject/resource.py @@ -45,11 +45,8 @@ def __ne__(self, obj): def __hash__(self): return int(self.id) - def __str__(self): - return '%s(0x%08x)' % (self.__class__, self.id) - def __repr__(self): - return '<%s 0x%08x>' % (self.__class__, self.id) + return '<%s 0x%08x>' % (self.__class__.__name__, self.id) def kill_client(self, onerror = None): request.KillClient(display = self.display, From 882714a336547ceaa1545cf68d0503cb75d11219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= Date: Fri, 20 Nov 2020 15:49:56 +0100 Subject: [PATCH 239/279] Use encode_array() in Drawable._get_struct_prop() The Xlib/protocol/rq.py file defines an helper function encode_array() that calls tostring() or tobytes() depending on which python version is used. The package maintainer Christoph Egger reported that the testsuite of the herbstluftwm project fails[1] with the error: def _get_struct_prop(self, pname, ptype, pstruct): r = self.get_property(pname, ptype, 0, pstruct.static_size // 4) if r and r.format == 32: > value = r.value.tostring() E AttributeError: 'array.array' object has no attribute 'tostring' /usr/lib/python3/dist-packages/Xlib/xobject/drawable.py:782: AttributeError Backtrace: ../tests/conftest.py:624: in is_window_urgent hints = window.get_wm_hints() /usr/lib/python3/dist-packages/Xlib/xobject/drawable.py:756: in get_wm_hints return self._get_struct_prop(Xatom.WM_HINTS, Xatom.WM_HINTS, I assume it should be rq.encode_array() instead of .tostring() but I'm not terribly sure. [1] https://pbot.rmdir.de/u/4lU98VkXkdjSypXmdekh5g --- Xlib/xobject/drawable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/xobject/drawable.py b/Xlib/xobject/drawable.py index 2f688c88..c36a9738 100644 --- a/Xlib/xobject/drawable.py +++ b/Xlib/xobject/drawable.py @@ -779,7 +779,7 @@ def get_wm_icon_size(self): def _get_struct_prop(self, pname, ptype, pstruct): r = self.get_property(pname, ptype, 0, pstruct.static_size // 4) if r and r.format == 32: - value = r.value.tostring() + value = rq.encode_array(r.value) if len(value) == pstruct.static_size: return pstruct.parse_binary(value, self.display)[0] From f2d092ee4b7eb8de3a1bc09b36f47595efd10b00 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 22 Nov 2020 14:30:20 +0300 Subject: [PATCH 240/279] Add Python 3.9 to Travis CI tests, bump version. --- .travis.yml | 1 + Xlib/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 524f0998..e7b949f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ python: - "3.6" - "3.7" - "3.8" + - "3.9" # command to install dependencies install: diff --git a/Xlib/__init__.py b/Xlib/__init__.py index e38da5ea..2ff7aabc 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 28) +__version__ = (0, 29) __version_extra__ = '' From e04b89e373151db7d631f0a0aa9ca71e7342fd8d Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 22 Nov 2020 14:40:54 +0300 Subject: [PATCH 241/279] Use encode_array() for array.array objects everywhere (.tostring() will be removed in Python 3.9). --- Xlib/ext/xinput.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index fee0d93c..e219bffe 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -236,7 +236,7 @@ def fun(val): else: mask_seq.extend(val) - return mask_seq.tostring(), len(mask_seq), None + return rq.encode_array(mask_seq), len(mask_seq), None EventMask = rq.Struct( DEVICE('deviceid'), From d1180422496bb057f0f665c968d912e59d23f5e8 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 22 Nov 2020 14:45:17 +0300 Subject: [PATCH 242/279] Update change log for 0.29. --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 128a892d..a5eba75f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ NEWS for Python X Library +Version 0.29 +============ + +Extensions +-------------------- + +- Drawable & XInput: Avoid using array.array.tostring() which wiil be removed in Python 3.9 (thanks @t-wissmann). + +--- Version 0.28 ============ From cae68404027cfb49f99e6353d45faf7feb29f8da Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 23 Nov 2020 17:15:07 +0200 Subject: [PATCH 243/279] Fix minor typo in documentation isntance -> instance --- doc/src/objects.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/objects.texi b/doc/src/objects.texi index 6d47137a..c6dfd7ee 100644 --- a/doc/src/objects.texi +++ b/doc/src/objects.texi @@ -1175,7 +1175,7 @@ Returns None or string. @end defmethod @defmethod Window get_wm_class ( ) -Returns None or (isntance, class) +Returns None or (instance, class) @end defmethod @defmethod Window set_wm_transient_for ( window, onerror = None ) From 376703ebb0069cf01727e22a679590fc14ac0152 Mon Sep 17 00:00:00 2001 From: Jimmy Loyola Date: Tue, 16 Mar 2021 11:45:27 +0100 Subject: [PATCH 244/279] Add missing parameters to xrandr delete_output_mode function --- Xlib/ext/randr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index 0a1dfb9c..48f4b635 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -699,7 +699,7 @@ class DeleteOutputMode(rq.Request): rq.Card32('mode'), ) -def delete_output_mode(self): +def delete_output_mode(self, output, mode): return DeleteOutputMode( display=self.display, opcode=self.display.get_extension_major(extname), From 0f970167fc424c9dea1b404e0dd11417f8cb9f63 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Sat, 17 Apr 2021 16:44:57 -0700 Subject: [PATCH 245/279] Add Xlib.ext.res Based on the xcb bindings sources and the protocol documentation: - https://www.x.org/releases/current/doc/resourceproto/resproto.txt - https://cgit.freedesktop.org/xcb/proto/tree/src/res.xml Verified that all methods are working with an example application. --- README.rst | 2 +- Xlib/ext/__init__.py | 1 + Xlib/ext/res.py | 285 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 287 insertions(+), 1 deletion(-) create mode 100644 Xlib/ext/res.py diff --git a/README.rst b/README.rst index 8c06870e..572e701f 100644 --- a/README.rst +++ b/README.rst @@ -93,7 +93,7 @@ starting with version 2.0. There is a resource database implementation, ICCCM support and a framework for adding X extension code. Several extensions have been implemented (RECORD, SHAPE, Xinerama, Composite, RANDR, DAMAGE, -Generic Event, SECURITY, XFIXES, XInput, XTEST, NV-CONTROL and DPMS); +Generic Event, SECURITY, XFIXES, XInput, XTEST, NV-CONTROL, DPMS and XRes); patches for additions are very welcome. There are most likely still bugs, but the library is at least stable diff --git a/Xlib/ext/__init__.py b/Xlib/ext/__init__.py index 0da2800c..71a855b0 100644 --- a/Xlib/ext/__init__.py +++ b/Xlib/ext/__init__.py @@ -39,6 +39,7 @@ ('NV-CONTROL', 'nvcontrol'), ('DAMAGE', 'damage'), ('DPMS', 'dpms'), + ('X-Resource', 'res'), ] __all__ = map(lambda x: x[1], __extensions__) diff --git a/Xlib/ext/res.py b/Xlib/ext/res.py new file mode 100644 index 00000000..0a1ea79b --- /dev/null +++ b/Xlib/ext/res.py @@ -0,0 +1,285 @@ +# Xlib.ext.res -- X-Resource extension module +# +# Copyright (C) 2021 Aleksei Bavshin +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, +# Fifth Floor, +# Boston, MA 02110-1301 USA + +"""X-Resource extension allows a client to query the X server about its usage +of various resources. + +For detailed description see any of the following documents. +Protocol specification: + https://www.x.org/releases/current/doc/resourceproto/resproto.txt +XCB Protocol specification: + https://cgit.freedesktop.org/xcb/proto/tree/src/res.xml +""" +from Xlib.protocol import rq + +RES_MAJOR_VERSION = 1 +RES_MINOR_VERSION = 2 + +extname = "X-Resource" + +# v1.0 +ResQueryVersion = 0 +ResQueryClients = 1 +ResQueryClientResources = 2 +ResQueryClientPixmapBytes = 3 +# v1.2 +ResQueryClientIds = 4 +ResQueryResourceBytes = 5 + + +class QueryVersion(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8("opcode"), + rq.Opcode(ResQueryVersion), + rq.RequestLength(), + rq.Card8("client_major"), + rq.Card8("client_minor"), + rq.Pad(2)) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16("sequence_number"), + rq.ReplyLength(), + rq.Card16("server_major"), + rq.Card16("server_minor"), + rq.Pad(20)) + + +def query_version(self, client_major=RES_MAJOR_VERSION, + client_minor=RES_MINOR_VERSION): + """ Query the protocol version supported by the X server. + + The client sends the highest supported version to the server and the + server sends the highest version it supports, but no higher than the + requested version.""" + return QueryVersion( + display=self.display, + opcode=self.display.get_extension_major(extname), + client_major=client_major, + client_minor=client_minor) + + +Client = rq.Struct( + rq.Card32("resource_base"), + rq.Card32("resource_mask")) + + +class QueryClients(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8("opcode"), + rq.Opcode(ResQueryClients), + rq.RequestLength()) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16("sequence_number"), + rq.ReplyLength(), + rq.LengthOf("clients", 4), + rq.Pad(20), + rq.List("clients", Client)) + + +def query_clients(self): + """Request the list of all currently connected clients.""" + return QueryClients( + display=self.display, + opcode=self.display.get_extension_major(extname)) + + +Type = rq.Struct( + rq.Card32("resource_type"), + rq.Card32("count")) + + +class QueryClientResources(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8("opcode"), + rq.Opcode(ResQueryClientResources), + rq.RequestLength(), + rq.Card32("client")) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16("sequence_number"), + rq.ReplyLength(), + rq.LengthOf("types", 4), + rq.Pad(20), + rq.List("types", Type)) + + +def query_client_resources(self, client): + """Request the number of resources owned by a client. + + The server will return the counts of each type of resource. + """ + return QueryClientResources( + display=self.display, + opcode=self.display.get_extension_major(extname), + client=client) + + +class QueryClientPixmapBytes(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8("opcode"), + rq.Opcode(ResQueryClientPixmapBytes), + rq.RequestLength(), + rq.Card32("client")) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16("sequence_number"), + rq.ReplyLength(), + rq.Card32("bytes"), + rq.Card32("bytes_overflow"), + rq.Pad(16)) + + +def query_client_pixmap_bytes(self, client): + """Query the pixmap usage of some client. + + The returned number is a sum of memory usage of each pixmap that can be + attributed to the given client. + """ + return QueryClientPixmapBytes( + display=self.display, + opcode=self.display.get_extension_major(extname), + client=client) + + +class SizeOf(rq.LengthOf): + """A SizeOf stores the size in bytes of some other Field whose size + may vary, e.g. List + """ + def __init__(self, name, size, item_size): + rq.LengthOf.__init__(self, name, size) + self.item_size = item_size + + def parse_value(self, length, display): + return length // self.item_size + + +ClientXIDMask = 1 << 0 +LocalClientPIDMask = 1 << 1 + + +ClientIdSpec = rq.Struct( + rq.Card32("client"), + rq.Card32("mask")) + + +ClientIdValue = rq.Struct( + rq.Object("spec", ClientIdSpec), + SizeOf("value", 4, 4), + rq.List("value", rq.Card32Obj)) + + +class QueryClientIds(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8("opcode"), + rq.Opcode(ResQueryClientIds), + rq.RequestLength(), + rq.LengthOf("specs", 4), + rq.List("specs", ClientIdSpec)) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16("sequence_number"), + rq.ReplyLength(), + rq.LengthOf("ids", 4), + rq.Pad(20), + rq.List("ids", ClientIdValue)) + + +def query_client_ids(self, specs): + """Request to identify a given set of clients with some identification method. + + The request sends a list of specifiers that select clients and + identification methods to server. The server then tries to identify the + chosen clients using the identification methods specified for each client. + The server returns IDs for those clients that were successfully identified. + """ + return QueryClientIds( + display=self.display, + opcode=self.display.get_extension_major(extname), + specs=specs) + + +ResourceIdSpec = rq.Struct( + rq.Card32("resource"), + rq.Card32("type")) + + +ResourceSizeSpec = rq.Struct( + rq.Object("spec", ResourceIdSpec), + rq.Card32("bytes"), + rq.Card32("ref_count"), + rq.Card32("use_count")) + + +ResourceSizeValue = rq.Struct( + rq.Object("size", ResourceSizeSpec), + rq.LengthOf("cross_references", 4), + rq.List("cross_references", ResourceSizeSpec)) + + +class QueryResourceBytes(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8("opcode"), + rq.Opcode(ResQueryResourceBytes), + rq.RequestLength(), + rq.Card32("client"), + rq.LengthOf("specs", 4), + rq.List("specs", ResourceIdSpec)) + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16("sequence_number"), + rq.ReplyLength(), + rq.LengthOf("sizes", 4), + rq.Pad(20), + rq.List("sizes", ResourceSizeValue)) + + +def query_resource_bytes(self, client, specs): + """Query the sizes of resources from X server. + + The request sends a list of specifiers that selects resources for size + calculation. The server tries to calculate the sizes of chosen resources + and returns an estimate for a resource only if the size could be determined + """ + return QueryResourceBytes( + display=self.display, + opcode=self.display.get_extension_major(extname), + client=client, + specs=specs) + + +def init(disp, info): + disp.extension_add_method("display", "res_query_version", query_version) + disp.extension_add_method("display", "res_query_clients", query_clients) + disp.extension_add_method("display", "res_query_client_resources", + query_client_resources) + disp.extension_add_method("display", "res_query_client_pixmap_bytes", + query_client_pixmap_bytes) + disp.extension_add_method("display", "res_query_client_ids", + query_client_ids) + disp.extension_add_method("display", "res_query_resource_bytes", + query_resource_bytes) From 1265f1f85307da6d617463c365efbeffeecf31a6 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Sat, 17 Apr 2021 16:49:17 -0700 Subject: [PATCH 246/279] Add examples/xres.py to demonstrate and test X-Resource extension --- examples/xres.py | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 examples/xres.py diff --git a/examples/xres.py b/examples/xres.py new file mode 100755 index 00000000..b28d7c38 --- /dev/null +++ b/examples/xres.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +# +# examples/xres.py -- demonstrate the X-Resource extension +# +# Copyright (C) 2021 Aleksei Bavshin +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, +# Fifth Floor, +# Boston, MA 02110-1301 USA + +import os +import sys + +# Change path so we find Xlib +sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) + +from Xlib.display import Display +from Xlib.ext import res as XRes + + +def check_ext(disp, extname, version): + if disp.query_extension(extname) is None: + raise AssertionError("Server has {} extension".format(extname)) + + r = disp.res_query_version() + if (r.server_major, r.server_minor) < version: + raise AssertionError( + "Server has requested version {} of {} extension".format(version, extname) + ) + + +def query_client_id(display, wid): + specs = [{"client": wid, "mask": XRes.LocalClientPIDMask}] + r = display.res_query_client_ids(specs) + for id in r.ids: + if id.spec.client > 0 and id.spec.mask == XRes.LocalClientPIDMask: + for value in id.value: + return value + return None + + +def print_client_info(disp, client): + print("client: {}".format(client)) + + resources = disp.res_query_client_resources(client) + rc = [r.count for r in resources.types] + print("\tresouces: {} resources of {} types".format(sum(rc), len(rc))) + + pb = disp.res_query_client_pixmap_bytes(client) + print("\tpixmaps: {} bytes {} overflow".format(pb.bytes, pb.bytes_overflow)) + + pid = query_client_id(disp, client) + print("\tpid: {}".format(pid)) + + rb = disp.res_query_resource_bytes(client, [{"resource": 0, "type": 0}]) + sizes = [s.size.bytes for s in rb.sizes] + print("\t{} resources consume {} bytes".format(len(sizes), sum(sizes))) + + +def main(): + display = Display() + check_ext(display, XRes.extname, (1, 2)) + + clients = display.res_query_clients().clients + print("{} clients connected to the server".format(len(clients))) + + for client in clients: + print_client_info(display, client.resource_base) + + +if __name__ == "__main__": + main() From 317548f106c5b4e0b1aa9bc6e412721c948d4fa7 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Sat, 17 Apr 2021 16:57:05 -0700 Subject: [PATCH 247/279] Xlib.ext.res: inline struct ResourceIdSpec to work around parser bug Fixes following error: ``` Traceback (most recent call last): File "examples/xres.py", line 85, in main() File "examples/xres.py", line 81, in main print_client_info(display, client.resource_base) File "examples/xres.py", line 68, in print_client_info rb = window.res_query_resource_bytes([{"resource": 0, "type": 0}]) File "examples/../Xlib/ext/res.py", line 268, in query_resource_bytes return QueryResourceBytes( File "examples/../Xlib/protocol/rq.py", line 1369, in __init__ self.reply() File "examples/../Xlib/protocol/rq.py", line 1381, in reply self._display.send_and_recv(request = self._serial) File "examples/../Xlib/protocol/display.py", line 612, in send_and_recv gotreq = self.parse_response(request) File "examples/../Xlib/protocol/display.py", line 704, in parse_response gotreq = self.parse_request_response(request) or gotreq File "examples/../Xlib/protocol/display.py", line 792, in parse_request_response req._parse_response(self.data_recv[:self.recv_packet_len]) File "examples/../Xlib/protocol/rq.py", line 1393, in _parse_response self._data, d = self._reply.parse_binary(data, self._display, rawdict = 1) File "examples/../Xlib/protocol/rq.py", line 1203, in parse_binary ret[f.name], data = f.parse_binary_value(data, display, File "examples/../Xlib/protocol/rq.py", line 533, in parse_binary_value ret[i], data = self.type.parse_binary(data, display) File "examples/../Xlib/protocol/rq.py", line 1192, in parse_binary field_val = f.parse_value(field_val, display) File "examples/../Xlib/protocol/rq.py", line 604, in parse_value return self.type.parse_value(val, display) File "examples/../Xlib/protocol/rq.py", line 1126, in parse_value field_val = f.parse_value(field_val, display, rawdict=rawdict) TypeError: parse_value() got an unexpected keyword argument 'rawdict' ``` --- Xlib/ext/res.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Xlib/ext/res.py b/Xlib/ext/res.py index 0a1ea79b..f2c4e9fe 100644 --- a/Xlib/ext/res.py +++ b/Xlib/ext/res.py @@ -228,7 +228,10 @@ def query_client_ids(self, specs): ResourceSizeSpec = rq.Struct( - rq.Object("spec", ResourceIdSpec), + # inline struct ResourceIdSpec to work around + # a parser bug with nested objects + rq.Card32("resource"), + rq.Card32("type"), rq.Card32("bytes"), rq.Card32("ref_count"), rq.Card32("use_count")) From 06c0cf0c6aa66d871685b3763acf7c45ac595243 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Sat, 17 Apr 2021 17:44:31 -0700 Subject: [PATCH 248/279] Add XRes to run_examples.py --- examples/run_examples.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/run_examples.py b/examples/run_examples.py index f97a4e0b..9c834dcd 100644 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -77,6 +77,10 @@ def test_xlsatoms(self): """ Run xlsatoms.py -- show list atoms on X server """ self.assertEqual(run_example(examples_folder + "xlsatoms.py"), 0) + def test_xres(self): + """ Run xres.py -- demonstrate the X-Resource extension """ + self.assertEqual(run_example(examples_folder + "xres.py"), 0) + if __name__ == '__main__': unittest.main() From 3d28d6bf9ab5f4d5e4a48c863f90c95b4f7eca30 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sat, 15 May 2021 21:22:25 +0300 Subject: [PATCH 249/279] Update CHANGELOG, bump version to 0.30 --- CHANGELOG.md | 10 ++++++++++ Xlib/__init__.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5eba75f..024c3ea3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ NEWS for Python X Library +Version 0.30 +============ + +Extensions +-------------------- + +- XResource: first implementation (thanks @alebastr). +- XRandr: add missing parameters to delete_output_mode function (thanks @jimmy-loyola). + +--- Version 0.29 ============ diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 2ff7aabc..d6af5d61 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 29) +__version__ = (0, 30) __version_extra__ = '' From 6781fd3f8cdbf7f2af7dd2830013f0fdcc0ec41a Mon Sep 17 00:00:00 2001 From: Davydov Denis Date: Wed, 23 Jun 2021 16:00:08 +0300 Subject: [PATCH 250/279] - added xinput event methods - added xinput property event data --- .gitignore | 4 +- Xlib/ext/xinput.py | 123 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ac3327fb..d8efd36c 100644 --- a/.gitignore +++ b/.gitignore @@ -59,7 +59,9 @@ docs/_build/ target/ # IntelliJ - .idea/ +# Visual Studio Code +.vscode/ + /.mypy_cache/ diff --git a/Xlib/ext/xinput.py b/Xlib/ext/xinput.py index e219bffe..f9218064 100644 --- a/Xlib/ext/xinput.py +++ b/Xlib/ext/xinput.py @@ -158,6 +158,8 @@ DEVICE = rq.Card16 DEVICEUSE = rq.Card8 +PROPERTY_TYPE_FLOAT = 'FLOAT' + class FP1616(rq.Int32): def check_value(self, value): @@ -426,6 +428,114 @@ def query_device(self, deviceid): deviceid=deviceid, ) +class XIListProperties(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(56), + rq.RequestLength(), + DEVICEID('deviceid'), + rq.Pad(2), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.LengthOf('atoms', 2), + rq.Pad(22), + rq.List('atoms', rq.Card32Obj), + ) + +def list_device_properties(self, deviceid): + return XIListProperties( + display=self.display, + opcode=self.display.get_extension_major(extname), + deviceid=deviceid, + ) + +class XIGetProperty(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(59), + rq.RequestLength(), + DEVICEID('deviceid'), + rq.Card8('delete'), + rq.Pad(1), + rq.Card32('property'), + rq.Card32('type'), + rq.Card32('offset'), + rq.Card32('length'), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('type'), + rq.Card32('bytes_after'), + rq.LengthOf('value', 4), + rq.Format('value', 1), + rq.Pad(11), + rq.PropertyData('value') + ) + +def get_device_property(self, deviceid, property, type, offset, length, delete=False): + return XIGetProperty( + display=self.display, + opcode=self.display.get_extension_major(extname), + deviceid=deviceid, + property=property, + type=type, + offset=offset, + length=length, + delete=delete, + ) + +class XIChangeProperty(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(57), + rq.RequestLength(), + DEVICEID('deviceid'), + rq.Card8('mode'), + rq.Format('value', 1), + rq.Card32('property'), + rq.Card32('type'), + rq.LengthOf('value', 4), + rq.PropertyData('value'), + ) + +def change_device_property(self, deviceid, property, type, mode, value): + return XIChangeProperty( + display=self.display, + opcode=self.display.get_extension_major(extname), + deviceid=deviceid, + property=property, + type=type, + mode=mode, + value=value, + ) + +class XIDeleteProperty(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(58), + rq.RequestLength(), + DEVICEID('deviceid'), + rq.Pad(2), + rq.Card32('property'), + ) + +def delete_device_property(self, deviceid, property): + return XIDeleteProperty( + display=self.display, + opcode=self.display.get_extension_major(extname), + deviceid=deviceid, + property=property, + ) + class XIGrabDevice(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), @@ -639,6 +749,14 @@ def ungrab_keycode(self, deviceid, keycode, modifiers): rq.List('classes', ClassInfo), ) +PropertyEventData = rq.Struct( + DEVICEID('deviceid'), + rq.Card32('time'), + rq.Card32('property'), + rq.Card8('what'), + rq.Pad(11), +) + def init(disp, info): disp.extension_add_method('display', 'xinput_query_version', query_version) disp.extension_add_method('window', 'xinput_select_events', select_events) @@ -647,8 +765,13 @@ def init(disp, info): disp.extension_add_method('display', 'xinput_ungrab_device', ungrab_device) disp.extension_add_method('window', 'xinput_grab_keycode', grab_keycode) disp.extension_add_method('window', 'xinput_ungrab_keycode', ungrab_keycode) + disp.extension_add_method('display', 'xinput_get_device_property', get_device_property) + disp.extension_add_method('display', 'xinput_list_device_properties', list_device_properties) + disp.extension_add_method('display', 'xinput_change_device_property', change_device_property) + disp.extension_add_method('display', 'xinput_delete_device_property', delete_device_property) if hasattr(disp,"ge_add_event_data"): for device_event in (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion): disp.ge_add_event_data(info.major_opcode, device_event, DeviceEventData) disp.ge_add_event_data(info.major_opcode, DeviceChanged, DeviceEventData) disp.ge_add_event_data(info.major_opcode, HierarchyChanged, HierarchyEventData) + disp.ge_add_event_data(info.major_opcode, PropertyEvent, PropertyEventData) From a734526ed33fe446396e32649e8895dde679f52c Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Fri, 2 Jul 2021 13:29:24 +0300 Subject: [PATCH 251/279] Update CHANGELOG, bump version to 0.31 --- CHANGELOG.md | 9 +++++++++ Xlib/__init__.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 024c3ea3..b960a8d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ NEWS for Python X Library +Version 0.31 +============ + +Extensions +-------------------- + +- XInput: add event methods (thanks @dd4e). + +--- Version 0.30 ============ diff --git a/Xlib/__init__.py b/Xlib/__init__.py index d6af5d61..89473730 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 30) +__version__ = (0, 31) __version_extra__ = '' From 1a3031544bb25464c4744edae39ac02b0e730f13 Mon Sep 17 00:00:00 2001 From: "B. Blechschmidt" Date: Sun, 26 Sep 2021 11:45:21 +0200 Subject: [PATCH 252/279] Add support for FamilyServerInterpreted and FamilyInternetV6 --- Xlib/X.py | 2 ++ Xlib/display.py | 5 +++-- Xlib/protocol/request.py | 3 ++- Xlib/xauth.py | 2 ++ doc/src/objects.texi | 6 ++++-- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Xlib/X.py b/Xlib/X.py index 3105e798..1a09e392 100644 --- a/Xlib/X.py +++ b/Xlib/X.py @@ -197,6 +197,8 @@ FamilyInternet = 0 FamilyDECnet = 1 FamilyChaos = 2 +FamilyServerInterpreted = 5 +FamilyInternetV6 = 6 PropertyNewValue = 0 PropertyDelete = 1 ColormapUninstalled = 0 diff --git a/Xlib/display.py b/Xlib/display.py index beaeaad6..ead0185c 100644 --- a/Xlib/display.py +++ b/Xlib/display.py @@ -849,7 +849,8 @@ def get_screen_saver(self): def change_hosts(self, mode, host_family, host, onerror = None): """mode is either X.HostInsert or X.HostDelete. host_family is - one of X.FamilyInternet, X.FamilyDECnet or X.FamilyChaos. + one of X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos, + X.FamilyServerInterpreted or X.FamilyInternetV6. host is a list of bytes. For the Internet family, it should be the four bytes of an IPv4 address.""" @@ -868,7 +869,7 @@ def list_hosts(self): The hosts on the access list. Each entry has the following attributes: family - X.FamilyInternet, X.FamilyDECnet, or X.FamilyChaos. + X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos, X.FamilyServerInterpreted or X.FamilyInternetV6. name A list of byte values, the coding depends on family. For the Internet family, it is the 4 bytes of an IPv4 address. diff --git a/Xlib/protocol/request.py b/Xlib/protocol/request.py index efe62ddb..b431e137 100644 --- a/Xlib/protocol/request.py +++ b/Xlib/protocol/request.py @@ -1640,7 +1640,8 @@ class ChangeHosts(rq.Request): rq.Opcode(109), rq.Set('mode', 1, (X.HostInsert, X.HostDelete)), rq.RequestLength(), - rq.Set('host_family', 1, (X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos)), + rq.Set('host_family', 1, (X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos, + X.FamilyServerInterpreted, X.FamilyInternetV6)), rq.Pad(1), rq.LengthOf('host', 2), rq.List('host', rq.Card8Obj) diff --git a/Xlib/xauth.py b/Xlib/xauth.py index 63eb7ef7..2ed7dd52 100644 --- a/Xlib/xauth.py +++ b/Xlib/xauth.py @@ -27,6 +27,8 @@ FamilyInternet = X.FamilyInternet FamilyDECnet = X.FamilyDECnet FamilyChaos = X.FamilyChaos +FamilyServerInterpreted = X.FamilyServerInterpreted +FamilyInternetV6 = X.FamilyInternetV6 FamilyLocal = 256 class Xauthority(object): diff --git a/doc/src/objects.texi b/doc/src/objects.texi index c6dfd7ee..094bf95c 100644 --- a/doc/src/objects.texi +++ b/doc/src/objects.texi @@ -678,7 +678,8 @@ XGetScreenSaver(3X11) for details. @var{mode} is either @code{X.HostInsert} or @code{X.HostDelete}. @var{host_family} is one of @code{X.FamilyInternet}, -@code{X.FamilyDECnet} or @code{X.FamilyChaos}. +@code{X.FamilyDECnet}, @code{X.FamilyChaos}, @code{X.FamilyServerInterpreted} +or @code{X.FamilyInternetV6}. @var{host} is a list of bytes. For the Internet family, it should be the four bytes of an IPv4 address. @@ -699,7 +700,8 @@ The hosts on the access list. Each entry has the following attributes: @table @code @item family -@code{X.FamilyInternet}, @code{X.FamilyDECnet}, or @code{X.FamilyChaos}. +@code{X.FamilyInternet}, @code{X.FamilyDECnet}, @code{X.FamilyChaos}, +@code{X.FamilyServerInterpreted} or @code{X.FamilyInternetV6}. @item name A list of byte values, the coding depends on @code{family}. For the From 0527e0f04de9b278b3d19c98b6aecfa3c014778b Mon Sep 17 00:00:00 2001 From: PythonCoderAS <13932583+PythonCoderAS@users.noreply.github.com> Date: Wed, 15 Dec 2021 09:42:22 -0500 Subject: [PATCH 253/279] Include note about OS support --- README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.rst b/README.rst index 572e701f..ad040fe4 100644 --- a/README.rst +++ b/README.rst @@ -27,6 +27,9 @@ Requirements The Python X Library requires Python 2.7 or newer. It has been tested to various extents with Python 2.7 and 3.3 through 3.6. +The Python X Library will only work on systems that have an X server installed, +such as most Linux distros, but will not work on Windows or MacOS. + Installation ~~~~~~~~~~~~ From fc47fde63d5a00a4100d05ebfeb48db088aca186 Mon Sep 17 00:00:00 2001 From: precondition <57645186+precondition@users.noreply.github.com> Date: Tue, 3 Aug 2021 11:22:24 +0200 Subject: [PATCH 254/279] Update xf86.py with new keysyms Suspend, hibernate, touchpad controls, microphone toggle, WWAN, RFKill, Audio preset, rotation lock toggle and full screen. These "new" keysyms were taken from `/usr/include/X11/XF86keysym.h` --- Xlib/keysymdef/xf86.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Xlib/keysymdef/xf86.py b/Xlib/keysymdef/xf86.py index 2640535c..e8610c09 100644 --- a/Xlib/keysymdef/xf86.py +++ b/Xlib/keysymdef/xf86.py @@ -159,6 +159,25 @@ XK_XF86_Yellow = 0x1008FFA5 XK_XF86_Blue = 0x1008FFA6 +XK_XF86_Suspend = 0x1008FFA7 +XK_XF86_Hibernate = 0x1008FFA8 +XK_XF86_TouchpadToggle = 0x1008FFA9 +XK_XF86_TouchpadOn = 0x1008FFB0 +XK_XF86_TouchpadOff = 0x1008FFB1 + +XK_XF86_AudioMicMute = 0x1008FFB2 + +XK_XF86_Keyboard = 0x1008FFB3 + +XK_XF86_WWAN = 0x1008FFB4 +XK_XF86_RFKill = 0x1008FFB5 + +XK_XF86_AudioPreset = 0x1008FFB6 + +XK_XF86_RotationLockToggle = 0x1008FFB7 + +XK_XF86_FullScreen = 0x1008FFB8 + XK_XF86_Switch_VT_1 = 0x1008FE01 XK_XF86_Switch_VT_2 = 0x1008FE02 XK_XF86_Switch_VT_3 = 0x1008FE03 From bb8685acf3351e10b3182034724dc16fa0a11630 Mon Sep 17 00:00:00 2001 From: precondition <57645186+precondition@users.noreply.github.com> Date: Tue, 3 Aug 2021 11:32:51 +0200 Subject: [PATCH 255/279] Added the four remaining XF86 keysyms to xf86.py ModeLock, MonBrightnessCycle, LogWindowTree, LogGrabInfo --- Xlib/keysymdef/xf86.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Xlib/keysymdef/xf86.py b/Xlib/keysymdef/xf86.py index e8610c09..4ccf12a7 100644 --- a/Xlib/keysymdef/xf86.py +++ b/Xlib/keysymdef/xf86.py @@ -1,8 +1,11 @@ -XK_XF86_MonBrightnessUp = 0x1008FF02 -XK_XF86_MonBrightnessDown = 0x1008FF03 -XK_XF86_KbdLightOnOff = 0x1008FF04 -XK_XF86_KbdBrightnessUp = 0x1008FF05 -XK_XF86_KbdBrightnessDown = 0x1008FF06 +XK_XF86_ModeLock = 0x1008FF01 + +XK_XF86_MonBrightnessUp = 0x1008FF02 +XK_XF86_MonBrightnessDown = 0x1008FF03 +XK_XF86_KbdLightOnOff = 0x1008FF04 +XK_XF86_KbdBrightnessUp = 0x1008FF05 +XK_XF86_KbdBrightnessDown = 0x1008FF06 +XK_XF86_MonBrightnessCycle = 0x1008FF07 XK_XF86_Standby = 0x1008FF10 XK_XF86_AudioLowerVolume = 0x1008FF11 @@ -195,3 +198,5 @@ XK_XF86_ClearGrab = 0x1008FE21 XK_XF86_Next_VMode = 0x1008FE22 XK_XF86_Prev_VMode = 0x1008FE23 +XK_XF86_LogWindowTree = 0x1008FE24 +XK_XF86_LogGrabInfo = 0x1008FE25 From c9d2428e4c3e956c06c2cb2c2b75fa3e3333635f Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Wed, 27 Apr 2022 05:17:06 +0000 Subject: [PATCH 256/279] Add screensaver extension --- Xlib/ext/__init__.py | 1 + Xlib/ext/screensaver.py | 198 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 199 insertions(+) create mode 100644 Xlib/ext/screensaver.py diff --git a/Xlib/ext/__init__.py b/Xlib/ext/__init__.py index 71a855b0..37229bac 100644 --- a/Xlib/ext/__init__.py +++ b/Xlib/ext/__init__.py @@ -40,6 +40,7 @@ ('DAMAGE', 'damage'), ('DPMS', 'dpms'), ('X-Resource', 'res'), + ('MIT-SCREEN-SAVER', 'screensaver'), ] __all__ = map(lambda x: x[1], __extensions__) diff --git a/Xlib/ext/screensaver.py b/Xlib/ext/screensaver.py new file mode 100644 index 00000000..90fb68a6 --- /dev/null +++ b/Xlib/ext/screensaver.py @@ -0,0 +1,198 @@ +# Xlib.ext.screensaver -- X ScreenSaver extension module +# +# Copyright (C) 2022 Vladimir Panteleev +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, +# Fifth Floor, +# Boston, MA 02110-1301 USA + +"""This extension allows registering the client as an X screensaver, +or query information about the current screensaver. + +For detailed description see any of the following documents. +Protocol specification: + https://www.x.org/releases/X11R7.7/doc/scrnsaverproto/saver.html +XCB Protocol specification: + https://cgit.freedesktop.org/xcb/proto/tree/src/screensaver.xml + +""" + +from Xlib import X +from Xlib.protocol import rq, structs + +extname = 'MIT-SCREEN-SAVER' + +# Event members +NotifyMask = 1 +CycleMask = 2 + +# Notify state +StateOff = 0 +StateOn = 1 +StateCycle = 2 + +# Notify kind +KindBlanked = 0 +KindInternal = 1 +KindExternal = 2 + +class QueryVersion(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(0), + rq.RequestLength(), + rq.Card8('major_version'), + rq.Card8('minor_version'), + rq.Pad(2), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card8('major_version'), + rq.Card8('minor_version'), + rq.Pad(22), + ) + +def query_version(self): + return QueryVersion(display=self.display, + opcode=self.display.get_extension_major(extname), + major_version=1, + minor_version=0) + + +class QueryInfo(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(1), + rq.RequestLength(), + rq.Drawable('drawable'), + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Card8('state'), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Window('saver_window'), + rq.Card32('til_or_since'), + rq.Card32('idle'), + rq.Card32('event_mask'), # rq.Set('event_mask', 4, (NotifyMask, CycleMask)), + rq.Card8('kind'), + rq.Pad(10), + ) + +def query_info(self): + return QueryInfo(display=self.display, + opcode=self.display.get_extension_major(extname), + drawable=self, + ) + + +class SelectInput(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(2), + rq.RequestLength(), + rq.Drawable('drawable'), + rq.Card32('event_mask'), # rq.Set('event_mask', 4, (NotifyMask, CycleMask)), + ) + +def select_input(self, mask): + return SelectInput(display=self.display, + opcode=self.display.get_extension_major(extname), + drawable=self, + event_mask=mask, + ) + + +class SetAttributes(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(3), + rq.RequestLength(), + rq.Drawable('drawable'), + rq.Int16('x'), + rq.Int16('y'), + rq.Card16('width'), + rq.Card16('height'), + rq.Card16('border_width'), + rq.Set('window_class', 1, (X.CopyFromParent, X.InputOutput, X.InputOnly)), + rq.Card8('depth'), + rq.Card32('visual'), + structs.WindowValues('attrs'), + ) + +def set_attributes(self, x, y, width, height, border_width, + window_class = X.CopyFromParent, + depth = X.CopyFromParent, + visual = X.CopyFromParent, + onerror = None, + **keys): + return SetAttributes(display=self.display, + onerror = onerror, + opcode=self.display.get_extension_major(extname), + drawable=self, + x = x, + y = y, + width = width, + height = height, + border_width = border_width, + window_class = window_class, + depth = depth, + visual = visual, + attrs = keys) + + +class UnsetAttributes(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(4), + rq.RequestLength(), + rq.Drawable('drawable'), + ) + +def unset_attributes(self, onerror = None): + return UnsetAttributes(display=self.display, + onerror = onerror, + opcode=self.display.get_extension_major(extname), + drawable=self) + + +class Notify(rq.Event): + _code = None + _fields = rq.Struct( + rq.Card8('type'), + rq.Set('state', 1, (StateOff, StateOn, StateCycle)), + rq.Card16('sequence_number'), + rq.Card32('timestamp'), + rq.Window('root'), + rq.Window('window'), + rq.Set('kind', 1, (KindBlanked, KindInternal, KindExternal)), + rq.Bool('forced'), + rq.Pad(14), + ) + +def init(disp, info): + disp.extension_add_method('display', 'screensaver_query_version', query_version) + disp.extension_add_method('drawable', 'screensaver_query_info', query_info) + disp.extension_add_method('drawable', 'screensaver_select_input', select_input) + disp.extension_add_method('drawable', 'screensaver_set_attributes', set_attributes) + disp.extension_add_method('drawable', 'screensaver_unset_attributes', unset_attributes) + + disp.extension_add_event(info.first_event + 0, Notify) From e8cf018557470a2735315c8ba5327cfee8a8124f Mon Sep 17 00:00:00 2001 From: Dan Isla Date: Fri, 4 Feb 2022 08:14:20 +0000 Subject: [PATCH 257/279] XFixes: add support for XFixesCursorNotify --- Xlib/ext/xfixes.py | 61 ++++++++++++++++++++++++++- examples/xfixes-cursor-notify.py | 72 ++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 1 deletion(-) create mode 100755 examples/xfixes-cursor-notify.py diff --git a/Xlib/ext/xfixes.py b/Xlib/ext/xfixes.py index 5f2f6438..59f9277b 100644 --- a/Xlib/ext/xfixes.py +++ b/Xlib/ext/xfixes.py @@ -25,19 +25,23 @@ ShowCursor requests and SelectionNotify events are provided. ''' -from Xlib.protocol import rq +from Xlib import X +from Xlib.protocol import rq, structs extname = 'XFIXES' XFixesSelectionNotify = 0 +XFixesCursorNotify = 1 XFixesSetSelectionOwnerNotifyMask = (1 << 0) XFixesSelectionWindowDestroyNotifyMask = (1 << 1) XFixesSelectionClientCloseNotifyMask = (1 << 2) +XFixesDisplayCursorNotifyMask = (1 << 0) XFixesSetSelectionOwnerNotify = 0 XFixesSelectionWindowDestroyNotify = 1 XFixesSelectionClientCloseNotify = 2 +XFixesDisplayCursorNotify = 0 class QueryVersion(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), @@ -131,12 +135,67 @@ class SelectionClientCloseNotify(SelectionNotify): pass +class SelectCursorInput(rq.Request): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(3), + rq.RequestLength(), + rq.Window('window'), + rq.Card32('mask') + ) + +def select_cursor_input(self, window, mask): + return SelectCursorInput(opcode=self.display.get_extension_major(extname), + display=self.display, + window=window, + cursor_serial=0, + mask=mask) + + +class GetCursorImage(rq.ReplyRequest): + _request = rq.Struct(rq.Card8('opcode'), + rq.Opcode(4), + rq.RequestLength() + ) + _reply = rq.Struct(rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Int16('x'), + rq.Int16('y'), + rq.Card16('width'), + rq.Card16('height'), + rq.Card16('xhot'), + rq.Card16('yhot'), + rq.Card32('cursor_serial'), + rq.Pad(8), + rq.List('cursor_image', rq.Card32) + ) + +def get_cursor_image(self, window): + return GetCursorImage(opcode=self.display.get_extension_major(extname), + display=self.display, + ) + + +class DisplayCursorNotify(rq.Event): + _code = None + _fields = rq.Struct(rq.Card8('type'), + rq.Card8('sub_code'), + rq.Card16('sequence_number'), + rq.Window('window'), + rq.Card32('cursor_serial'), + rq.Card32('timestamp')) + + def init(disp, info): disp.extension_add_method('display', 'xfixes_select_selection_input', select_selection_input) disp.extension_add_method('display', 'xfixes_query_version', query_version) disp.extension_add_method('window', 'xfixes_hide_cursor', hide_cursor) disp.extension_add_method('window', 'xfixes_show_cursor', show_cursor) + disp.extension_add_method('display', 'xfixes_select_cursor_input', select_cursor_input) + disp.extension_add_method('display', 'xfixes_get_cursor_image', get_cursor_image) disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSetSelectionOwnerNotify, SetSelectionOwnerNotify) disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionWindowDestroyNotify, SelectionWindowDestroyNotify) disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionClientCloseNotify, SelectionClientCloseNotify) + disp.extension_add_subevent(info.first_event + XFixesCursorNotify, XFixesDisplayCursorNotify, DisplayCursorNotify) diff --git a/examples/xfixes-cursor-notify.py b/examples/xfixes-cursor-notify.py new file mode 100755 index 00000000..cc443fe9 --- /dev/null +++ b/examples/xfixes-cursor-notify.py @@ -0,0 +1,72 @@ +#!/usr/bin/python3 +# +# examples/xfixes-cursor-notify.py -- demonstrate the XFIXES extension +# CursorNotify event. +# +# Copyright (C) 2022 +# Dan Isla +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2.1 +# of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, +# Suite 330, +# Boston, MA 02111-1307 USA + +# Python 2/3 compatibility. +from __future__ import print_function + +import sys +from Xlib.display import Display +from Xlib.ext import xfixes + +def main(): + display = Display() + + if not display.has_extension('XFIXES'): + if display.query_extension('XFIXES') is None: + print('XFIXES extension not supported') + return 1 + + xfixes_version = display.xfixes_query_version() + print('Found XFIXES version {}.{}'.format( + xfixes_version.major_version, + xfixes_version.minor_version + )) + + screen = display.screen() + + display.xfixes_select_cursor_input(screen.root, xfixes.XFixesDisplayCursorNotifyMask) + + cursor_cache = {} + + while True: + e = display.next_event() + print(e) + + if (e.type, e.sub_code) == display.extension_event.DisplayCursorNotify: + print("DisplayCursorNotify: cursor_serial={}".format(e.cursor_serial)) + image = display.xfixes_get_cursor_image(screen.root) + cached = False + if cursor_cache.get(image.cursor_serial): + cached = True + else: + cursor_cache[image.cursor_serial] = image.cursor_image + + print("Cursor position={},{}, size={}x{}, xyhot={},{}, cursor_serial={}, cached={}".format( + image.x, image.y, image.width,image.height, image.xhot, image.yhot, image.cursor_serial, cached + )) + + +if __name__ == "__main__": + sys.exit(main()) From c53a13ff61a0eecef23819141a4cf182055f8b3f Mon Sep 17 00:00:00 2001 From: Eric Johnson Date: Mon, 6 Jun 2022 18:31:46 -0400 Subject: [PATCH 258/279] Fix screensaver protocol mismatch The protocol encoding specified in the X11 documentation differs from the actual XCB protocol that Xorg uses. This makes `query_version()` report the wrong version and `query_info()` fail by trying to unpack too many bytes. --- Xlib/ext/screensaver.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Xlib/ext/screensaver.py b/Xlib/ext/screensaver.py index 90fb68a6..12f4325c 100644 --- a/Xlib/ext/screensaver.py +++ b/Xlib/ext/screensaver.py @@ -64,9 +64,9 @@ class QueryVersion(rq.ReplyRequest): rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), - rq.Card8('major_version'), - rq.Card8('minor_version'), - rq.Pad(22), + rq.Card16('major_version'), + rq.Card16('minor_version'), + rq.Pad(20), ) def query_version(self): @@ -94,7 +94,7 @@ class QueryInfo(rq.ReplyRequest): rq.Card32('idle'), rq.Card32('event_mask'), # rq.Set('event_mask', 4, (NotifyMask, CycleMask)), rq.Card8('kind'), - rq.Pad(10), + rq.Pad(7), ) def query_info(self): From 0feed9097dc8f1012edd7dfe0c849def601b97d0 Mon Sep 17 00:00:00 2001 From: Peter Ye Date: Sun, 10 Jul 2022 22:12:41 -0400 Subject: [PATCH 259/279] Use archived link for X documentation resource --- doc/src/concepts.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/concepts.texi b/doc/src/concepts.texi index 8c9f08b0..d71f62fe 100644 --- a/doc/src/concepts.texi +++ b/doc/src/concepts.texi @@ -9,4 +9,4 @@ Here you might find an introduction to X concepts sometime in the future. For now, I just refer to the introduction parts of the standard X documentation. A vast collection of X documentation links can be -found at @uref{http://www.rahul.net/kenton/xsites.html}. +found at @uref{https://web.archive.org/web/20201228053920/http://www.rahul.net/kenton/xsites.html}. From 93b294742c77e7b92bfc685e3a3f8d1b481d8cf9 Mon Sep 17 00:00:00 2001 From: Majiir Paktu Date: Fri, 15 Jul 2022 21:42:13 -0400 Subject: [PATCH 260/279] xauth: fix for auth entry having no display number --- Xlib/xauth.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Xlib/xauth.py b/Xlib/xauth.py index 2ed7dd52..303bd491 100644 --- a/Xlib/xauth.py +++ b/Xlib/xauth.py @@ -120,6 +120,8 @@ def get_best_auth(self, family, address, dispno, matches = {} for efam, eaddr, enum, ename, edata in self.entries: + if enum == b'' and ename not in matches: + enum = num if efam == family and eaddr == address and num == enum: matches[ename] = edata From 75100a2fe0847753cbf51e41f1adeb14fe8cc20a Mon Sep 17 00:00:00 2001 From: allfro Date: Mon, 9 May 2022 17:03:00 -0400 Subject: [PATCH 261/279] Update rq.py Fixes return type inconsistency with the `pack_value` for class `Object`. When using an `Object` field embedded in a request `pack_value` croaks because it calls to_binary which returns a byte buffer instead of a 3-value tuple. This fix addresses the issue. --- Xlib/protocol/rq.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 86cb2def..8a0cd6b0 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -604,7 +604,8 @@ def parse_value(self, val, display): return self.type.parse_value(val, display) def pack_value(self, val): - return self.type.pack_value(val) + val = self.type.pack_value(val) + return val, len(val), None def check_value(self, val): if isinstance(val, tuple): From b1bc5624b79a7a02eca3287be71a7fa58e328ec5 Mon Sep 17 00:00:00 2001 From: allfro Date: Mon, 9 May 2022 17:16:32 -0400 Subject: [PATCH 262/279] Update randr.py Add version 1.5 support for RRSetMonitor RRGetMonitors and RRDeleteMonitors --- Xlib/ext/randr.py | 96 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 4 deletions(-) diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index 48f4b635..ba37d60c 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -25,7 +25,7 @@ This implementation is based off version 1.3 of the XRandR protocol, and may not be compatible with other versions. -Version 1.2 of the protocol is documented at: +Version 1.5 of the protocol is documented at: http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt Version 1.3.1 here: @@ -168,6 +168,19 @@ rq.Card32('matrix33'), ) +MonitorInfo = rq.Struct( + rq.Card32('name'), + rq.Bool('primary'), + rq.Bool('automatic'), + rq.LengthOf('crtcs', 2), + rq.Int16('x'), + rq.Int16('y'), + rq.Card16('width_in_pixels'), + rq.Card16('height_in_pixels'), + rq.Card32('width_in_millimeters'), + rq.Card32('height_in_millimeters'), + rq.List('crtcs', rq.Card32Obj) +) # Requests # @@ -197,7 +210,7 @@ def query_version(self): display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, - minor_version=3, + minor_version=5, ) @@ -1078,6 +1091,76 @@ def get_output_primary(self): ) +# Version 1.5 methods + +class GetMonitors(rq.ReplyRequest): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(42), + rq.RequestLength(), + rq.Window('window'), + rq.Bool('is_active'), + rq.Pad(3) + ) + + _reply = rq.Struct( + rq.ReplyCode(), + rq.Pad(1), + rq.Card16('sequence_number'), + rq.ReplyLength(), + rq.Card32('timestamp'), + rq.LengthOf('monitors', 4), + rq.Card32('outputs'), + rq.Pad(12), + rq.List('monitors', MonitorInfo) + ) + + +def get_monitors(self, is_active=True): + return GetMonitors( + display=self.display, + opcode=self.display.get_extension_major(extname), + window=self, + is_active=is_active + ) + +class SetMonitor(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(43), + rq.RequestLength(), + rq.Window('window'), + rq.Object('monitor_info', MonitorInfo) + ) + + +def set_monitor(self, monitor_info): + return SetMonitor( + display=self.display, + opcode=self.display.get_extension_major(extname), + window=self, + monitor_info=monitor_info + ) + + +class DeleteMonitor(rq.Request): + _request = rq.Struct( + rq.Card8('opcode'), + rq.Opcode(44), + rq.RequestLength(), + rq.Window('window'), + rq.Card32('name') + ) + + +def delete_monitor(self, name): + return DeleteMonitor( + display=self.display, + opcode=self.display.get_extension_major(extname), + window=self, + name=name + ) + # Events # class ScreenChangeNotify(rq.Event): @@ -1149,8 +1232,8 @@ class OutputPropertyNotify(rq.Event): rq.Card8('state'), rq.Pad(11), ) - - + + # Initialization # def init(disp, info): @@ -1186,6 +1269,11 @@ def init(disp, info): disp.extension_add_method('display', 'xrandr_get_panning', get_panning) disp.extension_add_method('display', 'xrandr_set_panning', set_panning) + # version 1.5 compatible + disp.extension_add_method('window', 'xrandr_get_monitors', get_monitors) + disp.extension_add_method('window', 'xrandr_set_monitor', set_monitor) + disp.extension_add_method('window', 'xrandr_delete_monitor', delete_monitor) + disp.extension_add_event(info.first_event + RRScreenChangeNotify, ScreenChangeNotify) # add RRNotify events (1 event code with 3 subcodes) disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_CrtcChange, CrtcChangeNotify) From b8835036e2be7c0deb46e66db4eb7564437c8fdb Mon Sep 17 00:00:00 2001 From: James Longmore Date: Sun, 11 Sep 2022 14:59:17 +1000 Subject: [PATCH 263/279] Address comments in python-xlib/python-xlib#224 --- Xlib/ext/randr.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index ba37d60c..d054de0e 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -22,7 +22,7 @@ """RandR - provide access to the RandR extension information. -This implementation is based off version 1.3 of the XRandR protocol, and may +This implementation is based off version 1.5 of the XRandR protocol, and may not be compatible with other versions. Version 1.5 of the protocol is documented at: @@ -1232,8 +1232,6 @@ class OutputPropertyNotify(rq.Event): rq.Card8('state'), rq.Pad(11), ) - - # Initialization # def init(disp, info): @@ -1269,17 +1267,20 @@ def init(disp, info): disp.extension_add_method('display', 'xrandr_get_panning', get_panning) disp.extension_add_method('display', 'xrandr_set_panning', set_panning) - # version 1.5 compatible - disp.extension_add_method('window', 'xrandr_get_monitors', get_monitors) - disp.extension_add_method('window', 'xrandr_set_monitor', set_monitor) - disp.extension_add_method('window', 'xrandr_delete_monitor', delete_monitor) - - disp.extension_add_event(info.first_event + RRScreenChangeNotify, ScreenChangeNotify) - # add RRNotify events (1 event code with 3 subcodes) - disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_CrtcChange, CrtcChangeNotify) - disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputChange, OutputChangeNotify) - disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputProperty, OutputPropertyNotify) - - #disp.extension_add_error(BadRROutput, BadRROutputError) - #disp.extension_add_error(BadRRCrtc, BadRRCrtcError) - #disp.extension_add_error(BadRRMode, BadRRModeError) + # If the server is running RANDR 1.5+, enable 1.5 compatible methods and events + version = query_version(disp) + if version.major_version == 1 and version.minor_version >= 5: + # version 1.5 compatible + disp.extension_add_method('window', 'xrandr_get_monitors', get_monitors) + disp.extension_add_method('window', 'xrandr_set_monitor', set_monitor) + disp.extension_add_method('window', 'xrandr_delete_monitor', delete_monitor) + + disp.extension_add_event(info.first_event + RRScreenChangeNotify, ScreenChangeNotify) + # add RRNotify events (1 event code with 3 subcodes) + disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_CrtcChange, CrtcChangeNotify) + disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputChange, OutputChangeNotify) + disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputProperty, OutputPropertyNotify) + + #disp.extension_add_error(BadRROutput, BadRROutputError) + #disp.extension_add_error(BadRRCrtc, BadRRCrtcError) + #disp.extension_add_error(BadRRMode, BadRRModeError) From 29d67c733a49c26956a9b0eed08f2a9fe98f315d Mon Sep 17 00:00:00 2001 From: James Longmore Date: Sat, 17 Sep 2022 11:08:14 +1000 Subject: [PATCH 264/279] Revert changes to rq.py --- Xlib/protocol/rq.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 8a0cd6b0..86cb2def 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -604,8 +604,7 @@ def parse_value(self, val, display): return self.type.parse_value(val, display) def pack_value(self, val): - val = self.type.pack_value(val) - return val, len(val), None + return self.type.pack_value(val) def check_value(self, val): if isinstance(val, tuple): From c87624dd6ec780417e2d32529976d65fed344045 Mon Sep 17 00:00:00 2001 From: James Longmore Date: Sat, 17 Sep 2022 11:11:18 +1000 Subject: [PATCH 265/279] Add Randr error classes and register them during init --- Xlib/ext/randr.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index d054de0e..256e3dee 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -34,6 +34,7 @@ """ +from tkinter import W from Xlib import X from Xlib.protocol import rq, structs @@ -122,6 +123,12 @@ BadRRCrtc = 1 BadRRMode = 2 +# Error classes # +class BadRROutputError(Exception): pass + +class BadRRCrtcError(Exception): pass + +class BadRRModeError(Exception): pass # Data Structures # @@ -1281,6 +1288,6 @@ def init(disp, info): disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputChange, OutputChangeNotify) disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_OutputProperty, OutputPropertyNotify) - #disp.extension_add_error(BadRROutput, BadRROutputError) - #disp.extension_add_error(BadRRCrtc, BadRRCrtcError) - #disp.extension_add_error(BadRRMode, BadRRModeError) + disp.extension_add_error(BadRROutput, BadRROutputError) + disp.extension_add_error(BadRRCrtc, BadRRCrtcError) + disp.extension_add_error(BadRRMode, BadRRModeError) From 5a7ebe72c4281b3f5f875223c312a220bdd524e4 Mon Sep 17 00:00:00 2001 From: Matt Alexander Date: Mon, 31 Oct 2022 16:43:11 -0500 Subject: [PATCH 266/279] Fix Issue 233: Rename `add_extension_error` method --- Xlib/display.py | 4 ++-- Xlib/ext/damage.py | 2 +- test/test_xlib_display.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Xlib/display.py b/Xlib/display.py index ead0185c..e0f7b5c8 100644 --- a/Xlib/display.py +++ b/Xlib/display.py @@ -340,8 +340,8 @@ def extension_add_subevent(self, code, subcode, evt, name = None): # extension dict maintained in the display object setattr(self.extension_event, name, (code,subcode)) - def add_extension_error(self, code, err): - """add_extension_error(code, err) + def extension_add_error(self, code, err): + """extension_add_error(code, err) Add an extension error. CODE is the numeric code, and ERR is the error class. diff --git a/Xlib/ext/damage.py b/Xlib/ext/damage.py index 0cde5ed0..60c56606 100644 --- a/Xlib/ext/damage.py +++ b/Xlib/ext/damage.py @@ -179,4 +179,4 @@ def init(disp, info): disp.extension_add_event(info.first_event + DamageNotifyCode, DamageNotify) - disp.add_extension_error(code=BadDamageCode, err=BadDamageError) + disp.extension_add_error(code=BadDamageCode, err=BadDamageError) diff --git a/test/test_xlib_display.py b/test/test_xlib_display.py index fb617a3a..61994617 100644 --- a/test/test_xlib_display.py +++ b/test/test_xlib_display.py @@ -87,7 +87,7 @@ def test_cannot_add_existing_font_method(self): self.assertRaises(AssertionError, self.display.extension_add_method, "font", "__init__", lambda x: x) def test_can_add_extension_error(self): - self.display.add_extension_error(1, Xlib.error.XError) + self.display.extension_add_error(1, Xlib.error.XError) self.assertEqual(self.display.display.error_classes[1], Xlib.error.XError) def test_keycode_to_keysym_for_invalid_index(self): From 333fbcbc93501c86d84a70d704746360ee640dff Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Tue, 1 Nov 2022 13:18:12 +0300 Subject: [PATCH 267/279] Update CHANGELOG, bump version to 0.32 --- CHANGELOG.md | 18 ++++++++++++++++++ Xlib/__init__.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b960a8d9..cac28024 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ NEWS for Python X Library +Version 0.32 +============ + +Bug Fixes +--------- + +- Use archived link for X documentation resource (thanks @yaxollum). +- Fix for auth entry having no display number (thanks @Majiir). +- Fix return type inconsistency with the `pack_value` for class `Object` (thanks @allfro). +- Rename `add_extension_error` method to `extension_add_error` (thanks @mattalexx). + +Extensions +-------------------- + +- screensaver: fix screensaver protocol mismatch (thanks @yut23). +- XRandr: add version 1.5 support for RRSetMonitor RRGetMonitors and RRDeleteMonitors (thanks @allfro and @jklong). + +--- Version 0.31 ============ diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 89473730..9db8beec 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 31) +__version__ = (0, 32) __version_extra__ = '' From 32fafd9c92fab359b85bf3460c8af8347cad4ed5 Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 4 Nov 2022 18:45:10 -0400 Subject: [PATCH 268/279] Removed unused imports --- Xlib/ext/composite.py | 1 - Xlib/ext/damage.py | 1 - Xlib/ext/dpms.py | 1 - Xlib/ext/randr.py | 2 +- Xlib/ext/record.py | 1 - Xlib/ext/xfixes.py | 3 +-- 6 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Xlib/ext/composite.py b/Xlib/ext/composite.py index 0e10b635..5909b31e 100644 --- a/Xlib/ext/composite.py +++ b/Xlib/ext/composite.py @@ -33,7 +33,6 @@ graphics. """ -from Xlib import X from Xlib.protocol import rq from Xlib.xobject import drawable diff --git a/Xlib/ext/damage.py b/Xlib/ext/damage.py index 60c56606..126d8507 100644 --- a/Xlib/ext/damage.py +++ b/Xlib/ext/damage.py @@ -22,7 +22,6 @@ from Xlib import X from Xlib.protocol import rq, structs -from Xlib.xobject import resource from Xlib.error import XError extname = 'DAMAGE' diff --git a/Xlib/ext/dpms.py b/Xlib/ext/dpms.py index 3ff9a246..20b570bc 100644 --- a/Xlib/ext/dpms.py +++ b/Xlib/ext/dpms.py @@ -27,7 +27,6 @@ Documentation: https://www.x.org/releases/X11R7.7/doc/xextproto/dpms.html ''' -from Xlib import X from Xlib.protocol import rq extname = 'DPMS' diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index 256e3dee..61ce727d 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -34,7 +34,7 @@ """ -from tkinter import W +W = "w" from Xlib import X from Xlib.protocol import rq, structs diff --git a/Xlib/ext/record.py b/Xlib/ext/record.py index bb53ec19..638a5b38 100644 --- a/Xlib/ext/record.py +++ b/Xlib/ext/record.py @@ -19,7 +19,6 @@ # Suite 330, # Boston, MA 02111-1307 USA -from Xlib import X from Xlib.protocol import rq extname = 'RECORD' diff --git a/Xlib/ext/xfixes.py b/Xlib/ext/xfixes.py index 59f9277b..8b3c35fe 100644 --- a/Xlib/ext/xfixes.py +++ b/Xlib/ext/xfixes.py @@ -25,8 +25,7 @@ ShowCursor requests and SelectionNotify events are provided. ''' -from Xlib import X -from Xlib.protocol import rq, structs +from Xlib.protocol import rq extname = 'XFIXES' From 1791c97c3470c19e0645de2d32bfbeb0212b9b4e Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 16 Nov 2022 13:45:42 -0500 Subject: [PATCH 269/279] Update Xlib/ext/randr.py --- Xlib/ext/randr.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index 61ce727d..4003c8af 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -34,7 +34,6 @@ """ -W = "w" from Xlib import X from Xlib.protocol import rq, structs From dd01cee066fa1fd37a146b29bc3686abbd85877d Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 16 Nov 2022 18:22:25 -0500 Subject: [PATCH 270/279] Update Xlib/ext/randr.py --- Xlib/ext/randr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/ext/randr.py b/Xlib/ext/randr.py index 4003c8af..9cbfe2da 100644 --- a/Xlib/ext/randr.py +++ b/Xlib/ext/randr.py @@ -35,7 +35,7 @@ from Xlib import X -from Xlib.protocol import rq, structs +from Xlib.protocol import rq extname = 'RANDR' From a9890197d9c65753462f3e2f505b5e3750bf8842 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 16 Nov 2022 18:24:42 -0500 Subject: [PATCH 271/279] Update xinerama.py --- Xlib/ext/xinerama.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Xlib/ext/xinerama.py b/Xlib/ext/xinerama.py index f0546707..dcb78b89 100644 --- a/Xlib/ext/xinerama.py +++ b/Xlib/ext/xinerama.py @@ -35,7 +35,6 @@ returns the state information - because that's what libXinerama does.""" -from Xlib import X from Xlib.protocol import rq, structs extname = 'XINERAMA' From cf11374a42c656f0bb691f2f49f9e4d0fe32bb5e Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 16 Nov 2022 18:29:12 -0500 Subject: [PATCH 272/279] Update rq.py --- Xlib/protocol/rq.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 86cb2def..c1eba34b 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -24,7 +24,6 @@ import traceback import struct from array import array -import types # Python 2/3 compatibility. from six import PY3, binary_type, byte2int, indexbytes, iterbytes From b091980a349fb32a2d96824f144d7131732c8158 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 16 Nov 2022 18:32:05 -0500 Subject: [PATCH 273/279] Update drawable.py --- Xlib/xobject/drawable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xlib/xobject/drawable.py b/Xlib/xobject/drawable.py index c36a9738..3a56f532 100644 --- a/Xlib/xobject/drawable.py +++ b/Xlib/xobject/drawable.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -from Xlib import X, Xatom, Xutil +from Xlib import X, Xatom from Xlib.protocol import request, rq # Other X resource objects From 06cd8219872d422baa5a926d2dea11579d2bc8ad Mon Sep 17 00:00:00 2001 From: Yasushi Itoh Date: Sun, 2 Jan 2022 10:04:33 +0900 Subject: [PATCH 274/279] Avoid to use fcntl module on some environments --- Xlib/support/unix_connect.py | 47 ++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/Xlib/support/unix_connect.py b/Xlib/support/unix_connect.py index c2261dae..bd690c18 100644 --- a/Xlib/support/unix_connect.py +++ b/Xlib/support/unix_connect.py @@ -23,23 +23,6 @@ import os import platform import socket - -# FCNTL is deprecated from Python 2.2, so only import it if we doesn't -# get the names we need. Furthermore, FD_CLOEXEC seems to be missing -# in Python 2.2. - -import fcntl - -if hasattr(fcntl, 'F_SETFD'): - F_SETFD = fcntl.F_SETFD - if hasattr(fcntl, 'FD_CLOEXEC'): - FD_CLOEXEC = fcntl.FD_CLOEXEC - else: - FD_CLOEXEC = 1 -else: - from FCNTL import F_SETFD, FD_CLOEXEC - - from Xlib import error, xauth @@ -93,11 +76,13 @@ def _get_tcp_socket(host, dno): s.connect((host, 6000 + dno)) return s + def _get_unix_socket(address): s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect(address) return s + def get_socket(dname, protocol, host, dno): assert protocol in SUPPORTED_PROTOCOLS try: @@ -127,11 +112,37 @@ def get_socket(dname, protocol, host, dno): raise error.DisplayConnectionError(dname, str(val)) # Make sure that the connection isn't inherited in child processes. - fcntl.fcntl(s.fileno(), F_SETFD, FD_CLOEXEC) + _ensure_not_inheritable(s) return s +def _ensure_not_inheritable(sock): + # According to PEP446, in Python 3.4 and above, + # it is not inherited in child processes by default. + # However, just in case, we explicitly make it non-inheritable. + # Also, we don't use the code like the following, + # because there would be no possibility of backporting to past versions. + # if sys.version_info.major == 3 and sys.version_info.minor >= 4: + # sock.set_inheritable(False) + # return + # We just check if the socket has `set_inheritable`. + if hasattr(sock, 'set_inheritable'): + sock.set_inheritable(False) + return + + # On Windows, + # Python doesn't support fcntl module because Windows doesn't have fcntl API. + # At least by not importing fcntl, we will be able to import python-xlib on Windows. + if platform.system() == 'Windows': + # so.. unfortunately, for Python 3.3 and below, on Windows, + # we can't make sure that the connection isn't inherited in child processes for now. + return + + import fcntl + fcntl.fcntl(sock.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC) + + def new_get_auth(sock, dname, protocol, host, dno): assert protocol in SUPPORTED_PROTOCOLS # Translate socket address into the xauth domain From 1127b311b3dce054eebc2deabc6f96b41310b92e Mon Sep 17 00:00:00 2001 From: Yasushi Itoh Date: Sun, 2 Jan 2022 17:40:10 +0900 Subject: [PATCH 275/279] Change a test behavior for unix_connect.get_socket --- test/test_unix_connect.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/test_unix_connect.py b/test/test_unix_connect.py index 7680ba5b..3199fa5f 100644 --- a/test/test_unix_connect.py +++ b/test/test_unix_connect.py @@ -72,8 +72,8 @@ def _get_socket(socket_type, raises, *params): def path_exists(returns, path): calls.append(('os.path.exists', path)) return returns - def fcntl(*args): - calls.append(('fcntl',) + args) + def ensure_not_inheritable(*args): + calls.append(('ensure_not_inheritable',) + args) for params, allow_unix, unix_addr_exists, allow_tcp, expect_connection_error, expected_calls in ( # Successful explicit TCP socket connection. (('tcp/host:6', None, 'host', 6), False, False, True, False, [ @@ -141,7 +141,7 @@ def fcntl(*args): partial(_get_socket, 'tcp', not allow_tcp)), \ patch('os.path.exists', partial(path_exists, unix_addr_exists)), \ - patch('fcntl.fcntl', fcntl): + patch('Xlib.support.unix_connect._ensure_not_inheritable', ensure_not_inheritable): del calls[:] if expect_connection_error: with self.assertRaises(DisplayConnectionError): @@ -149,9 +149,7 @@ def fcntl(*args): else: s = unix_connect.get_socket(*params) self.assertIsInstance(s, FakeSocket) - expected_calls.append(('fcntl', 42, - unix_connect.F_SETFD, - unix_connect.FD_CLOEXEC)) + expected_calls.append(('ensure_not_inheritable', s)) self.assertEqual(calls, expected_calls) From 9f406d4e50a4b947915739ea4e1068b78fd5910d Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 16 Nov 2022 19:22:09 -0500 Subject: [PATCH 276/279] Prefer `bool` over `Literal[0, 1, None]` --- Xlib/display.py | 8 ++++---- Xlib/error.py | 2 +- Xlib/protocol/display.py | 28 ++++++++++++++-------------- Xlib/protocol/rq.py | 20 ++++++++++---------- Xlib/xobject/drawable.py | 6 +++--- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Xlib/display.py b/Xlib/display.py index e0f7b5c8..87b9aa61 100644 --- a/Xlib/display.py +++ b/Xlib/display.py @@ -71,7 +71,7 @@ def __init__(self, *args, **keys): protocol_display.Display.__init__(self, *args, **keys) self._atom_cache = {} - def get_atom(self, atomname, only_if_exists=0): + def get_atom(self, atomname, only_if_exists=False): if atomname in self._atom_cache: return self._atom_cache[atomname] @@ -473,7 +473,7 @@ def rebind_string(self, keysym, newstring): ### X requests ### - def intern_atom(self, name, only_if_exists = 0): + def intern_atom(self, name, only_if_exists = False): """Intern the string name, returning its atom number. If only_if_exists is true and the atom does not already exist, it will not be created and X.NONE is returned.""" @@ -482,7 +482,7 @@ def intern_atom(self, name, only_if_exists = 0): only_if_exists = only_if_exists) return r.atom - def get_atom(self, atom, only_if_exists = 0): + def get_atom(self, atom, only_if_exists = False): """Alias for intern_atom, using internal cache""" return self.display.get_atom(atom, only_if_exists) @@ -501,7 +501,7 @@ def get_selection_owner(self, selection): selection = selection) return r.owner - def send_event(self, destination, event, event_mask = 0, propagate = 0, + def send_event(self, destination, event, event_mask = 0, propagate = False, onerror = None): """Send a synthetic event to the window destination which can be a window object, or X.PointerWindow or X.InputFocus. event is the diff --git a/Xlib/error.py b/Xlib/error.py index cb6d0d07..3b6e13f8 100644 --- a/Xlib/error.py +++ b/Xlib/error.py @@ -70,7 +70,7 @@ class XError(rq.GetAttrData, Exception): ) def __init__(self, display, data): - self._data, data = self._fields.parse_binary(data, display, rawdict = 1) + self._data, _ = self._fields.parse_binary(data, display, rawdict = True) def __str__(self): s = [] diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 56623c35..4bd939e9 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -214,7 +214,7 @@ def next_event(self): # Call send_and_recv, which will return when # something has occured - self.send_and_recv(event = 1) + self.send_and_recv(event = True) # Before looping around, lock the event queue against # modifications. @@ -240,7 +240,7 @@ def pending_events(self): # Make a send_and_recv pass, receiving any events self.send_recv_lock.acquire() - self.send_and_recv(recv = 1) + self.send_and_recv(recv = True) # Lock the queue, get the event count, and unlock again. self.event_queue_write_lock.acquire() @@ -252,7 +252,7 @@ def pending_events(self): def flush(self): self.check_for_error() self.send_recv_lock.acquire() - self.send_and_recv(flush = 1) + self.send_and_recv(flush = True) def close(self): self.flush() @@ -384,7 +384,7 @@ def close_internal(self, whom): self.socket_error_lock.release() - def send_and_recv(self, flush = None, event = None, request = None, recv = None): + def send_and_recv(self, flush = False, event = False, request = None, recv = False): """send_and_recv(flush = None, event = None, request = None, recv = None) Perform I/O, or wait for some other thread to do it for us. @@ -689,8 +689,8 @@ def parse_response(self, request): return self.parse_connection_setup() # Parse ordinary server response - gotreq = 0 - while 1: + gotreq = False + while True: if self.data_recv: # Check the first byte to find out what kind of response it is rtype = byte2int(self.data_recv) @@ -772,7 +772,7 @@ def parse_error_response(self, request): else: self.default_error_handler(e) - return 0 + return False def default_error_handler(self, err): @@ -937,7 +937,7 @@ def parse_connection_setup(self): # Only the ConnectionSetupRequest has been sent so far r = self.sent_requests[0] - while 1: + while True: # print 'data_send:', repr(self.data_send) # print 'data_recv:', repr(self.data_recv) @@ -946,7 +946,7 @@ def parse_connection_setup(self): # The full response haven't arrived yet if len(self.data_recv) < alen: - return 0 + return False # Connection failed or further authentication is needed. # Set reason to the reason string @@ -956,22 +956,22 @@ def parse_connection_setup(self): # Else connection succeeded, parse the reply else: x, d = r._success_reply.parse_binary(self.data_recv[:alen], - self, rawdict = 1) + self, rawdict = True) r._data.update(x) del self.sent_requests[0] self.data_recv = self.data_recv[alen:] - return 1 + return True else: # The base reply is 8 bytes long if len(self.data_recv) < 8: - return 0 + return False r._data, d = r._reply.parse_binary(self.data_recv[:8], - self, rawdict = 1) + self, rawdict = True) self.data_recv = self.data_recv[8:] # Loop around to see if we have got the additional data @@ -1066,7 +1066,7 @@ def __init__(self, display, *args, **keys): # Don't bother about locking, since no other threads have # access to the display yet - display.request_queue.append((self, 1)) + display.request_queue.append((self, True)) # However, we must lock send_and_recv, but we don't have # to loop. diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index c1eba34b..5fff5e77 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -118,7 +118,7 @@ class Field(object): check_value = None parse_value = None - keyword_args = 0 + keyword_args = False def __init__(self): pass @@ -723,7 +723,7 @@ def pack_value(self, value): class ValueList(Field): structcode = None - keyword_args = 1 + keyword_args = True default = 'usekeywords' def __init__(self, name, mask, pad, *fields): @@ -1088,7 +1088,7 @@ def pack_value(self, value): raise BadDataError('%s is not a tuple or a list' % (value)) - def parse_value(self, val, display, rawdict = 0): + def parse_value(self, val, display, rawdict = False): """This function is used by List and Object fields to convert Struct objects with no var_fields into Python values. @@ -1131,9 +1131,9 @@ def parse_value(self, val, display, rawdict = 0): return DictWrapper(ret) return ret - def parse_binary(self, data, display, rawdict = 0): + def parse_binary(self, data, display, rawdict = False): - """values, remdata = s.parse_binary(data, display, rawdict = 0) + """values, remdata = s.parse_binary(data, display, rawdict = False) Convert a binary representation of the structure into Python values. @@ -1354,16 +1354,16 @@ def _set_error(self, error): return 0 class ReplyRequest(GetAttrData): - def __init__(self, display, defer = 0, *args, **keys): + def __init__(self, display, defer = False, *args, **keys): self._display = display self._binary = self._request.to_binary(*args, **keys) self._serial = None - self._data = None + self._data = {} self._error = None self._response_lock = lock.allocate_lock() - self._display.send_request(self, 1) + self._display.send_request(self, True) if not defer: self.reply() @@ -1389,7 +1389,7 @@ def reply(self): def _parse_response(self, data): self._response_lock.acquire() - self._data, d = self._reply.parse_binary(data, self._display, rawdict = 1) + self._data, d = self._reply.parse_binary(data, self._display, rawdict = True) self._response_lock.release() def _set_error(self, error): @@ -1408,7 +1408,7 @@ def __init__(self, binarydata = None, display = None, if binarydata: self._binary = binarydata self._data, data = self._fields.parse_binary(binarydata, display, - rawdict = 1) + rawdict = True) # split event type into type and send_event bit self._data['send_event'] = not not self._data['type'] & 0x80 self._data['type'] = self._data['type'] & 0x7f diff --git a/Xlib/xobject/drawable.py b/Xlib/xobject/drawable.py index 3a56f532..f8e625f6 100644 --- a/Xlib/xobject/drawable.py +++ b/Xlib/xobject/drawable.py @@ -451,7 +451,7 @@ def delete_property(self, property, onerror = None): window = self.id, property = property) - def get_property(self, property, property_type, offset, length, delete = 0): + def get_property(self, property, property_type, offset, length, delete = False): r = request.GetProperty(display = self.display, delete = delete, window = self.id, @@ -516,7 +516,7 @@ def convert_selection(self, selection, target, property, time, onerror = None): property = property, time = time) - def send_event(self, event, event_mask = 0, propagate = 0, onerror = None): + def send_event(self, event, event_mask = 0, propagate = False, onerror = None): request.SendEvent(display = self.display, onerror = onerror, propagate = propagate, @@ -629,7 +629,7 @@ def set_input_focus(self, revert_to, time, onerror = None): focus = self.id, time = time) - def clear_area(self, x = 0, y = 0, width = 0, height = 0, exposures = 0, onerror = None): + def clear_area(self, x = 0, y = 0, width = 0, height = 0, exposures = False, onerror = None): request.ClearArea(display = self.display, onerror = onerror, exposures = exposures, From fdf873908ed300d4af685fe889079df0f5b7845f Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 18 Nov 2022 15:42:54 -0500 Subject: [PATCH 277/279] fix accidental data change --- Xlib/protocol/display.py | 2 +- Xlib/protocol/rq.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Xlib/protocol/display.py b/Xlib/protocol/display.py index 4bd939e9..0d910dab 100644 --- a/Xlib/protocol/display.py +++ b/Xlib/protocol/display.py @@ -402,7 +402,7 @@ def send_and_recv(self, flush = False, event = False, request = None, recv = Fal To wait for an event to be received, event should be true. To wait for a response to a certain request (either an error - or a response), request should be set the that request's + or a response), request should be set to that request's serial number. To just read any pending data from the server, recv should be true. diff --git a/Xlib/protocol/rq.py b/Xlib/protocol/rq.py index 5fff5e77..8bc82059 100644 --- a/Xlib/protocol/rq.py +++ b/Xlib/protocol/rq.py @@ -1358,7 +1358,7 @@ def __init__(self, display, defer = False, *args, **keys): self._display = display self._binary = self._request.to_binary(*args, **keys) self._serial = None - self._data = {} + self._data = None self._error = None self._response_lock = lock.allocate_lock() From b04e96a39b8ae0b82c52d0385d1edc1d8f96cb6a Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Thu, 15 Dec 2022 22:07:31 +0100 Subject: [PATCH 278/279] Change parentheses to brackets in LICENSE --- LICENSE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 19e30718..d762d815 100644 --- a/LICENSE +++ b/LICENSE @@ -6,9 +6,9 @@ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. -(This is the first released version of the Lesser GPL. It also counts +[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.) + the version number 2.1.] Preamble From 4e8bbf8fc4941e5da301a8b3db8d27e98de68666 Mon Sep 17 00:00:00 2001 From: Vasily Ryabov Date: Sun, 25 Dec 2022 21:49:10 +0300 Subject: [PATCH 279/279] Update CHANGELOG, bump version to 0.33 --- CHANGELOG.md | 14 ++++++++++++++ Xlib/__init__.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cac28024..74eb66b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ NEWS for Python X Library +Version 0.33 +============ + +Bug Fixes +--------- + +- Removed unused imports (thanks @Avasam). +- Avoid to use fcntl module on some environments (thanks @i2y). +- Change a test behavior for `unix_connect.get_socket` (thanks @i2y). +- Fix accidental data change (thanks @Avasam). +- Prefer `bool` over `Literal[0, 1, None]` (thanks @Avasam). +- Change parentheses to brackets in LICENSE (thanks @mtelka). + +--- Version 0.32 ============ diff --git a/Xlib/__init__.py b/Xlib/__init__.py index 9db8beec..28a0e017 100644 --- a/Xlib/__init__.py +++ b/Xlib/__init__.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -__version__ = (0, 32) +__version__ = (0, 33) __version_extra__ = ''