Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/walkr/oi
python library for writing long running processes with a cli interface
https://github.com/walkr/oi
nanomsg python
Last synced: about 2 months ago
JSON representation
python library for writing long running processes with a cli interface
- Host: GitHub
- URL: https://github.com/walkr/oi
- Owner: walkr
- License: mit
- Created: 2015-05-14T23:34:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-11T23:25:44.000Z (almost 9 years ago)
- Last Synced: 2024-08-22T08:54:33.510Z (4 months ago)
- Topics: nanomsg, python
- Language: Python
- Homepage:
- Size: 42 KB
- Stars: 234
- Watchers: 12
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- my-awesome-starred - oi - python library for writing long running processes with a cli interface (Python)
README
oi
==
python library for writing long running processes with a cli interface[![Build Status](https://travis-ci.org/walkr/oi.svg?branch=master)](https://travis-ci.org/walkr/oi)
![oi image](http://i.imgur.com/iH08GNq.png)
### Install
Note: You need [nanomsg](https://github.com/nanomsg/nanomsg) installed on your system:
```shell
$ git clone [email protected]:nanomsg/nanomsg.git
$ cd nanomsg
$ ./configure
$ make
$ make check
$ sudo make install
```Then install oi
```shell
$ pip install oi
```### Usage
####1. Write your long running program
```python
# programd.pyimport oi
program = oi.Program('my program', 'ipc:///tmp/program.sock')
program.add_command('ping', lambda: 'pong')
program.add_command('state', lambda: program.state)
program.run() # program will run forever
```####2. Add a ctl interface
```python
# programctl.pyimport oi
ctl = oi.CtlProgram('ctl program', address='ipc:///tmp/program.sock')
ctl.run()
```####3. Run program, then connect to it via ctl
```shell
# Run process
$ python programd# OR with a configuration file
$ python programd --config /etc/program.conf$ python programctl # enter ctl loop
programctl > ping
pong# OR ping end exit
$ python programctl ping
```#### Quickly get started with a new project
```shell
$ mkdir xprogram
$ cd xprogram$ oi init
$ make install# Start your program
$ xprogramd# Start ctl program
$ xprogramctl
ctl > ping
pong# Upload to pypi (Edit setup.py before distributing)
$ make distribute
```### Now the interesting bit. Are you ready?
Run your program on one computer, then control it from another with a single line change (actually two).Just change the address `ipc:///tmp/program.sock` to a tcp address, such as `tcp://192.168.1.100:5000` in both your `programd.py` and `programctl.py`. That's it! (:
#### TODO
- [ ] Add more testing
#### License
MIT License