You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2021/01/25 18:52:35 UTC

[GitHub] [hadoop] goiri commented on a change in pull request #1738: HADOOP-16748. Support Python 3 in dev-support scripts.

goiri commented on a change in pull request #1738:
URL: https://github.com/apache/hadoop/pull/1738#discussion_r563964062



##########
File path: dev-support/bin/checkcompatibility.py
##########
@@ -30,316 +30,308 @@
 import shutil
 import subprocess
 import sys
-import urllib2
-try:
-  import argparse
-except ImportError:
-  sys.stderr.write("Please install argparse, e.g. via `pip install argparse`.")
-  sys.exit(2)
+import urllib.request
+import argparse
 
 # Various relative paths
 REPO_DIR = os.getcwd()
 
+
 def check_output(*popenargs, **kwargs):
-  r"""Run command with arguments and return its output as a byte string.
-  Backported from Python 2.7 as it's implemented as pure python on stdlib.
-  >>> check_output(['/usr/bin/python', '--version'])
-  Python 2.6.2
-  """
-  process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
-  output, _ = process.communicate()
-  retcode = process.poll()
-  if retcode:
-    cmd = kwargs.get("args")
-    if cmd is None:
-      cmd = popenargs[0]
-    error = subprocess.CalledProcessError(retcode, cmd)
-    error.output = output
-    raise error
-  return output
+    """ Run command with arguments and return its output as a string. """
+    return subprocess.check_output(*popenargs, **kwargs, encoding='utf-8')
+
 
 def get_repo_dir():
-  """ Return the path to the top of the repo. """
-  dirname, _ = os.path.split(os.path.abspath(__file__))
-  return os.path.join(dirname, "../..")
+    """ Return the path to the top of the repo. """
+    dirname, _ = os.path.split(os.path.abspath(__file__))
+    return os.path.join(dirname, "../..")
+
 
 def get_scratch_dir():
-  """ Return the path to the scratch dir that we build within. """
-  scratch_dir = os.path.join(get_repo_dir(), "target", "compat-check")
-  if not os.path.exists(scratch_dir):
-    os.makedirs(scratch_dir)
-  return scratch_dir
+    """ Return the path to the scratch dir that we build within. """
+    scratch_dir = os.path.join(get_repo_dir(), "target", "compat-check")
+    if not os.path.exists(scratch_dir):
+        os.makedirs(scratch_dir)
+    return scratch_dir
+
 
 def get_java_acc_dir():
-  """ Return the path where we check out the Java API Compliance Checker. """
-  return os.path.join(get_repo_dir(), "target", "java-acc")
+    """ Return the path where we check out the Java API Compliance Checker. """

Review comment:
       Do we want to do all the indentation changes in this JIRA? I would prefer to separate indentation fixes from python3 specific changes.




----------------------------------------------------------------
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.

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



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org