def main():
    usage = """%prog
    Generates doxygen documentation in build/doxygen.
    Optionaly makes a tarball of the documentation to dist/.

    Must be started in the project top directory.    
    """
    from optparse import OptionParser
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False
    parser.add_option('--with-dot', dest="with_dot", action='store_true', default=False,
        help="""Enable usage of DOT to generate collaboration diagram""")
    parser.add_option('--dot', dest="dot_path", action='store', default=find_program('dot'),
        help="""Path to GraphViz dot tool. Must be full qualified path. [Default: %default]""")
    parser.add_option('--doxygen', dest="doxygen_path", action='store', default=find_program('doxygen'),
        help="""Path to Doxygen tool. [Default: %default]""")
    parser.add_option('--with-html-help', dest="with_html_help", action='store_true', default=False,
        help="""Enable generation of Microsoft HTML HELP""")
    parser.add_option('--no-uml-look', dest="with_uml_look", action='store_false', default=True,
        help="""Generates DOT graph without UML look [Default: False]""")
    parser.add_option('--open', dest="open", action='store_true', default=False,
        help="""Open the HTML index in the web browser after generation""")
    parser.add_option('--tarball', dest="make_tarball", action='store_true', default=False,
        help="""Generates a tarball of the documentation in dist/ directory""")
    parser.add_option('-s', '--silent', dest="silent", action='store_true', default=False,
        help="""Hides doxygen output""")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()
    build_doc( options )
Beispiel #2
0
def main():
    from optparse import OptionParser
    parser = OptionParser(usage="%prog [options] <path to jsontestrunner.exe> [test case directory]")
    parser.add_option("--valgrind",
                  action="store_true", dest="valgrind", default=False,
                  help="run all the tests using valgrind to detect memory leaks")
    parser.add_option("-c", "--with-json-checker",
                  action="store_true", dest="with_json_checker", default=False,
                  help="run all the tests from the official JSONChecker test suite of json.org")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()

    if len(args) < 1 or len(args) > 2:
        parser.error('Must provides at least path to jsontestrunner executable.')
        sys.exit(1)

    jsontest_executable_path = os.path.normpath(os.path.abspath(args[0]))
    if len(args) > 1:
        input_path = os.path.normpath(os.path.abspath(args[1]))
    else:
        input_path = None
    runAllTests(jsontest_executable_path, input_path,
                         use_valgrind=options.valgrind,
                         with_json_checker=options.with_json_checker,
                         writerClass='StyledWriter')
    runAllTests(jsontest_executable_path, input_path,
                         use_valgrind=options.valgrind,
                         with_json_checker=options.with_json_checker,
                         writerClass='StyledStreamWriter')
    runAllTests(jsontest_executable_path, input_path,
                         use_valgrind=options.valgrind,
                         with_json_checker=options.with_json_checker,
                         writerClass='BuiltStyledStreamWriter')
Beispiel #3
0
def main():
    usage = """%prog DIR [DIR2...]
Updates license text in sources of the project in source files found
in the directory specified on the command-line.

Example of call:
python devtools\licenseupdater.py include src -n --diff
=> Show change that would be made to the sources.

python devtools\licenseupdater.py include src
=> Update license statement on all sources in directories include/ and src/.
"""
    from optparse import OptionParser
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False
    parser.add_option(
        '-n',
        '--dry-run',
        dest="dry_run",
        action='store_true',
        default=False,
        help="""Only show what files are updated, do not update the files""")
    parser.add_option('--diff',
                      dest="show_diff",
                      action='store_true',
                      default=False,
                      help="""On update, show change made to the file.""")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()
    update_license_in_source_directories(args, options.dry_run,
                                         options.show_diff)
    print('Done')
def main():
    usage = """%prog
    Generates doxygen documentation in build/doxygen.
    Optionaly makes a tarball of the documentation to dist/.

    Must be started in the project top directory.    
    """
    from optparse import OptionParser
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False
    parser.add_option('--with-dot', dest="with_dot", action='store_true', default=False,
        help="""Enable usage of DOT to generate collaboration diagram""")
    parser.add_option('--dot', dest="dot_path", action='store', default=find_program('dot'),
        help="""Path to GraphViz dot tool. Must be full qualified path. [Default: %default]""")
    parser.add_option('--doxygen', dest="doxygen_path", action='store', default=find_program('doxygen'),
        help="""Path to Doxygen tool. [Default: %default]""")
    parser.add_option('--with-html-help', dest="with_html_help", action='store_true', default=False,
        help="""Enable generation of Microsoft HTML HELP""")
    parser.add_option('--no-uml-look', dest="with_uml_look", action='store_false', default=True,
        help="""Generates DOT graph without UML look [Default: False]""")
    parser.add_option('--open', dest="open", action='store_true', default=False,
        help="""Open the HTML index in the web browser after generation""")
    parser.add_option('--tarball', dest="make_tarball", action='store_true', default=False,
        help="""Generates a tarball of the documentation in dist/ directory""")
    parser.add_option('-s', '--silent', dest="silent", action='store_true', default=False,
        help="""Hides doxygen output""")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()
    build_doc( options )
Beispiel #5
0
def main():
    usage = """%prog [options]
Generate a single amalgated source and header file from the sources.
"""
    from optparse import OptionParser
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False
    parser.add_option('-s',
                      '--source',
                      dest="target_source_path",
                      action='store',
                      default='dist/amalgated-src/cppunit_lib.cpp',
                      help="""Output .cpp source path. [Default: %default]""")
    parser.add_option('-t',
                      '--top-dir',
                      dest="top_dir",
                      action='store',
                      default=os.getcwd(),
                      help="""Source top-directory. [Default: %default]""")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()

    msg = amalgamate_source(source_top_dir=options.top_dir,
                            target_source_path=options.target_source_path)
    if msg:
        sys.stderr.write(msg + '\n')
        sys.exit(1)
    else:
        print 'Source succesfully amalagated'
Beispiel #6
0
    def getParser():
        """ Returns dictionnary with ALL program options """
        p = OptionParser(usage="%prog --user=USER --pass=PASS --host=HOST")
        p.enable_interspersed_args()

        p.add_option("--user", action="store", dest="user_db")
        p.add_option("--pass", action="store", dest="pass_db")
        p.add_option("--host", action="store", dest="host_db")

        return p
Beispiel #7
0
def CmdLineParse():   
    """
    命令行程序: from python-swiftclient
    """
    parser = OptionParser(version='%%prog %s' % version,
                          usage = '''
Usage: %%prog <command> [options] [args]
.....
'''.strip('\n') )
    parser.add_option('-v', '--verbose', action='count', dest='verbose',
            default=1, help='print more info')
    parser.disable_interspersed_args()
    (options, args) = parse_args(parser, argv[1:], enforce_requires=False)
    parser.enable_interspersed_args()
Beispiel #8
0
def CmdLineParse():   
    """
    命令行程序: from python-swiftclient
    """
    parser = OptionParser(version='%%prog %s' % version,
                          usage = '''
Usage: %%prog <command> [options] [args]
.....
'''.strip('\n') )
    parser.add_option('-v', '--verbose', action='count', dest='verbose',
            default=1, help='print more info')
    parser.disable_interspersed_args()
    (options, args) = parse_args(parser, argv[1:], enforce_requires=False)
    parser.enable_interspersed_args()
Beispiel #9
0
def main():
    from optparse import OptionParser
    parser = OptionParser(usage="%prog [options] <path to test_lib_json.exe>")
    parser.add_option("--valgrind",
                  action="store_true", dest="valgrind", default=False,
                  help="run all the tests using valgrind to detect memory leaks")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()

    if len(args) != 1:
        parser.error('Must provides at least path to test_lib_json executable.')
        sys.exit(1)

    exit_code = runAllTests(args[0], use_valgrind=options.valgrind)
    sys.exit(exit_code)
Beispiel #10
0
def main():
    from optparse import OptionParser
    parser = OptionParser(usage="%prog [options] <path to test_lib_json.exe>")
    parser.add_option("--valgrind",
                  action="store_true", dest="valgrind", default=False,
                  help="run all the tests using valgrind to detect memory leaks")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()

    if len(args) != 1:
        parser.error('Must provides at least path to test_lib_json executable.')
        sys.exit(1)

    exit_code = runAllTests(args[0], use_valgrind=options.valgrind)
    sys.exit(exit_code)
Beispiel #11
0
def main():
    usage = r"""%prog WORK_DIR SOURCE_DIR CONFIG_JSON_PATH [CONFIG2_JSON_PATH...]
Build a given CMake based project located in SOURCE_DIR with multiple generators/options.dry_run
as described in CONFIG_JSON_PATH building in WORK_DIR.

Example of call:
python devtools\batchbuild.py e:\buildbots\jsoncpp\build . devtools\agent_vmw7.json
"""
    from optparse import OptionParser
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = True
    #    parser.add_option('-v', '--verbose', dest="verbose", action='store_true',
    #        help="""Be verbose.""")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()
    if len(args) < 3:
        parser.error("Missing one of WORK_DIR SOURCE_DIR CONFIG_JSON_PATH.")
    work_dir = args[0]
    source_dir = args[1].rstrip('/\\')
    config_paths = args[2:]
    for config_path in config_paths:
        if not os.path.isfile(config_path):
            parser.error("Can not read: %r" % config_path)

    # generate build variants
    build_descs = []
    for config_path in config_paths:
        build_descs_by_axis = load_build_variants_from_config(config_path)
        build_descs.extend(generate_build_variants(build_descs_by_axis))
    print('Build variants (%d):' % len(build_descs))
    # assign build directory for each variant
    if not os.path.isdir(work_dir):
        os.makedirs(work_dir)
    builds = []
    with open(os.path.join(work_dir, 'matrix-dir-map.txt'),
              'wt') as fmatrixmap:
        for index, build_desc in enumerate(build_descs):
            build_desc_work_dir = os.path.join(work_dir, '%03d' % (index + 1))
            builds.append(
                BuildData(build_desc, build_desc_work_dir, source_dir))
            fmatrixmap.write('%s: %s\n' % (build_desc_work_dir, build_desc))
    for build in builds:
        build.execute_build()
    html_report_path = os.path.join(work_dir, 'batchbuild-report.html')
    generate_html_report(html_report_path, builds)
    print('Done')
Beispiel #12
0
def main():
    usage = """%prog [options]
Generate a single amalgated source and header file from the sources.
"""
    from optparse import OptionParser

    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False
    parser.add_option(
        "-s",
        "--source",
        dest="target_source_path",
        action="store",
        default="dist/jsoncpp.cpp",
        help="""Output .cpp source path. [Default: %default]""",
    )
    parser.add_option(
        "-i",
        "--include",
        dest="header_include_path",
        action="store",
        default="json/json.h",
        help="""Header include path. Used to include the header from the amalgated source file. [Default: %default]""",
    )
    parser.add_option(
        "-t",
        "--top-dir",
        dest="top_dir",
        action="store",
        default=os.getcwd(),
        help="""Source top-directory. [Default: %default]""",
    )
    parser.enable_interspersed_args()
    options, args = parser.parse_args()

    msg = amalgate_source(
        source_top_dir=options.top_dir,
        target_source_path=options.target_source_path,
        header_include_path=options.header_include_path,
    )
    if msg:
        sys.stderr.write(msg + "\n")
        sys.exit(1)
    else:
        print "Source succesfully amalagated"
Beispiel #13
0
def main():
    usage = r"""%prog WORK_DIR SOURCE_DIR CONFIG_JSON_PATH [CONFIG2_JSON_PATH...]
Build a given CMake based project located in SOURCE_DIR with multiple generators/options.dry_run
as described in CONFIG_JSON_PATH building in WORK_DIR.

Example of call:
python devtools\batchbuild.py e:\buildbots\jsoncpp\build . devtools\agent_vmw7.json
"""
    from optparse import OptionParser
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = True
#    parser.add_option('-v', '--verbose', dest="verbose", action='store_true',
#        help="""Be verbose.""")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()
    if len(args) < 3:
        parser.error( "Missing one of WORK_DIR SOURCE_DIR CONFIG_JSON_PATH." )
    work_dir = args[0]
    source_dir = args[1].rstrip('/\\')
    config_paths = args[2:]
    for config_path in config_paths:
        if not os.path.isfile( config_path ):
            parser.error( "Can not read: %r" % config_path )

    # generate build variants
    build_descs = []
    for config_path in config_paths:
        build_descs_by_axis = load_build_variants_from_config( config_path )
        build_descs.extend( generate_build_variants( build_descs_by_axis ) )
    print 'Build variants (%d):' % len(build_descs)
    # assign build directory for each variant
    if not os.path.isdir( work_dir ):
        os.makedirs( work_dir )
    builds = []
    with open( os.path.join( work_dir, 'matrix-dir-map.txt' ), 'wt' ) as fmatrixmap:
        for index, build_desc in enumerate( build_descs ):
            build_desc_work_dir = os.path.join( work_dir, '%03d' % (index+1) )
            builds.append( BuildData( build_desc, build_desc_work_dir, source_dir ) )
            fmatrixmap.write( '%s: %s\n' % (build_desc_work_dir, build_desc) )
    for build in builds:
        build.execute_build()
    html_report_path = os.path.join( work_dir, 'batchbuild-report.html' )
    generate_html_report( html_report_path, builds )
    print 'Done'
Beispiel #14
0
def main():
    usage = """%prog [options]
Generate a single amalgated source and header file from the sources.
"""
    from optparse import OptionParser
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False
    parser.add_option('-s', '--source', dest="target_source_path", action='store', default='dist/amalgated-src/cppunit_lib.cpp',
        help="""Output .cpp source path. [Default: %default]""")
    parser.add_option('-t', '--top-dir', dest="top_dir", action='store', default=os.getcwd(),
        help="""Source top-directory. [Default: %default]""")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()

    msg = amalgamate_source( source_top_dir=options.top_dir,
                             target_source_path=options.target_source_path )
    if msg:
        sys.stderr.write( msg + '\n' )
        sys.exit( 1 )
    else:
        print 'Source succesfully amalagated'
Beispiel #15
0
def main():
    from optparse import OptionParser
    parser = OptionParser( usage="%prog [options] <path to jsontestrunner.exe> [test case directory]" )
    parser.add_option("--valgrind",
                  action="store_true", dest="valgrind", default=False,
                  help="run all the tests using valgrind to detect memory leaks")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()

    if len(args) < 1 or len(args) > 2:
        parser.error( 'Must provides at least path to jsontestrunner executable.' )
        sys.exit( 1 )

    jsontest_executable_path = os.path.normpath( os.path.abspath( args[0] ) )
    if len(args) > 1:
        input_path = os.path.normpath( os.path.abspath( args[1] ) )
    else:
        input_path = None
    status = runAllTests( jsontest_executable_path, input_path,
                          use_valgrind=options.valgrind )
    sys.exit( status )
Beispiel #16
0
    def run(self):
        parser = OptionParser()

        usage = "usage: %prog [options] command [...]\n\n" + self._get_commands()
        parser.set_usage(usage)
        parser.add_option(
            "-p",
            "--python",
            dest="python",
            default=None,
            help=("use the given python executable instead of " + repr(sys.executable)),
        )
        parser.add_option(
            "--allow-root",
            action="store_true",
            dest="allow_root",
            default=False,
            help="allow starting bots as the root user",
        )

        parser.disable_interspersed_args()
        options, args = self._parse(parser)

        if not args:
            parser.print_usage()
            sys.exit(0)

        command = args[0]
        if command not in self._commands:
            parser.error("unknown command " + repr(command))

        parser.enable_interspersed_args()
        parser.set_usage("usage: %prog " + command + " [options] [...]")

        command_obj = self._commands[command]
        command_obj.prep(parser)

        options, args = self._parse(parser)
        for line in _flatten(command_obj.run(parser, options, args[1:])):
            print(line)
Beispiel #17
0
def main():
    usage = """%prog [options]
Generate a single amalgated source and header file from the sources.
"""
    from optparse import OptionParser
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False
    parser.add_option("-s",
                      "--source",
                      dest="target_source_path",
                      action="store",
                      default="dist/jsoncpp.cpp",
                      help="""Output .cpp source path. [Default: %default]""")
    parser.add_option(
        "-i",
        "--include",
        dest="header_include_path",
        action="store",
        default="json/json.h",
        help=
        """Header include path. Used to include the header from the amalgated source file. [Default: %default]"""
    )
    parser.add_option("-t",
                      "--top-dir",
                      dest="top_dir",
                      action="store",
                      default=os.getcwd(),
                      help="""Source top-directory. [Default: %default]""")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()

    msg = amalgamate_source(source_top_dir=options.top_dir,
                            target_source_path=options.target_source_path,
                            header_include_path=options.header_include_path)
    if msg:
        sys.stderr.write(msg + "\n")
        sys.exit(1)
    else:
        print("Source succesfully amalagated")
Beispiel #18
0
def main():
    from optparse import OptionParser
    parser = OptionParser(usage="%prog [options] <path to jsontestrunner.exe> [test case directory]")
    parser.add_option("--valgrind",
                  action="store_true", dest="valgrind", default=False,
                  help="run all the tests using valgrind to detect memory leaks")
    parser.add_option("-c", "--with-json-checker",
                  action="store_true", dest="with_json_checker", default=False,
                  help="run all the tests from the official JSONChecker test suite of json.org")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()

    if len(args) < 1 or len(args) > 2:
        parser.error('Must provides at least path to jsontestrunner executable.')
        sys.exit(1)

    jsontest_executable_path = os.path.normpath(os.path.abspath(args[0]))
    if len(args) > 1:
        input_path = os.path.normpath(os.path.abspath(args[1]))
    else:
        input_path = None
    status = runAllTests(jsontest_executable_path, input_path,
                         use_valgrind=options.valgrind,
                         with_json_checker=options.with_json_checker,
                         writerClass='StyledWriter')
    if status:
        sys.exit(status)
    status = runAllTests(jsontest_executable_path, input_path,
                         use_valgrind=options.valgrind,
                         with_json_checker=options.with_json_checker,
                         writerClass='StyledStreamWriter')
    if status:
        sys.exit(status)
    status = runAllTests(jsontest_executable_path, input_path,
                         use_valgrind=options.valgrind,
                         with_json_checker=options.with_json_checker,
                         writerClass='BuiltStyledStreamWriter')
    if status:
        sys.exit(status)
Beispiel #19
0
def main():
    usage = """%prog DIR [DIR2...]
Updates license text in sources of the project in source files found
in the directory specified on the command-line.

Example of call:
python devtools\licenseupdater.py include src -n --diff
=> Show change that would be made to the sources.

python devtools\licenseupdater.py include src
=> Update license statement on all sources in directories include/ and src/.
"""
    from optparse import OptionParser
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False
    parser.add_option('-n', '--dry-run', dest="dry_run", action='store_true', default=False,
        help="""Only show what files are updated, do not update the files""")
    parser.add_option('--diff', dest="show_diff", action='store_true', default=False,
        help="""On update, show change made to the file.""")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()
    update_license_in_source_directories(args, options.dry_run, options.show_diff)
    print('Done')
Beispiel #20
0
Commands:
    auth
    create 
    delete
    start
    stop
    list_pvs
    list_vgs

Example:
    %%prog list_pvs
'''.strip('\n') % globals())

    parser.disable_interspersed_args()
    (options, args) = parse_args(parser, argv[1:], enforce_requires=False)
    parser.enable_interspersed_args()

    commands = ('auth', 'list_pvs', 'list_vgs', 'create', 'stop', 'start', 'delete')
    if not args or args[0] not in commands:
        parser.print_usage()
        if args:
            exit('no such command: %s' % args[0])
        exit()
    result = globals()['gw_%s' % args[0]](parser, argv[1:])
    print result




Beispiel #21
0
def main(arguments=None):
    if arguments:
        argv = arguments
    else:
        argv = sys_argv

    version = client_version
    parser = OptionParser(version='%%prog %s' % version,
                          usage='''
usage: %%prog [--version] [--help] [--snet] [--verbose]
             [--debug] [--info] [--quiet] [--auth <auth_url>]
             [--auth-version <auth_version>] [--user <username>]
             [--key <api_key>] [--retries <num_retries>]
             [--os-username <auth-user-name>] [--os-password <auth-password>]
             [--os-tenant-id <auth-tenant-id>]
             [--os-tenant-name <auth-tenant-name>]
             [--os-auth-url <auth-url>] [--os-auth-token <auth-token>]
             [--os-storage-url <storage-url>] [--os-region-name <region-name>]
             [--os-service-type <service-type>]
             [--os-endpoint-type <endpoint-type>]
             [--os-cacert <ca-certificate>] [--insecure]
             [--no-ssl-compression]
             <subcommand> ...

Command-line interface to the OpenStack Swift API.

Positional arguments:
  <subcommand>
    delete               Delete a container or objects within a container.
    download             Download objects from containers.
    list                 Lists the containers for the account or the objects
                         for a container.
    post                 Updates meta information for the account, container,
                         or object; creates containers if not present.
    stat                 Displays information for the account, container,
                         or object.
    upload               Uploads files or directories to the given container
    capabilities         List cluster capabilities.
    exec                 Execute ZeroCloud job


Examples:
  %%prog -A https://auth.api.rackspacecloud.com/v1.0 -U user -K api_key stat -v

  %%prog --os-auth-url https://api.example.com/v2.0 --os-tenant-name tenant \\
      --os-username user --os-password password list

  %%prog --os-auth-token 6ee5eb33efad4e45ab46806eac010566 \\
      --os-storage-url https://10.1.5.2:8080/v1/AUTH_ced809b6a4baea7aeab61a \\
      list

  %%prog list --lh
'''.strip('\n') % globals())
    parser.add_option('-s', '--snet', action='store_true', dest='snet',
                      default=False, help='Use SERVICENET internal network.')
    parser.add_option('-v', '--verbose', action='count', dest='verbose',
                      default=1, help='Print more info.')
    parser.add_option('--debug', action='store_true', dest='debug',
                      default=False, help='Show the curl commands and results '
                      'of all http queries regardless of result status.')
    parser.add_option('--info', action='store_true', dest='info',
                      default=False, help='Show the curl commands and results '
                      ' of all http queries which return an error.')
    parser.add_option('-q', '--quiet', action='store_const', dest='verbose',
                      const=0, default=1, help='Suppress status output.')
    parser.add_option('-A', '--auth', dest='auth',
                      default=environ.get('ST_AUTH'),
                      help='URL for obtaining an auth token.')
    parser.add_option('-V', '--auth-version',
                      dest='auth_version',
                      default=environ.get('ST_AUTH_VERSION', '1.0'),
                      type=str,
                      help='Specify a version for authentication. '
                           'Defaults to 1.0.')
    parser.add_option('-U', '--user', dest='user',
                      default=environ.get('ST_USER'),
                      help='User name for obtaining an auth token.')
    parser.add_option('-K', '--key', dest='key',
                      default=environ.get('ST_KEY'),
                      help='Key for obtaining an auth token.')
    parser.add_option('-R', '--retries', type=int, default=5, dest='retries',
                      help='The number of times to retry a failed connection.')
    parser.add_option('--os-username',
                      metavar='<auth-user-name>',
                      default=environ.get('OS_USERNAME'),
                      help='OpenStack username. Defaults to env[OS_USERNAME].')
    parser.add_option('--os_username',
                      help=SUPPRESS_HELP)
    parser.add_option('--os-password',
                      metavar='<auth-password>',
                      default=environ.get('OS_PASSWORD'),
                      help='OpenStack password. Defaults to env[OS_PASSWORD].')
    parser.add_option('--os_password',
                      help=SUPPRESS_HELP)
    parser.add_option('--os-tenant-id',
                      metavar='<auth-tenant-id>',
                      default=environ.get('OS_TENANT_ID'),
                      help='OpenStack tenant ID. '
                      'Defaults to env[OS_TENANT_ID].')
    parser.add_option('--os_tenant_id',
                      help=SUPPRESS_HELP)
    parser.add_option('--os-tenant-name',
                      metavar='<auth-tenant-name>',
                      default=environ.get('OS_TENANT_NAME'),
                      help='OpenStack tenant name. '
                           'Defaults to env[OS_TENANT_NAME].')
    parser.add_option('--os_tenant_name',
                      help=SUPPRESS_HELP)
    parser.add_option('--os-auth-url',
                      metavar='<auth-url>',
                      default=environ.get('OS_AUTH_URL'),
                      help='OpenStack auth URL. Defaults to env[OS_AUTH_URL].')
    parser.add_option('--os_auth_url',
                      help=SUPPRESS_HELP)
    parser.add_option('--os-auth-token',
                      metavar='<auth-token>',
                      default=environ.get('OS_AUTH_TOKEN'),
                      help='OpenStack token. Defaults to env[OS_AUTH_TOKEN]. '
                           'Used with --os-storage-url to bypass the '
                           'usual username/password authentication.')
    parser.add_option('--os_auth_token',
                      help=SUPPRESS_HELP)
    parser.add_option('--os-storage-url',
                      metavar='<storage-url>',
                      default=environ.get('OS_STORAGE_URL'),
                      help='OpenStack storage URL. '
                           'Defaults to env[OS_STORAGE_URL]. '
                           'Overrides the storage url returned during auth. '
                           'Will bypass authentication when used with '
                           '--os-auth-token.')
    parser.add_option('--os_storage_url',
                      help=SUPPRESS_HELP)
    parser.add_option('--os-region-name',
                      metavar='<region-name>',
                      default=environ.get('OS_REGION_NAME'),
                      help='OpenStack region name. '
                           'Defaults to env[OS_REGION_NAME].')
    parser.add_option('--os_region_name',
                      help=SUPPRESS_HELP)
    parser.add_option('--os-service-type',
                      metavar='<service-type>',
                      default=environ.get('OS_SERVICE_TYPE'),
                      help='OpenStack Service type. '
                           'Defaults to env[OS_SERVICE_TYPE].')
    parser.add_option('--os_service_type',
                      help=SUPPRESS_HELP)
    parser.add_option('--os-endpoint-type',
                      metavar='<endpoint-type>',
                      default=environ.get('OS_ENDPOINT_TYPE'),
                      help='OpenStack Endpoint type. '
                           'Defaults to env[OS_ENDPOINT_TYPE].')
    parser.add_option('--os-cacert',
                      metavar='<ca-certificate>',
                      default=environ.get('OS_CACERT'),
                      help='Specify a CA bundle file to use in verifying a '
                      'TLS (https) server certificate. '
                      'Defaults to env[OS_CACERT].')
    default_val = config_true_value(environ.get('SWIFTCLIENT_INSECURE'))
    parser.add_option('--insecure',
                      action="store_true", dest="insecure",
                      default=default_val,
                      help='Allow swiftclient to access servers without '
                           'having to verify the SSL certificate. '
                           'Defaults to env[SWIFTCLIENT_INSECURE] '
                           '(set to \'true\' to enable).')
    parser.add_option('--no-ssl-compression',
                      action='store_false', dest='ssl_compression',
                      default=True,
                      help='This option is deprecated and not used anymore. '
                           'SSL compression should be disabled by default '
                           'by the system SSL library.')
    parser.disable_interspersed_args()
    (options, args) = parse_args(parser, argv[1:], enforce_requires=False)
    parser.enable_interspersed_args()

    commands = ('delete', 'download', 'list', 'post',
                'stat', 'upload', 'capabilities', 'info', 'exec')
    if not args or args[0] not in commands:
        parser.print_usage()
        if args:
            exit('no such command: %s' % args[0])
        exit()

    signal.signal(signal.SIGINT, immediate_exit)

    if options.debug or options.info:
        logging.getLogger("zwiftclient")
        if options.debug:
            logging.basicConfig(level=logging.DEBUG)
        elif options.info:
            logging.basicConfig(level=logging.INFO)

    had_error = False

    with MultiThreadingManager() as thread_manager:
        parser.usage = globals()['st_%s_help' % args[0]]
        try:
            globals()['st_%s' % args[0]](parser, argv[1:], thread_manager)
        except (ClientException, RequestException, socket.error) as err:
            thread_manager.error(str(err))

        had_error = thread_manager.error_count

    if had_error:
        exit(1)
Beispiel #22
0
def _parse_options(arguments):
    ''' Parses sysconfig subcommands'''

    usage = "\t%prog unconfigure [-s] [-g system] " + \
            "[--destructive]" + \
            "\n\t%prog configure [-s] [-g system] " + \
            "[-c config_profile.xml | dir] [--destructive]" + \
            "\n\t%prog create-profile [-g system] " + \
            "[-o output_file] [-l logfile] [-v verbosity] [-b]"

    parser = OptionParser(usage=usage)

    try:
        i = arguments.index(DASH_G)
        try:
            if ' ' in arguments[i + 1]:
                parser.error("groupings must be a comma separated list")
                sys.exit(SU_FATAL_ERR)
        except IndexError:
            # Not necessarily an error if there isn't something at the
            # index value. The user may have passed in configuration with
            # no options, which defaults to system
            pass
    except ValueError:
        # no -g option found
        pass

    # This allows parsing of different subcommand options. It stops
    # parsing after the subcommand is populated.
    parser.disable_interspersed_args()
    (options, sub_cmd) = parser.parse_args(arguments)
    parser.enable_interspersed_args()

    if not sub_cmd:
        parser.error("Subcommand not specified\n"
            "Please select one of the following subcommands: "
            "%s" % SUBCOMMANDS)

    if sub_cmd[0] == CONFIGURE or sub_cmd[0] == UNCONFIGURE:
        # Set up valid options shared by configure and unconfigure subcommands.
        parser.add_option("-g", dest="grouping", action="callback",
                          callback=vararg_callback,
                          help="Grouping to %s" % sub_cmd[0])
        parser.add_option("-s", action="store_true",
                          dest="shutdown", default=False,
                          help="Shuts down the system after the "
                          "unconfiguration")
        parser.add_option("--destructive", dest="destructive",
                          default=False, action="store_true",
                          help="Do not preserve system data for a "
                          "group")

        # configure subcommand additionally supports '-c profile'.
        if sub_cmd[0] == CONFIGURE:
            parser.add_option("-c", dest="profile",
                              help="Custom site profile to use")

        (options, sub_cmd) = parse_unconfig_args(parser, arguments)
    elif sub_cmd[0] == CREATE_PROFILE:
        parser.add_option("-g", dest="grouping",
                          help=_("Grouping to configure"),
                          default=SC_GROUP_SYSTEM)
        parser.add_option("-o", dest="profile", metavar="FILE",
                          help=_("Saves created system configuration profile "
                          "into FILE.\t\t[default: %default]"),
                          default=DEFAULT_SC_LOCATION)
        parser.add_option("-l", "--log-location", dest="logname",
                          help=_("Set log location to FILE "
                          "(default: %default)"),
                          metavar="FILE", default=DEFAULT_LOG_LOCATION)
        parser.add_option("-v", "--log-level", dest="log_level",
                          default=DEFAULT_LOG_LEVEL,
                          help=_("Set log verbosity to LEVEL. In order of "
                          "increasing verbosity, valid values are 'error' "
                          "'warn' 'info' 'debug' or 'input'\n[default:"
                          " %default]"),
                          choices=["error", "warn", "info", "debug", "input"],
                          metavar="LEVEL")
        parser.add_option("-b", "--no-color", action="store_true",
                          dest="force_bw", default=False,
                          help=_("Force the tool to run in "
                          "black and white. This may be useful on some SPARC "
                          "machines with unsupported frame buffers\n"))
        (options, sub_cmd) = parse_create_profile_args(parser, arguments)
    else:
        parser.error("Invalid subcommand \n"
            "Please select one of the following subcommands: "
            "%s" % SUBCOMMANDS)

    return (options, sub_cmd)
Beispiel #23
0
def main():
    usage = """%prog [options]
Generate a single amalgamated source and header file from the sources.
"""
    from optparse import OptionParser
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False

    parser.add_option(
            "-s",
            "--source",
            dest="target_source_path",
            action="store",
            default="dist/arbiter.cpp",
            help="""Output .cpp source path. [Default: %default]""")

    parser.add_option(
            "-i", "--include",
            dest="header_include_path",
            action="store",
            default="arbiter.hpp",
            help="""Header include path. Used to include the header from the amalgamated source file. [Default: %default]""")

    parser.add_option(
            "-t",
            "--top-dir",
            dest="top_dir",
            action="store",
            default=os.getcwd(),
            help="""Source top-directory. [Default: %default]""")

    parser.add_option(
            "-j",
            "--no-include-json",
            dest="include_json",
            action="store_false",
            default=True)

    parser.add_option(
            "-x",
            "--no-include-xml",
            dest="include_xml",
            action="store_false",
            default=True)

    parser.add_option(
            "-c",
            "--custom-namespace",
            dest="custom_namespace",
            action="store",
            default=None)

    parser.enable_interspersed_args()
    options, args = parser.parse_args()

    msg = amalgamate_source(source_top_dir=options.top_dir,
                             target_source_path=options.target_source_path,
                             header_include_path=options.header_include_path,
                             include_json=options.include_json,
                             include_xml=options.include_xml,
                             custom_namespace=options.custom_namespace)
    if msg:
        sys.stderr.write(msg + "\n")
        sys.exit(1)
    else:
        print("Source successfully amalgamated")
Beispiel #24
0
def main():
    usage = """%prog release_version next_dev_version
Update 'version' file to release_version and commit.
Generates the document tarball.
Tags the sandbox revision with release_version.
Update 'version' file to next_dev_version and commit.

Performs an svn export of tag release version, and build a source tarball.    

Must be started in the project top directory.

Warning: --force should only be used when developing/testing the release script.
"""
    from optparse import OptionParser
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False
    parser.add_option('--dot', dest="dot_path", action='store', default=doxybuild.find_program('dot'),
        help="""Path to GraphViz dot tool. Must be full qualified path. [Default: %default]""")
    parser.add_option('--doxygen', dest="doxygen_path", action='store', default=doxybuild.find_program('doxygen'),
        help="""Path to Doxygen tool. [Default: %default]""")
    parser.add_option('--force', dest="ignore_pending_commit", action='store_true', default=False,
        help="""Ignore pending commit. [Default: %default]""")
    parser.add_option('--retag', dest="retag_release", action='store_true', default=False,
        help="""Overwrite release existing tag if it exist. [Default: %default]""")
    parser.add_option('-p', '--platforms', dest="platforms", action='store', default='',
        help="""Comma separated list of platform passed to scons for build check.""")
    parser.add_option('--no-test', dest="no_test", action='store_true', default=False,
        help="""Skips build check.""")
    parser.add_option('--no-web', dest="no_web", action='store_true', default=False,
        help="""Do not update web site.""")
    parser.add_option('-u', '--upload-user', dest="user", action='store',
                      help="""Sourceforge user for SFTP documentation upload.""")
    parser.add_option('--sftp', dest='sftp', action='store', default=doxybuild.find_program('psftp', 'sftp'),
                      help="""Path of the SFTP compatible binary used to upload the documentation.""")
    parser.enable_interspersed_args()
    options, args = parser.parse_args()

    if len(args) != 2:
        parser.error('release_version missing on command-line.')
    release_version = args[0]
    next_version = args[1]

    if not options.platforms and not options.no_test:
        parser.error('You must specify either --platform or --no-test option.')

    if options.ignore_pending_commit:
        msg = ''
    else:
        msg = check_no_pending_commit()
    if not msg:
        print('Setting version to', release_version)
        set_version(release_version)
        svn_commit('Release ' + release_version)
        tag_url = svn_join_url(SVN_TAG_ROOT, release_version)
        if svn_check_if_tag_exist(tag_url):
            if options.retag_release:
                svn_remove_tag(tag_url, 'Overwriting previous tag')
            else:
                print('Aborting, tag %s already exist. Use --retag to overwrite it!' % tag_url)
                sys.exit(1)
        svn_tag_sandbox(tag_url, 'Release ' + release_version)

        print('Generated doxygen document...')
##        doc_dirname = r'jsoncpp-api-html-0.5.0'
##        doc_tarball_path = r'e:\prg\vc\Lib\jsoncpp-trunk\dist\jsoncpp-api-html-0.5.0.tar.gz'
        doc_tarball_path, doc_dirname = doxybuild.build_doc(options, make_release=True)
        doc_distcheck_dir = 'dist/doccheck'
        tarball.decompress(doc_tarball_path, doc_distcheck_dir)
        doc_distcheck_top_dir = os.path.join(doc_distcheck_dir, doc_dirname)
        
        export_dir = 'dist/export'
        svn_export(tag_url, export_dir)
        fix_sources_eol(export_dir)
        
        source_dir = 'jsoncpp-src-' + release_version
        source_tarball_path = 'dist/%s.tar.gz' % source_dir
        print('Generating source tarball to', source_tarball_path)
        tarball.make_tarball(source_tarball_path, [export_dir], export_dir, prefix_dir=source_dir)

        amalgamation_tarball_path = 'dist/%s-amalgamation.tar.gz' % source_dir
        print('Generating amalgamation source tarball to', amalgamation_tarball_path)
        amalgamation_dir = 'dist/amalgamation'
        amalgamate.amalgamate_source(export_dir, '%s/jsoncpp.cpp' % amalgamation_dir, 'json/json.h')
        amalgamation_source_dir = 'jsoncpp-src-amalgamation' + release_version
        tarball.make_tarball(amalgamation_tarball_path, [amalgamation_dir],
                              amalgamation_dir, prefix_dir=amalgamation_source_dir)

        # Decompress source tarball, download and install scons-local
        distcheck_dir = 'dist/distcheck'
        distcheck_top_dir = distcheck_dir + '/' + source_dir
        print('Decompressing source tarball to', distcheck_dir)
        rmdir_if_exist(distcheck_dir)
        tarball.decompress(source_tarball_path, distcheck_dir)
        scons_local_path = 'dist/scons-local.tar.gz'
        print('Downloading scons-local to', scons_local_path)
        download(SCONS_LOCAL_URL, scons_local_path)
        print('Decompressing scons-local to', distcheck_top_dir)
        tarball.decompress(scons_local_path, distcheck_top_dir)

        # Run compilation
        print('Compiling decompressed tarball')
        all_build_status = True
        for platform in options.platforms.split(','):
            print('Testing platform:', platform)
            build_status, log_path = check_compile(distcheck_top_dir, platform)
            print('see build log:', log_path)
            print(build_status and '=> ok' or '=> FAILED')
            all_build_status = all_build_status and build_status
        if not build_status:
            print('Testing failed on at least one platform, aborting...')
            svn_remove_tag(tag_url, 'Removing tag due to failed testing')
            sys.exit(1)
        if options.user:
            if not options.no_web:
                print('Uploading documentation using user', options.user)
                sourceforge_web_synchro(SOURCEFORGE_PROJECT, doc_distcheck_top_dir, user=options.user, sftp=options.sftp)
                print('Completed documentation upload')
            print('Uploading source and documentation tarballs for release using user', options.user)
            sourceforge_release_tarball(SOURCEFORGE_PROJECT,
                                         [source_tarball_path, doc_tarball_path],
                                         user=options.user, sftp=options.sftp)
            print('Source and doc release tarballs uploaded')
        else:
            print('No upload user specified. Web site and download tarball were not uploaded.')
            print('Tarball can be found at:', doc_tarball_path)

        # Set next version number and commit            
        set_version(next_version)
        svn_commit('Released ' + release_version)
    else:
        sys.stderr.write(msg + '\n')
Beispiel #25
0
def main():
    usage = """%prog [options]
Generate a single amalgamated source and header file from the sources.
"""
    from optparse import OptionParser
    parser = OptionParser(usage=usage)
    parser.allow_interspersed_args = False

    parser.add_option("-s",
                      "--source",
                      dest="target_source_path",
                      action="store",
                      default="dist/arbiter.cpp",
                      help="""Output .cpp source path. [Default: %default]""")

    parser.add_option(
        "-i",
        "--include",
        dest="header_include_path",
        action="store",
        default="arbiter.hpp",
        help=
        """Header include path. Used to include the header from the amalgamated source file. [Default: %default]"""
    )

    parser.add_option("-t",
                      "--top-dir",
                      dest="top_dir",
                      action="store",
                      default=os.getcwd(),
                      help="""Source top-directory. [Default: %default]""")

    parser.add_option("-x",
                      "--no-include-xml",
                      dest="include_xml",
                      action="store_false",
                      default=True)

    parser.add_option("-d",
                      "--define-curl",
                      dest="define_curl",
                      action="store_true",
                      default=False)

    parser.add_option("-j",
                      "--bundle-json",
                      dest="bundle_json",
                      action="store_true",
                      default=False)

    parser.add_option("-c",
                      "--custom-namespace",
                      dest="custom_namespace",
                      action="store",
                      default=None)

    parser.enable_interspersed_args()
    options, args = parser.parse_args()

    msg = amalgamate_source(source_top_dir=options.top_dir,
                            target_source_path=options.target_source_path,
                            header_include_path=options.header_include_path,
                            include_xml=options.include_xml,
                            custom_namespace=options.custom_namespace,
                            define_curl=options.define_curl,
                            bundle_json=options.bundle_json)
    if msg:
        sys.stderr.write(msg + "\n")
        sys.exit(1)
    else:
        print("Source successfully amalgamated")
def _parse_options(arguments):
    ''' Parses sysconfig subcommands'''

    usage = "\t%prog unconfigure [-s] [-g system] " + \
            "[--destructive]" + \
            "\n\t%prog configure [-s] [-g system] " + \
            "[-c config_profile.xml | dir] [--destructive]" + \
            "\n\t%prog create-profile [-g system] " + \
            "[-o output_file] [-l logfile] [-v verbosity] [-b]"

    parser = OptionParser(usage=usage)

    try:
        i = arguments.index(DASH_G)
        try:
            if ' ' in arguments[i + 1]:
                parser.error("groupings must be a comma separated list")
                sys.exit(SU_FATAL_ERR)
        except IndexError:
            # Not necessarily an error if there isn't something at the
            # index value. The user may have passed in configuration with
            # no options, which defaults to system
            pass
    except ValueError:
        # no -g option found
        pass

    # This allows parsing of different subcommand options. It stops
    # parsing after the subcommand is populated.
    parser.disable_interspersed_args()
    (options, sub_cmd) = parser.parse_args(arguments)
    parser.enable_interspersed_args()

    if not sub_cmd:
        parser.error("Subcommand not specified\n"
            "Please select one of the following subcommands: "
            "%s" % SUBCOMMANDS)

    if sub_cmd[0] == CONFIGURE or sub_cmd[0] == UNCONFIGURE:
        # Set up valid options shared by configure and unconfigure subcommands.
        parser.add_option("-g", dest="grouping", action="callback",
                          callback=vararg_callback,
                          help="Grouping to %s" % sub_cmd[0])
        parser.add_option("-s", action="store_true",
                          dest="shutdown", default=False,
                          help="Shuts down the system after the "
                          "unconfiguration")
        parser.add_option("--destructive", dest="destructive",
                          default=False, action="store_true",
                          help="Do not preserve system data for a "
                          "group")

        # configure subcommand additionally supports '-c profile'.
        if sub_cmd[0] == CONFIGURE:
            parser.add_option("-c", dest="profile",
                              help="Custom site profile to use")

        (options, sub_cmd) = parse_unconfig_args(parser, arguments)
    elif sub_cmd[0] == CREATE_PROFILE:
        parser.add_option("-g", dest="grouping",
                          help=_("Grouping to configure"),
                          default=SC_GROUP_SYSTEM)
        parser.add_option("-o", dest="profile", metavar="FILE",
                          help=_("Saves created system configuration profile "
                          "into FILE.\t\t[default: %default]"),
                          default=DEFAULT_SC_LOCATION)
        parser.add_option("-l", "--log-location", dest="logname",
                          help=_("Set log location to FILE "
                          "(default: %default)"),
                          metavar="FILE", default=DEFAULT_LOG_LOCATION)
        parser.add_option("-v", "--log-level", dest="log_level",
                          default=DEFAULT_LOG_LEVEL,
                          help=_("Set log verbosity to LEVEL. In order of "
                          "increasing verbosity, valid values are 'error' "
                          "'warn' 'info' 'debug' or 'input'\n[default:"
                          " %default]"),
                          choices=["error", "warn", "info", "debug", "input"],
                          metavar="LEVEL")
        parser.add_option("-b", "--no-color", action="store_true",
                          dest="force_bw", default=False,
                          help=_("Force the tool to run in "
                          "black and white. This may be useful on some SPARC "
                          "machines with unsupported frame buffers\n"))
        (options, sub_cmd) = parse_create_profile_args(parser, arguments)
    else:
        parser.error("Invalid subcommand \n"
            "Please select one of the following subcommands: "
            "%s" % SUBCOMMANDS)

    return (options, sub_cmd)