client/tools/rhncfg/config_common/utils.py | 11 +++++++---
client/tools/rhncfg/config_management/rhncfg_download_channel.py | 3 +-
client/tools/rhncfg/config_management/rhncfg_upload_channel.py | 7 +++---
3 files changed, 14 insertions(+), 7 deletions(-)
New commits:
commit 226c3fc5c9fe92a40dca9da56705f78cfdbf1e72
Author: Partha Aji <paji(a)redhat.com>
Date: Tue Aug 3 19:24:36 2010 -0400
Made the upload_channel and download_channel calls deal with symlinks
diff --git a/client/tools/rhncfg/config_common/utils.py
b/client/tools/rhncfg/config_common/utils.py
index e321031..a0872fe 100644
--- a/client/tools/rhncfg/config_common/utils.py
+++ b/client/tools/rhncfg/config_common/utils.py
@@ -81,10 +81,15 @@ def copyfile_p(src, dst):
raise
if os.path.isdir(src):
- if not os.path.exists(dst):
- os.mkdir(dst)
+ if not os.path.exists(dst):
+ os.mkdir(dst)
+ elif os.path.islink(src):
+ exists = hasattr(os.path, "lexists") and os.path.lexists or
os.path.exists
+ if exists(dst):
+ os.remove(dst)
+ os.symlink(os.readlink(src), dst)
else:
- shutil.copyfile(src, dst)
+ shutil.copyfile(src, dst)
def mkdir_p(path, mode=None):
"""
diff --git a/client/tools/rhncfg/config_management/rhncfg_download_channel.py
b/client/tools/rhncfg/config_management/rhncfg_download_channel.py
index 136f12f..d6be6b0 100644
--- a/client/tools/rhncfg/config_management/rhncfg_download_channel.py
+++ b/client/tools/rhncfg/config_management/rhncfg_download_channel.py
@@ -53,4 +53,5 @@ class Handler(handler_base.HandlerBase):
dest_file = utils.join_path(topdir, ns, file_path)
print "Deploying %s -> %s" % (file_path, dest_file)
utils.copyfile_p(temp_file, dest_file)
- utils.set_file_info(dest_file, info)
+ if info['filetype'] != 'symlink':
+ utils.set_file_info(dest_file, info)
diff --git a/client/tools/rhncfg/config_management/rhncfg_upload_channel.py
b/client/tools/rhncfg/config_management/rhncfg_upload_channel.py
index 4543a60..56fe3d4 100644
--- a/client/tools/rhncfg/config_management/rhncfg_upload_channel.py
+++ b/client/tools/rhncfg/config_management/rhncfg_upload_channel.py
@@ -111,12 +111,13 @@ class Handler(handler_base.HandlerBase):
log_error(e)
-def is_file(dirname, basename):
- return os.path.isfile(os.path.join(dirname, basename))
+def is_file_or_link(dirname, basename):
+ return os.path.isfile(os.path.join(dirname, basename)) or \
+ os.path.islink(os.path.join(dirname, basename))
def list_files_recursive(d):
def visitfunc(arg, dirname, names):
- arg.append((dirname, filter(lambda x, d=dirname: is_file(d, x),
+ arg.append((dirname, filter(lambda x, d=dirname: is_file_or_link(d, x),
names)))
file_list = []
Show replies by date