summaryrefslogtreecommitdiffstats
path: root/base/common/python/pki/util.py
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2013-05-08 19:32:26 -0400
committerEndi Sukma Dewata <edewata@redhat.com>2013-05-15 15:47:27 -0400
commitaaf6e899f28ecfc5d75bc378a7dc6ccee5b2249e (patch)
treea6c32a5edbc3f1a3c60ed995a9d0cf4d0e084fa9 /base/common/python/pki/util.py
parentc90155c4983b55cc93b6d7cf131bd4aa541ab515 (diff)
downloadpki-aaf6e899f28ecfc5d75bc378a7dc6ccee5b2249e.tar.gz
pki-aaf6e899f28ecfc5d75bc378a7dc6ccee5b2249e.tar.xz
pki-aaf6e899f28ecfc5d75bc378a7dc6ccee5b2249e.zip
Added support for backup/restore on upgrade.
The upgrade framework has been modified to support backup and restore functionality. A new method backup(filename) has been added to save a file into a backup folder. The CLI's have been modified to accept a --revert parameter which will restore the backup files one version at a time. Ticket #583
Diffstat (limited to 'base/common/python/pki/util.py')
-rw-r--r--base/common/python/pki/util.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/base/common/python/pki/util.py b/base/common/python/pki/util.py
new file mode 100644
index 000000000..7db4fbe79
--- /dev/null
+++ b/base/common/python/pki/util.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+# Authors:
+# Endi S. Dewata <edewata@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2013 Red Hat, Inc.
+# All rights reserved.
+#
+
+import os
+import shutil
+
+
+def copyfile(source, dest):
+
+ dir = os.path.dirname(dest)
+ if not os.path.exists(dir):
+ os.makedirs(dir)
+
+ shutil.copy2(source, dest)
+ st = os.stat(source)
+ os.chown(dest, st.st_uid, st.st_gid)