<s> import os <EOL> import subprocess <EOL> from pyplease import modules <EOL> class Module ( modules . Module ) : <EOL> """<STR_LIT>""" <EOL> @ modules . action <EOL> def generate_key ( self , args ) : <EOL> """<STR_LIT>""" <EOL> self . extra_params ( args ) <EOL> self . prepare_folder ( ) <EOL> if os . path . exists ( self . normalize_path ( '<STR_LIT>' ) ) : <EOL> return self . failure ( '<STR_LIT>' ) <EOL> p = subprocess . Popen ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) . wait ( ) <EOL> if not p : <EOL> self . success ( '<STR_LIT>' ) <EOL> else : <EOL> self . failure ( '<STR_LIT>' % p ) <EOL> @ modules . action <EOL> def authorize ( self , args ) : <EOL> """<STR_LIT>""" <EOL> self . prepare_folder ( ) <EOL> if args : <EOL> key = args [ <NUM_LIT:0> ] <EOL> self . extra_params ( args [ <NUM_LIT:1> : ] ) <EOL> else : <EOL> key = self . ask ( '<STR_LIT>' , validate = self . validate_not_blank ) <EOL> path = self . normalize_path ( '<STR_LIT>' ) <EOL> if os . path . exists ( path ) and self . has_line ( path , key ) : <EOL> return self . failure ( '<STR_LIT>' ) <EOL> self . append ( path , '<STR_LIT>' % key . strip ( ) ) <EOL> return self . success ( '<STR_LIT>' ) <EOL> def prepare_folder ( self ) : <EOL> ssh = self . normalize_path ( '<STR_LIT>' ) <EOL> if not os . path . isdir ( ssh ) : <EOL> self . note ( '<STR_LIT>' % ssh ) <EOL> os . mkdir ( ssh , <NUM_LIT:0> <NUM_LIT> ) </s>
