This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 2dea9fb AMBARI-24461. Python 2/3 compatible topology_script.py (#2038)
2dea9fb is described below
commit 2dea9fb811a66dcf25b2b1f526560c16d0aeb2fd
Author: Peter Parente <[email protected]>
AuthorDate: Mon Oct 29 02:53:47 2018 -0400
AMBARI-24461. Python 2/3 compatible topology_script.py (#2038)
---
.../stack-hooks/before-START/files/topology_script.py | 13 +++++++++----
.../HDF/2.0/hooks/before-START/files/topology_script.py | 13 +++++++++----
.../ODPi/2.0/hooks/before-START/files/topology_script.py | 13 +++++++++----
3 files changed, 27 insertions(+), 12 deletions(-)
diff --git
a/ambari-server/src/main/resources/stack-hooks/before-START/files/topology_script.py
b/ambari-server/src/main/resources/stack-hooks/before-START/files/topology_script.py
index 0f7a55c..e026ba7 100644
---
a/ambari-server/src/main/resources/stack-hooks/before-START/files/topology_script.py
+++
b/ambari-server/src/main/resources/stack-hooks/before-START/files/topology_script.py
@@ -18,9 +18,14 @@ limitations under the License.
'''
import sys, os
-from string import join
-import ConfigParser
-
+try:
+ # Python 2
+ from string import join
+ import ConfigParser
+except ImportError:
+ # Python 3
+ join = ' '.join
+ import configparser as ConfigParser
DEFAULT_RACK = "/default-rack"
DATA_FILE_NAME = os.path.dirname(os.path.abspath(__file__)) +
"/topology_mappings.data"
@@ -60,7 +65,7 @@ class TopologyScript():
def execute(self, args):
rack_map = self.load_rack_map()
rack = self.get_racks(rack_map, args)
- print rack
+ print(rack)
if __name__ == "__main__":
TopologyScript().execute(sys.argv)
diff --git
a/contrib/management-packs/hdf-ambari-mpack/src/main/resources/stacks/HDF/2.0/hooks/before-START/files/topology_script.py
b/contrib/management-packs/hdf-ambari-mpack/src/main/resources/stacks/HDF/2.0/hooks/before-START/files/topology_script.py
index 0f7a55c..e026ba7 100644
---
a/contrib/management-packs/hdf-ambari-mpack/src/main/resources/stacks/HDF/2.0/hooks/before-START/files/topology_script.py
+++
b/contrib/management-packs/hdf-ambari-mpack/src/main/resources/stacks/HDF/2.0/hooks/before-START/files/topology_script.py
@@ -18,9 +18,14 @@ limitations under the License.
'''
import sys, os
-from string import join
-import ConfigParser
-
+try:
+ # Python 2
+ from string import join
+ import ConfigParser
+except ImportError:
+ # Python 3
+ join = ' '.join
+ import configparser as ConfigParser
DEFAULT_RACK = "/default-rack"
DATA_FILE_NAME = os.path.dirname(os.path.abspath(__file__)) +
"/topology_mappings.data"
@@ -60,7 +65,7 @@ class TopologyScript():
def execute(self, args):
rack_map = self.load_rack_map()
rack = self.get_racks(rack_map, args)
- print rack
+ print(rack)
if __name__ == "__main__":
TopologyScript().execute(sys.argv)
diff --git
a/contrib/management-packs/odpi-ambari-mpack/src/main/resources/stacks/ODPi/2.0/hooks/before-START/files/topology_script.py
b/contrib/management-packs/odpi-ambari-mpack/src/main/resources/stacks/ODPi/2.0/hooks/before-START/files/topology_script.py
index 0f7a55c..e026ba7 100755
---
a/contrib/management-packs/odpi-ambari-mpack/src/main/resources/stacks/ODPi/2.0/hooks/before-START/files/topology_script.py
+++
b/contrib/management-packs/odpi-ambari-mpack/src/main/resources/stacks/ODPi/2.0/hooks/before-START/files/topology_script.py
@@ -18,9 +18,14 @@ limitations under the License.
'''
import sys, os
-from string import join
-import ConfigParser
-
+try:
+ # Python 2
+ from string import join
+ import ConfigParser
+except ImportError:
+ # Python 3
+ join = ' '.join
+ import configparser as ConfigParser
DEFAULT_RACK = "/default-rack"
DATA_FILE_NAME = os.path.dirname(os.path.abspath(__file__)) +
"/topology_mappings.data"
@@ -60,7 +65,7 @@ class TopologyScript():
def execute(self, args):
rack_map = self.load_rack_map()
rack = self.get_racks(rack_map, args)
- print rack
+ print(rack)
if __name__ == "__main__":
TopologyScript().execute(sys.argv)