mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-01 06:19:57 +01:00
test script for messaging devices
This commit is contained in:
parent
4eff38a85d
commit
2df4199a77
2 changed files with 35 additions and 0 deletions
3
xwords4/relay/scripts/.gitignore
vendored
Normal file
3
xwords4/relay/scripts/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
gcm.py
|
||||
gcm.pyc
|
||||
mykey.py*
|
32
xwords4/relay/scripts/gcm_msg.py
Executable file
32
xwords4/relay/scripts/gcm_msg.py
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import sys, gcm, psycopg2
|
||||
|
||||
# I'm not checking my key in...
|
||||
import mykey
|
||||
|
||||
|
||||
def msgViaGCM( devid, msg ):
|
||||
instance = gcm.GCM( mykey.myKey )
|
||||
data = { 'title' : 'Msg from Darth',
|
||||
'msg' : msg,
|
||||
}
|
||||
|
||||
response = instance.json_request( registration_ids = [devid],
|
||||
data = data )
|
||||
|
||||
if 'errors' in response:
|
||||
for error, reg_ids in response.items():
|
||||
print error
|
||||
else:
|
||||
print 'no errors'
|
||||
|
||||
|
||||
def main():
|
||||
msg = sys.argv[1]
|
||||
print 'got "%s"' % msg
|
||||
msgViaGCM( mykey.myBlaze, msg )
|
||||
|
||||
##############################################################################
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in a new issue