<s> """<STR_LIT>""" <EOL> import os <EOL> import web <EOL> import socket <EOL> from karesansui . lib . rest import Rest , auth <EOL> from karesansui . lib . log . config import LogViewConfigParam <EOL> from karesansui . lib . const import LOG_VIEW_XML_FILE , DEFAULT_LANGS <EOL> from karesansui . lib . utils import json_dumps , is_param , str2datetime , create_epochsec <EOL> from karesansui . lib . log . viewer import read_all_log <EOL> from karesansui . lib . checker import Checker , CHECK_EMPTY , CHECK_VALID <EOL> def validates_log ( obj ) : <EOL> checker = Checker ( ) <EOL> check = True <EOL> _ = obj . _ <EOL> checker . errors = [ ] <EOL> if is_param ( obj . input , '<STR_LIT:s>' ) : <EOL> check = checker . check_datetime_string ( _ ( '<STR_LIT>' ) , <EOL> obj . input . s , <EOL> CHECK_EMPTY | CHECK_VALID , <EOL> obj . me . languages , <EOL> ) and check <EOL> if is_param ( obj . input , '<STR_LIT:e>' ) : <EOL> check = checker . check_datetime_string ( _ ( '<STR_LIT>' ) , <EOL> obj . input . e , <EOL> CHECK_EMPTY | CHECK_VALID , <EOL> obj . me . languages , <EOL> ) and check <EOL> if is_param ( obj . input , '<STR_LIT>' ) : <EOL> check = checker . check_time_string ( _ ( '<STR_LIT>' ) , <EOL> obj . input . st , <EOL> CHECK_EMPTY | CHECK_VALID , <EOL> ) and check <EOL> if is_param ( obj . input , '<STR_LIT>' ) : <EOL> check = checker . check_time_string ( _ ( '<STR_LIT>' ) , <EOL> obj . input . et , <EOL> CHECK_EMPTY | CHECK_VALID , <EOL> ) and check <EOL> obj . view . alert = checker . errors <EOL> return check <EOL> class HostBy1LogBy1 ( Rest ) : <EOL> @ auth <EOL> def _GET ( self , * param , ** params ) : <EOL> self . __template__ . dir = "<STR_LIT>" <EOL> self . __template__ . file = "<STR_LIT>" <EOL> self . __template__ . media = "<STR_LIT>" <EOL> appname = param [ <NUM_LIT:1> ] <EOL> log_config = None <EOL> if not validates_log ( self ) : <EOL> self . logger . debug ( "<STR_LIT>" ) <EOL> return web . badrequest ( self . view . alert ) <EOL> config = LogViewConfigParam ( LOG_VIEW_XML_FILE ) <EOL> config . load_xml_config ( ) <EOL> app = config . findby1application ( appname ) <EOL> lines = [ ] <EOL> param_value = { } <EOL> if self . input . has_key ( "<STR_LIT:k>" ) : <EOL> param_value [ "<STR_LIT:k>" ] = self . input . k <EOL> else : <EOL> param_value [ "<STR_LIT:k>" ] = "<STR_LIT>" <EOL> start_day = str2datetime ( self . input . s , <EOL> DEFAULT_LANGS [ self . me . languages ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> end_day = str2datetime ( self . input . e , <EOL> DEFAULT_LANGS [ self . me . languages ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> ( start_hour , start_minute ) = self . input . st . split ( '<STR_LIT::>' , <NUM_LIT:2> ) <EOL> ( end_hour , end_minute ) = self . input . et . split ( '<STR_LIT::>' , <NUM_LIT:2> ) <EOL> start_time = create_epochsec ( start_day . year , <EOL> start_day . month , <EOL> start_day . day , <EOL> int ( start_hour ) , <EOL> int ( start_minute ) , <EOL> ) <EOL> end_time = create_epochsec ( end_day . year , <EOL> end_day . month , <EOL> end_day . day , <EOL> int ( end_hour ) , <EOL> int ( end_minute ) , <EOL> ) <EOL> if int ( start_time ) > int ( end_time ) : <EOL> self . logger . error ( "<STR_LIT>" ) <EOL> return web . badrequest ( _ ( '<STR_LIT>' ) ) <EOL> param_value [ "<STR_LIT>" ] = "<STR_LIT>" % ( start_day . strftime ( "<STR_LIT>" ) , self . input . st ) <EOL> param_value [ "<STR_LIT>" ] = "<STR_LIT>" % ( end_day . strftime ( "<STR_LIT>" ) , self . input . et ) <EOL> lines = read_all_log ( app , <EOL> int ( self . input . m ) , <EOL> param_value [ "<STR_LIT>" ] , <EOL> param_value [ "<STR_LIT>" ] , <EOL> param_value [ "<STR_LIT:k>" ] ) <EOL> self . view . log_json = json_dumps ( lines ) <EOL> return True <EOL> urls = ( '<STR_LIT>' , HostBy1LogBy1 , ) </s>
