Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: SACNR Monitor Python API (By PBomb)

  1. #1
    Donating Player PBomb's Avatar
    Join Date
    Jun 2012
    Location
    Wellington, NZ
    Posts
    62
    Rep Power
    1

    Post PySACNRMonitor (Python) - UPDATED FOR PYTHON 3.0+

    PySACNRMonitor (Python)
    By PBomb

    Description:

    This Python Module allows for easier access to the SACNR Monitor's API.
    The module connects to SACNR Monitor's API via HTTP. This is slightly
    different to Blacklite's PHP API, so please, look over the module and example
    source code to understand it better.

    NOTE: That the version for Python 2.7 and Python 3.0+ are slightly different in
    terms of how they return data and deal with errors. Please be aware of that.

    Classes, Functions & Methods:

    Class - Initialisation

    SACNRMonitor(string/int serverID)
    SACNRMonitor(string IP, string/int Port)

    Methods:

    PYTHON 2.7: All Methods return a dictionary containing the requested data AS WELL AS keys named 'response' and 'response_message'.
    'response' returns boolean. True if request was successful or False if not successful. 'response_message' returns string and
    will display the success/error message.


    PYTHON 3.0+: All Methods return either a dictionary or a list of the corresponding data requested. If an error occurs when retrieving the data an 'IOError' is raised.

    SACNRMonitor::get_info() - Returns a Dictionary of Server Information
    SACNRMonitor::get_players() - Returns list of dictionaries. Each dictionary contains information on each player's information (such as player name, ID, ping & score)
    SACNRMonitor::get_query() - Returns a list of dictionaries. Each dictionary contains a timestamp and the number of players online at the time.
    SACNRMonitor::get_ad() - Returns Dictionary Object of Server Ad Information

    Functions (Outside of Class):

    check_api_status() - Returns Boolean. True if API is available, otherwise False.

    Zip File Contains:

    • SACNRMonitor.py - The main module
    • SACNRMonitor-example.py - The example code on how to use SACNRMonitor.py
    • README - Explains a few things, including how to install
    • LICENSE - GPLv3 License file


    Downloads:

    For Python 2.7
    For Python 3.0+
    Last edited by PBomb; 19-07-2015 at 06:14 AM. Reason: Updated for Python 3.0+


    Social Networks


    Codes (Related to SACNR)
    SACNR Monitor Python API

  2. #2
    Cyka Blyat
    Join Date
    May 2011
    Posts
    3,349
    Rep Power
    1
    really nice job Pbomb!

  3. #3
    Donating Player
    Join Date
    Aug 2011
    Location
    Mexico
    Posts
    2,228
    Rep Power
    1
    Well , as i don't use Python at all. I haven't or belive i will not test it . But awsome way to work. This is Kandyman right? I Believe you will continue with more functions , am i right?

  4. #4
    Donating Player KURZALEWSKI's Avatar
    Join Date
    Jan 2012
    Location
    ::1/128
    Posts
    2,059
    Rep Power
    1
    Good one, I was going to write something close to that for my bot but the problem is that the data updates too slowly, so I chose SA-MP Query instead. However, n1 :)

  5. #5
    big booty dog
    Join Date
    Aug 2011
    Posts
    160
    Rep Power
    1
    Nice one, Keep it up :)



  6. #6
    Donating Player XaX's Avatar
    Join Date
    Nov 2011
    Location
    Chennai,India
    Posts
    763
    Rep Power
    1
    n1 ....


    :D

  7. #7
    Donating Player KURZALEWSKI's Avatar
    Join Date
    Jan 2012
    Location
    ::1/128
    Posts
    2,059
    Rep Power
    1
    Quote Originally Posted by PBomb View Post
    This module is designed for Python 2.7
    and has not been tested on any other verison.

    Tested it today on Python 2.6.0, seems to be working fine or at least I had no problems running it :)

  8. #8
    Donating Player
    Join Date
    May 2011
    Posts
    1,430
    Rep Power
    1
    PHP4Life niggas...

  9. #9
    Donating Player
    Join Date
    Aug 2011
    Location
    Mexico
    Posts
    2,228
    Rep Power
    1
    Quote Originally Posted by Mr_Djole View Post
    PHP4Life niggas...
    This guy is awsome!

  10. #10
    Donating Player joemomma53's Avatar
    Join Date
    May 2011
    Location
    NYC > Florida
    Posts
    165
    Rep Power
    1
    +111111111 n1 good shit my nig

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •