Exemple #1
0
    def __init__(self, formData, construct=False):
        '''Constructor
		
		Parameters:
			formData - A FormData instance
			construct - If True this method calls construct immediately,
				otherwise construct must be called at a later stage.
				This allows parameters to be modified.'''

        self.formData = formData
        self.runString = None
        self.errorData = None
        self.job = None
        self.jobManager = None

        try:
            self.options = UtilityFunctions.DefaultWebAppConfiguration()
            self.connection = UtilityFunctions.ConnectionFromConfiguration(
                self.options)
            self.webServerDirectory = self.options.get('WEB APPLICATION',
                                                       'webServerDirectory')
            self.uploadLimit = int(
                self.options.get('WEB APPLICATION', 'uploadLimit'))
        except Core.Exceptions.EnvironmentError, data:
            self._setErrorData(data)
            return
Exemple #2
0
    def __init__(self):

        #Get environment
        self.environment = Core.Environment.Environment()

        #Parse command line
        self.parser = CommandLineParser()
        self.parser.parseCommandLine()

        #Read Configuration, connect to database and create Job object.
        self.configuration = Core.Environment.Configuration(
            filename=self.parser.configurationFile())
        self.connection = None
        self.job = None
        if self.environment.isRoot():
            self.connection = UtilityFunctions.ConnectionFromConfiguration(
                self.configuration)
            print '[WEBAPP] Connection %s' % self.connection
            print '[WEBAPP] Retrieving job data'
            self.job = Data.Job(jobID=self.parser.jobID(),
                                connection=self.connection)
            if not self.job.exists():
                raise Exceptions.DatabaseRetrievalError, 'Data for job %d is not present in database' % self.job.identification
            else:
                print '[WEBAPP] Obtained job data'
                self.job.setState('Running')
                self.job.setQueueStatusMessage('Your job is running')

        self.environment.wait()

        #Set the $HOME environment variable for apache to the path to the .WHAT_IF file
        #specifying the path to the whatif executable (used by pKarun.WHATIF.py)
        os.environ['HOME'] = self.configuration.get('PATHS', 'whatif')

        #Create the output directory
        if self.environment.isRoot() and self.parser.outputDirectory(
        ) is not None:
            if not os.path.exists(self.parser.outputDirectory()):
                os.mkdir(self.parser.outputDirectory())

        self.environment.wait()