예제 #1
0
파일: command.py 프로젝트: mhworth/examples
"""
This module defines a number of utilities that are useful
for executing command-line commands.

The main class is the CommandExecutor, which defines the method
execute(command,arg_spec,stdout,stderr,stdin,kwargs**).

"""

import os,sys,re
from subprocess import Popen,PIPE
from logging import Logger

logger = Logger(__name__)
logger.disabled = True #Keep the logging off by default

class CommandError(Exception):
    def __init__(self,msg):
        self.msg = msg
    def __str__(self):
        return self.msg
    
class ICommandExecutor:
    """
    An interface for an object that may execute commands.
    
    :Author: Matt Hollingsworth
    :Date: 8-6-2008
    
    """
    def execute(self,command_to_execute,arg_spec,stdout,stderr,stdin,**kwargs):