Module app
A base class for applications that can be run under job control.
Derive your application class from app.App and overwrite the following
methods:
commandLine() - Use to set instance attributes according to the command line
                args and any input file parameters.
backend() - Execute the main backend code. Should use the instance attributes
            set by commandLine()
gui() - (optional) Run a user-designed GUI.  Call launchBackend() with a list
        of command-line args to run the job.
Here is an example script that illustrates the usage of App for indenting
a set of files...
----------
import sys, os
import schrodinger.job.app as app
                                                                                
class ExampleApp(app.App):
    # Indent a set of files.
                                                                                
    def commandLine(self,args):
        self.input_files = []
        for a in args:
            self.input_files.append(a)
            self.addInputFile(a)
        self.setJobName("myappexample")
        self.outputfile = self.getJobName()+".out"
        self.addOutputFileFE(self.outputfile)
        self.nfilesread = 0
        return []     # Don't return None
                                                                                
    def gui(self):
        # NOT IMPLEMENTED.  Launch a GUI for this silly example. Call
        # self.launchBackend(command_line_args) to start the job.
        pass
                                                                                
    def backend(self):
        for ifile,filename in enumerate(self.input_files):
            if ifile<self.nfilesread:
                print "File '%s' already processed" % filename
            else:
                print "Processing file '%s'" % filename
                fh = open(filename,'r')
                outputfilename = self.getJobName()+"_indent_"+filename
                self.addOutputFileBE(outputfilename)
                ofh = open(outputfilename,'w')
                iline = 0
                for line in fh:
                    ofh.write("    "+line)
                    iline += 1
                ofh.close()
                fh.close()
                print "    Number of lines = ",iline
                self.nfilesread = ifile+1
                self.dumpBE()
        ofh.close()
        print "
Backend complete."
                                                                                
def appexample():     # Invoke the GUI from Maestro
    ExampleApp(__file__,["-gui"]).run()
                                                                                
if __name__ == '__main__':
    ExampleApp(__file__,sys.argv[1:]).run()
----------
Copyright Schrodinger, LLC. All rights reserved.
    |  | App A class to handle all aspects of job setup and running.
 | 
    |  | 
        
          | _remove(file) Removes a file if it exists.
 |  |  | 
    |  | _version = '$Revision: 1.37 $' | 
    |  | logger = log.get_logger("schrodinger.job.app") | 
    |  | maestro = Nonehash(x)
 | 
    |  | __package__ = 'schrodinger.job' |