Example #1
0
    def status(self):
        url = self.get_absolute_url()
        if process_is_running(url):
            status = """Analysis for <em>%s</em> is currently running.""" % (self.name,)
            code = 2
        elif process_is_complete(url):
            status = "%s processing is done." % self.name
            code = 3
        elif process_is_pending(url):
            status = "%s is in the queue but not yet running." % self.name
            res = get_process_result(url)
            code = 1
            if res is not None:
                status += ".. "
                status += str(res)
        else:
            status = "An error occured while running this analysis."
            code = 0
            res = get_process_result(url)
            if res is not None:
                status += "..<br/> "
                status += str(res)
            status += "<br/>Please edit the scenario and try again. If the problem persists, please contact us."

        return (code, "<p>%s</p>" % status)
Example #2
0
    def status(self):
        url = self.get_absolute_url()
        if process_is_running(url):
            status = """Analysis is currently running."""
            if self.progress[0] == 0:
                status += " (Pre-processing)"
            code = 2
        elif process_is_complete(url):
            status = "Analysis completed. Compiling results..."
            code = 3
        elif process_is_pending(url):
            status = "Analysis is in the queue but not yet running."
            res = get_process_result(url)
            code = 1
            if res is not None:
                status += ".. "
                status += str(res)
        else:
            status = "An error occured while running this analysis."
            code = 0
            res = get_process_result(url)
            if res is not None:
                status += "..<br/> "
                status += str(res)
            status += "<br/>Please edit the scenario and try again. If the problem persists, please contact us."

        return (code, "<p>%s</p>" % status)
Example #3
0
 def process_results(self):
     if process_is_complete(self.get_absolute_url()):
         chosen = get_process_result(self.get_absolute_url())
         wshds = PlanningUnit.objects.filter(pk__in=chosen)
         self.output_best = json.dumps({'best': [str(x.pk) for x in wshds]})
         ssoln = [x.strip().split(',') for x in 
                  open(os.path.join(self.outdir,"output","seak_ssoln.csv"),'r').readlines()][1:]
         selected = {}
         for s in ssoln:
             num = int(s[1])
             if num > 0:
                 selected[int(s[0])] = num
         self.output_pu_count = json.dumps(selected) 
         super(Analysis, self).save() # save without calling save()
         self.invalidate_cache()