<s> from ajenti . api import * <EOL> class RAIDDevice ( object ) : <EOL> def __init__ ( self ) : <EOL> self . name = '<STR_LIT>' <EOL> self . up = False <EOL> self . failed = False <EOL> self . spared = False <EOL> self . index = <NUM_LIT:0> <EOL> class RAIDArray ( object ) : <EOL> def __init__ ( self ) : <EOL> self . name = '<STR_LIT>' <EOL> self . type = '<STR_LIT>' <EOL> self . blocks = <NUM_LIT:0> <EOL> self . metadata = '<STR_LIT>' <EOL> self . devices = [ ] <EOL> self . recovery = False <EOL> self . recovery_progress = <NUM_LIT:0> <EOL> self . recovery_remaining = '<STR_LIT>' <EOL> @ plugin <EOL> class RAIDManager ( BasePlugin ) : <EOL> def __init__ ( self ) : <EOL> self . refresh ( ) <EOL> def refresh ( self ) : <EOL> self . arrays = [ ] <EOL> ll = open ( '<STR_LIT>' ) . read ( ) . splitlines ( ) <EOL> while ll : <EOL> l = ll . pop ( <NUM_LIT:0> ) <EOL> if l . startswith ( '<STR_LIT>' ) : <EOL> continue <EOL> if l . startswith ( '<STR_LIT>' ) : <EOL> continue <EOL> if '<STR_LIT::>' in l : <EOL> array = RAIDArray ( ) <EOL> array . name , tokens = l . split ( '<STR_LIT::>' ) <EOL> array . name = array . name . strip ( ) <EOL> tokens = tokens . split ( ) <EOL> if tokens [ <NUM_LIT:1> ] . startswith ( '<STR_LIT:(>' ) : <EOL> tokens [ <NUM_LIT:0> ] += '<STR_LIT:U+0020>' + tokens [ <NUM_LIT:1> ] <EOL> tokens . pop ( <NUM_LIT:1> ) <EOL> array . state = tokens [ <NUM_LIT:0> ] <EOL> array . active = array . state == '<STR_LIT>' <EOL> array . type = tokens [ <NUM_LIT:1> ] <EOL> devices = tokens [ <NUM_LIT:2> : ] <EOL> l = ll . pop ( <NUM_LIT:0> ) <EOL> tokens = l . split ( ) <EOL> array . blocks = int ( tokens [ <NUM_LIT:0> ] ) <EOL> array . metadata = tokens [ <NUM_LIT:3> ] <EOL> states = tokens [ - <NUM_LIT:1> ] [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> self . arrays . append ( array ) <EOL> for i , device_str in enumerate ( devices ) : <EOL> device = RAIDDevice ( ) <EOL> device . name = device_str . split ( '<STR_LIT:[>' ) [ <NUM_LIT:0> ] <EOL> device . index = int ( device_str . split ( '<STR_LIT:[>' ) [ <NUM_LIT:1> ] . split ( '<STR_LIT:]>' ) [ <NUM_LIT:0> ] ) <EOL> if device_str . endswith ( "<STR_LIT>" ) : <EOL> device . failed = True <EOL> elif device_str . endswith ( "<STR_LIT>" ) : <EOL> device . spared = True <EOL> else : <EOL> device . up = True <EOL> array . devices . append ( device ) <EOL> l = ll . pop ( <NUM_LIT:0> ) <EOL> if '<STR_LIT>' in l : <EOL> array . recovery = True <EOL> array . recovery_progress = float ( l . split ( ) [ <NUM_LIT:3> ] . strip ( '<STR_LIT:%>' ) ) / <NUM_LIT:100> <EOL> array . recovery_remaining = l . split ( ) [ <NUM_LIT:5> ] . split ( '<STR_LIT:=>' ) [ <NUM_LIT:1> ] </s>
