-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example tac is now the tac you should use; updated
* updated conf * updated pyapns.tac
- Loading branch information
Samuel Sutch
committed
Jan 25, 2013
1 parent
a7bdc7a
commit aff1106
Showing
3 changed files
with
65 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,12 @@ | ||
{ | ||
"port": 7077, | ||
"rest_port": 8088, | ||
"autoprovision": [ | ||
{ | ||
"app_id": "sandbox:com.ficture.ficturebeta", | ||
"cert": "/Users/sam/dev/ficture/push_certs/development-com.ficture.ficturebeta.pem", | ||
"app_id": "com.example.myapp", | ||
"cert": "/path/to/cert.pem", | ||
"environment": "sandbox", | ||
"timeout": 15 | ||
}, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
{ | ||
"app_id": "production:com.ficture.ficturebeta", | ||
"cert": "/Users/sam/dev/ficture/push_certs/production-com.ficture.ficturebeta.pem", | ||
"environment": "production", | ||
"timeout": 15 | ||
}, | ||
{ | ||
"app_id": "sandbox:com.ficture.ficturebeta2", | ||
"cert": "/Users/sam/dev/ficture/push_certs/development-com.ficture.ficturebeta2.pem", | ||
"environment": "sandbox", | ||
"timeout": 15 | ||
}, | ||
{ | ||
"app_id": "production:com.ficture.ficturebeta2", | ||
"cert": "/Users/sam/dev/ficture/push_certs/production-com.ficture.ficturebeta2.pem", | ||
"environment": "production", | ||
"timeout": 15 | ||
}, | ||
{ | ||
"app_id": "sandbox:com.ficture.ficturebeta3", | ||
"cert": "/Users/sam/dev/ficture/push_certs/development-com.ficture.ficturebeta3.pem", | ||
"environment": "sandbox", | ||
"timeout": 15 | ||
}, | ||
{ | ||
"app_id": "production:com.ficture.ficturebeta3", | ||
"cert": "/Users/sam/dev/ficture/push_certs/production-com.ficture.ficturebeta3.pem", | ||
"environment": "production", | ||
"timeout": 15 | ||
} | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# CONFIG FILE LOCATION | ||
# relative to this file or absolute path | ||
|
||
config_file = '/path/to/config/pyapns_conf.json' | ||
|
||
# you don't need to change anything below this line really | ||
|
||
import twisted.application, twisted.web, twisted.application.internet | ||
import pyapns.server, pyapns._json | ||
import pyapns.rest_service, pyapns.model | ||
import os | ||
|
||
config = {} | ||
|
||
if os.path.exists(os.path.abspath(config_file)): | ||
with open(os.path.abspath(config_file)) as f: | ||
config.update(pyapns._json.loads(f.read())) | ||
else: | ||
print 'No config file loaded. Alter the `config_file` variable at', \ | ||
'the top of this file to set one.' | ||
|
||
xml_service = pyapns.server.APNSServer() | ||
|
||
# get automatic provisioning | ||
if 'autoprovision' in config: | ||
for app in config['autoprovision']: | ||
# for XML-RPC | ||
xml_service.xmlrpc_provision(app['app_id'], app['cert'], | ||
app['environment'], app['timeout']) | ||
# for REST | ||
pyapns.model.AppRegistry.put( | ||
app['app_id'], app['environment'], app['cert'], | ||
timeout=app['timeout'] | ||
) | ||
|
||
application = twisted.application.service.Application("pyapns application") | ||
|
||
# XML-RPC server support ------------------------------------------------------ | ||
|
||
if 'port' in config: | ||
port = config['port'] | ||
else: | ||
port = 7077 | ||
|
||
resource = twisted.web.resource.Resource() | ||
resource.putChild('', xml_service) | ||
|
||
site = twisted.web.server.Site(resource) | ||
|
||
server = twisted.application.internet.TCPServer(port, site) | ||
server.setServiceParent(application) | ||
|
||
# rest service support -------------------------------------------------------- | ||
if 'rest_port' in config: | ||
rest_port = config['rest_port'] | ||
else: | ||
rest_port = 8088 | ||
|
||
site = twisted.web.server.Site(pyapns.rest_service.default_resource) | ||
|
||
server = twisted.application.internet.TCPServer(rest_port, site) | ||
server.setServiceParent(application) |
This trailing comma is tripping up the json parser for me