Created
May 17, 2012 03:54
-
-
Save clvrobj/2716151 to your computer and use it in GitHub Desktop.
pyapns test script (https://github.com/samuraisam/pyapns)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding:utf-8 -*- | |
from optparse import OptionParser | |
from pyapns import configure, provision, notify, feedback | |
def send_notify(host, app, cert, token, string, is_feedback): | |
print 'Sending...\nhost: %s\napp: %s\ndevice: %s\nstring: %s' % (host, app, token, string) | |
configure({'HOST': host}) | |
if cert: | |
provision(app, open(cert).read(), 'sandbox') | |
notify(app, token, {'aps':{'alert': string}}) | |
print 'done' | |
if is_feedback != None: | |
print feedback(app) | |
if __name__ == '__main__': | |
parser = OptionParser(usage="%prog [options]") | |
parser.add_option("-o", "--host", help='host', default="http://localhost:7077/") | |
parser.add_option("-a", "--app", help='app name') | |
parser.add_option("-c", "--cert", help='cert path') | |
parser.add_option("-t", "--token", help='device token') | |
parser.add_option("-s", "--string", help='content string to send', default='Hello!') | |
parser.add_option("-f", "--feedback", action="store_false", help='acquire feedbacks') | |
(options, args) = parser.parse_args() | |
host, app, cert, token, string, is_feedback = options.host, options.app, options.cert, options.token, options.string, options.feedback | |
send_notify(host, app, cert, token, string, is_feedback) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment