<s> import web <EOL> import os <EOL> import socket <EOL> import karesansui <EOL> from karesansui . lib . rest import Rest , auth <EOL> from karesansui . db . access . machine import findbyhost1 <EOL> from karesansui . lib . utils import uri_split , uri_join <EOL> def _prep_console ( ) : <EOL> java_dir = karesansui . dirname + '<STR_LIT>' <EOL> sources = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> target = java_dir + '<STR_LIT>' <EOL> if not os . path . lexists ( target ) : <EOL> if not os . path . exists ( java_dir ) : <EOL> os . makedirs ( java_dir ) <EOL> for source in sources : <EOL> if os . path . exists ( source ) : <EOL> os . symlink ( source , target ) <EOL> class UriGuestBy1Console ( Rest ) : <EOL> @ auth <EOL> def _GET ( self , * param , ** params ) : <EOL> _prep_console ( ) <EOL> host_id = param [ <NUM_LIT:0> ] <EOL> host_id = self . chk_hostby1 ( param ) <EOL> if host_id is None : <EOL> return web . notfound ( ) <EOL> uri_id = param [ <NUM_LIT:1> ] <EOL> if uri_id is None : <EOL> return web . notfound ( ) <EOL> model = findbyhost1 ( self . orm , host_id ) <EOL> try : <EOL> segs = uri_split ( model . hostname ) <EOL> self . view . host_ipaddr = socket . gethostbyname ( segs [ '<STR_LIT:host>' ] ) <EOL> except : <EOL> self . view . host_ipaddr = socket . gethostbyname ( socket . gethostname ( ) ) <EOL> return True <EOL> urls = ( <EOL> '<STR_LIT>' , UriGuestBy1Console , <EOL> ) </s>
