GithubHelp home page GithubHelp logo

jaredballou / python-valve Goto Github PK

View Code? Open in Web Editor NEW

This project forked from serverstf/python-valve

0.0 2.0 0.0 322 KB

A Python Interface to various Valve products and services

License: Other

Python 100.00%

python-valve's Introduction

python-valve

python-valve is a Python library which intends to provide an all-in-one interface to various Valve products and services, including:

  • Steam web API
  • Local Steam Clients
  • Source servers
    • A2S server queries
    • RCON
  • Source master server
  • Valve Data Format (.vdf) (de)serialiser

RCON Example

In this example we connect to a Source servers remote console and issue a simple echo command to it.

from valve.source.rcon import RCON

SERVER_ADDRESS = ("...", 27015)
PASSWORD = "top_secret"

with RCON(SERVER_ADDRESS, PASSWORD) as rcon:
    print(rcon("echo Hello, world!"))

Server Query Example

In this example we demonstrate the Source master server and A2S query implementations by listing all Team Fortress 2 servers in Europe and Asia running the map ctf_2fort along with the players on each server sorted by their score.

import valve.source.a2s
import valve.source.master_server

msq = valve.source.master_server.MasterServerQuerier()
try:
    for address in msq.find(region=[u"eu", u"as"],
                            gamedir=u"tf",
                            map=u"ctf_2fort"):
        server = valve.source.a2s.ServerQuerier(address)
        info = server.info()
        players = server.players()

        print "{player_count}/{max_players} {server_name}".format(**info)
        for player in sorted(players["players"],
                             key=lambda p: p["score"], reverse=True):
            print "{score} {name}".format(**player)
except valve.source.a2s.NoResponseError:
    print "Master server request timed out!"

Testing

python-valve uses py.test for running its test suite as well as using Jenkins CI to actively test the A2S implementation against thousands of servers. See http://servers.tf:8080/.

Documentation

Documentation is hosted on read the docs at http://python-valve.readthedocs.org/.

Python 3

Currently there is partial support for Python 3 -- 3.4 to be specific. Everything in valve.source will/should work in both Python 2.7 and Python 3.4 but currently that is the only section that has been ported. The rest will be updated in due course but those other components need reworking anyway.

python-valve's People

Contributors

holiverh avatar fantoms avatar melbaa avatar fizzadar avatar wastrachan avatar

Watchers

James Cloos avatar Jared Ballou avatar

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.