def get(self):
        if 'reqType' in self.request.GET:
            if self.request.get('reqType') == 'delete':
                errorLogsId = int(self.request.get('id'))

                errorLogsDb = SBMLImportErrorLogs.get_by_id(errorLogsId)

                errorLogsDb.delete()

                self.redirect("/importFromSBML")

        errorLogsDbQuery = list(
            db.GqlQuery("SELECT * FROM SBMLImportErrorLogs WHERE user_id = :1",
                        self.user.user_id()).run())
        errorLogsDbQuery = sorted(
            errorLogsDbQuery,
            key=lambda x:
            (datetime.datetime.strptime(x.date, '%Y-%m-%d-%H-%M-%S')
             if hasattr(x, 'date') and x.date != None else datetime.datetime.
             now()),
            reverse=True)

        result = []

        for error in errorLogsDbQuery:
            modelDb = StochKitModelWrapper.get_by_id(error.modelId)
            result.append({
                'id': error.key().id(),
                'date': error.date,
                'fileName': error.fileName,
                'modelName': modelDb.name if modelDb else None
            })

        self.render_response('importFromSBML.html', **{"errors": result})
Beispiel #2
0
    def get(self):
        if 'id' in self.request.GET:
            errorLogsId = int(self.request.get('id'));
            errorLogsDb = SBMLImportErrorLogs.get_by_id(errorLogsId)

            modelDb = StochKitModelWrapper.get_by_id(errorLogsDb.modelId)

            result = { "db" : errorLogsDb,
                       "modelName" : modelDb.name if modelDb else None }

            print result["db"].errors

        self.render_response('SBMLErrorLogs.html', **result)
Beispiel #3
0
    def get(self):
        if 'id' in self.request.GET:
            errorLogsId = int(self.request.get('id'));
            errorLogsDb = SBMLImportErrorLogs.get_by_id(errorLogsId)

            modelDb = StochKitModelWrapper.get_by_id(errorLogsDb.modelId)

            result = { "db" : errorLogsDb,
                       "modelName" : modelDb.name if modelDb else None }

            print result["db"].errors

        self.render_response('SBMLErrorLogs.html', **result)
    def post(self):
        try:
            storage = self.request.POST['datafile']

            name = storage.filename.split('.')[0]

            tmp = tempfile.NamedTemporaryFile(delete=False)
            filename = tmp.name
            tmp.write(storage.file.read())
            tmp.close()

            #stochKitModel = stochss.stochkit.StochMLDocument.fromString(storage.file.read()).toModel(name)
            model, errors = stochss.SBMLconverter.convertToStochSS(filename)

            modelDb = createStochKitModelWrapperFromStochKitModel(self, model)

            modelDb.units = model.units
            modelDb.put()

            errorLogsDb = SBMLImportErrorLogs()
            errorLogsDb.modelId = modelDb.key().id()
            errorLogsDb.user_id = self.user.user_id()
            errorLogsDb.fileName = storage.filename
            errorLogsDb.errors = errors
            errorLogsDb.date = time.strftime("%Y-%m-%d-%H-%M-%S")
            errorLogsDb.put()

            os.remove(filename)

            #self.redirect("/modeleditor?select={0}".format(modelDb.key().id()))
            self.redirect("/SBMLErrorLogs?id={0}".format(
                errorLogsDb.key().id()))
        except Exception as e:
            traceback.print_exc()
            result = {}
            result['status'] = False
            result['msg'] = 'Error: {0}'.format(e)

            self.render_response("importFromSBML.html", **result)
Beispiel #5
0
    def post(self):
        try:
            storage = self.request.POST['datafile']

            name = storage.filename.split('.')[0]

            tmp = tempfile.NamedTemporaryFile(delete = False)
            filename = tmp.name
            tmp.write(storage.file.read())
            tmp.close()

            #stochKitModel = stochss.stochkit.StochMLDocument.fromString(storage.file.read()).toModel(name)
            model, errors = stochss.SBMLconverter.convertToStochSS(filename)

            modelDb = createStochKitModelWrapperFromStochKitModel(self, model)
            
            modelDb.units = model.units
            modelDb.put()

            errorLogsDb = SBMLImportErrorLogs()
            errorLogsDb.modelId = modelDb.key().id()
            errorLogsDb.user_id = self.user.user_id()
            errorLogsDb.fileName = storage.filename
            errorLogsDb.errors = errors
            errorLogsDb.date = time.strftime("%Y-%m-%d-%H-%M-%S")
            errorLogsDb.put()

            os.remove(filename)
            
            #self.redirect("/modeleditor?select={0}".format(modelDb.key().id()))
            self.redirect("/SBMLErrorLogs?id={0}".format(errorLogsDb.key().id()))
        except Exception as e:
            traceback.print_exc()
            result = {}
            result['status'] = False
            result['msg'] = 'Error: {0}'.format(e)

            self.render_response("importFromSBML.html", **result)
Beispiel #6
0
    def get(self):
        if 'reqType' in self.request.GET:
            if self.request.get('reqType') == 'delete':
                errorLogsId = int(self.request.get('id'));
                    
                errorLogsDb = SBMLImportErrorLogs.get_by_id(errorLogsId)

                errorLogsDb.delete()
                    
                self.redirect("/importFromSBML")

        errorLogsDbQuery = list(db.GqlQuery("SELECT * FROM SBMLImportErrorLogs WHERE user_id = :1", self.user.user_id()).run())
        errorLogsDbQuery = sorted(errorLogsDbQuery, key = lambda x : (datetime.datetime.strptime(x.date, '%Y-%m-%d-%H-%M-%S') if hasattr(x, 'date') and x.date != None else datetime.datetime.now()), reverse = True)

        result = []

        for error in errorLogsDbQuery:
            modelDb = StochKitModelWrapper.get_by_id(error.modelId)
            result.append( { 'id' : error.key().id(),
                             'date' : error.date,
                             'fileName' : error.fileName,
                             'modelName' : modelDb.name if modelDb else None } )

        self.render_response('importFromSBML.html', **{ "errors" : result })