<s> import re <EOL> from pyinfra . api import FactBase <EOL> class UpstartStatus ( FactBase ) : <EOL> '''<STR_LIT>''' <EOL> command = '<STR_LIT>' <EOL> _regex = r'<STR_LIT>' <EOL> def process ( self , output ) : <EOL> services = { } <EOL> for line in output : <EOL> matches = re . match ( self . _regex , line ) <EOL> if matches : <EOL> services [ matches . group ( <NUM_LIT:1> ) ] = matches . group ( <NUM_LIT:2> ) == '<STR_LIT>' <EOL> return services <EOL> class SystemdStatus ( FactBase ) : <EOL> '''<STR_LIT>''' <EOL> command = '<STR_LIT>' <EOL> _regex = r'<STR_LIT>' <EOL> def process ( self , output ) : <EOL> services = { } <EOL> for line in output : <EOL> matches = re . match ( self . _regex , line ) <EOL> if matches : <EOL> services [ matches . group ( <NUM_LIT:1> ) ] = matches . group ( <NUM_LIT:2> ) == '<STR_LIT>' <EOL> return services <EOL> class SystemdEnabled ( FactBase ) : <EOL> '''<STR_LIT>''' <EOL> command = '<STR_LIT>' <EOL> _regex = r'<STR_LIT>' <EOL> def process ( self , output ) : <EOL> services = { } <EOL> for line in output : <EOL> matches = re . match ( self . _regex , line ) <EOL> if matches : <EOL> services [ matches . group ( <NUM_LIT:1> ) ] = matches . group ( <NUM_LIT:2> ) in ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> return services <EOL> class InitdStatus ( FactBase ) : <EOL> '''<STR_LIT>''' <EOL> command = '''<STR_LIT>''' <EOL> _regex = r'<STR_LIT>' <EOL> def process ( self , output ) : <EOL> services = { } <EOL> for line in output : <EOL> matches = re . match ( self . _regex , line ) <EOL> if matches : <EOL> status = int ( matches . group ( <NUM_LIT:2> ) ) <EOL> if status == <NUM_LIT:0> : <EOL> status = True <EOL> elif status < <NUM_LIT:4> : <EOL> status = False <EOL> else : <EOL> status = None <EOL> services [ matches . group ( <NUM_LIT:1> ) ] = status <EOL> return services <EOL> class RcdStatus ( InitdStatus ) : <EOL> '''<STR_LIT>''' <EOL> command = '''<STR_LIT>''' <EOL> class RcdEnabled ( FactBase ) : <EOL> '''<STR_LIT>''' </s>
