Giter VIP home page Giter VIP logo

camplight's Introduction

Camplight

Camplight is a Python implementation of the Campfire API.

The project comes with a Python module that can be imported via import camplight and a simple command-line tool named camplight to utilize it.

Installation

The easiest way to install Camplight and its dependencies:

$ pip install camplight

Alternatively, you can install it from source:

$ git clone git://github.com/mlafeldt/camplight.git
$ cd camplight/
$ python setup.py install

(Note that Camplight requires Requests.)

API Usage

from camplight import Request, Campfire

request = Request('https://your-subdomain.campfirenow.com', 'your_token')
campfire = Campfire(request)

account = campfire.account()
rooms = campfire.rooms()

room = campfire.room('Danger')
room.join()
room.speak('ohai')
room.leave()

Client Usage

Usage: camplight [options] <command> [args]

Options:
  -h, --help            show this help message and exit
  -u URL, --url=URL     set Campfire URL
  -t TOKEN, --token=TOKEN
                        set API token for authentication
  -r ROOM, --room=ROOM  set Campfire room
  -v, --verbose         be more verbose

Global commands:
  account               get account information
  rooms                 list available rooms
  user [id]             get user information
  presence              list rooms the user is present in
  search <term>         search transcripts for term

Room commands (require --room to be set):
  status                get general room information
  recent                list recent messages in the room
  transcript [date]     list all messages sent to the room (on date YYYY/MM/DD)
  uploads               list recently uploaded files in the room
  join                  join the room
  leave                 leave the room
  lock                  lock the room
  unlock                unlock the room
  speak <message>       send a regular chat message
  paste <message>       paste a message
  play <sound>          play a sound
  set-name <name>       change the room's name
  set-topic <topic>     change the room's topic

Environment variables:
  CAMPFIRE_URL          same as --url
  CAMPFIRE_TOKEN        same as --token
  CAMPFIRE_ROOM         same as --room
  CAMPFIRE_VERBOSE      same as --verbose

Testing

Build Status

After cloning the repository, run the test suite using:

$ python setup.py test

You can generate a coverage report using coverage.py. First, install the coverage package:

$ pip install coverage

Now gather the data by running:

$ coverage run setup.py test

And create a report:

$ coverage report

You can also create a much nicer HTML report:

$ coverage html

Now open htmlcov/index.html in your browser.

License

Camplight is licensed under the terms of the MIT License. See LICENSE file.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Contact

camplight's People

Contributors

jwilder avatar keimlink avatar luchux avatar mlafeldt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

camplight's Issues

Installing via pip in virtualenv fails because setup.py depends on requests

setup.py imports camplight, which imports camplight.api, which imports requests. If you are trying to install camplight into a virtualenv via pip, this will fail because requests isn't installed yet. (Especially a problem because pip seems to install packages from git before ones from pypi?)

Here's the output.

$ ./virtualenv-run.sh pip install git+git://github.com/mlafeldt/camplight.git
Downloading/unpacking git+git://github.com/mlafeldt/camplight.git
  Cloning git://github.com/mlafeldt/camplight.git to /var/folders/j9/m1g4r4hn1t1gk2xf79bf01g40000gn/T/pip-nTM5rm-build
  Running setup.py egg_info for package from git+git://github.com/mlafeldt/camplight.git
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/var/folders/j9/m1g4r4hn1t1gk2xf79bf01g40000gn/T/pip-nTM5rm-build/setup.py", line 4, in <module>
        import camplight
      File "camplight/__init__.py", line 15, in <module>
        from .api import *
      File "camplight/api.py", line 11, in <module>
        import requests
    ImportError: No module named requests
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "/var/folders/j9/m1g4r4hn1t1gk2xf79bf01g40000gn/T/pip-nTM5rm-build/setup.py", line 4, in <module>

    import camplight

  File "camplight/__init__.py", line 15, in <module>

    from .api import *

  File "camplight/api.py", line 11, in <module>

    import requests

ImportError: No module named requests

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /var/folders/j9/m1g4r4hn1t1gk2xf79bf01g40000gn/T/pip-nTM5rm-build
Storing complete log in /Users/joe/.pip/pip.log

I'm not sure the best way to solve that without duplicating the version string in both camplight/__init__.py and in setup.py.

Example code not working. Unable to join a room

I tried to run the code from the example but it breaks when trying to join a room. It throws:

Traceback (most recent call last):
  File "test.py", line 10, in <module>
    room.join()
  File "/usr/local/lib/python2.7/dist-packages/camplight-0.7-py2.7.egg/camplight/api.py", line 109, in join
    self.request.post(self._path + '/join')
  File "/usr/local/lib/python2.7/dist-packages/camplight-0.7-py2.7.egg/camplight/api.py", line 47, in post
    return self._request('POST', *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/camplight-0.7-py2.7.egg/camplight/api.py", line 41, in _request
    return r.json()
  File "/usr/local/lib/python2.7/dist-packages/requests-1.1.0-py2.7.egg/requests/models.py", line 604, in json
    return json.loads(self.text or self.content)
  File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 451, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 406, in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 426, in raw_decode
    raise JSONDecodeError("No JSON object could be decoded", s, idx)
simplejson.decoder.JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)

Is there a step missing, like getting an user and use it some how?

I've installed Requests from the Ubuntu 12.10 repos.

Submit to Pypi?

Hey there,

  1. Thanks for writing and sharing this - super helpful.
  2. Any chance you can submit to pypi? This package is the one thing left in my requirements.txt file that I can't just automatically freeze.

Thanks again!
-Steven

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.