K2LL33D SHELL

 Apache/2.4.7 (Ubuntu)
 Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64
 uid=33(www-data) gid=33(www-data) groups=33(www-data)
 safemode : OFF
 MySQL: ON | Perl: ON | cURL: OFF | WGet: ON
  >  / usr / lib / python2.7 / dist-packages / landscape / manager /
server ip : 172.67.156.115

your ip : 108.162.241.220

H O M E


Filename/usr/lib/python2.7/dist-packages/landscape/manager/store.py
Size2.75 kb
Permissionrw-r--r--
Ownerroot : root
Create time27-Apr-2025 09:56
Last modified20-Feb-2014 23:01
Last accessed06-Jul-2025 20:07
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
try:
import sqlite3
except ImportError:
from pysqlite2 import dbapi2 as sqlite3

from landscape.package.store import with_cursor


class ManagerStore(object):

def __init__(self, filename):
self._db = sqlite3.connect(filename)
ensure_schema(self._db)

@with_cursor
def get_graph(self, cursor, graph_id):
cursor.execute(
"SELECT graph_id, filename, user FROM graph WHERE graph_id=?",
(graph_id,))
return cursor.fetchone()

@with_cursor
def get_graphs(self, cursor):
cursor.execute("SELECT graph_id, filename, user FROM graph")
return cursor.fetchall()

@with_cursor
def add_graph(self, cursor, graph_id, filename, user):
cursor.execute(
"SELECT graph_id FROM graph WHERE graph_id=?",
(graph_id,))
if cursor.fetchone():
cursor.execute(
"UPDATE graph SET filename=?, user=? WHERE graph_id=?",
(filename, user, graph_id))
else:
cursor.execute(
"INSERT INTO graph (graph_id, filename, user) VALUES (?, ?, ?)",
(graph_id, filename, user))

@with_cursor
def remove_graph(self, cursor, graph_id):
cursor.execute("DELETE FROM graph WHERE graph_id=?", (graph_id,))

@with_cursor
def set_graph_accumulate(self, cursor, graph_id, timestamp, value):
cursor.execute(
"SELECT graph_id, graph_timestamp, graph_value FROM "
"graph_accumulate WHERE graph_id=?", (graph_id,))
graph_accumulate = cursor.fetchone()
if graph_accumulate:
cursor.execute(
"UPDATE graph_accumulate SET graph_timestamp = ?, "
"graph_value = ? WHERE graph_id=?",
(timestamp, value, graph_id))
else:
cursor.execute(
"INSERT INTO graph_accumulate (graph_id, graph_timestamp, "
"graph_value) VALUES (?, ?, ?)", (graph_id, timestamp, value))

@with_cursor
def get_graph_accumulate(self, cursor, graph_id):
cursor.execute(
"SELECT graph_id, graph_timestamp, graph_value FROM "
"graph_accumulate WHERE graph_id=?", (graph_id,))
return cursor.fetchone()


def ensure_schema(db):
cursor = db.cursor()
try:
cursor.execute("CREATE TABLE graph"
" (graph_id INTEGER PRIMARY KEY,"
" filename TEXT NOT NULL, user TEXT)")
cursor.execute("CREATE TABLE graph_accumulate"
" (graph_id INTEGER PRIMARY KEY,"
" graph_timestamp INTEGER, graph_value FLOAT)")
except sqlite3.OperationalError:
cursor.close()
db.rollback()
else:
cursor.close()
db.commit()