<s> """<STR_LIT>""" <EOL> import re <EOL> import sys <EOL> import os <EOL> import pwd <EOL> import grp <EOL> from optparse import OptionParser <EOL> try : <EOL> from cStringIO import StringIO <EOL> except ImportError : <EOL> from StringIO import StringIO <EOL> from pysilhouette import __version__ <EOL> usage = '<STR_LIT>' <EOL> def getopts ( ) : <EOL> optp = OptionParser ( usage = usage , version = __version__ ) <EOL> optp . add_option ( '<STR_LIT:-c>' , '<STR_LIT>' , dest = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> optp . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = "<STR_LIT:store_true>" , help = '<STR_LIT>' ) <EOL> optp . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = "<STR_LIT:store_true>" , help = '<STR_LIT>' ) <EOL> optp . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = "<STR_LIT:store>" , type = '<STR_LIT:string>' , help = '<STR_LIT>' ) <EOL> optp . add_option ( '<STR_LIT>' , '<STR_LIT>' , dest = '<STR_LIT>' , action = "<STR_LIT:store_true>" , help = '<STR_LIT>' ) <EOL> return optp . parse_args ( ) <EOL> def chkopts ( opts ) : <EOL> if not opts . config : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return True <EOL> if os . path . isfile ( opts . config ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return True <EOL> if opts . uniqkey : <EOL> return False <EOL> if opts . daemon is True and not opts . pidfile : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return True <EOL> if not opts . daemon and opts . pidfile : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return True <EOL> return False <EOL> def parse_conf ( cf ) : <EOL> from pysilhouette . util import is_int , is_key , set_cf_int <EOL> from pysilhouette . uniqkey import is_uuid <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if len ( err_key ) <= <NUM_LIT:0> and is_key ( cf , "<STR_LIT>" ) is False : <EOL> err_key = "<STR_LIT>" <EOL> if is_uuid ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return False <EOL> if <NUM_LIT:0> < len ( err_key ) : <EOL> print >> sys . stderr , '<STR_LIT>' % ( err_key ) <EOL> return False <EOL> if os . access ( cf [ "<STR_LIT>" ] , os . R_OK | os . X_OK ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> if os . access ( cf [ "<STR_LIT>" ] , os . R_OK | os . X_OK ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> if os . access ( cf [ "<STR_LIT>" ] , os . R_OK ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> if os . access ( cf [ "<STR_LIT>" ] , os . R_OK ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> else : <EOL> set_cf_int ( cf , "<STR_LIT>" ) <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> else : <EOL> set_cf_int ( cf , "<STR_LIT>" ) <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> else : <EOL> set_cf_int ( cf , "<STR_LIT>" ) <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> else : <EOL> set_cf_int ( cf , "<STR_LIT>" ) <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> else : <EOL> set_cf_int ( cf , "<STR_LIT>" ) <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> else : <EOL> set_cf_int ( cf , "<STR_LIT>" ) <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> else : <EOL> set_cf_int ( cf , "<STR_LIT>" ) <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> else : <EOL> set_cf_int ( cf , "<STR_LIT>" ) <EOL> p_mkfifo = set ( [ cf [ "<STR_LIT>" ] , <EOL> cf [ "<STR_LIT>" ] , <EOL> cf [ "<STR_LIT>" ] ] , <EOL> ) <EOL> if len ( p_mkfifo ) != <NUM_LIT:3> : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] , <EOL> cf [ "<STR_LIT>" ] , <EOL> cf [ "<STR_LIT>" ] , <EOL> ) <EOL> return False <EOL> try : <EOL> pwd . getpwnam ( cf [ "<STR_LIT>" ] ) <EOL> except : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> try : <EOL> grp . getgrnam ( cf [ "<STR_LIT>" ] ) <EOL> except : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> try : <EOL> int ( cf [ "<STR_LIT>" ] , <NUM_LIT:8> ) <EOL> except : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> a_mkfifo = set ( [ cf [ "<STR_LIT>" ] , <EOL> cf [ "<STR_LIT>" ] , <EOL> cf [ "<STR_LIT>" ] ] , <EOL> ) <EOL> if len ( a_mkfifo ) != <NUM_LIT:3> : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] , <EOL> cf [ "<STR_LIT>" ] , <EOL> cf [ "<STR_LIT>" ] , <EOL> ) <EOL> return False <EOL> try : <EOL> pwd . getpwnam ( cf [ "<STR_LIT>" ] ) <EOL> except : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> try : <EOL> grp . getgrnam ( cf [ "<STR_LIT>" ] ) <EOL> except : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> try : <EOL> int ( cf [ "<STR_LIT>" ] , <NUM_LIT:8> ) <EOL> except : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> if cf . has_key ( "<STR_LIT>" ) is True and cf [ "<STR_LIT>" ] == "<STR_LIT:1>" and cf . has_key ( "<STR_LIT>" ) is True and <NUM_LIT:0> < len ( cf [ "<STR_LIT>" ] ) : <EOL> if os . path . isfile ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' % ( cf [ "<STR_LIT>" ] ) <EOL> return False <EOL> if ( cf [ "<STR_LIT>" ] in ( "<STR_LIT:0>" , "<STR_LIT:1>" ) ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return False <EOL> if cf [ "<STR_LIT>" ] == "<STR_LIT:1>" : <EOL> if cf . has_key ( "<STR_LIT>" ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return False <EOL> if cf . has_key ( "<STR_LIT>" ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return False <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return False <EOL> else : <EOL> set_cf_int ( cf , "<STR_LIT>" ) <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return False <EOL> else : <EOL> set_cf_int ( cf , "<STR_LIT>" ) <EOL> if int ( cf [ "<STR_LIT>" ] ) <= <NUM_LIT:0> : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return False <EOL> else : <EOL> set_cf_int ( cf , "<STR_LIT>" ) <EOL> if int ( cf [ "<STR_LIT>" ] ) < int ( cf [ "<STR_LIT>" ] ) : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return False <EOL> if cf . has_key ( "<STR_LIT>" ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return False <EOL> if is_int ( cf [ "<STR_LIT>" ] ) is False : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return False <EOL> else : <EOL> set_cf_int ( cf , "<STR_LIT>" ) <EOL> if int ( cf [ "<STR_LIT>" ] ) <= <NUM_LIT:0> : <EOL> print >> sys . stderr , '<STR_LIT>' <EOL> return False <EOL> return True <EOL> def readconf ( path ) : <EOL> if not os . path . isfile ( path ) : <EOL> print >> sys . stderr , '<STR_LIT>' % path <EOL> return None <EOL> fp = open ( path , '<STR_LIT:r>' ) <EOL> try : <EOL> try : <EOL> _r = { } <EOL> for line in fp : <EOL> line = re . sub ( r'<STR_LIT>' , '<STR_LIT>' , line ) . strip ( ) <EOL> if len ( line ) <= <NUM_LIT:0> or line [ <NUM_LIT:0> ] == '<STR_LIT:#>' : <EOL> continue <EOL> key , value = line . split ( '<STR_LIT:=>' , <NUM_LIT:1> ) <EOL> try : <EOL> value = value [ : value . rindex ( '<STR_LIT:#>' ) ] <EOL> except ValueError , ve : <EOL> pass <EOL> _r [ key ] = value <EOL> return _r <EOL> except Exception , e : <EOL> print >> sys . stderr , '<STR_LIT>' % ( path , e . args ) <EOL> return None <EOL> finally : <EOL> fp . close ( ) <EOL> def sysappend ( pkg ) : <EOL> lines = [ ] <EOL> if type ( pkg ) is list : <EOL> lines = pkg <EOL> else : <EOL> print >> sys . stderr , '<STR_LIT>' % ( pkg , ) <EOL> return False <EOL> for line in lines : <EOL> f = False <EOL> for path in sys . path : <EOL> if line == path : <EOL> f = True <EOL> break <EOL> if f is False : <EOL> sys . path . insert ( <NUM_LIT:1> , line ) <EOL> return True <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> pass </s>
