def buildOpts( self ): """ TODO """ print "TODO: No build options for python yet." self.opts = [] debug( "buildOpts: using " + str( self.opts ) )
def execute( self ): """ Once we have all of the command-line options and such, invokes the program using the correct syntax. """ # Essentially, just a semantic wrapper to subprocess in case we want to # change the execution method. print "==============================================================\n" for command in self.commandLines(): debug( "Executing: '" + " ".join( command ) + "'" ) try: subprocess.call( command, stdin=self.stdin, stdout=self.stdout ) except OSError as e: print "Error during execution:", e print "(Command was '" + " ".join( command ) + "')" # If the user had output piped to a file, be nice and show them anyway if self.stdout != sys.stdout: with open( self.stdout.name, "r" ) as f: print f.read() else: # Keep the number of whitespace lines even print "" print "=============================================================="
def commandLines(self): """ TODO """ # Java compiling compileLine = [self.compiler()] + self.compileOpts + self.toCompile debug("Compile Line: " + str(compileLine)) # Java running runLine = [self.executable()] + self.runOpts + [self.filenameOnly] + self.args debug("Run Line: " + str(runLine)) return [compileLine, runLine]
def __init__( self, filename, settings, noPrompt ): """ Set default values. """ self.stdin = sys.stdin self.stdout = sys.stdout self.filename = filename self.extension = filename.split( '.' )[ -1 ] self.settings = settings self.noPrompt = noPrompt # Isolate the filetype from the concrete class name self.filetype = self.__module__.replace( 'Builder', '' ).lower() debug( "Filetype is: '" + self.filetype + "'" ) # Eliminate the file extension self.filenameOnly = "".join( self.filename.split( '.' )[ :-1 ] ) # Eliminate the /path/to/ self.filenameOnly = self.filenameOnly.split( os.path.sep )[ -1 ] # Just in case: Get in the correct directory os.chdir( os.path.sep.join( self.filename.split( os.path.sep )[ :-1 ] ) )