ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fba...@apache.org
Subject ambari git commit: AMBARI-8980 [WinGA] Ambari Metrics Monitor service fails to import the psutil module
Date Mon, 05 Jan 2015 16:51:11 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 8a7a4f2e3 -> 3247aa461


AMBARI-8980 [WinGA] Ambari Metrics Monitor service fails to import the psutil module

Replaced the psutil egg generation and registration with a plain build which yields a readily-usable
pyd module + scripts.


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3247aa46
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3247aa46
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3247aa46

Branch: refs/heads/trunk
Commit: 3247aa4617154579bd426054f3a1b809225fa860
Parents: 8a7a4f2
Author: Florian Barca <fbarca@hortonworks.com>
Authored: Mon Jan 5 08:50:58 2015 -0800
Committer: Florian Barca <fbarca@hortonworks.com>
Committed: Mon Jan 5 08:50:58 2015 -0800

----------------------------------------------------------------------
 ambari-metrics/ambari-metrics-assembly/pom.xml  |  1 +
 .../src/main/assembly/monitor-windows.xml       |  7 +---
 .../ambari-metrics-host-monitoring/pom.xml      |  8 ++--
 .../src/main/python/amhm_service.py             | 42 +-------------------
 .../src/main/python/core/__init__.py            | 11 +++--
 5 files changed, 15 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3247aa46/ambari-metrics/ambari-metrics-assembly/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-assembly/pom.xml b/ambari-metrics/ambari-metrics-assembly/pom.xml
index 10fbab9..69ed536 100644
--- a/ambari-metrics/ambari-metrics-assembly/pom.xml
+++ b/ambari-metrics/ambari-metrics-assembly/pom.xml
@@ -779,6 +779,7 @@
         <assemblydescriptor.monitor>src/main/assembly/monitor-windows.xml</assemblydescriptor.monitor>
         <assemblydescriptor.sink>src/main/assembly/sink-windows.xml</assemblydescriptor.sink>
         <packagingFormat>jar</packagingFormat>
+        <python.build.version>2.7</python.build.version>
       </properties>
     </profile>
     <profile>

http://git-wip-us.apache.org/repos/asf/ambari/blob/3247aa46/ambari-metrics/ambari-metrics-assembly/src/main/assembly/monitor-windows.xml
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-assembly/src/main/assembly/monitor-windows.xml
b/ambari-metrics/ambari-metrics-assembly/src/main/assembly/monitor-windows.xml
index 3b877a7..7372e13 100644
--- a/ambari-metrics/ambari-metrics-assembly/src/main/assembly/monitor-windows.xml
+++ b/ambari-metrics/ambari-metrics-assembly/src/main/assembly/monitor-windows.xml
@@ -51,11 +51,8 @@
       </includes>
     </fileSet>
     <fileSet>
-      <directory>${monitor.dir}/target/psutil_build</directory>
-      <outputDirectory>/sbin/psutil/build</outputDirectory>
-      <includes>
-        <include>*.egg</include>
-      </includes>
+      <directory>${monitor.dir}/target/psutil_build/lib.win-amd64-${python.build.version}</directory>
+      <outputDirectory>/sbin</outputDirectory>
     </fileSet>
     <fileSet>
       <directory>${monitor.dir}/conf/windows</directory>

http://git-wip-us.apache.org/repos/asf/ambari/blob/3247aa46/ambari-metrics/ambari-metrics-host-monitoring/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-host-monitoring/pom.xml b/ambari-metrics/ambari-metrics-host-monitoring/pom.xml
index 3a130ff..efe7112 100644
--- a/ambari-metrics/ambari-metrics-host-monitoring/pom.xml
+++ b/ambari-metrics/ambari-metrics-host-monitoring/pom.xml
@@ -164,10 +164,10 @@
                   <target name="psutils-compile">
                     <exec dir="${basedir}/src/main/python/psutil" executable="${executable.python}"
failonerror="true">
                       <arg value="setup.py" />
-                      <arg value="bdist_egg" />
-                      <arg value="--bdist-dir" />
-                      <arg value="${basedir}/target/psutil_build_temp" />
-                      <arg value="--dist-dir" />
+                      <arg value="build" />
+                      <arg value="--build-temp" />
+                      <arg value="${basedir}\target\psutil_build_temp" />
+                      <arg value="--build-base" />
                       <arg value="${basedir}/target/psutil_build" />
                     </exec>
                   </target>

http://git-wip-us.apache.org/repos/asf/ambari/blob/3247aa46/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/amhm_service.py
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/amhm_service.py
b/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/amhm_service.py
index 0f8daab..9d74f27 100644
--- a/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/amhm_service.py
+++ b/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/amhm_service.py
@@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 '''
-import glob
 
 import optparse
 import os
@@ -25,8 +24,7 @@ import sys
 
 from ambari_commons.ambari_service import AmbariService
 from ambari_commons.exceptions import FatalException, NonFatalException
-from ambari_commons.logging_utils import print_warning_msg, print_error_msg, print_info_msg
-from ambari_commons.os_utils import search_file, run_os_command
+from ambari_commons.logging_utils import print_warning_msg, print_error_msg
 from ambari_commons.os_windows import SvcStatusCallback
 from core.config_reader import SERVER_OUT_FILE, SERVICE_USERNAME_KEY, SERVICE_PASSWORD_KEY,
\
   SETUP_ACTION, START_ACTION, STOP_ACTION, RESTART_ACTION, STATUS_ACTION
@@ -134,43 +132,6 @@ def init_options_parser():
   # --help reserved for help
   return parser
 
-def find_python_exe_path():
-  paths = "." + os.pathsep + os.environ["PATH"]
-
-  # Find python.exe by attempting to load it as a resource dll
-  python_path = search_file("python.exe", paths)
-  return os.path.dirname(python_path)
-
-
-def find_psutil_egg():
-  abs_subdir = os.path.join(os.getcwd(), "sbin", "psutil", "build")
-  egg_files = glob.glob(os.path.join(abs_subdir, "psutil*-win-amd64.egg"))
-  if egg_files is None or len(egg_files) == 0:
-    err = "Unable to find the expected psutil egg file in {0}. " \
-          "Verify that the installation carried out correctly.".format(abs_subdir)
-    raise FatalException(1, err)
-  if len(egg_files) > 1:
-    err = "Multiple psutil egg files found in {0}".format(abs_subdir)
-    print_warning_msg(err)
-  #Return the latest
-  return egg_files[len(egg_files) - 1]
-
-
-def setup_psutil():
-  python_exe_path = find_python_exe_path()
-  egg_file = find_psutil_egg()
-  cmd = [os.path.join(python_exe_path, "Scripts", "easy_install"), "--upgrade", egg_file]
-
-  retval, std_out, std_err = run_os_command(cmd)
-  if std_err is not None and std_err != '':
-    print_warning_msg(std_err)
-    print_info_msg(std_out)
-  if 0 != retval:
-    err = "Psutil egg installation failed. Exit code={0}, err output={1}".format(retval,
std_err)
-    raise FatalException(1, err)
-
-  # Now the egg should be installed in the site_packages dir
-
 def win_main():
   parser = init_options_parser()
   (options, args) = parser.parse_args()
@@ -189,7 +150,6 @@ def win_main():
 
   try:
     if action == SETUP_ACTION:
-      setup_psutil()
       svcsetup()
     elif action == START_ACTION:
       start(options)

http://git-wip-us.apache.org/repos/asf/ambari/blob/3247aa46/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/__init__.py
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/__init__.py
b/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/__init__.py
index eb87cb5..84bb8a8 100644
--- a/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/__init__.py
+++ b/ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/__init__.py
@@ -18,14 +18,17 @@ limitations under the License.
 
 """
 
-import os, sys
+import platform, os, sys
 
 path = os.path.abspath(__file__)
 path = os.path.join(os.path.dirname(os.path.dirname(path)), "psutil", "build")
 
-for dir in os.walk(path).next()[1]:
-  if 'lib' in dir:
-    sys.path.append(os.path.join(path, dir))
+IS_WINDOWS = platform.system() == "Windows"
+
+if not IS_WINDOWS:
+  for dir in os.walk(path).next()[1]:
+    if 'lib' in dir:
+      sys.path.append(os.path.join(path, dir))
 
 try:
   import psutil


Mime
View raw message