ia64/xen-unstable

changeset 7045:5805b47583ba

Remove unused XendDB.py.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Fri Sep 23 16:05:37 2005 +0100 (2005-09-23)
parents 0e2fdfe6b2bc
children b2c9acd6fdfc
files
line diff
     1.1 --- a/tools/python/xen/xend/XendDB.py	Fri Sep 23 16:04:43 2005 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,127 +0,0 @@
     1.4 -#============================================================================
     1.5 -# This library is free software; you can redistribute it and/or
     1.6 -# modify it under the terms of version 2.1 of the GNU Lesser General Public
     1.7 -# License as published by the Free Software Foundation.
     1.8 -#
     1.9 -# This library is distributed in the hope that it will be useful,
    1.10 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.11 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.12 -# Lesser General Public License for more details.
    1.13 -#
    1.14 -# You should have received a copy of the GNU Lesser General Public
    1.15 -# License along with this library; if not, write to the Free Software
    1.16 -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.17 -#============================================================================
    1.18 -# Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
    1.19 -#============================================================================
    1.20 -
    1.21 -import os
    1.22 -import os.path
    1.23 -import errno
    1.24 -import dircache
    1.25 -import time
    1.26 -
    1.27 -import sxp
    1.28 -import XendRoot
    1.29 -xroot = XendRoot.instance()
    1.30 -
    1.31 -class XendDB:
    1.32 -    """Persistence for Xend. Stores data in files and directories.
    1.33 -    """
    1.34 -
    1.35 -    def __init__(self, path=None):
    1.36 -        self.dbpath = xroot.get_dbroot()
    1.37 -        if path:
    1.38 -            self.dbpath = os.path.join(self.dbpath, path)
    1.39 -        pass
    1.40 -
    1.41 -    def listdir(self, dpath):
    1.42 -        try:
    1.43 -            return dircache.listdir(dpath)
    1.44 -        except:
    1.45 -            return []
    1.46 -
    1.47 -    def filepath(self, path):
    1.48 -        return os.path.join(self.dbpath, path)
    1.49 -        
    1.50 -    def fetch(self, path):
    1.51 -        fpath = self.filepath(path)
    1.52 -        return self.fetchfile(fpath)
    1.53 -
    1.54 -    def fetchfile(self, fpath):
    1.55 -        pin = sxp.Parser()
    1.56 -        fin = file(fpath, "rb")
    1.57 -        try:
    1.58 -            while 1:
    1.59 -                try:
    1.60 -                    buf = fin.read(1024)
    1.61 -                except IOError, ex:
    1.62 -                    if ex.errno == errno.EINTR:
    1.63 -                        continue
    1.64 -                    else:
    1.65 -                        raise
    1.66 -                pin.input(buf)
    1.67 -                if buf == '':
    1.68 -                    pin.input_eof()
    1.69 -                    break
    1.70 -        finally:
    1.71 -            fin.close()
    1.72 -        return pin.get_val()
    1.73 -
    1.74 -    def save(self, path, sxpr):
    1.75 -        fpath = self.filepath(path)
    1.76 -        return self.savefile(fpath, sxpr)
    1.77 -    
    1.78 -    def savefile(self, fpath, sxpr):
    1.79 -        backup = False
    1.80 -        fdir = os.path.dirname(fpath)
    1.81 -        if not os.path.isdir(fdir):
    1.82 -            os.makedirs(fdir)
    1.83 -        if os.path.exists(fpath):
    1.84 -            backup = True
    1.85 -            real_fpath = fpath
    1.86 -            fpath += ".new."
    1.87 -            
    1.88 -        fout = file(fpath, "wb+")
    1.89 -        try:
    1.90 -            try:
    1.91 -                t = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    1.92 -                fout.write("# %s %s\n" % (fpath, t))
    1.93 -                sxp.show(sxpr, out=fout)
    1.94 -            finally:
    1.95 -                fout.close()
    1.96 -        except:
    1.97 -            if backup:
    1.98 -                try:
    1.99 -                    os.unlink(fpath)
   1.100 -                except:
   1.101 -                    pass
   1.102 -                raise
   1.103 -        if backup:
   1.104 -            os.rename(fpath, real_fpath)
   1.105 -
   1.106 -    def fetchall(self, path):
   1.107 -        dpath = self.filepath(path)
   1.108 -        d = {}
   1.109 -        for k in self.listdir(dpath):
   1.110 -            try:
   1.111 -                v = self.fetchfile(os.path.join(dpath, k))
   1.112 -                d[k] = v
   1.113 -            except:
   1.114 -                pass
   1.115 -        return d
   1.116 -
   1.117 -    def saveall(self, path, d):
   1.118 -        for (k, v) in d.items():
   1.119 -            self.save(os.path.join(path, k), v)
   1.120 -
   1.121 -    def delete(self, path):
   1.122 -        dpath = self.filepath(path)
   1.123 -        os.unlink(dpath)
   1.124 -
   1.125 -    def ls(self, path):
   1.126 -        dpath = self.filepath(path)
   1.127 -        return self.listdir(dpath)
   1.128 -        
   1.129 -
   1.130 -