You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by "lingarajg (via GitHub)" <gi...@apache.org> on 2023/05/11 20:03:26 UTC

[GitHub] [ambari] lingarajg commented on a diff in pull request #3681: Adapt Ambari 2.7.5 from python2 to python3.9[AMBARI-25854]

lingarajg commented on code in PR #3681:
URL: https://github.com/apache/ambari/pull/3681#discussion_r1191615369


##########
ambari-agent/conf/unix/agent-multiplier.py:
##########
@@ -317,42 +317,42 @@ def run(self):
       self.cmd_status()
 
   def cmd_start(self):
-    print "Starting %d host(s)" % len(self.hosts)
+    print("Starting %d host(s)" % len(self.hosts))
     for host in self.hosts:
       cmd = "ambari-agent start --home %s" % (host.home_dir)
       os.environ['AMBARI_AGENT_CONF_DIR'] = os.path.join(host.home_dir, "etc/ambari-agent/conf")
       subprocess32.call(cmd, shell=True, env=os.environ)
 
   def cmd_stop(self):
-    print "Stopping %d host(s)" % len(self.hosts)
+    print("Stopping %d host(s)" % len(self.hosts))
     for host in self.hosts:
       cmd = "ambari-agent stop --home %s" % (host.home_dir)
       os.environ['AMBARI_AGENT_CONF_DIR'] = os.path.join(host.home_dir, "etc/ambari-agent/conf")
       subprocess32.call(cmd, shell=True, env=os.environ)

Review Comment:
   Update subprocess32 to subprocess ?



##########
ambari-agent/conf/unix/agent-multiplier.py:
##########
@@ -317,42 +317,42 @@ def run(self):
       self.cmd_status()
 
   def cmd_start(self):
-    print "Starting %d host(s)" % len(self.hosts)
+    print("Starting %d host(s)" % len(self.hosts))
     for host in self.hosts:
       cmd = "ambari-agent start --home %s" % (host.home_dir)
       os.environ['AMBARI_AGENT_CONF_DIR'] = os.path.join(host.home_dir, "etc/ambari-agent/conf")
       subprocess32.call(cmd, shell=True, env=os.environ)
 
   def cmd_stop(self):
-    print "Stopping %d host(s)" % len(self.hosts)
+    print("Stopping %d host(s)" % len(self.hosts))
     for host in self.hosts:
       cmd = "ambari-agent stop --home %s" % (host.home_dir)
       os.environ['AMBARI_AGENT_CONF_DIR'] = os.path.join(host.home_dir, "etc/ambari-agent/conf")
       subprocess32.call(cmd, shell=True, env=os.environ)
 
   def cmd_restart(self):
-    print "Restarting %d host(s)" % len(self.hosts)
+    print("Restarting %d host(s)" % len(self.hosts))
     for host in self.hosts:
       cmd = "ambari-agent restart --home %s" % (host.home_dir)
       os.environ['AMBARI_AGENT_CONF_DIR'] = os.path.join(host.home_dir, "etc/ambari-agent/conf")
       subprocess32.call(cmd, shell=True, env=os.environ)

Review Comment:
   Update subprocess32 to subprocess ?



##########
ambari-agent/conf/unix/agent-multiplier.py:
##########
@@ -317,42 +317,42 @@ def run(self):
       self.cmd_status()
 
   def cmd_start(self):
-    print "Starting %d host(s)" % len(self.hosts)
+    print("Starting %d host(s)" % len(self.hosts))
     for host in self.hosts:
       cmd = "ambari-agent start --home %s" % (host.home_dir)
       os.environ['AMBARI_AGENT_CONF_DIR'] = os.path.join(host.home_dir, "etc/ambari-agent/conf")
       subprocess32.call(cmd, shell=True, env=os.environ)

Review Comment:
   Update subprocess32 to subprocess ?



##########
ambari-agent/conf/unix/agent-multiplier.py:
##########
@@ -226,7 +226,7 @@ def create_host_name_script(self, host_name, host_name_script):
                "echo HOSTNAME"
     with open(str(host_name_script), "w+") as f:
       f.writelines(template.replace("HOSTNAME", host_name))
-    subprocess32.call("chmod +x %s" % host_name_script, shell=True)
+    subprocess.call("chmod +x %s" % host_name_script, shell=True)

Review Comment:
   Any security considerations here ? can the subprocess call be used with shell=False ? 
   
   Example - subprocess.call(["chmod" + " +x " + host_name_script], shell=False)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@ambari.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ambari.apache.org
For additional commands, e-mail: dev-help@ambari.apache.org