Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding entry point for urbansim_serve #14

Merged
merged 3 commits into from
Mar 25, 2014
Merged
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ install:
# install urbansim
- pip install .
script:
- pep8 urbansim scripts urbansimd
- pep8 urbansim scripts
- py.test --cov urbansim --cov-report term-missing
after_success:
- coveralls
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'Programming Language :: Python :: 2.7',
'License :: OSI Approved :: GNU Affero General Public License v3'
],
packages=find_packages(exclude=['urbansimd', '*.tests']),
packages=find_packages(exclude=['*.tests']),
package_data={'urbansim.urbansim': ['templates/*.template']},
install_requires=[
'Django>=1.6.2',
Expand All @@ -33,7 +33,8 @@
],
entry_points={
'console_scripts': [
'urbansim_compile = urbansim.urbansim.compilecli:main'
'urbansim_compile = urbansim.urbansim.compilecli:main',
'urbansim_serve = urbansim.server.servecli:main'
]
}
)
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions urbansim/server/servecli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from __future__ import print_function

import argparse
import os.path
import sys

from urbansim.server import urbansimd


def parse_args(args=None):
parser = argparse.ArgumentParser(
description=('Start the UrbanSim server for use with the UrbanSim web portal'))
parser.add_argument(
'dataset', help='HDF5 file which contains UrbanSim data.')
return parser.parse_args(args)


def main(args=None):
args = parse_args(args)

sys.path.insert(0, ".")
import dataset
dset = dataset.LocalDataset(args.dataset)

urbansimd.start_service(dset)
File renamed without changes.
File renamed without changes.
15 changes: 3 additions & 12 deletions urbansimd/urbansimd.py → urbansim/server/urbansimd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
import pandas as pd
import simplejson
from bottle import Bottle, route, run, response, hook, request, post
from django.http import HttpResponse
from django.conf import settings

sys.path.insert(0, ".")
import dataset
from urbansim.urbansim import modelcompile
from urbansim.utils import misc

Expand Down Expand Up @@ -333,16 +329,11 @@ def query():
return jsonp(request, s)


def start_service(port=8765, host='localhost'):
def start_service(dset, port=8765, host='localhost'):
global DSET
DSET = dset

try:
settings.configure()
except:
pass
run(host=host, port=port, debug=True, server='tornado')

if __name__ == '__main__':
global DSET
args = sys.argv[1:]
DSET = dataset.BayAreaDataset(args[0])
start_service()