Package pyvb :: Module command
[hide private]
[frames] | no frames]

Source Code for Module pyvb.command

 1  """ 
 2  command - pyvb module that holds a simple command abstraction 
 3  used to run VirtualBox commands. 
 4  """ 
 5  import popen2 
 6  from pyvb.exception import vbCommandError 
 7   
8 -class VBCommand:
9 """An abstraction representing a command line command."""
10 - def __init__(self, command=''):
11 """Constructor. Initialize the command to run. 12 @keyword command: The command to run. 13 @type command: String 14 @return: A new L{pyvb.command.VBCommand} instance. 15 @rtype: L{pyvb.command.VBCommand}""" 16 self.command=command
17
18 - def run(self):
19 """Run the command and set the read, write, and error attributes. 20 If there was and error, and exception is raised. 21 @return: None 22 @rtype: None""" 23 self.read, self.write, self.error=popen2.popen3(self.command) 24 error_message=self.error.read() 25 if error_message: 26 raise vbCommandError(error_message)
27