summaryrefslogtreecommitdiffstats
path: root/pyfirstaidkit/utils
diff options
context:
space:
mode:
authorJoel Andres Granados <jgranado@redhat.com>2008-07-14 15:12:37 +0200
committerJoel Andres Granados <jgranado@redhat.com>2008-07-14 15:13:50 +0200
commita42a5734a0023f2da45f78347f75c2d72364f7b3 (patch)
tree6280bd9cf41c2408b17047865144427b0d2340ca /pyfirstaidkit/utils
parent437a267ddace57e1877e0376fd6ec3aae28ef52b (diff)
downloadfirstaidkit-a42a5734a0023f2da45f78347f75c2d72364f7b3.tar.gz
firstaidkit-a42a5734a0023f2da45f78347f75c2d72364f7b3.tar.xz
firstaidkit-a42a5734a0023f2da45f78347f75c2d72364f7b3.zip
These file was missed in the previous format checks.
Diffstat (limited to 'pyfirstaidkit/utils')
-rw-r--r--pyfirstaidkit/utils/__init__.py6
-rw-r--r--pyfirstaidkit/utils/backup.py38
2 files changed, 27 insertions, 17 deletions
diff --git a/pyfirstaidkit/utils/__init__.py b/pyfirstaidkit/utils/__init__.py
index 035de46..94e9279 100644
--- a/pyfirstaidkit/utils/__init__.py
+++ b/pyfirstaidkit/utils/__init__.py
@@ -38,8 +38,10 @@ def spawnvch(executable, args, chroot, env = None):
Returns the subprocess.Popen object"""
- return subprocess.Popen(executable = executable, args = args, preexec_fn = chroot_func(chroot), env = env,
- stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
+ return subprocess.Popen(executable = executable, args = args,
+ preexec_fn = chroot_func(chroot), env = env,
+ stdin = subprocess.PIPE, stdout = subprocess.PIPE,
+ stderr = subprocess.PIPE)
diff --git a/pyfirstaidkit/utils/backup.py b/pyfirstaidkit/utils/backup.py
index 5271cd6..9ccee42 100644
--- a/pyfirstaidkit/utils/backup.py
+++ b/pyfirstaidkit/utils/backup.py
@@ -81,24 +81,28 @@ class FileBackupStore(BackupStoreInterface):
name = path
if self._origin.has_key(path):
- raise BackupException("Path %s already in the backup store %s!" % (path,self._id))
+ raise BackupException("Path %s already in the backup store %s!"
+ % (path,self._id))
if self._data.has_key(name):
- raise BackupException("Named backup %s already in the backup store %s!" % (name,self._id))
+ raise BackupException("Named backup %s already in the backup "
+ "store %s!" % (name,self._id))
stored = hashlib.sha224(name).hexdigest()
if os.path.isdir(path):
- shutil.copytree(path, os.path.join(self._path, stored), symlinks = True)
+ shutil.copytree(path, os.path.join(self._path, stored),
+ symlinks = True)
else:
shutil.copy2(path, os.path.join(self._path, stored))
self._origin[path] = name
self._data[name] = (stored, path)
return True
-
+
def backupValue(self, value, name):
if self._data.has_key(name):
- raise BackupException("Named backup %s already in the backup store %s!" % (name,self._id))
+ raise BackupException("Named backup %s already in the backup "
+ "store %s!" % (name,self._id))
stored = hashlib.sha224(name).hexdigest()
f = open(os.path.join(self._path, stored), "wb")
@@ -108,23 +112,25 @@ class FileBackupStore(BackupStoreInterface):
self._data[name] = (stored, None)
return True
-
+
def restoreValue(self, name):
stored, origin = self._data[name]
if origin is not None:
- raise BackupException("Named backup %s is not a value object!" % (name,))
+ raise BackupException("Named backup %s is not a value object!"
+ % (name,))
f = open(os.path.join(self._path, stored), "rb")
val = pickle.load(f)
f.close()
-
+
return val
-
+
def restoreName(self, name, path = None):
stored, origin = self._data[name]
if origin is None:
- raise BackupException("Named backup %s is not a filesystem object!" % (name,))
+ raise BackupException("Named backup %s is not a filesystem "
+ "object!" % (name,))
assert self._origin[name]==origin
@@ -138,14 +144,13 @@ class FileBackupStore(BackupStoreInterface):
os.unlink(path)
stored = os.path.join(self._path, stored)
-
+
if os.path.isdir(stored):
shutil.copytree(stored, path, symlinks = True)
else:
shutil.copy2(stored, path)
return True
-
def restorePath(self, path, name = None):
assert self._data[self._origin[path]][1]==path
@@ -176,7 +181,8 @@ class FileBackupStore(BackupStoreInterface):
def exists(self, name=None, path=None):
if name == None and path == None:
- raise BackupException("Cannot call the exists method with both the arguments equal to None")
+ raise BackupException("Cannot call the exists method with both "
+ "the arguments equal to None")
if name != None and path != None:
try:
@@ -197,14 +203,16 @@ class FileBackupStore(BackupStoreInterface):
def __init__(self, path):
if self.__class__._singleton:
- raise BackupException("BackupStore with %s type can have only one instance" % (self.__name__,))
+ raise BackupException("BackupStore with %s type can have only "
+ "one instance" % (self.__name__,))
assert self.__class__._singleton==None
self._path = path
self._backups = {}
if os.path.isdir(self._path):
- raise BackupException("Backupdir %s already exists. Erase dir or change backup dir." % self._path)
+ raise BackupException("Backupdir %s already exists. Erase dir or "
+ "change backup dir." % self._path)
else:
os.makedirs(self._path)
self.__class__._singleton = weakref.proxy(self)