コード例 #1
0
ファイル: install.py プロジェクト: mightymarc/kittyviewer
def parse_args():
    parser = optparse.OptionParser(
        usage="usage: %prog [options] [installable1 [installable2...]]",
        formatter = helpformatter.Formatter(),
        description="""This script fetches and installs installable packages.
It also handles uninstalling those packages and manages the mapping between
packages and their license.

The process is to open and read an install manifest file which specifies
what files should be installed. For each installable to be installed.
 * make sure it has a license
 * check the installed version
 ** if not installed and needs to be, download and install
 ** if installed version differs, download & install

If no installables are specified on the command line, then the defaut
behavior is to install all known installables appropriate for the platform
specified or uninstall all installables if --uninstall is set. You can specify
more than one installable on the command line.

When specifying a platform, you can specify 'all' to install all
packages, or any platform of the form:

OS[/arch[/compiler[/compiler_version]]]

Where the supported values for each are:
OS: darwin, linux, windows, solaris
arch: i686, x86_64, ppc, universal
compiler: vs, gcc
compiler_version: 2003, 2005, 2008, 3.3, 3.4, 4.0, etc.

No checks are made to ensure a valid combination of platform
parts. Some exmples of valid platforms:

windows
windows/i686/vs/2005
linux/x86_64/gcc/3.3
linux/x86_64/gcc/4.0
darwin/universal/gcc/4.0
""")
    parser.add_option(
        '--dry-run', 
        action='store_true',
        default=False,
        dest='dryrun',
        help='Do not actually install files. Downloads will still happen.')
    parser.add_option(
        '--install-manifest', 
        type='string',
        default=os.path.join(base_dir, 'install.xml'),
        dest='install_filename',
        help='The file used to describe what should be installed.')
    parser.add_option(
        '--installed-manifest', 
        type='string',
        default=os.path.join(base_dir, 'installed.xml'),
        dest='installed_filename',
        help='The file used to record what is installed.')
    parser.add_option(
        '--export-manifest', 
        action='store_true',
        default=False,
        dest='export_manifest',
        help="Print the install manifest to stdout and exit.")
    parser.add_option(
        '-p', '--platform', 
        type='string',
        default=_get_platform(),
        dest='platform',
        help="""Override the automatically determined platform. \
You can specify 'all' to do a installation of installables for all platforms.""")
    parser.add_option(
        '--cache-dir', 
        type='string',
        default=_default_installable_cache(),
        dest='cache_dir',
        help='Where to download files. Default: %s'% \
             (_default_installable_cache()))
    parser.add_option(
        '--install-dir', 
        type='string',
        default=base_dir,
        dest='install_dir',
        help='Where to unpack the installed files.')
    parser.add_option(
        '--list-installed', 
        action='store_true',
        default=False,
        dest='list_installed',
        help="List the installed package names and exit.")
    parser.add_option(
        '--skip-license-check', 
        action='store_false',
        default=True,
        dest='check_license',
        help="Do not perform the license check.")
    parser.add_option(
        '--list-licenses', 
        action='store_true',
        default=False,
        dest='list_licenses',
        help="List known licenses and exit.")
    parser.add_option(
        '--detail-license', 
        type='string',
        default=None,
        dest='detail_license',
        help="Get detailed information on specified license and exit.")
    parser.add_option(
        '--add-license', 
        type='string',
        default=None,
        dest='new_license',
        help="""Add a license to the install file. Argument is the name of \
license. Specify --license-url if the license is remote or specify \
--license-text, otherwse the license text will be read from standard \
input.""")
    parser.add_option(
        '--license-url', 
        type='string',
        default=None,
        dest='license_url',
        help="""Put the specified url into an added license. \
Ignored if --add-license is not specified.""")
    parser.add_option(
        '--license-text', 
        type='string',
        default=None,
        dest='license_text',
        help="""Put the text into an added license. \
Ignored if --add-license is not specified.""")
    parser.add_option(
        '--remove-license', 
        type='string',
        default=None,
        dest='remove_license',
        help="Remove a named license.")
    parser.add_option(
        '--remove-installable', 
        type='string',
        default=None,
        dest='remove_installable',
        help="Remove a installable from the install file.")
    parser.add_option(
        '--add-installable', 
        type='string',
        default=None,
        dest='add_installable',
        help="""Add a installable into the install file. Argument is \ 
the name of the installable to add.""")
    parser.add_option(
        '--add-installable-metadata', 
        type='string',
        default=None,
        dest='add_installable_metadata',
        help="""Add package for library into the install file. Argument is \
the name of the library to add.""")
    parser.add_option(
        '--installable-copyright', 
        type='string',
        default=None,
        dest='installable_copyright',
        help="""Copyright for specified new package. Ignored if \
--add-installable is not specified.""")
    parser.add_option(
        '--installable-license', 
        type='string',
        default=None,
        dest='installable_license',
        help="""Name of license for specified new package. Ignored if \
--add-installable is not specified.""")
    parser.add_option(
        '--installable-description', 
        type='string',
        default=None,
        dest='installable_description',
        help="""Description for specified new package. Ignored if \
--add-installable is not specified.""")
    parser.add_option(
        '--add-installable-package', 
        type='string',
        default=None,
        dest='add_installable_package',
        help="""Add package for library into the install file. Argument is \
the name of the library to add.""")
    parser.add_option(
        '--package-platform', 
        type='string',
        default=None,
        dest='package_platform',
        help="""Platform for specified new package. \
Ignored if --add-installable or --add-installable-package is not specified.""")
    parser.add_option(
        '--package-url', 
        type='string',
        default=None,
        dest='package_url',
        help="""URL for specified package. \
Ignored if --add-installable or --add-installable-package is not specified.""")
    parser.add_option(
        '--package-md5', 
        type='string',
        default=None,
        dest='package_md5',
        help="""md5sum for new package. \
Ignored if --add-installable or --add-installable-package is not specified.""")
    parser.add_option(
        '--list', 
        action='store_true',
        default=False,
        dest='list_installables',
        help="List the installables in the install manifest and exit.")
    parser.add_option(
        '--detail', 
        type='string',
        default=None,
        dest='detail_installable',
        help="Get detailed information on specified installable and exit.")
    parser.add_option(
        '--detail-installed', 
        type='string',
        default=None,
        dest='detail_installed',
        help="Get list of files for specified installed installable and exit.")
    parser.add_option(
        '--uninstall', 
        action='store_true',
        default=False,
        dest='uninstall',
        help="""Remove the installables specified in the arguments. Just like \
during installation, if no installables are listed then all installed \
installables are removed.""")
    parser.add_option(
        '--scp', 
        type='string',
        default='scp',
        dest='scp',
        help="Specify the path to your scp program.")

    return parser.parse_args()
コード例 #2
0
def parse_args():
    parser = optparse.OptionParser(
        usage="usage: %prog [options]",
        formatter=helpformatter.Formatter(),
        description="""This script f***s with settings.xml and company. :V
        
        by N3X15, for Luna
""")
    parser.add_option('--sort',
                      action='store_true',
                      default=False,
                      dest='sort',
                      help='Sort shit')

    parser.add_option('--target-file',
                      type='string',
                      default=os.path.join(base_dir, 'indra', 'newview',
                                           'app_settings', 'settings.xml'),
                      dest='filename',
                      help='The file getting raped')

    parser.add_option('--source-file',
                      type='string',
                      default='',
                      dest='src_filename',
                      help='The file we --cp stuff from')

    parser.add_option('--set',
                      type='string',
                      default='',
                      dest='set_llsd',
                      help='key=value;key2=value...')

    parser.add_option('--rm',
                      type='string',
                      default='',
                      dest='remove_keys',
                      help='Removes a key (comma-separated list)')

    parser.add_option(
        '--cp',
        type='string',
        default='',
        dest='copy_keys',
        help=
        'Copies keys from --source-file to --target-file.  (comma-separated list)'
    )

    parser.add_option(
        '--mv',
        type='string',
        default='',
        dest='move_keys',
        help=
        'Moves keys from --source-file to --target-file.  (comma-separated list)'
    )

    parser.add_option("--import-from",
                      type="string",
                      default='',
                      dest='import_from',
                      help='Compare settings and bring over new keys')

    parser.add_option(
        "--key-replace",
        type="string",
        default='',
        dest='key_replace',
        help=
        '(format: OLD=NEW;OLD2=NEW2) Find any instances of OLD and replace it with NEW in key names.'
    )

    parser.add_option('--find',
                      type='string',
                      default='',
                      dest='find_key',
                      help='Finds keys matching the indicated substring')

    parser.add_option(
        '--find-action',
        type="string",
        default='print',
        dest='find_action',
        help='What to do after finding a key? (print, remove, copy)')

    parser.add_option('--set-type',
                      type="string",
                      default='',
                      dest='set_type',
                      help="Set KEY to TYPE (KEY=TYPE)")

    parser.add_option(
        '-P',
        '--full-print',
        action="store_true",
        default=False,
        dest='fullprint',
        help="Print the type and value of a key when using --find.")

    parser.add_option('-G',
                      '--get',
                      type="string",
                      default=False,
                      dest='get_value',
                      help="Print the value of a key.")

    return parser.parse_args()