aboutsummaryrefslogtreecommitdiffstats
path: root/pushover.py
diff options
context:
space:
mode:
authorSam Birch <sam.m.birch@gmail.com>2014-07-23 23:34:32 -0400
committerSam Birch <sam.m.birch@gmail.com>2014-07-23 23:34:32 -0400
commit201bbafc647595b33cde31ba988d5d61a5545b9c (patch)
treebe6cc3ff01e1eddb2f7f86323dcffb322a6611b4 /pushover.py
parent989327291c6a53e457f034c2c1d03848eb32ed46 (diff)
downloadpython-pushover-201bbafc647595b33cde31ba988d5d61a5545b9c.tar.gz
Addressed changes
Diffstat (limited to 'pushover.py')
-rw-r--r--pushover.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/pushover.py b/pushover.py
index 2284c7a..8b840df 100644
--- a/pushover.py
+++ b/pushover.py
@@ -12,6 +12,8 @@ A typical use of the module looks like this::
import requests
import time
+from ConfigParser import RawConfigParser
+import os
__all__ = ["init", "get_sounds", "Client", "MessageRequest",
"InitError", "RequestError", "get_client"]
@@ -226,24 +228,23 @@ def get_client(profile=None, config_path='~/.pushover'):
* ``profile``: the profile to load as a client (`Default` by default.)
* ``config_path``: path of the configuration file (`~/.pushover` by default.)
"""
- import ConfigParser
- import os
+
config_path = os.path.expanduser(config_path)
if not os.path.exists(config_path):
- raise Exception("Configuration file not found ({0})".format(config_path))
+ raise IOError(2, "No such file", config_path)
- config = ConfigParser.RawConfigParser()
+ config = RawConfigParser({"device": None})
config.read(config_path)
- section = profile if profile is not None else 'Default'
+ section = profile or 'Default'
init(config.get(section, 'api_token'), sound=False)
return Client(
config.get(section, 'user_key'),
- device=config.get(section, 'device') if config.has_option(section, 'device') else None
+ device=config.get(section, 'device')
)