<s> import os <EOL> import os . path <EOL> import sys <EOL> import logging <EOL> from optparse import OptionParser <EOL> from ksscommand import KssCommand , KssCommandException , KssCommandOptException <EOL> import __cmd__ <EOL> try : <EOL> import karesansui <EOL> from karesansui import __version__ <EOL> from karesansui . lib . utils import load_locale , copy_file , remove_file <EOL> from karesansui . lib . const import LIGHTTPD_CONF_TEMP_DIR , LIGHTTPD_PORT_CONFIG , LIGHTTPD_ACCESS_CONFIG , LIGHTTPD_SSL_CONFIG <EOL> except ImportError , e : <EOL> print >> sys . stderr , "<STR_LIT>" % e <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> _ = load_locale ( ) <EOL> usage = '<STR_LIT>' <EOL> def getopts ( ) : <EOL> opts = OptionParser ( usage = usage , version = __version__ ) <EOL> opts . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = ( '<STR_LIT>' ) ) <EOL> opts . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = ( '<STR_LIT>' ) ) <EOL> opts . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = ( '<STR_LIT>' ) ) <EOL> opts . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = ( '<STR_LIT>' ) ) <EOL> return opts . parse_args ( ) <EOL> def chkopts ( opts ) : <EOL> if not opts . dest : <EOL> raise KssCommandOptException ( '<STR_LIT>' ) <EOL> elif not opts . tmp_port_conf : <EOL> raise KssCommandOptException ( '<STR_LIT>' ) <EOL> elif not opts . tmp_ssl_conf : <EOL> raise KssCommandOptException ( '<STR_LIT>' ) <EOL> elif not opts . tmp_access_conf : <EOL> raise KssCommandOptException ( '<STR_LIT>' ) <EOL> if os . path . isdir ( opts . dest ) is False : <EOL> raise KssCommandOptException ( '<STR_LIT>' % opts . dest ) <EOL> elif os . path . isfile ( opts . tmp_port_conf ) is False : <EOL> raise KssCommandOptException ( '<STR_LIT>' % opts . tmp_port_conf ) <EOL> elif os . path . isfile ( opts . tmp_ssl_conf ) is False : <EOL> raise KssCommandOptException ( '<STR_LIT>' % opts . tmp_ssl_conf ) <EOL> elif os . path . isfile ( opts . tmp_access_conf ) is False : <EOL> raise KssCommandOptException ( '<STR_LIT>' % opts . tmp_access_conf ) <EOL> class LighttpdConfigFile ( KssCommand ) : <EOL> def process ( self ) : <EOL> ( opts , args ) = getopts ( ) <EOL> chkopts ( opts ) <EOL> opts . dest = opts . dest . rstrip ( '<STR_LIT:/>' ) <EOL> self . up_progress ( <NUM_LIT:10> ) <EOL> tmp_configfiles = { <EOL> LIGHTTPD_PORT_CONFIG : opts . tmp_port_conf , <EOL> LIGHTTPD_SSL_CONFIG : opts . tmp_ssl_conf , <EOL> LIGHTTPD_ACCESS_CONFIG : opts . tmp_access_conf <EOL> } <EOL> self . up_progress ( <NUM_LIT:10> ) <EOL> for srcfile in tmp_configfiles . values ( ) : <EOL> if os . path . isfile ( srcfile ) is False : <EOL> raise KssCommandException ( <EOL> '<STR_LIT>' % srcfile ) <EOL> self . up_progress ( <NUM_LIT:20> ) <EOL> try : <EOL> for dest , src in tmp_configfiles . items ( ) : <EOL> copy_file ( src , opts . dest + '<STR_LIT:/>' + dest ) <EOL> remove_file ( src ) <EOL> self . up_progress ( <NUM_LIT> ) <EOL> except : <EOL> raise KssCommandException ( '<STR_LIT>' % ( src , dest ) ) <EOL> self . logger . info ( '<STR_LIT>' ) <EOL> print >> sys . stdout , _ ( '<STR_LIT>' ) <EOL> return True <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> target = LighttpdConfigFile ( ) <EOL> sys . exit ( target . run ( ) ) </s>
