Giter VIP home page Giter VIP logo

python-pushover's Introduction

python-pushover aims at providing comprehensive Python bindings for the API of the Pushover Notification Service as documented here.

Installation

You can install python-pushover from Pypi with:

$ pip install python-pushover

Or you can install it directly from GitHub:

git clone https://github.com/Thibauth/python-pushover.git
cd python-pushover
pip install .

Overview

After being imported, the module must be initialized by calling the init function with a valid application token. Thus, a typical use of the pushover module looks like this:

from pushover import init, Client

init("<token>")
Client("<user-key>").send_message("Hello!", title="Hello")

You can also pass the api_token optional argument to Client to initialize the module at the same time:

from pushover import Client

client = Client("<user-key>", api_token="<api-token>")
client.send_message("Hello!", title="Hello")

Attachments can be sent with the attachment parameter which takes as argument as file object:

with open('/path/to/my/image.png', 'rb') as image:
    client.send_message('Message with image', attachment=image)

Command line

python-pushover also comes with a command line utility pushover that you can use as follows:

pushover --api-token <api-token> --user-key <user-key> "Hello!"

Use pushover --help to see the list of available options.

Configuration

Both the pushover module and the pushover command line utility support reading arguments from a configuration file.

The most basic configuration file looks like this:

[Default]
api_token=aaaaaa
user_key=xxxxxx

You can have additional sections and specify a device as well:

[Sam-iPhone]
api_token=bbbbbb
user_key=yyyyyy
device=iPhone

python-pushover will attempt to read the configuration from ~/.pushoverrc by default. The section to read can be specified by using the profile argument. With the configuration file above, you can send a message by simply doing:

from pushover import Client

Client().send_message("Hello!", title="Hello")

or pushover --title "Hello" "Hello!" from the command line.

API

You can access the full API documentation here.

python-pushover's People

Contributors

copart avatar crupuk avatar dchevell avatar drachenminister avatar filipl avatar philipbl avatar sbirch avatar thibauth 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-pushover's Issues

sending a message to more then one device

How can we send a message to more than one device at the time?
Not implemented? Or any pointers.

I need to do it in python code , thus without an external file.

BTW, nice work.

Pushover does not work on my mac with Maveric

When I use pushover in a python script in windows and linux it works fine, but when I run the same script on my mac I get this error message:
attributeerror module pushover does not have an attribute Client.
I tried to reinstall pushover , but it does not help..
What can be wrong?
The python environment on the mac is setup similar to the windows and linux environments.
And the python version is 3.7

priority 2 poll method bug

request.poll()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.4/dist-packages/pushover.py", line 164, in poll
request.answer[parameter + "_at"])
KeyError: 'expired_at'

The polling method tries to use the expired_at parameter from pushover's api. This parameter does not exist. The correct parameter is expires_at.

NameError: name 'init' is not defined

Hi there,

So code which has been working for some time, is no longer working with python-pushover 1.0 running on Python 3.7.

from pushover import init, Client

Used to work, but now gives the error: "NameError: name 'init' is not defined"

However, doing:

import pushover from pushover import Client

Doesn't work either, giving a "ImportError: cannot import name 'Client' from 'pushover'."

Can you please advise how I should now be importing (and using) this module at version 1.0 under Python 3.7? Thank you!

Latest release? Global api-token

Hi,
is this lib still maintained? The latest release was 0.4, but there are some commits after that.

This lib is used by a home-assistant component. The problem is that if I use multiple api-keys, in version 0.4 it seems to be stored globally, so not working.

But it seems that this is fixed on master branch. But I can't use and adopt it in home-assistant as there is no release after 0.4

Error defining client

Hello
The command:
client = Client("user or group key")

cause the error below:

Traceback (most recent call last):
File "", line 1, in
NameError: name 'Client' is not defined

Any Help?

Use_2to3 has been removed from setuptools. No longer builds.

https://setuptools.pypa.io/en/latest/history.html#v58-0-0

No longer installs it throws a

bash-5.1# pip3 install python-pushover Collecting python-pushover Using cached python-pushover-0.4.tar.gz (19 kB) ERROR: Command errored out with exit status 1: command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rdilmzkd/python-pushover/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rdilmzkd/python-pushover/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-d0zpskx4 cwd: /tmp/pip-install-rdilmzkd/python-pushover/ Complete output (1 lines): error in python-pushover setup command: use_2to3 is invalid. ----------------------------------------

due to a call to use_2to3 in setup.py.

Glances API

Any plans to support the new glances API ?

Unable to import on raspberry pi 3

I got a freshly installed raspberry and I was trying to install this pushover script

Now I installed it over pip with:

$ pip install python-pushover

and created the following script

from pushover import Client

client = Client("myUserToken", 
api_token="myAppToken")
client.send_message("message!", title="myTitle")

And that results in the following response

python test.py

Traceback (most recent call last):

  File "test.py", line 1, in <module>

from pushover import Client

  File "/home/pi/Desktop/project/test.py", line 1, in <module>

from pushover import init, Client

ImportError: cannot import name init

My python version used : Python 2.7.13

setuptools rather than distutils?

I noticed while I was playing with my fork that this uses distutils (which doesn't allow setup.py develop.) I don't know if you have an opinion here, but AFAIK setuptools is the latest and greatest, and only requires changing the import line in setup.py.

[feature request] Run as script

It would be awesome to be able to run python-pushover as a script, and that script to be installed with python setup.py install.

From the command line I want to be able to:

pushover --user-key=$KEY1 --app-key=$KEY2 --title="foo" "bar spam eggs"

Fails to install: error in python-pushover setup command: use_2to3 is invalid.

pip install python-pushover
Collecting python-pushover
  Using cached python-pushover-0.4.tar.gz (19 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in python-pushover setup command: use_2to3 is invalid.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

request to add expire parameter to command line pushover

Thanks for the pushover python etc interface!

Since priority can be set to 2, where expire value must be set (according to error message), it would be good to add an expire argument to the command line interface.

I may make an attempt at this and subbmit a pull request ...

Compatibility with Python 3.11.2

Can you make it compatible with Python 3.11.2 ?

It has few errors like:
client.send_message("test")
File "/usr/local/lib/python3.11/dist-packages/pushover.py", line 259, in send_message
for key, value in kwords.iteritems():
^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'iteritems'

cli.py Import Error

ImportError: cannot import name 'Pushover' from 'pushover' (/usr/local/lib/python3.7/site-packages/pushover.py)

I have the above error in my scripts recently. Coming here, I tried using cli.py, but I get the same error. I installed with pip3 install python-pushover without issue, after removing it first, to try an clear and cruft from the install path. Still have this issue.

Error after sending a message

I got this error after sending a simple message, it seems to be the rerun fonction that doesn't recognize the pushover api frame. here it is:

'
Exception in thread Thread-4:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 552, in *bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 505, in run
self.__target(_self.__args, _self.__kwargs)
File "main.py", line 596, in gf100_init
client.send_message("Starting Initialization of")
File "/usr/local/lib/python2.7/dist-packages/python_pushover-0.1-py2.7.egg/pushover.py", line 211, in send_message
return MessageRequest(payload)
File "/usr/local/lib/python2.7/dist-packages/python_pushover-0.1-py2.7.egg/pushover.py", line 108, in __init

Request.init(self, "post", MESSAGE_URL, payload)
File "/usr/local/lib/python2.7/dist-packages/python_pushover-0.1-py2.7.egg/pushover.py", line 88, in init
self.answer = request.json()
TypeError: 'dict' object is not callable
'

I still receive the message, but this error happen in the shell.

Thanx a lot!

bad magic number

What do I need to do to get rid of the error"

Traceback (most recent call last):
  File "mypushover.py", line 1 in <module>
    from pushover import init, Client
ImportError: bad magic number in 'pushover': b'\x03\xf3\r\n'

py3 compat

Your recent commit of line 135 introduced a .iteritems() which is not python 3..

License GPL?

Thanks so much for making this python pushover package. I love this python package other than the license is using GPL? This stops me to use it in my works. Is there any particular reason it has to be GPL?

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.