Coder Social home page Coder Social logo

simple-hipchat-py's People

Contributors

claudyus avatar ghickman avatar kurttheviking avatar mwarkentin avatar pimterry avatar raizex avatar zachsnow avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

simple-hipchat-py's Issues

doesn't handle unicode messages gracefully

If I try to use simple-hipchat-py to send a unicode message to a hipchat room I get the following error

  File "/app/utils.py", line 800, in send_hipchat_notification
    hipster.message_room(room_id, from_name, message)
  File "/app/.heroku/python/lib/python2.7/site-packages/hipchat/__init__.py", line 83, in message_room
    return self.method('rooms/message', 'POST', parameters)
  File "/app/.heroku/python/lib/python2.7/site-packages/hipchat/__init__.py", line 53, in method
    request_data = urlencode(parameters).encode('utf-8')
  File "/app/.heroku/python/lib/python2.7/urllib.py", line 1347, in urlencode
    v = quote_plus(str(v))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 20: ordinal not in range(128)

I had to install the unidecode library and put from unidecode import unidecode at the top of my file then do message = unidecode(message) before hipster.message_room(room_id, from_name, message) to get it working correctly.

Seems like simple-hipchat-py should handle unicode messages internally.

simplify version switching

First off, thanks for the module! Just have a quick suggestion for the project:

Looks like this could use some more-obvious API version switching documentation.

Didn't know url= kwarg was available until I read through https://github.com/kurttheviking/python-simple-hipchat/blob/master/hipchat/__init__.py#L7 and saw https://github.com/kurttheviking/python-simple-hipchat/blob/master/hipchat/__init__.py#L12-L13

Since there's a V2 API now, might be worth documenting hipchat.HipChat(method=.., url=..) and the constructor might be simplified by just making it hipchat.HipChat(method=..., version=2)

api difference reasoning

Hipchat fallback

I've found myself wrapping calls to send messages to Hipchat with fallbacks (generally to email). This works fine, but I was wondering if it makes any sense to add some support for this to the library? The code generally looks something like this:

try:
    hipster.message_room(room_id=settings.HIPCHAT_ROOM_PRONETWORK, message_from=msg_from, message=msg, message_format='html', color=color, notify=True)
except URLError as e:
    body = u"Hipchat notification failed.\n{}\n\n".format(msg)
    if hasattr(e, 'reason'):
        body += u"Couldn't contact Hipchat:\n{}".format(e.reason)
    elif hasattr(e, 'code'):
        body += u"Hipchat error: {}".format(e.code)
        mail_managers(msg, body)
    except socket.timeout as e:
        body = u"Hipchat notification failed.\n{}\n\nSocket timeout.".format(msg)
        mail_managers(msg, body)

Color does not change on subsequent posts

Hello, the color='whatever' option works just fine, however if I post, for example, with color='orange', and immediately follow it with a post color='green' the second post is also orange. That said, if I sleep after the first post, and then manually post myself in the HipChat room... then the second post color='green' does in fact come through as green (after my manual post). Have you seen this?

AttributeError: 'module' object has no attribute 'HipChat'

I'm not sure what I'm doing wrong exactly. Possibly I'm doing my initial import/install wrong? Running the follow script:

import hipchat

hipster = hipchat.HipChat(token='APIKEY')   # For notification only

hipster.method('rooms/message', method='POST', parameters={'room_id': 'IDNUM', 'from': 'ThisBot', 'message': 'My Message', 'notify': '1', 'color': 'red'} )

I receive the following error:

$ python2.6 tt.py
Traceback (most recent call last):
  File "tt.py", line 5, in <module>
    hipster = hipchat.HipChat(token='APITOKENT')    # For notification only
AttributeError: 'module' object has no attribute 'HipChat'

And

$ python tt.py
Traceback (most recent call last):
  File "tt.py", line 5, in <module>
    hipster = hipchat.HipChat(token='APITOKENHERE') # For notification only
AttributeError: 'module' object has no attribute 'HipChat'

I'm running this on CentOS:

$ uname -r
2.6.32-431.5.1.el6.x86_64

Tried pip install:

$ pip install python-simple-hipchat
Downloading/unpacking python-simple-hipchat
  Downloading python-simple-hipchat-0.2.tar.gz
  Running setup.py (path:/tmp/pip_build_root/python-simple-hipchat/setup.py) egg_info for package python-simple-hipchat
Installing collected packages: python-simple-hipchat
  Running setup.py install for python-simple-hipchat
Successfully installed python-simple-hipchat
Cleaning up...

Also tried installing from git:

$ python setup.py install
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/hipchat
copying hipchat/__init__.py -> build/lib/hipchat
running install_lib
copying build/lib/hipchat/__init__.py -> /usr/lib/python2.6/site-packages/hipchat
byte-compiling /usr/lib/python2.6/site-packages/hipchat/__init__.py to __init__.pyc
running install_egg_info
removing '/usr/lib/python2.6/site-packages/python_simple_hipchat-0.2-py2.6.egg-info' (and everything under it)
Writing /usr/lib/python2.6/site-packages/python_simple_hipchat-0.2-py2.6.egg-info
$ pip freeze
hipchat==0.0.1
httplib2==0.8
pycurl==7.19.0
pygpgme==0.1
python-simple-hipchat==0.2

Had my initial testing running perfectly on OSx. Please let me know if you need any other info.

How to find new messages?

If there was a way to find the most recent comment that would be really convenient. I'm thinking something like

While True:
if com = getComment() :
and have com be the most recent comment

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.