<s> import subprocess <EOL> import installation <EOL> username = None <EOL> email = None <EOL> fullname = None <EOL> password = None <EOL> system_recipients = None <EOL> def add_arguments ( mode , parser ) : <EOL> if mode != "<STR_LIT>" : <EOL> return <EOL> parser . add_argument ( "<STR_LIT>" , action = "<STR_LIT:store>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , action = "<STR_LIT:store>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , action = "<STR_LIT:store>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , action = "<STR_LIT:store>" , <EOL> help = "<STR_LIT>" ) <EOL> def prepare ( mode , arguments , data ) : <EOL> global username , email , fullname , password <EOL> if mode == "<STR_LIT>" : <EOL> print """<STR_LIT>""" <EOL> if arguments . admin_username : username = arguments . admin_username <EOL> else : username = installation . input . string ( prompt = "<STR_LIT>" ) <EOL> if arguments . admin_email : email = arguments . admin_email <EOL> else : email = installation . input . string ( prompt = "<STR_LIT>" ) <EOL> if arguments . admin_fullname : fullname = arguments . admin_fullname <EOL> else : fullname = installation . input . string ( prompt = "<STR_LIT>" ) <EOL> if installation . config . auth_mode == "<STR_LIT>" : <EOL> if arguments . admin_password : password = arguments . admin_password <EOL> else : password = installation . input . password ( "<STR_LIT>" % username ) <EOL> print """<STR_LIT>""" <EOL> if arguments . system_recipients : <EOL> system_recipients = arguments . system_recipients <EOL> else : <EOL> system_recipient = installation . input . string ( <EOL> prompt = "<STR_LIT>" , <EOL> default = "<STR_LIT>" % ( fullname , email ) ) <EOL> system_recipients = [ system_recipient ] <EOL> data [ "<STR_LIT>" ] = email <EOL> else : <EOL> import configuration <EOL> try : <EOL> system_recipients = configuration . base . SYSTEM_RECIPIENTS <EOL> except AttributeError : <EOL> system_recipients = [ "<STR_LIT>" % admin <EOL> for admin in configuration . base . ADMINISTRATORS ] <EOL> if arguments . system_recipients : <EOL> system_recipients = arguments . system_recipients <EOL> data [ "<STR_LIT>" ] = system_recipients <EOL> return True <EOL> def install ( data ) : <EOL> global password <EOL> try : <EOL> criticctl_argv = [ installation . criticctl . criticctl_path , "<STR_LIT>" , <EOL> "<STR_LIT>" , username , <EOL> "<STR_LIT>" , email , <EOL> "<STR_LIT>" , fullname ] <EOL> if not password : <EOL> criticctl_argv . extend ( [ "<STR_LIT>" ] ) <EOL> else : <EOL> criticctl_argv . extend ( [ "<STR_LIT>" , password ] ) <EOL> subprocess . check_output ( criticctl_argv ) <EOL> for role in [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] : <EOL> subprocess . check_output ( <EOL> [ installation . criticctl . criticctl_path , "<STR_LIT>" , <EOL> "<STR_LIT>" , username , <EOL> "<STR_LIT>" , role ] ) <EOL> except subprocess . CalledProcessError : <EOL> return False <EOL> return True </s>
