Giter Club home page Giter Club logo

flow-python's Introduction

Python Flow Module

Description

flow-python is a module to interact with the Flow stack using python.

Install

  1. Download and install Semaphor: https://spideroak.com/opendownload.
  2. Clone and install the flow-python repo:
$ git clone https://github.com/SpiderOak/flow-python.git
$ cd flow-python
$ python setup.py install

Basic Usage

Here's a simple script to list a user's Organizations/Teams:

#!/usr/bin/env python
from flow import Flow

# Create flow intance and start using the API
flow = Flow('flow-username')

# Print user's organizations
print(flow.enumerate_orgs())

Here's a script that listens for messages and prints them to stdout:

#!/usr/bin/env python
from flow import Flow

flow = Flow('flow-username')

# Here we register our callback to be executed when we receive a message
@flow.message
def print_message(notif_type, notif_data):
    regular_messages = notif_data["regularMessages"]
    for message in regular_messages:
        print("Got message '%s' from ChannelID='%s'" %
              (message["text"], message["channelId"]))

# Once you registered all your callbacks, all you have to do is loop.
flow.process_notifications()

Comments

  • Tested support on Linux, Windows and MacOS.
  • Supports Python2.7 and Python3.3-3.5
  • If you intend to use one of the examples above, 'your-flow-username' should already be logged-in in your device.
  • See samples directory for examples on how to use the module.
  • An application should use a single instance of flow.Flow per account.
  • Use logging.getLogger("flow") to configure the log level for the module.
  • By default, local databases and semaphor-backend output are located under ~/.config/flow-python, you can override this on Flow init (db_dir). The config directory prior to 0.3 was ~/.config/semaphor, see here.
  • Flow init starts the semaphor-backend as a subprocess.
  • To start using Flow with an account you must use only one of these three API: (the three methods start the notification loop that listens from incoming events from the server)
    • Flow.start_up # This starts an already logged-in account
    • Flow.create_account # This creates a new account
    • Flow.create_device # This creates a new device for an existing account
  • Flow methods raise Flow.FlowError if something went wrong.

Changelog

See CHANGELOG.md

TODO

  • Implement remaining Flow API methods.
  • Document all arguments of the Flow API.
  • Document Flow dict objects that are returned on many of the methods. Or find a better way to return these (objects vs dicts?).
  • Unit Testing the flow module.
  • It has support for multiple sessions but this hasn't been tested yet.
  • Auto-generate API methods from the flowapp API.
  • See other TODOs in source code.

flow-python's People

Contributors

chiiph avatar hamptus avatar lucasmrod avatar

Watchers

 avatar  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.