Repository: gameservermanagers/linuxgsm
Issue: [gsquery] TypeError

After a fresh installation of a TeamFortress2 server, I was not able to monitor it :

``` sh
[testlgsm@myserver:~/TF2]$ ./tf2server start
[  OK  ] Starting tf2-server: Test Server LGSM
[testlgsm@myserver:~/TF2]$ ./tf2server monitor
[  OK  ] Monitor tf2-server: Checking session: OK
[ FAIL ] Monitor tf2-server: Querying port: 10.240.0.1:27015 : 0/1 : Traceback (most recent call last):
  File "/home/testlgsm/TF2/lgsm/functions/gsquery.py", line 125, in <module>
    server.responding()
  File "/home/testlgsm/TF2/lgsm/functions/gsquery.py", line 61, in responding
    connection.send( self.query_prompt_string )
...
[ FAIL ] Monitor tf2-server: Querying port: 10.240.0.1:27015 : 3/1 : Traceback (most recent call last):
  File "/home/testlgsm/TF2/lgsm/functions/gsquery.py", line 125, in <module>
    server.responding()
  File "/home/testlgsm/TF2/lgsm/functions/gsquery.py", line 61, in responding
    connection.send( self.query_prompt_string )
```

I patched it by adding a b in front of the query strings in gsquery.py :

``` python
       self.query_prompt_string = b'\\xFF\\xFF\\xFF\\xFFTSource Engine Query\\0'
elif self.option.engine == 'goldsource':
       self.query_prompt_string = b'\\xFF\\xFF\\xFF\\xFFTSource Engine Query\\0'
       ...
elif self.option.engine == 'avalanche':
       self.query_prompt_string = b'\\xFE\\xFD\\x09\\x10\\x20\\x30\\x40'
```

I am using python 3.5.2.
Is it really an issue, should I send a Pull-Request of this small fix ?

Best regards, Mathieu


Changed files:
lgsm/functions/gsquery.py

diff --git a/lgsm/functions/gsquery.py b/lgsm/functions/gsquery.py
index 8102e28a..76d5478d 100644
--- a/lgsm/functions/gsquery.py
+++ b/lgsm/functions/gsquery.py
@@ -18,23 +18,23 @@ class GameServer:
 		self.default_buffer_length = 1024
 		#
 		if self.option.engine == 'source':
-			self.query_prompt_string = '\\xFF\\xFF\\xFF\\xFFTSource Engine Query\\0'
+			self.query_prompt_string = b'\\xFF\\xFF\\xFF\\xFFTSource Engine Query\\0'
 		elif self.option.engine == 'goldsource':
-			self.query_prompt_string = '\\xFF\\xFF\\xFF\\xFFTSource Engine Query\\0'
+			self.query_prompt_string = b'\\xFF\\xFF\\xFF\\xFFTSource Engine Query\\0'
 		elif self.option.engine == 'spark':
-			self.query_prompt_string = '\\xFF\\xFF\\xFF\\xFFTSource Engine Query\\0'
+			self.query_prompt_string = b'\\xFF\\xFF\\xFF\\xFFTSource Engine Query\\0'
 		elif self.option.engine == 'realvirtuality':
-			self.query_prompt_string = '\\xFF\\xFF\\xFF\\xFFTSource Engine Query\\0'
+			self.query_prompt_string = b'\\xFF\\xFF\\xFF\\xFFTSource Engine Query\\0'
 		elif self.option.engine == 'unity3d':
 			self.query_prompt_string = '\\xFF\\xFF\\xFF\\xFFTSource Engine Query\\0'
 		elif self.option.engine == 'idtech3':
-			self.query_prompt_string = '\\xFF\\xFF\\xFF\\xFFTSource Engine Query\\0'			
+			self.query_prompt_string = b'\\xFF\\xFF\\xFF\\xFFTSource Engine Query\\0'			
 		elif self.option.engine == 'unreal':
-			self.query_prompt_string = '\\x5C\\x69\\x6E\\x66\\x6F\\x5C'
+			self.query_prompt_string = b'\\x5C\\x69\\x6E\\x66\\x6F\\x5C'
 		elif self.option.engine == 'unreal2':
-			self.query_prompt_string = '\\x79\\x00\\x00\\x00\\x00'
+			self.query_prompt_string = b'\\x79\\x00\\x00\\x00\\x00'
 		elif self.option.engine == 'avalanche':
-			self.query_prompt_string = '\\xFE\\xFD\\x09\\x10\\x20\\x30\\x40'
+			self.query_prompt_string = b'\\xFE\\xFD\\x09\\x10\\x20\\x30\\x40'
 		self.connected = False
 		self.response = None
 		self.sanity_checks()