-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from synthicity/subcommands
Add subcommand CLI.
- Loading branch information
Showing
6 changed files
with
61 additions
and
34 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
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,17 @@ | ||
import sys | ||
|
||
from cliff.app import App | ||
from cliff.commandmanager import CommandManager | ||
|
||
|
||
class UrbansimCLI(App): | ||
def __init__(self): | ||
super(UrbansimCLI, self).__init__( | ||
description='UrbanSim Interface', | ||
version='0.2dev', | ||
command_manager=CommandManager('urbansim.commands')) | ||
|
||
|
||
def main(args=sys.argv[1:]): | ||
app = UrbansimCLI() | ||
return app.run(args) |
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,25 +1,29 @@ | ||
from __future__ import print_function | ||
|
||
import argparse | ||
import os.path | ||
import sys | ||
|
||
from urbansim.server import urbansimd | ||
from cliff.command import Command | ||
|
||
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) | ||
|
||
class Serve(Command): | ||
def get_description(self): | ||
return ('Start the UrbanSim server for use ' | ||
'with the UrbanSim web portal') | ||
|
||
def main(args=None): | ||
args = parse_args(args) | ||
def get_parser(self, prog_name): | ||
parser = argparse.ArgumentParser( | ||
description=self.get_description(), | ||
prog=prog_name) | ||
parser.add_argument( | ||
'dataset', help='HDF5 file which contains UrbanSim data.') | ||
return parser | ||
|
||
sys.path.insert(0, ".") | ||
import dataset | ||
dset = dataset.LocalDataset(args.dataset) | ||
def take_action(self, args): | ||
sys.path.insert(0, ".") | ||
import dataset | ||
dset = dataset.LocalDataset(args.dataset) | ||
|
||
urbansimd.start_service(dset) | ||
urbansimd.start_service(dset) |
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
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
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