Giter Club home page Giter Club logo

mcstatus's People

Contributors

5igi0 avatar antonok-edm avatar b23r0 avatar christracy avatar coolcat467 avatar dinnerbone avatar dominique57 avatar fyssion avatar iapetus-11 avatar ikeviny avatar itsdrike avatar jamestheawesomedude avatar kevinkjt2000 avatar klemek avatar lgc2333 avatar meruslan avatar nramsbottom avatar pangeacake avatar preeded avatar shoghicp avatar thesadru avatar thewlr9 avatar ulidtko avatar urda avatar winny- avatar zeroflow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mcstatus's Issues

Why is the 'motd' called 'hostname' in the raw query output?

Consider the following:

from mcstatus import MinecraftServer

server = MinecraftServer.lookup("server.com")
query = server.query()

# query.raw contains:
{u'game_id': u'MINECRAFT',
 u'gametype': u'SMP',
 u'hostip': u'server.com',
 u'hostname': u"MOTD MOTD MOTD HERE",
 u'hostport': u'25565',
 u'map': u'world map',
 u'maxplayers': u'10',
 u'numplayers': u'2',
 u'plugins': u'',
 u'version': u'1.8'}

It's called 'hostname' when it should be titled 'motd' or something similar. Opening this issue now in case I don't patch it right away.

Cannot pickle mcstatus.pinger.PingResponse

Hi, I am not entirely certain what is going on here:

Python 3.4.2 (default, Oct 19 2014, 17:52:17)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle, mcstatus
>>> server = mcstatus.MinecraftServer('p.nerd.nu', 25565)
>>> result = server.status()
>>> pickle.dumps(result)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
_pickle.PicklingError: Can't pickle <class 'mcstatus.pinger.PingResponse.Players'>: attribute lookup Players on mcstatus.pinger failed

I originally found this through parallelizing server list pings using the multiprocessing module, with the following error (see the script here: https://gist.github.com/winny-/681fb7f8cf22ee23feb1/5841611b8d7a9d14b962a113c68bb5590834f7a6):

➜  mcstatus-py git:(master) python3 ~/Desktop/ping_servers.py
Traceback (most recent call last):
  File "/Users/winston/Desktop/ping_servers.py", line 98, in <module>
    main()
  File "/Users/winston/Desktop/ping_servers.py", line 80, in main
    for s in ping_servers_async(get_servers()):
  File "/Users/winston/Desktop/ping_servers.py", line 76, in ping_servers_async
    yield from pool.map(ping_server, servers)
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/multiprocessing/pool.py", line 260, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/multiprocessing/pool.py", line 599, in get
    raise self._value
multiprocessing.pool.MaybeEncodingError: Error sending result: '[PingResult(server=Server(name='Bytesadism', ip='minecraft.bytesadism.org', port=25565), status=<mcstatus.pinger.PingResponse object at 0x1044e2a90>, error=None)]'. Reason: 'PicklingError("Can't pickle <class 'mcstatus.pinger.PingResponse.Version'>: attribute lookup Version on mcstatus.pinger failed",)'

ImportError: cannot import name MinecraftServer

Not sure where to begin troubleshooting this, if this is just an issue with my environment configuration let me know and I can continue to troubleshoot my system.

Trying to execute this in a script results in the same error.

root@Aluminium:/home/bleon# python
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mcstatus
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mcstatus.py", line 1, in <module>
    from mcstatus import MinecraftServer
ImportError: cannot import name MinecraftServer
>>> from mcstatus import MinecraftServer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mcstatus.py", line 1, in <module>
    from mcstatus import MinecraftServer
ImportError: cannot import name MinecraftServer
>>>

however, running mcstatus from the command line works:

root@Aluminium:/home/bleon# mcstatus localhost status
version: v1.12.2 (protocol 340)
description: "{u'text': u'A Minecraft Server'}"
players: 0/20 No players online

Your Site Is Broken

Hey there,

Umm I don't really know how to put this, but the mcstatus instance on your website is broken. It only shows up for 1/4 of a second then dissapears. Tested on multiple computers and browsers without any plugins affecting your site.

socket.timeout: timed out

Whenever I try to run a query based on a minecraft server IP, I keep getting the error: "socket.timeout: timed out"

Here is the code I am using:
server = MinecraftServer.lookup('mc.charliecraft.com')
query = server.query()
print("The server has the following players online: {0}".format(", ".join(query.players.names)))

Here is the exact error I am getting:

Traceback (most recent call last):
  File "/mcstatus-master/run.py", line 5, in <module>
    query = server.query()
  File "/mcstatus-master/mcstatus/server.py", line 84, in query
    raise exception
  File "/mcstatus-master/mcstatus/server.py", line 79, in query
    querier.handshake()
  File "/mcstatus-master/mcstatus/querier.py", line 32, in handshake
    packet = self._read_packet()
  File "/mcstatus-master/mcstatus/querier.py", line 25, in _read_packet
    packet.receive(self.connection.read(self.connection.remaining()))
  File "/mcstatus-master/mcstatus/protocol/connection.py", line 172, in read
    result.extend(self.socket.recvfrom(self.remaining())[0])
socket.timeout: timed out

UDP socket.timeout: timed out

query = server.query()
Traceback (most recent call last):
  File "", line 1, in 
  File "mcstatus/server.py", line 74, in query
    raise exception
socket.timeout: timed out

The Ping and Status works fine, only the Query not.
When i test the same Adress with https://dinnerbone.com/minecraft/tools/status/, it shows also MOTD, Servericon, Software etc, so the Server is reachable and querys turned on there.

query() not working

I can't get the query() to work.
I have enable-query set to true.
I am just running the example code on the front page.

Traceback (most recent call last): File "C:/Users/User/Desktop/server_status.py", line 17, in <module> query = server.query() File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\mcstatus\server.py", line 82, in query raise exception File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\mcstatus\server.py", line 77, in query querier.handshake() File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\mcstatus\querier.py", line 32, in handshake packet = self._read_packet() File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\mcstatus\querier.py", line 25, in _read_packet packet.receive(self.connection.read(self.connection.remaining())) File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\mcstatus\protocol\connection.py", line 175, in read result.extend(self.socket.recvfrom(self.remaining())[0]) socket.timeout: timed out

Problem installing with pip.

I just attempted installing with pip, and got a missing module error in setup.py

(env)root@minecraft:/opt/minecraft# pip install mcstatus
Downloading/unpacking mcstatus
  Downloading mcstatus-2.0.zip
  Running setup.py egg_info for package mcstatus
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/opt/minecraft/env/build/mcstatus/setup.py", line 2, in <module>
        from six import PY2
    ImportError: No module named six
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/opt/minecraft/env/build/mcstatus/setup.py", line 2, in <module>

    from six import PY2

ImportError: No module named six

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /opt/minecraft/env/build/mcstatus
Storing complete log in /root/.pip/pip.log

I then installed six by itself, and mcstatus installed fine afterwards.

(env)root@minecraft:/opt/minecraft# pip install six
Downloading/unpacking six
  Downloading six-1.8.0.tar.gz
  Running setup.py egg_info for package six

    no previously-included directories found matching 'documentation/_build'
Installing collected packages: six
  Running setup.py install for six

    no previously-included directories found matching 'documentation/_build'
Successfully installed six
Cleaning up...
(env)root@minecraft:/opt/minecraft# pip install mcstatus
Downloading/unpacking mcstatus
  Downloading mcstatus-2.0.zip
  Running setup.py egg_info for package mcstatus

Requirement already satisfied (use --upgrade to upgrade): six in ./env/lib/python2.7/site-packages (from mcstatus)
Downloading/unpacking dnspython (from mcstatus)
  Downloading dnspython-1.12.0.zip (230kB): 230kB downloaded
  Running setup.py egg_info for package dnspython

Installing collected packages: mcstatus, dnspython
  Running setup.py install for mcstatus

  Running setup.py install for dnspython

Successfully installed mcstatus dnspython
Cleaning up...

My python version says 2.7.5+ (not sure what the + is for)

(env)root@minecraft:/opt/minecraft# python --version
Python 2.7.5+

I'm on Ubuntu 14.04.

Exception when trying to use the repository

I use MacOS Sierra

I downloaded the repository (with git clone https://github.com/Dinnerbone/mcstatus on the command line)
Then I included the few lines told in the main page of this repo in a js file meant to be a discord bot :
from /Users/*********/mcstatus import MinecraftServer;
And I get this error :

from /Users/*********/mcstatus import MinecraftServer;
                               ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:537:28)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)
    at Function.Module.runMain (module.js:609:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:598:3

I also have the node.js and discord.js files...
Can anyone explain me what this error means ? Being new to coding is quite hard...

[Errno 111] Connection refused

I get this error after installing it with pip and trying to run "test.py" which is a copy of the usage code.

Traceback (most recent call last):
File "test.py", line 7, in
status = server.status()
File "/home/urbanmc/.local/lib/python2.7/site-packages/mcstatus/server.py", line 49, in status
connection = TCPSocketConnection((self.host, self.port))
File "/home/urbanmc/.local/lib/python2.7/site-packages/mcstatus/protocol/connection.py", line 129, in init
self.socket = socket.create_connection(addr, timeout=timeout)
File "/usr/lib/python2.7/socket.py", line 575, in create_connection
raise err
socket.error: [Errno 111] Connection refused

query() Not functioning

I am trying to make a discord bot that pings minecraft servers. This is my code (which just so happens to be the example you provided)
# If you know the host and port, you may skip this and use MinecraftServer("example.org", 1234) server = MinecraftServer("doge.bitquest.co",25565) # 'status' is supported by all Minecraft servers that are version 1.7 or higher. status = server.status() print("The server has {0} players and replied in {1} ms".format(status.players.online, status.latency)) # 'ping' is supported by all Minecraft servers that are version 1.7 or higher. # It is included in a 'status' call, but is exposed separate if you do not require the additional info. latency = server.ping() print("The server replied in {0} ms".format(latency)) # 'query' has to be enabled in a servers' server.properties file. # It may give more information than a ping, such as a full player list or mod information. query = server.query() print("The server has the following players online: {0}".format(", ".join(query.players.names)))

And when I run this i get the following error
The server has 5 players and replied in 416.592 ms The server replied in 374.217 ms Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\super\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 307, in _run_event yield from getattr(self, event)(*args, **kwargs) File "C:\Users\super\Desktop\BOTPY\DogeBit\bot.py", line 104, in on_message query = server.query() File "C:\Users\super\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\server.py", line 82, in query raise exception File "C:\Users\super\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\server.py", line 77, in query querier.handshake() File "C:\Users\super\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\querier.py", line 32, in handshake packet = self._read_packet() File "C:\Users\super\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\querier.py", line 25, in _read_packet packet.receive(self.connection.read(self.connection.remaining())) File "C:\Users\super\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\protocol\connection.py", line 175, in read result.extend(self.socket.recvfrom(self.remaining())[0]) socket.timeout: timed out
The server is online, and has the query enabled in it's code.

Player list is missing from 'raw' output.

Consider the following:

from mcstatus import MinecraftServer

server = MinecraftServer.lookup("server.com")
query = server.query()

# query.raw contains:
{u'game_id': u'MINECRAFT',
 u'gametype': u'SMP',
 u'hostip': u'server.com',
 u'hostname': u"MOTD MOTD MOTD HERE",
 u'hostport': u'25565',
 u'map': u'world map',
 u'maxplayers': u'10',
 u'numplayers': u'2',
 u'plugins': u'',
 u'version': u'1.8'}

There's no player list in the raw output! Opening this issue now in case I don't patch it right away.

Exception when trying to check the status of a starting server in a while loop

Hey ho,

as the title already mentions, im trying to check the status of a starting minecraft server using a while-loop with server.status()

My log then shows the following exception:

AttributeError: 'TCPSocketConnection' object has no attribute 'socket' Exception ignored in: <bound method TCPSocketConnection.__del__ of <mcstatus.protocol.connection.TCPSocketConnection object at 0x7fb4005e1e10>> Traceback (most recent call last): File "/path/to/project/.venv/lib/python3.6/site-packages/mcstatus/protocol/connection.py", line 153, in __del__ self.socket.close()

If the server is up, it works. So it works if you request the server a single time, just not when trying to request it several times in a loop.
Any suggestions?

Time out on 1.8.8 server

Hi,

i'm trying to use mcstatus to query the player list of my minecraft server. Unfortunately, no matter what I try, it doesn't work:

Python 2.7.9 (default, Apr  2 2015, 15:33:21) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mcstatus
>>> server = mcstatus.MinecraftServer.lookup(myserverurl)
>>> server
<mcstatus.server.MinecraftServer instance at 0x7f5000eaa560>
>>> server.ping()
69.326
>>> q = server.query()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/mcstatus/server.py", line 82, in query
    raise exception
socket.timeout: timed out

Traceback:

Traceback:
File "/home/mathias/.local/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/mathias/Projects/mclobby/mclobby/views.py" in query
  26.         query = server.query()
File "/home/mathias/.local/lib/python3.4/site-packages/mcstatus/server.py" in query
  82.             raise exception
File "/home/mathias/.local/lib/python3.4/site-packages/mcstatus/server.py" in query
  77.                 querier.handshake()
File "/home/mathias/.local/lib/python3.4/site-packages/mcstatus/querier.py" in handshake
  32.         packet = self._read_packet()
File "/home/mathias/.local/lib/python3.4/site-packages/mcstatus/querier.py" in _read_packet
  25.         packet.receive(self.connection.read(self.connection.remaining()))
File "/home/mathias/.local/lib/python3.4/site-packages/mcstatus/protocol/connection.py" in read
  172.             result.extend(self.socket.recvfrom(self.remaining())[0])

The calls server.status() and server.ping() work just fine. Also on the example page http://dinnerbone.com/minecraft/tools/status/ I can query my server, presumably using the same code. Any idea what could be the problem?

server query issue

i am trying to make a python program where i get an email whenever certain people join the server, however when i try to query the server i get this error:

Traceback (most recent call last):
File "D:\Josh\Desktop\test1.py", line 5, in
query = server.query()
File "D:\Programs\python\lib\site-packages\mcstatus\server.py", line 82, in query
raise exception
File "D:\Programs\python\lib\site-packages\mcstatus\server.py", line 77, in query
querier.handshake()
File "D:\Programs\python\lib\site-packages\mcstatus\querier.py", line 32, in handshake
packet = self._read_packet()
File "D:\Programs\python\lib\site-packages\mcstatus\querier.py", line 25, in _read_packet
packet.receive(self.connection.read(self.connection.remaining()))
File "D:\Programs\python\lib\site-packages\mcstatus\protocol\connection.py", line 172, in read
result.extend(self.socket.recvfrom(self.remaining())[0])
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

additional info:
query is enabled in the server.properties
running vanilla minecraft
when using this site http://goo.gl/YRVYIQ i can see who is on the server just fine
i get the error on both my raspberry pi and pc

Doesn't respect DNS SRV records

You can user DNS SRV records to specify the port number Minecraft is running on. This enables you to run multiple servers on the same IP address, using subdomains, with each subdomain using a SRV record to specify the port number. Players then don't have to specify the port number when entering the subdomain address in their MineCraft client.

mcstatus doesn't seem to look up the port number in the SRV record.

Hanging on recieve

I have a small daemon that repeatedly gets the status of a list of servers to find out how many players they have online. The deamon is single-threaded and consists mostly of a loop and calls to mcstatus' MinecraftServer.status.

After running for a couple of hours, the daemon suddenly hangs, and the daemon process uses over 90% of the system CPU. The function that does the server calls is decorated by a @timeout_decorator.timeout(30), to prevent the whole app from stopping, but this doesn't work.

This is all running on Ubuntu 14.04.1 LTS, with mcstatus==2.0.

Here is the stack trace from when i do Ctrl + C to kill the daemon:

Traceback (most recent call last):
  File "loader.py", line 22, in <module>
    main()
  File "loader.py", line 13, in main
    do_ping(app, db)
  File "/var/www/PlayerCountGraph/env/src/timeout-decorator/timeout_decorator/timeout_decorator.py", line 46, in new_f
    result = f(*args, **kwargs)
  File "/var/www/PlayerCountGraph/playercountgraph/scheduler.py", line 15, in do_ping
    ping_server(db, server)
  File "/var/www/PlayerCountGraph/playercountgraph/scheduler.py", line 29, in ping_server
    players = new_ping(server)
  File "/var/www/PlayerCountGraph/playercountgraph/scheduler.py", line 45, in new_ping
    .online ## This is really a call like this: MinecraftServer..status().players.online
  File "/var/www/PlayerCountGraph/env/lib/python3.4/site-packages/mcstatus/server.py", line 57, in status
    result = pinger.read_status()
  File "/var/www/PlayerCountGraph/env/lib/python3.4/site-packages/mcstatus/pinger.py", line 34, in read_status
    response = self.connection.read_buffer()
  File "/var/www/PlayerCountGraph/env/lib/python3.4/site-packages/mcstatus/protocol/connection.py", line 115, in read_buffer
    length = self.read_varint()
  File "/var/www/PlayerCountGraph/env/lib/python3.4/site-packages/mcstatus/protocol/connection.py", line 44, in read_varint
    part = ord(self.read(1))
  File "/var/www/PlayerCountGraph/env/lib/python3.4/site-packages/mcstatus/protocol/connection.py", line 143, in read
    result.extend(self.socket.recv(length - len(result)))
KeyboardInterrupt

From the stack trace, it seems the freezing/hanging happens in mcstatus. Is there any fix that could be applied to mcstatus, or a work around I could use?

ReferenceError: Recaptcha is not defined (site shows nothing)

Heya,

In chrome and firefox, I get the following error in the console. and all elements on the page disappear. I can't run the query check.

recaptcha_ajax.js:1 Failed to load resource: the server responded with a status of 404 ()
angular-recaptcha.min.js:7 Uncaught ReferenceError: Recaptcha is not defined
at angular-recaptcha.min.js:7
angular.js:10573 Error: [$injector:unpr] http://errors.angularjs.org/1.3.0-rc.0/$injector/unpr?p0=vcRecaptchaServiceProvider%20%3C-%20vcRecaptchaService
at angular.js:38
at angular.js:3925
at Object.d [as get] (angular.js:4058)
at angular.js:3930
at d (angular.js:4058)
at Object.e [as invoke] (angular.js:4090)
at B.instance (angular.js:7712)
at angular.js:6991
at r (angular.js:340)
at A (angular.js:6990)

Ping server sends duplicate handshakes

9340ab4 Introduces a bug where handshakes are sent multiple times. This is invalid because the handshakes are not lost, as this is a tcp commection, and this causes an invalid packet to be sent.

Socket Timeout

Hi there. I just installed mcstatus 2.2.1 on my raspberry pi using pip. I can successfully run ping and status on my Minecraft Server (1.14.3) with results. When I run query I get a socket timeout. Below is there error.

$ mcstatus 192.168.1.150 query Traceback (most recent call last):   File "/usr/local/bin/mcstatus", line 11, in <module>     sys.exit(cli())   File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 764, in __call__     return self.main(*args, **kwargs)   File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 717, in main     rv = self.invoke(ctx)   File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke     return _process_result(sub_ctx.command.invoke(sub_ctx))   File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 956, in invoke     return ctx.invoke(self.callback, **ctx.params)   File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 555, in invoke     return callback(*args, **kwargs)   File "/usr/local/lib/python2.7/dist-packages/mcstatus/scripts/mcstatus.py", line 79, in query     response = server.query()   File "/usr/local/lib/python2.7/dist-packages/mcstatus/server.py", line 82, in query     raise exception socket.timeout: timed out

Ports > 32767 do not work

If the port used to connect to/lookup a server is not less than or equal to 32767, mcstatus will error.

Traceback:

----> 1 test.status()

C:\Python34\lib\site-packages\mcstatus\server.py in status(self, retries, **kwargs)
     61                 exception = e
     62                 attempt += 1
---> 63         raise exception
     64
     65     def query(self, retries=3):

C:\Python34\lib\site-packages\mcstatus\server.py in status(self, retries, **kwargs)
     54             try:
     55                 pinger = ServerPinger(connection, host=self.host, port=self.port, **kwargs)
---> 56                 pinger.handshake()
     57                 result = pinger.read_status()
     58                 result.latency = pinger.test_ping()

C:\Python34\lib\site-packages\mcstatus\pinger.py in handshake(self)
     22         packet.write_varint(self.version)
     23         packet.write_utf(self.host)
---> 24         packet.write_short(self.port)
     25         packet.write_varint(1)  # Intention to query status
     26

C:\Python34\lib\site-packages\mcstatus\protocol\connection.py in write_short(self, value)
     80
     81     def write_short(self, value):
---> 82         self.write(self._pack("h", value))
     83
     84     def read_ushort(self):

C:\Python34\lib\site-packages\mcstatus\protocol\connection.py in _pack(self, format, data)
     37
     38     def _pack(self, format, data):
---> 39         return struct.pack(">" + format, data)
     40
     41     def read_varint(self):

error: 'h' format requires -32768 <= number <= 32767

AttributeError: 'TCPSocketConnection' object has no attribute 'socket'

Exception ignored in: <bound method TCPSocketConnection.del of <mcstatus.protocol.connection.TCPSocketConnection object at 0x7fb1991eccc0>>
Traceback (most recent call last):
File "/root/Factions-Discord-Bot/Factions-Discord-Bot/mcstatus/protocol/connection.py", line 153, in del
self.socket.close()
AttributeError: 'TCPSocketConnection' object has no attribute 'socket'
Exception ignored in: <bound method TCPSocketConnection.del of <mcstatus.protocol.connection.TCPSocketConnection object at 0x7fb19878e208>>
Traceback (most recent call last):
File "/root/Factions-Discord-Bot/Factions-Discord-Bot/mcstatus/protocol/connection.py", line 153, in del
self.socket.close()
AttributeError: 'TCPSocketConnection' object has no attribute 'socket'

more docu for installing it

i want more info on how to install and use this handy tool
sins i dont know how i need to get this to work in my website

Hiding server player list

When using the query on my server, I get the message "Unfortunately, this server is hiding their player list.". All the other information loads normally.
How do I un-hide the player list on my server?

Settings in server.properties:
enable-query=true

Minecraft version:
1.7.10

Query consistently times out

Tested on multiple servers both on 1.12 and 1.13, using the command line tool after installing it through pip.

Traceback (most recent call last):
  File "C:\Python27\Scripts\mcstatus-script.py", line 11, in <module>
    load_entry_point('mcstatus==2.2', 'console_scripts', 'mcstatus')()
  File "c:\python27\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\python27\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\python27\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python27\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\python27\lib\site-packages\mcstatus\scripts\mcstatus.py", line 79, in query
    response = server.query()
  File "c:\python27\lib\site-packages\mcstatus\server.py", line 82, in query
    raise exception
socket.timeout: timed out

The ping and status protocols do work as expected, and I am able to join both servers in-game.

No updates?

I can see in the contribution history that @Dinnerbone is active on github, yet there are 4 easy to merge pull requests waiting.. what's going on? :/

UnicodeEncodeError mcstatus.py", line 83, in query click.echo("motd: \"{}\"".format(response.motd))

C:\Python27\Scripts>mcstatus mc.nigeltodman.com status
version: v17w17b (protocol 325)
description: "{u'text': u'\xa7l\xa7a[17w17b]\xa7r \xa7eVanilla Survival 1.12 (Snapshot) by \xa7cNigelTodman.com'}"
players: 0/100 No players online
C:\Python27\Scripts>mcstatus mc.nigeltodman.com query
host: mc.nigeltodman.com:25565
software: v17w17b vanilla
plugins: []
Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\mcstatus.exe\__main__.py", line 9, in <module>
  File "c:\python27\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\python27\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\python27\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python27\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\python27\lib\site-packages\mcstatus\scripts\mcstatus.py", line 83, in query
    click.echo("motd: \"{}\"".format(response.motd))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa7' in position 0: ordinal not in range(128)

Not working after a while.

Exception in command 'players'
Traceback (most recent call last):
  File "C:\Users\gameserver\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 62, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "C:\Users\gameserver\Desktop\Derps-Testing-Droid\cogs\players\players.py", line 20, in players
    ozquery = ozserver.query()
  File "C:\Users\gameserver\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\server.py", line 82, in query
    raise exception
  File "C:\Users\gameserver\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\server.py", line 77, in query
    querier.handshake()
  File "C:\Users\gameserver\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\querier.py", line 30, in handshake
    self.connection.write(self._create_packet(self.PACKET_TYPE_CHALLENGE))
  File "C:\Users\gameserver\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\protocol\connection.py", line 181, in write
    self.socket.sendto(data, self.addr)
socket.gaierror: [Errno 11001] getaddrinfo failed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\gameserver\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\bot.py", line 886, in invoke
    yield from ctx.command.invoke(ctx)
  File "C:\Users\gameserver\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 514, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\gameserver\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 71, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: gaierror: [Errno 11001] getaddrinfo failed

I got this error after a bit Code:

import discord
from discord.ext import commands
from discord import utils
from mcstatus import MinecraftServer
import asyncio

class players:
    """Get the player count and display the data"""


    @commands.command(name="players")
    async def players(self, ctx):

        dwserver = MinecraftServer.lookup("direwolf.forgottenmc.net:25565")
        dwquery = dwserver.query()
        dwplayers = dwquery.players.online

        djserver = MinecraftServer.lookup("divine.forgottenmc.net:25565")
        djquery = djserver.query()
        djplayers = djquery.players.online

        ozserver = MinecraftServer.lookup("divine.forgottenmc.net:25565")
        ozquery = ozserver.query()
        ozplayers = ozquery.players.online

        vaserver = MinecraftServer.lookup("divine.forgottenmc.net:25565")
        vaquery = vaserver.query()
        vaplayers = vaquery.players.online


        embed = discord.Embed(title="Currently online", description="-----------------------", color=0xffffff)
        embed.add_field(name="Direwolf20: ", value=dwplayers)
        embed.add_field(name="Divine Journey: ", value=djplayers)
        embed.add_field(name="Ozone 2: ", value=ozplayers)
        embed.add_field(name="Vanilla: ", value=vaplayers)
        await ctx.send(embed=embed)


Better API to query/ping/status

Per #13 (Thanks @urda):
server.ping() - ONLY returns the ping value of the server
server.query() - This gets a full query about the server
server.status() - This gets a quick status about the server (also including ping)

[Feature Request] Async

It would be cool to be able to use this together with asyncio, to be able to gather info about servers for a Discord bot for example :)

How can I get plugins list without versions?

Now when I check minecraft server with query.software.plugins I get a list with versions:
WorldBorder 1.6.0,MultiWorld 2.9.0,AutomaticPrivates 1,Fix_bugs 0.1,WorldEdit 1141-2ed92da,PlgSetspawn 5.0,CreativeGates 1.4,ColoredSigns 4.1,FullJoinVip 1.0,RandomChestCmd 2.3.0,PlayerServer Information 1.0,PermissionsEx 1.20.4,AntiRelog 2.5.0,TP_RG_kot525 0.1,WorldGuard 5.7.1,OtkatPlagin 0.1,InversionTimeWorld 0.1,FixedIS_kot525 0.1,AutoMessage 2.3.1,iConomy 7.0,bonus_kot525 1,LogKot525 0.1,LokiBlocker 0.5.2,ShoppingRG_kot525 0.1,OpenInv 2.0.8,ChestShop 3.5,FirstJoinPlus 1.8.2,ProtocolLib 3.1.2,AutoSaveWorld 3.6,ProMessage_Kot525 0.1,Essentials 2.9.6,ChatManager 1.19.1,NoCheatPlus 3.11.1-RC-sMD5NET-b743,ChatGuard 5.8

How can I get plugins list without versions? Is it possible?

ImportError: No module named 'dns'

Using Python 3.4 on Raspberry Pi
When importing the module, I get the following error:

Traceback (most recent call last):
File "/home/pi/Python/conn/mcserver.py", line 1, in
from mcstatus import MinecraftServer
File "/home/pi/Python/conn/mcstatus/init.py", line 1, in
from mcstatus.server import MinecraftServer
File "/home/pi/Python/conn/mcstatus/server.py", line 4, in
import dns.resolver
ImportError: No module named 'dns'

What is the 'dns' module shown here?

Error when importing.

When I run "from mcstatus import MinecraftServer", it says:
"ImportError: No module named 'six'"

Does not work with 1.6.4 or below servers

Trying to set this up for a group of modded servers I'm developing for. It looks as if I cannot check the status of, or query a 1.6 or below server.

1.7+ Servers work perfectly
1.6 Servers timeout, on both a .status(), and a .query()
1.5 Servers do not respond to either, resulting in a IOError

My test results:

Updating Servers...
   - inf.brierie.co
   - dw20.brierie.co
   - horizons.brierie.net
   - departed.brierie.net
   - cloud9.brierie.co
   - mc.brierie.co
   - monster.brierie.co
     - socket.timeout
   - lite3.brierie.net
   - ultimate.brierie.co
     - IOError
   - horizons.brierie.co
     - socket.timeout
   - tw2.brierie.co
     - socket.timeout
   - regrowth.brierie.net
   - sf2.brierie.net
   - skyblock.brierie.co
   - tppi.brierie.co
     - IOError

Update the pypi build

The pypi/pip build setup.py still requires Six, meaning it will fail to install unless you separately install Six beforehand

Animated MOTDs result in errors.

I know it's not a proper part of the MOTD spec, but a lot of servers now are using "animated" MOTDs. As long as minecraft itself "supports" them, MCStatus should be able to at least get the first frame from an animated MOTD.

Python 3.3.2 - TypeError: can't concat bytes to str

Traceback (most recent call last):
File "test.py", line 8, in
print("Players: %s" % query.get_status()['numplayers'])
File "/home/tak/git/mcstatus/minecraft_query.py", line 67, in get_status
self.handshake()
File "/home/tak/git/mcstatus/minecraft_query.py", line 48, in handshake
self.send_packet(self.PACKET_TYPE_CHALLENGE)
File "/home/tak/git/mcstatus/minecraft_query.py", line 39, in send_packet
self.send_raw(struct.pack('>B', type) + self.id_packed + self.challenge_packed + data)
TypeError: can't concat bytes to str

Add simple CLI For checking server status

I thought it would be useful to add a simple command-line script for checking the status of a server.

Something like:

$ mcstatus server 25599

There are 2 users online.

query = server.query() throws socket.timeout: timed out

I'm trying to make a code to get notified when my friends come online on a server but apparently server.query() doesn't work?

from mcstatus import MinecraftServer
import time

ip = input("IP: ")
port = int(input("PORT: "))

server = MinecraftServer(ip, port)

while True:
    try:
        ping = server.status().latency
        print(f"PING: {ping}")
    except Exception as e:
        print(f"ERROR_PING: {str(e)}")

    try:
        query = server.query()
        print(f"PLAYERS: {query.players.names}")
    except Exception as e:
        print(f"ERROR_PLAYERS: {str(e)}")

    print("==========")
    time.sleep(10)

I used the ping to prove the server is running (the ping was pretty bad tbh, 367.996) but then query = server.query() throwed socket.timeout: timed out

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    server.query()
  File "C:\Users\kiron\AppData\Local\Programs\Python\Python37\lib\site-packages\mcstatus\server.py", line 82, in query
    raise exception
  File "C:\Users\kiron\AppData\Local\Programs\Python\Python37\lib\site-packages\mcstatus\server.py", line 77, in query
    querier.handshake()
  File "C:\Users\kiron\AppData\Local\Programs\Python\Python37\lib\site-packages\mcstatus\querier.py", line 32, in handshake
    packet = self._read_packet()
  File "C:\Users\kiron\AppData\Local\Programs\Python\Python37\lib\site-packages\mcstatus\querier.py", line 25, in _read_packet
    packet.receive(self.connection.read(self.connection.remaining()))
  File "C:\Users\kiron\AppData\Local\Programs\Python\Python37\lib\site-packages\mcstatus\protocol\connection.py", line 178, in read
    result.extend(self.socket.recvfrom(self.remaining())[0])
socket.timeout: timed out

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.