<s> from __future__ import print_function <EOL> import os <EOL> from argparse import ArgumentTypeError <EOL> from kaylee . server import run <EOL> from kaylee . manager import LocalCommand <EOL> def port_type ( port ) : <EOL> try : <EOL> p = int ( port ) <EOL> if not <NUM_LIT> < p <= <NUM_LIT> : <EOL> msg = '<STR_LIT>' <EOL> raise ArgumentTypeError ( msg ) <EOL> return p <EOL> except ValueError : <EOL> raise '<STR_LIT>' . format ( port ) <EOL> class RunCommand ( LocalCommand ) : <EOL> name = '<STR_LIT>' <EOL> help = '<STR_LIT>' <EOL> args = { <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : dict ( default = '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : dict ( default = '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : dict ( default = '<STR_LIT>' , <EOL> type = port_type , <EOL> help = '<STR_LIT>' ) , <EOL> '<STR_LIT>' : dict ( default = False , <EOL> action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' ) , <EOL> } <EOL> @ staticmethod <EOL> def execute ( opts ) : <EOL> validate_settings_file ( opts ) <EOL> validate_build_dir ( opts ) <EOL> run_dev_server ( opts ) <EOL> def validate_settings_file ( opts ) : <EOL> if not os . path . exists ( opts . settings_file ) : <EOL> raise OSError ( '<STR_LIT>' <EOL> . format ( opts . settings_file ) ) <EOL> def validate_build_dir ( opts ) : <EOL> if not os . path . exists ( opts . build_dir ) : <EOL> raise OSError ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> . format ( opts . build_dir ) ) <EOL> def run_dev_server ( opts ) : <EOL> print ( '<STR_LIT>' ) <EOL> run ( opts . settings_file , opts . build_dir , opts . port , opts . debug ) </s>
