00001 #!/usr/bin/env python 00002 # 00003 # Copyright 2009, Google Inc. 00004 # All rights reserved. 00005 # 00006 # Redistribution and use in source and binary forms, with or without 00007 # modification, are permitted provided that the following conditions are 00008 # met: 00009 # 00010 # * Redistributions of source code must retain the above copyright 00011 # notice, this list of conditions and the following disclaimer. 00012 # * Redistributions in binary form must reproduce the above 00013 # copyright notice, this list of conditions and the following disclaimer 00014 # in the documentation and/or other materials provided with the 00015 # distribution. 00016 # * Neither the name of Google Inc. nor the names of its 00017 # contributors may be used to endorse or promote products derived from 00018 # this software without specific prior written permission. 00019 # 00020 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00021 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00022 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00023 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00024 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00025 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00026 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00027 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00028 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00029 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00030 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 00032 """upload_gtest.py v0.1.0 -- uploads a Google Test patch for review. 00033 00034 This simple wrapper passes all command line flags and 00035 --cc=googletestframework@googlegroups.com to upload.py. 00036 00037 USAGE: upload_gtest.py [options for upload.py] 00038 """ 00039 00040 __author__ = 'wan@google.com (Zhanyong Wan)' 00041 00042 import os 00043 import sys 00044 00045 CC_FLAG = '--cc=' 00046 GTEST_GROUP = 'googletestframework@googlegroups.com' 00047 00048 00049 def main(): 00050 # Finds the path to upload.py, assuming it is in the same directory 00051 # as this file. 00052 my_dir = os.path.dirname(os.path.abspath(__file__)) 00053 upload_py_path = os.path.join(my_dir, 'upload.py') 00054 00055 # Adds Google Test discussion group to the cc line if it's not there 00056 # already. 00057 upload_py_argv = [upload_py_path] 00058 found_cc_flag = False 00059 for arg in sys.argv[1:]: 00060 if arg.startswith(CC_FLAG): 00061 found_cc_flag = True 00062 cc_line = arg[len(CC_FLAG):] 00063 cc_list = [addr for addr in cc_line.split(',') if addr] 00064 if GTEST_GROUP not in cc_list: 00065 cc_list.append(GTEST_GROUP) 00066 upload_py_argv.append(CC_FLAG + ','.join(cc_list)) 00067 else: 00068 upload_py_argv.append(arg) 00069 00070 if not found_cc_flag: 00071 upload_py_argv.append(CC_FLAG + GTEST_GROUP) 00072 00073 # Invokes upload.py with the modified command line flags. 00074 os.execv(upload_py_path, upload_py_argv) 00075 00076 00077 if __name__ == '__main__': 00078 main()