Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Python package

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.7]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run tox
run: tox --skip-missing-interpreters
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build/

*.egg-info
*.py[cod]
.tox
build/
8 changes: 4 additions & 4 deletions pushover.py → pushover/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self, payload):
if payload.get("priority", 0) == 2:
self.url = RECEIPT_URL + self.answer["receipt"]
self.status["done"] = False
for param, when in MessageRequest.params.iteritems():
for param, when in MessageRequest.params.items():
self.status[param] = False
self.status[when] = 0

Expand All @@ -108,7 +108,7 @@ def poll(self):
"""
if not self.status["done"]:
r = Request("get", self.url + ".json", {"token": self.payload["token"]})
for param, when in MessageRequest.params.iteritems():
for param, when in MessageRequest.params.items():
self.status[param] = bool(r.answer[param])
self.status[when] = int(r.answer[when])
for param in ["acknowledged_by", "acknowledged_by_device"]:
Expand Down Expand Up @@ -201,7 +201,7 @@ def message(self, user, message, **kwargs):
"""

payload = {"message": message, "user": user, "token": self.token}
for key, value in kwargs.iteritems():
for key, value in kwargs.items():
if key not in Pushover.message_keywords:
raise ValueError("{0}: invalid message parameter".format(key))
elif key == "timestamp" and value is True:
Expand All @@ -225,7 +225,7 @@ def glance(self, user, **kwargs):
"""
payload = {"user": user, "token": self.token}

for key, value in kwargs.iteritems():
for key, value in kwargs.items():
if key not in Pushover.glance_keywords:
raise ValueError("{0}: invalid glance parameter".format(key))
else:
Expand Down
10 changes: 7 additions & 3 deletions cli.py → pushover/cli.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from ConfigParser import RawConfigParser, NoSectionError, NoOptionError
try:
import configparser
except ImportError: # Python 2
import ConfigParser as configparser

from argparse import ArgumentParser, RawDescriptionHelpFormatter
import os
from pushover import Pushover


def read_config(config_path):
config_path = os.path.expanduser(config_path)
config = RawConfigParser()
config = configparser.RawConfigParser()
params = {"users": {}}
files = config.read(config_path)
if not files:
Expand All @@ -18,7 +22,7 @@ def read_config(config_path):
user["user_key"] = config.get(name, "user_key")
try:
user["device"] = config.get(name, "device")
except NoOptionError:
except configparser.NoOptionError:
user["device"] = None
params["users"][name] = user
return params
Expand Down
12 changes: 4 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@

from setuptools import setup

long_description = "\n".join([open(f).read() for f in ("README.rst", "AUTHORS.rst", "CHANGES.rst")])
setup(
name="python-pushover",
version="1.0",
description="Comprehensive bindings and command line utility for the "
"Pushover notification service",
long_description=open("README.rst").read()
+ "\n"
+ open("AUTHORS.rst").read()
+ "\n"
+ open("CHANGES.rst").read(),
long_description=long_description,
url="https://github.com/Thibauth/python-pushover",
author="Thibaut Horel",
author_email="thibaut.horel+pushover@gmail.com",
py_modules=["pushover", "cli"],
entry_points={"console_scripts": ["pushover = cli:main"]},
packages=["pushover"],
entry_points={"console_scripts": ["pushover = pushover.cli:main"]},
install_requires=["requests>=1.0"],
use_2to3=True,
license="GNU GPLv3",
)
4 changes: 4 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[testenv]
deps = flake8
commands =
flake8 pushover setup.py --ignore=E501 --count --max-complexity=10 --statistics