kurttheviking / simple-hipchat-py Goto Github PK
View Code? Open in Web Editor NEWPython client fo HipChat's v1 API
License: Other
Python client fo HipChat's v1 API
License: Other
Specify which versions are supported (including the major version identifiers) using trove classifiers.
This helps show people which versions the project supports and also tools like caniusepython3.
example message that triggers error:
rm: cannot remove `/home/ec2-user/js/stuff.js': Permission denied
as title says
Python 3 support lacking; can contribute
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.
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)
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)
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?
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.