浏览代码

HUE-1510 [core] Remove symlink from pth manager

Abraham Elmahrek 12 年之前
父节点
当前提交
0c06825c9d
共有 2 个文件被更改,包括 0 次插入50 次删除
  1. 0 23
      tools/app_reg/common.py
  2. 0 27
      tools/app_reg/pth.py

+ 0 - 23
tools/app_reg/common.py

@@ -59,26 +59,3 @@ def _get_python_lib_dir():
 
 def _get_python_site_packages_dir():
   return os.path.join(_get_python_lib_dir(), 'site-packages')
-
-
-# Creates os.path.relpath for Python 2.4 and 2.5
-if not hasattr(os.path, 'relpath'):
-  # default to posixpath definition
-  # no windows support
-  def relpath(path, start=os.path.curdir):
-    """Return a relative version of a path"""
-
-    if not path:
-      raise ValueError("no path specified")
-
-    start_list = os.path.abspath(start).split(os.path.sep)
-    path_list = os.path.abspath(path).split(os.path.sep)
-
-    # Work out how much of the filepath is shared by start and path.
-    i = len(os.path.commonprefix([start_list, path_list]))
-
-    rel_list = [os.path.pardir] * (len(start_list)-i) + path_list[i:]
-    if not rel_list:
-        return os.path.curdir
-    return os.path.join(*rel_list)
-  os.path.relpath = relpath

+ 0 - 27
tools/app_reg/pth.py

@@ -26,18 +26,9 @@ import os
 import common
 
 LOG = logging.getLogger(__name__)
-PTH_SYMLINK = 'hue.link.pth'
 PTH_FILE = 'hue.pth'
 
 
-def _get_pth_symlink():
-  """
-  _get_pth_symlink -> Path to the .pth symlink.
-  May raise SystemError if the virtual env is absent.
-  """
-  return os.path.join(common._get_python_site_packages_dir(), PTH_SYMLINK)
-
-
 def _get_pth_filename():
   """
   _get_pth_filename -> Path to the .pth file.
@@ -54,7 +45,6 @@ def _get_pth_filename():
 class PthFile(object):
   def __init__(self):
     """May raise SystemError if the virtual env is absent"""
-    self._symlink_path = _get_pth_symlink()
     self._path = _get_pth_filename()
     self._entries = [ ]
     self._read()
@@ -130,23 +120,6 @@ class PthFile(object):
     os.rename(tmp_path, self._path)
     LOG.info('=== Saved %s' % self._path)
 
-    # relpath defined in common.py for python 2.4 and 2.5
-    rel_symlink_path = os.path.relpath(self._path, os.path.dirname(self._symlink_path))
-
-    # overwrite symlink if the path it points to is different from desired PTH.
-    if os.path.islink(self._symlink_path) and os.readlink(self._symlink_path) != rel_symlink_path:
-      LOG.info('=== Removing symbolic link at %s' % (self._symlink_path))
-      os.unlink(self._symlink_path)
-      LOG.info('=== Removed symbolic link at %s' % (self._symlink_path))
-
-    if not os.path.islink(self._symlink_path):
-      if os.path.exists(self._symlink_path):
-        raise RuntimeError("Path %s already exists and is not a symbolic link." % self._symlink_path)
-
-      LOG.info('=== Creating symbolic link at %s to %s' % (self._symlink_path, rel_symlink_path))
-      os.symlink(rel_symlink_path, self._symlink_path)
-      LOG.info('=== Created symbolic link at %s to %s' % (self._symlink_path, rel_symlink_path))
-
   def sync(self, apps):
     """Sync the .pth file with the installed apps"""
     self._entries = set()