Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2A5B8200B3C for ; Wed, 13 Jul 2016 20:57:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 273B7160A6A; Wed, 13 Jul 2016 18:57:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4AC85160A62 for ; Wed, 13 Jul 2016 20:57:05 +0200 (CEST) Received: (qmail 21721 invoked by uid 500); 13 Jul 2016 18:57:04 -0000 Mailing-List: contact commits-help@kudu.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@kudu.incubator.apache.org Delivered-To: mailing list commits@kudu.incubator.apache.org Received: (qmail 21712 invoked by uid 99); 13 Jul 2016 18:57:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jul 2016 18:57:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 1794CC04FD for ; Wed, 13 Jul 2016 18:57:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id SPq879Ur3UJx for ; Wed, 13 Jul 2016 18:57:02 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id CE5005FB33 for ; Wed, 13 Jul 2016 18:57:01 +0000 (UTC) Received: (qmail 21703 invoked by uid 99); 13 Jul 2016 18:57:01 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jul 2016 18:57:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0786DE04BE; Wed, 13 Jul 2016 18:57:01 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mpercy@apache.org To: commits@kudu.incubator.apache.org Message-Id: <6044864e9d904dea89e68b173f541334@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-kudu git commit: Make site_tool.py support Python 2.6 and Centos 6 Date: Wed, 13 Jul 2016 18:57:01 +0000 (UTC) archived-at: Wed, 13 Jul 2016 18:57:06 -0000 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 Tested-by: Mike Percy 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 Authored: Tue Jul 12 19:24:37 2016 -0700 Committer: Mike Percy 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)