Exemplo n.º 1
0
    def getAll(self, params, page, limit):

        whereStr = " 1=1 "
        limitStr = ""

        if ("jobName" in params.keys()):
            whereStr = whereStr + " and jobName=\'" + params["jobName"] + "\'"

        if ("jobParams" in params.keys()):
            whereStr = whereStr + " and jobParams=\'" + params[
                "jobParams"] + "\'"

        if ("jobDesc" in params.keys()):
            whereStr = whereStr + " and jobDesc=\'" + params["jobDesc"] + "\'"

        if ((page != None) and (limit != None)):
            limitStr = " order by id desc limit " + str(
                (int(page) - 1) * int(limit)) + " , " + str(limit)

        sqlStr = whereStr + limitStr
        try:
            jobDescs = dbSession.query(JobDesc).filter(text(sqlStr)).all()
            jobsDescTotal = dbSession.query(func.count(JobDesc.id)).filter(
                text(whereStr)).all()
            results = self.getResult(jobDescs, totalTmps=jobsDescTotal)
            dbSession.commit()
        except Exception as e:
            dbSession.rollback()
            app.logger.info("ERROR:ServiceJobDesc.getAll():" +
                            e.args.__str__())

        return results
Exemplo n.º 2
0
    def getByIpByDate(self, params, page=None, limit=None):
        results = {}
        whereStr = " 1=1 "

        if ("ip" in params.keys()):
            whereStr = whereStr + " and  ip=\'" + params["ip"] + "\'"

        if ("reportDate" in params.keys()):
            whereStr = whereStr + " and  reportDate=\'" + params[
                "reportDate"] + "\'"

        if ((page != None) and (limit != None)):
            limitStr = " order by ip limit " + str(
                (int(page) - 1) * int(limit)) + " , " + str(limit)

        sqlStr = whereStr + limitStr
        try:
            backups = dbSession.query(Report).filter(text(sqlStr)).all()
            backupsTotal = dbSession.query(func.count(Report.id)).filter(
                text(whereStr)).all()
            results = self.getResult(backups, totalTmps=backupsTotal)
            dbSession.rollback()
        except Exception as e:
            dbSession.rollback()
            app.logger.info(e.args.__str__())

        return results
Exemplo n.º 3
0
 def wrapper(self, *args, **kwargs):
     try:
         result = func(self, *args, **kwargs)
         dbSession.commit()
         return result
     except Exception as e:
         dbSession.rollback()
         raise e
Exemplo n.º 4
0
 def deleteJob(self, jobId):
     try:
         dbSession.query(CronJob).filter(CronJob.jobId == jobId).delete()
         dbSession.commit()
     except Exception as e:
         dbSession.rollback()
         app.logger.info("ERROR:ServiceJob.deleteJob():" +
                         e.args.__str__() + jobId)
Exemplo n.º 5
0
 def saveReport(self, report):
     try:
         dbSession.add(report)
         dbSession.commit()
         return 1
     except Exception as e:
         dbSession.rollback()
         app.logger.info(e.args.__str__())
         return 0
Exemplo n.º 6
0
    def getByJobId(self, jobId):
        job = None
        try:
            job = dbSession.query(CronJob).filter(
                CronJob.jobId == jobId).first()
            dbSession.commit()

        except Exception as e:
            dbSession.rollback()
            app.logger.info("ERROR:ServiceJob.getByJobId():" +
                            e.args.__str__() + ":" + jobId)

        return job
Exemplo n.º 7
0
def getMainMenu():
    datas=[]
    id=request.args.get("node");

    if id=='root':
            menus = dbSession.query(MainMenu).filter(MainMenu.parentId==0).all()
    else:
            menus=dbSession.query(MainMenu).filter(MainMenu.parentId==id).all()
    for item in menus:
            datas.append(item.to_json())
    try:
       dbSession.rollback()
    except Exception as e:
        app.logger.info(e.args.__str__())
        dbSession.rollback()

    return  jsonify(datas)
    def getAll(self, page, limit):
        whereStr = " 1=1 "
        limitStr = ""
        if ((page != None) and (limit != None)):
            limitStr = " order by taskBeginTime desc limit " + str(
                (int(page) - 1) * int(limit)) + " , " + str(limit)

        sqlStr = whereStr + limitStr
        try:
            tasks = dbSession.query(Task).filter(text(sqlStr)).all()
            tasksTotal = dbSession.query(func.count(Task.id)).filter().all()
            results = self.getResult(tasks, totalTmps=tasksTotal)
            dbSession.rollback()
        except Exception as e:
            dbSession.rollback()
            app.logger.info(e.args.__str__())

        return results
Exemplo n.º 9
0
 def add(self, data, type=1, level=1):
     """
     添加
     :param data:
     :param type:
     :param level:
     :return:
     """
     data_dict = {
         'data': data,
         'type': type,
         'level': level,
         'create_time': int(time.time())
     }
     try:
         log = HotLog(**data_dict)
         dbSession.add(log)
         dbSession.flush()
         id = log.id
         dbSession.commit()
         return id
     except Exception as e:
         dbSession.rollback()
         return 0