资源简介
sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz
代码片段和文件信息
#!/usr/local/bin/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 argparse
import sys
import os
import time
import datetime
import tempfile
import commands
from jira.client import JIRA
def get_jira_config():
# read the config file
home=jira_home=os.getenv(‘HOME‘)
home=home.rstrip(‘/‘)
jira_config = dict(line.strip().split(‘=‘) for line in open(home + ‘/jira.ini‘))
return jira_config
def get_jira():
options = {
‘server‘: ‘https://issues.apache.org/jira‘
}
jira_config = get_jira_config()
jira = JIRA(optionsbasic_auth=(jira_config[‘user‘] jira_config[‘password‘]))
return jira
def cmd_exists(cmd):
status result = commands.getstatusoutput(cmd)
return status
def main():
‘‘‘ main() shut up pylint ‘‘‘
popt = argparse.ArgumentParser(description=‘Sqoop patch review tool‘)
popt.add_argument(‘-b‘ ‘--branch‘ action=‘store‘ dest=‘branch‘ required=True help=‘Tracking branch to create diff against‘)
popt.add_argument(‘-j‘ ‘--jira‘ action=‘store‘ dest=‘jira‘ required=True help=‘JIRA corresponding to the reviewboard‘)
popt.add_argument(‘-s‘ ‘--summary‘ action=‘store‘ dest=‘summary‘ required=False help=‘Summary for the reviewboard‘)
popt.add_argument(‘-d‘ ‘--description‘ action=‘store‘ dest=‘description‘ required=False help=‘Description for reviewboard‘)
popt.add_argument(‘-r‘ ‘--rb‘ action=‘store‘ dest=‘reviewboard‘ required=False help=‘Review board that needs to be updated‘)
popt.add_argument(‘-t‘ ‘--testing-done‘ action=‘store‘ dest=‘testing‘ required=False help=‘Text for the Testing Done section of the reviewboard‘)
popt.add_argument(‘-db‘ ‘--debug‘ action=‘store_true‘ required=False help=‘Enable debug mode‘)
opt = popt.parse_args()
post_review_tool = None
if (cmd_exists(“post-review“) == 0):
post_review_tool = “post-review“
elif (cmd_exists(“rbt“) == 0):
post_review_tool = “rbt post“
else:
print “please install RBTools“
sys.exit(1)
patch_file=tempfile.gettempdir() + “/“ + opt.jira + “.patch“
if opt.reviewboard:
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime(‘%Y-%m-%d_%H:%M:%S‘)
patch_file=tempfile.gettempdir() + “/“ + opt.jira + ‘_‘ + st + ‘.patch‘
# first check if r
评论
共有 条评论