kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpe...@apache.org
Subject incubator-kudu git commit: Make site_tool.py support Python 2.6 and Centos 6
Date Wed, 13 Jul 2016 18:57:01 GMT
Repository: incubator-kudu
Updated Branches:
  refs/heads/gh-pages 3fe5f0e8f -> cc80da352


Make site_tool.py support Python 2.6 and Centos 6

This pulls in kudu_util.py from the Kudu master branch to get the
check_output() function.

Additional notes have been added to README.adoc indicating how to run
site_tool on Centos 6.

Change-Id: I971045e24000b5824a378909a4b28b2e9ac2a45a
Reviewed-on: http://gerrit.cloudera.org:8080/3629
Reviewed-by: Jean-Daniel Cryans <jdcryans@apache.org>
Tested-by: Mike Percy <mpercy@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/cc80da35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/cc80da35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/cc80da35

Branch: refs/heads/gh-pages
Commit: cc80da3520df16202e057402d0770c4ff2cf5fde
Parents: 3fe5f0e
Author: Mike Percy <mpercy@cloudera.com>
Authored: Tue Jul 12 19:24:37 2016 -0700
Committer: Mike Percy <mpercy@apache.org>
Committed: Wed Jul 13 18:56:30 2016 +0000

----------------------------------------------------------------------
 .gitignore          |  1 +
 README.adoc         | 14 +++++++--
 _tools/kudu_util.py | 79 ++++++++++++++++++++++++++++++++++++++++++++++++
 site_tool           | 16 ++++++----
 4 files changed, 102 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cc80da35/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 047658d..7549f1a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 *.swp
+*.pyc
 _site
 _publish
 

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cc80da35/README.adoc
----------------------------------------------------------------------
diff --git a/README.adoc b/README.adoc
index d3dd259..2987907 100644
--- a/README.adoc
+++ b/README.adoc
@@ -4,8 +4,13 @@ This repository contains a handy wrapper tool called 'site_tool'
 which takes care of installing and running the correct version of
 jekyll.
 
-NOTE:  this tool requires that libxslt and libxml2 development headers are
-installed. On Ubuntu, these are `libxslt-dev` and `libxml2-dev` packages.
+NOTE: this tool has the following minimum dependencies:
+
+* Python 2.6.6
+* Ruby 1.9.3 and the Ruby development headers. On Ubuntu, these are the `ruby`
+  and `ruby-dev` packages.
+* libxslt and libxml2 development headers. On Ubuntu, these are the
+  `libxslt-dev` and `libxml2-dev` packages.
 
 [source,bash]
 ----
@@ -18,6 +23,11 @@ the site just like it renders on the site.
 In addition to serving static content, jekyll will render Markdown (the kramdown
 flavor) and also supports templating using Liquid templates.
 
+NOTE: to use `site_tool` on CentOS 6.x, Ruby 1.9.3 and a compatible version of
+the V8 Javascript engine must be installed by enabling the `ruby193` and
+`v8314` SCL repos, installing the `ruby193` and `ruby193-ruby-devel` packages,
+and running `scl enable ruby193 bash` before running `site_tool`.
+
 = Checking for broken links or syntax errors
 
 Use the following command to verify that you didn't introduce any broken links

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cc80da35/_tools/kudu_util.py
----------------------------------------------------------------------
diff --git a/_tools/kudu_util.py b/_tools/kudu_util.py
new file mode 100644
index 0000000..3b8e2f9
--- /dev/null
+++ b/_tools/kudu_util.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, 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 os
+import subprocess
+import sys
+
+class Colors(object):
+  """ ANSI color codes. """
+
+  def __on_tty(x):
+    if not os.isatty(sys.stdout.fileno()):
+      return ""
+    return x
+
+  RED = __on_tty("\x1b[31m")
+  GREEN = __on_tty("\x1b[32m")
+  YELLOW = __on_tty("\x1b[33m")
+  RESET = __on_tty("\x1b[m")
+
+
+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, unused_err = 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
+
+
+def confirm_prompt(prompt):
+  """
+  Issue the given prompt, and ask the user to confirm yes/no. Returns true
+  if the user confirms.
+  """
+  while True:
+    print prompt, "[Y/n]:",
+
+    if not os.isatty(sys.stdout.fileno()):
+      print "Not running interactively. Assuming 'N'."
+      return False
+      pass
+
+    r = raw_input().strip().lower()
+    if r in ['y', 'yes', '']:
+      return True
+    elif r in ['n', 'no']:
+      return False
+
+
+def get_my_email():
+  """ Return the email address in the user's git config. """
+  return check_output(['git', 'config', '--get', 'user.email']).strip()

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cc80da35/site_tool
----------------------------------------------------------------------
diff --git a/site_tool b/site_tool
index 1e529ba..11a69e7 100755
--- a/site_tool
+++ b/site_tool
@@ -32,6 +32,10 @@ SITE_ROOT = os.path.abspath(os.path.dirname(__file__))
 GEM_PATH = os.path.join(SITE_ROOT, ".gem")
 BUNDLE_PATH = os.path.join(GEM_PATH, "bin", "bundle")
 
+# Import helpers to support Python 2.6 (CentOS 6).
+sys.path.append(os.path.join(SITE_ROOT, "_tools"))
+from kudu_util import check_output
+
 # The repository and branch where we version the actual site source (jekyll
 # code, posts, etc)
 SITE_REPO = "https://git-wip-us.apache.org/repos/asf/incubator-kudu.git"
@@ -131,11 +135,11 @@ def publish(args):
 
   # Check that the site source repo has a commit which has been
   # pushed (don't let people publish uncommitted work)
-  source_sha = subprocess.check_output(
+  source_sha = check_output(
       ["git", "rev-parse", "HEAD"]).strip()
   subprocess.check_call(
       ["git", "fetch", SITE_REPO, SITE_BRANCH])
-  upstream_sha = subprocess.check_output(
+  upstream_sha = check_output(
       ["git", "rev-parse", "FETCH_HEAD"]).strip()
   if "--no-verify-source" not in args:
     if source_sha != upstream_sha:
@@ -150,7 +154,7 @@ def publish(args):
                  site_branch=SITE_BRANCH,
                  upstream_sha=upstream_sha[:8])))
       return 1
-    status = subprocess.check_output(["git", "status", "--porcelain"] )
+    status = check_output(["git", "status", "--porcelain"] )
     if status.strip() != "":
       print >>sys.stderr, "Source dir has untracked or modified files"
       print >>sys.stderr, status
@@ -168,7 +172,7 @@ def publish(args):
   os.chdir(PUBLISH_DIR)
 
   # Check that the directory to publish is not dirty and has no untracked files.
-  status = subprocess.check_output(["git", "status", "--porcelain"] )
+  status = check_output(["git", "status", "--porcelain"] )
   if status.strip() != "":
     print >>sys.stderr, "Build dir %s has untracked or modified files:" % PUBLISH_DIR
     print >>sys.stderr, status
@@ -186,7 +190,7 @@ def publish(args):
   #
   # Each commit in the destination repo is tagged with the source repo's hash,
   # so that we can easily figure out which commits have been published.
-  last_publish_log = subprocess.check_output(
+  last_publish_log = check_output(
     ["git", "log", "--grep=^%s: " % SITE_COMMIT_TAG, "-n1"])
   if last_publish_log == "":
     commit_msg = "Initial import from site repo"
@@ -199,7 +203,7 @@ def publish(args):
       print >>sys.stderr, "The site has already been published as of %s" % source_sha
       return 1
 
-    commit_msg = subprocess.check_output(
+    commit_msg = check_output(
       ["git", "log", "--pretty=oneline", "--abbrev-commit",
        "%s..HEAD" % last_publish_sha],
       cwd=SITE_ROOT)


Mime
View raw message