Giter VIP home page Giter VIP logo

dartmist's Introduction

dartmist

A library for interacting with the Mist Systems API

Requirements

Python libraries

  • websocket
  • websocket-client

Installation

pip3 install dartmist

Will install this library and all required libraries

Setup

Environment

You must specify a Mist Org ID and a Mist API Token. These can be passed in via the command line (see Usage) or, preferably, set as envinronment variables:

export MIST_ORGID="00000000-0000-0000-0000-000000000000"
export MIST_TOKEN="12345123451234512345123451234512345"

To get an API Token, refer to the documentation provided by Mist https://api.mist.com/api/v1/docs/Auth#api-token

Usage

In your python script:

from dartmist import mist, misthelpers
api = mist.Mist(TOKEN, ORGID)
helper = misthelpers.MistHelpers(api)

To use the MistWebsocket class:

import threading
ev = threading.Event()
mwsock = mistwebsocket.MistWebsocket(TOKEN, ev)
mswock.open()
if ws.is_open:
    print("Yes, the Websocket is open")
else:
    logging.error("Failed to open Websocket")
    exit(-1)
mwsock.subscribe()
while not ev.isSet() and len(ws.messages) == 0:
    logging.debug("Waiting...")
    msg_rcvd = ev.wait(10)
if msg_rcvd or ev.isSet() or len(ws.messages) > 0:
    # Process messages
    msg = json.loads(ws.get_next_message())
mwsock.unsubscribe()
mwsock.close()

dartmist's People

Contributors

bryanward-net avatar

Stargazers

 avatar Thomas Munzer avatar  avatar Satish Jain avatar  avatar  avatar Guess Works avatar Jason Grider avatar  avatar  avatar  avatar  avatar

Watchers

 avatar Justin Cox avatar  avatar  avatar

dartmist's Issues

Fix logging in docs

logging.error("Failed to open Websocket")

since you don't actually define logging in your example, means it won't run

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.