<s> EVENT_APPLIANCE = <NUM_LIT> <EOL> EVENT_LIBRARY = <NUM_LIT> <EOL> EVENT_WARNING = <NUM_LIT> <EOL> EVENT_TRACE = <NUM_LIT> <EOL> class GuestFS ( object ) : <EOL> SUPPORT_CLOSE_ON_EXIT = True <EOL> SUPPORT_RETURN_DICT = True <EOL> def __init__ ( self , ** kwargs ) : <EOL> if not self . SUPPORT_CLOSE_ON_EXIT and '<STR_LIT>' in kwargs : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> if not self . SUPPORT_RETURN_DICT and '<STR_LIT>' in kwargs : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> self . _python_return_dict = kwargs . get ( '<STR_LIT>' , False ) <EOL> self . kwargs = kwargs <EOL> self . drives = [ ] <EOL> self . running = False <EOL> self . closed = False <EOL> self . mounts = [ ] <EOL> self . files = { } <EOL> self . auginit = False <EOL> self . root_mounted = False <EOL> self . backend_settings = None <EOL> self . trace_enabled = False <EOL> self . verbose_enabled = False <EOL> self . event_callback = None <EOL> def launch ( self ) : <EOL> self . running = True <EOL> def shutdown ( self ) : <EOL> self . running = False <EOL> self . mounts = [ ] <EOL> self . drives = [ ] <EOL> def set_backend_settings ( self , settings ) : <EOL> self . backend_settings = settings <EOL> def close ( self ) : <EOL> self . closed = True <EOL> def add_drive_opts ( self , file , * args , ** kwargs ) : <EOL> if file == "<STR_LIT>" : <EOL> raise RuntimeError ( "<STR_LIT>" , file ) <EOL> self . drives . append ( ( file , kwargs ) ) <EOL> def add_drive ( self , file , format = None , * args , ** kwargs ) : <EOL> self . add_drive_opts ( file , format = None , * args , ** kwargs ) <EOL> def inspect_os ( self ) : <EOL> return [ "<STR_LIT>" ] <EOL> def inspect_get_mountpoints ( self , dev ) : <EOL> mountpoints = [ ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT:/>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) ] <EOL> if self . SUPPORT_RETURN_DICT and self . _python_return_dict : <EOL> return dict ( mountpoints ) <EOL> else : <EOL> return mountpoints <EOL> def mount_options ( self , options , device , mntpoint ) : <EOL> if mntpoint == "<STR_LIT:/>" : <EOL> self . root_mounted = True <EOL> else : <EOL> if not self . root_mounted : <EOL> raise RuntimeError ( <EOL> "<STR_LIT>" % mntpoint ) <EOL> self . mounts . append ( ( options , device , mntpoint ) ) <EOL> def mkdir_p ( self , path ) : <EOL> if path not in self . files : <EOL> self . files [ path ] = { <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : <NUM_LIT:100> , <EOL> "<STR_LIT>" : <NUM_LIT:100> , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } <EOL> def read_file ( self , path ) : <EOL> if path not in self . files : <EOL> self . files [ path ] = { <EOL> "<STR_LIT>" : False , <EOL> "<STR_LIT:content>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:100> , <EOL> "<STR_LIT>" : <NUM_LIT:100> , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } <EOL> return self . files [ path ] [ "<STR_LIT:content>" ] <EOL> def write ( self , path , content ) : <EOL> if path not in self . files : <EOL> self . files [ path ] = { <EOL> "<STR_LIT>" : False , <EOL> "<STR_LIT:content>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:100> , <EOL> "<STR_LIT>" : <NUM_LIT:100> , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } <EOL> self . files [ path ] [ "<STR_LIT:content>" ] = content <EOL> def write_append ( self , path , content ) : <EOL> if path not in self . files : <EOL> self . files [ path ] = { <EOL> "<STR_LIT>" : False , <EOL> "<STR_LIT:content>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:100> , <EOL> "<STR_LIT>" : <NUM_LIT:100> , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } <EOL> self . files [ path ] [ "<STR_LIT:content>" ] = self . files [ path ] [ "<STR_LIT:content>" ] + content <EOL> def stat ( self , path ) : <EOL> if path not in self . files : <EOL> raise RuntimeError ( "<STR_LIT>" + path ) <EOL> return self . files [ path ] [ "<STR_LIT>" ] <EOL> def chown ( self , uid , gid , path ) : <EOL> if path not in self . files : <EOL> raise RuntimeError ( "<STR_LIT>" + path ) <EOL> if uid != - <NUM_LIT:1> : <EOL> self . files [ path ] [ "<STR_LIT>" ] = uid <EOL> if gid != - <NUM_LIT:1> : <EOL> self . files [ path ] [ "<STR_LIT>" ] = gid <EOL> def chmod ( self , mode , path ) : <EOL> if path not in self . files : <EOL> raise RuntimeError ( "<STR_LIT>" + path ) <EOL> self . files [ path ] [ "<STR_LIT>" ] = mode <EOL> def aug_init ( self , root , flags ) : <EOL> self . auginit = True <EOL> def aug_close ( self ) : <EOL> self . auginit = False <EOL> def aug_get ( self , cfgpath ) : <EOL> if not self . auginit : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> if cfgpath == "<STR_LIT>" : <EOL> return <NUM_LIT:0> <EOL> elif cfgpath == "<STR_LIT>" : <EOL> return <NUM_LIT> <EOL> elif cfgpath == "<STR_LIT>" : <EOL> return <NUM_LIT> <EOL> elif cfgpath == "<STR_LIT>" : <EOL> return <NUM_LIT:0> <EOL> elif cfgpath == "<STR_LIT>" : <EOL> return <NUM_LIT> <EOL> elif cfgpath == "<STR_LIT>" : <EOL> return <NUM_LIT> <EOL> raise RuntimeError ( "<STR_LIT>" , cfgpath ) <EOL> def set_trace ( self , enabled ) : <EOL> self . trace_enabled = enabled <EOL> def set_verbose ( self , enabled ) : <EOL> self . verbose_enabled = enabled <EOL> def set_event_callback ( self , func , events ) : <EOL> self . event_callback = ( func , events ) <EOL> def vfs_type ( self , dev ) : <EOL> return '<STR_LIT>' </s>
