Beispiel #1
0
 def next(self, queue):
     connection = self.get_connection()
     cursor = connection.cursor()
     tablename = queue['tablename']
     statement = "select * from " + tablename + " where state='READY' order by created_at"
     cursor.execute(statement)
     result = Helper.cursor_to_json(cursor)
     if len(result) == 0:
         return None
     return result[0]
Beispiel #2
0
 def find_by_name(self, name):
     connection = self.get_connection()
     cursor = connection.cursor()
     statement = Helper.statement("select * from queues where name={}",
                                  name)
     cursor.execute(statement)
     result = Helper.cursor_to_json(cursor)
     if len(result) == 0:
         return None
     return result[0]
Beispiel #3
0
    def find_by_hashcode(self, hashcode):
        connection = self.get_connection()
        cursor = connection.cursor()

        m = {}
        m['hashcode'] = hashcode

        statement = "select * from users where hashcode=:hashcode"
        statement, parameters = self.statement(statement, m)
        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)
        cursor.close()
        if len(result) == 0:
            return None
        return result[0]
Beispiel #4
0
    def list_by_job_name(self, job_name):
        connection = self.get_connection()
        cursor = connection.cursor()
        statement = "select * from log where job_name=:job_name"

        m = {}
        m['job_name'] = job_name

        statement, parameters = self.statement(statement, m)
        cursor.execute(statement, parameters)

        result = Helper.cursor_to_json(cursor)
        if len(result) == 0:
            return None
        return result
Beispiel #5
0
    def find_by_id(self, id):
        connection = self.get_connection()
        cursor = connection.cursor()

        m = {}
        m['id'] = id

        statement = "select * from sessions where id=:id"
        statement, parameters = self.statement(statement, m)
        print statement, parameters
        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)
        cursor.close()
        if len(result) == 0:
            return None
        return result[0]
    def find_by_name(self, content):
        logger = Logger(self)
        connection = self.get_connection()
        cursor = connection.cursor()

        statement = "select * from commands where name=:name and environment=:environment"

        m = {}
        m['name'] = content['command']
        m['environment'] = content['environment']
        statement, parameters = self.statement(statement, m)

        cursor.execute(statement, parameters)
        result = Helper.cursor_to_json(cursor)
        if len(result) == 0:
            return None
        return result[0]
Beispiel #7
0
 def list(self):
     connection = self.get_connection()
     cursor = connection.cursor()
     cursor.execute("select * from users")
     return Helper.cursor_to_json(cursor)
Beispiel #8
0
 def list_active(self):
     connection = self.get_connection()
     cursor = connection.cursor()
     cursor.execute("select * from queues where active=1")
     return Helper.cursor_to_json(cursor)