本文整理汇总了Python中gppylib.gpparseopts.OptParser.remove_option方法的典型用法代码示例。如果您正苦于以下问题:Python OptParser.remove_option方法的具体用法?Python OptParser.remove_option怎么用?Python OptParser.remove_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gppylib.gpparseopts.OptParser
的用法示例。
在下文中一共展示了OptParser.remove_option方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_parser
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def create_parser():
parser = OptParser(option_class=OptChecker,
description="Greenplum Package Manager",
version='%prog version $Revision: #1 $')
parser.setHelp([])
addStandardLoggingAndHelpOptions(parser, includeNonInteractiveOption=True)
parser.remove_option('-q')
parser.remove_option('-l')
add_to = OptionGroup(parser, 'General Options')
parser.add_option_group(add_to)
addMasterDirectoryOptionForSingleClusterProgram(add_to)
# TODO: AK: Eventually, these options may need to be flexible enough to accept mutiple packages
# in one invocation. If so, the structure of this parser may need to change.
add_to.add_option('-i', '--install', help='install the given gppkg', metavar='<package>')
add_to.add_option('-u', '--update', help='update the given gppkg', metavar='<package>')
add_to.add_option('-r', '--remove', help='remove the given gppkg', metavar='<name>-<version>')
add_to.add_option('-q', '--query', help='query the gppkg database or a particular gppkg', action='store_true')
add_to.add_option('-b', '--build', help='build a gppkg', metavar='<directory>')
add_to.add_option('-c', '--clean', help='clean the cluster of the given gppkg', action='store_true')
add_to.add_option('--migrate', help='migrate gppkgs from a separate $GPHOME', metavar='<from_gphome> <to_gphome>', action='store_true', default=False)
add_to = OptionGroup(parser, 'Query Options')
parser.add_option_group(add_to)
add_to.add_option('--info', action='store_true', help='print information about the gppkg including name, version, description')
add_to.add_option('--list', action='store_true', help='print all the files present in the gppkg')
add_to.add_option('--all', action='store_true', help='print all the gppkgs installed by gppkg')
return parser
示例2: parseargs
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def parseargs():
evs = ((g_gphome, 'GPHOME'), (g_gpperfmonhome, 'GPPERFMONHOME'), (g_master_data_directory, 'MASTER_DATA_DIRECTORY'))
for (var, desc) in evs:
if not var:
print >> sys.stderr, "$%s must be set" % desc
sys.exit(1)
global g_options
parser = OptParser(option_class=OptChecker)
parser.remove_option('-h')
parser.add_option('-h', '-?', '--help', action='store_true')
parser.add_option('-c', '--commandline', type='string')
parser.add_option('-d', '--directory', type='string')
parser.add_option('-g', '--group', type='string')
parser.add_option('-a', '--application', type='string')
parser.add_option('-t', '--token', type='string')
parser.add_option('-r', '--remotehost', type='string')
parser.add_option('--nodaemon', action='store_true')
parser.add_option('--nostreaming', action='store_true')
(g_options, args) = parser.parse_args()
if g_options.help:
print __doc__
sys.exit(0)
mustHaves = ['commandline', 'directory', 'application', 'token']
for clo in mustHaves:
if not getattr(g_options, clo):
print >> sys.stderr, "Missing required command line attribute: --%s" % clo
sys.exit(1)
示例3: parseargs
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def parseargs():
parser = OptParser(option_class=OptChecker
, description=' '.join(DESCRIPTION.split())
, version='%prog version $Revision: #12 $'
)
parser.setHelp(_help)
parser.set_usage('%prog ' + _usage)
parser.remove_option('-h')
parser.add_option('-f', '--file', default='',
help='the name of a file containing the re-sync file list.')
parser.add_option('-v', '--verbose', action='store_true',
help='debug output.', default=False)
parser.add_option('-h', '-?', '--help', action='help',
help='show this help message and exit.', default=False)
parser.add_option('--usage', action="briefhelp")
parser.add_option('-d', '--master_data_directory', type='string',
dest="masterDataDirectory",
metavar="<master data directory>",
help="Optional. The master host data directory. If not specified, the value set for $MASTER_DATA_DIRECTORY will be used.",
default=get_masterdatadir()
)
parser.add_option('-a', help='don\'t ask to confirm repairs',
dest='confirm', default=True, action='store_false')
"""
Parse the command line arguments
"""
(options, args) = parser.parse_args()
if len(args) > 0:
logger.error('Unknown argument %s' % args[0])
parser.exit()
return options, args
示例4: parseargs
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def parseargs():
parser = OptParser(option_class=OptChecker)
parser.remove_option('-h')
parser.add_option('-h', '-?', '--help', action='store_true')
parser.add_option('-t', '--timestamp', type='string')
parser.add_option('-b', '--backupdir', type='string')
parser.add_option('-d', '--dbname', type='string')
parser.add_option('-p', '--password', type='string')
parser.add_option('-n', '--nthreads', type='int')
(options, args) = parser.parse_args()
if options.help or (not options.dbname and not options.filename):
print """Script performs serial restore of the backup files in case
of the cluster topology change.
Usage:
./serial_restore.py -n thread_number -t backup_timestamp -b backup_directory -d dbname [-p gpadmin_password]
Parameters:
thread_number - number of parallel threads to run
backup_timestamp - timestamp of the backup to be restored
backup_directory - folder with the complete backup set visible from the current server
dbname - name of the database to restore to
gpadmin_password - password of the gpadmin user"""
sys.exit(0)
if not options.timestamp:
logger.error('Failed to start utility. Please, specify backup timestamp with "-t" key')
sys.exit(1)
if not options.backupdir:
logger.error('Failed to start utility. Please, specify backup directory with "-b" key')
sys.exit(1)
if not options.dbname:
logger.error('Failed to start utility. Please, specify database name with "-d" key')
sys.exit(1)
if not options.nthreads:
options.nthreads = 1
return options
示例5: parseargs
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def parseargs():
parser = OptParser(option_class=OptChecker)
parser.remove_option("-h")
parser.add_option("-h", "-?", "--help", action="store_true")
parser.add_option("-d", "--dbname", type="string")
parser.add_option("-p", "--password", type="string")
parser.add_option("-n", "--nthreads", type="int")
(options, args) = parser.parse_args()
if options.help or (not options.dbname and not options.filename):
print """Script performs serial restore of the backup files in case
of the cluster topology change.
Usage:
./parallel_analyze.py -n thread_number -d dbname [-p gpadmin_password]
Parameters:
thread_number - number of parallel threads to run
dbname - name of the database
gpadmin_password - password of the gpadmin user"""
sys.exit(0)
if not options.dbname:
logger.error('Failed to start utility. Please, specify database name with "-d" key')
sys.exit(1)
if not options.nthreads:
logger.error('Failed to start utility. Please, specify number of threads with "-n" key')
sys.exit(1)
return options
示例6: parseargs
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def parseargs():
parser = OptParser(option_class=OptChecker)
parser.remove_option('-h')
parser.add_option('-h', '-?', '--help', action='store_true')
parser.add_option('-d', '--database', type='string')
parser.add_option('-u', '--username', type='string')
parser.add_option('-p', '--password', type='string')
parser.add_option('-l', '--logfile', type='string')
parser.add_option('-n', '--nrows', type='int')
(options, args) = parser.parse_args()
if options.help:
print """
Script executes baseline performance test on the database
Usage:
python performance_baseline.py -d database_name
[-u username -p password]
[-l logfile]
[-n number_of_rows]
-d | --database - name of the database to run the test
-u | --username - name of the user to be used for testing (default is $PGUSER)
-p | --password - password of the user used for testing (default is $PGPASSWORD)
-l | --logfile - performance test output file (default is stdout)
-n | --nrows - number of rows generated in test table (default is 5000)
"""
sys.exit(0)
if not options.nrows:
options.nrows = 5000
if options.nrows < 5000:
raise_err('Number of rows should be 5000 or more')
if not options.database:
raise_err('You must specify database name (-d)')
if (options.password and not options.username) or (not options.password and options.username):
raise_err('You should either specify both username and password or not specify them both')
return options
示例7: parseargs
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def parseargs(args):
global logger
pguser = os.environ.get("PGUSER") or unix.getUserName()
pghost = os.environ.get("PGHOST") or unix.getLocalHostname()
pgport = os.environ.get("PGPORT") or 5432
parser = OptParser(option_class=OptChecker)
parser.remove_option('-h')
parser.add_option('-?', '--help', '-h', action='store_true', default=False)
parser.add_option('-n', '--host', default=pghost)
parser.add_option('-p', '--port', default=pgport)
parser.add_option('-u', '--username', default=pguser)
parser.add_option('-w', '--password', default=False, action='store_true')
parser.add_option('-v', '--verbose', default=False, action='store_true')
parser.add_option('-q', '--quiet', default=True, action='store_true')
(options, args) = parser.parse_args()
if options.help:
print __doc__
sys.exit(1)
try:
options.port = int(options.port)
except:
logger.error("Invalid PORT: '%s'" % options.port)
sys.exit(1)
if options.verbose:
gplog.enable_verbose_logging()
elif options.quiet:
gplog.quiet_stdout_logging()
return options
示例8: parseargs
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def parseargs():
parser = OptParser(option_class=OptChecker)
parser.remove_option('-h')
parser.add_option('-h', '-?', '--help', action='store_true')
parser.add_option('-f', '--fromthreads', type='int')
parser.add_option('-t', '--tothreads', type='int')
parser.add_option('-d', '--database', type='string')
(options, args) = parser.parse_args()
if options.help:
print """
Script generates a big CPU workload on the cluster within configured diapason of
thread number to check the elasicity of cluster CPU resources
Usage:
python cpu_stresstest.py -f fromthreads -t tothreads -d database
-t | --fromthreads - Lower bound of thread number to start
-t | --tothreads - Upper bound of thread number to start
-d | --database - Database to run the test on
"""
sys.exit(0)
if not options.fromthreads:
raise_err('You must specify the lower bound of thread number with -f parameter')
if not options.tothreads:
raise_err('You must specify the upper bound of thread number with -t parameter')
if not options.database:
raise_err('You must specify the database name with -d parameter')
return options
示例9: parseargs
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def parseargs():
parser = OptParser(option_class=OptChecker)
parser.setHelp(_help)
parser.remove_option('-h')
parser.add_option('-h', '-?', '--help', action='help', help='show this help message and exit')
parser.add_option('--entry', type='string')
parser.add_option('--value', type='string')
parser.add_option('--removeonly', action='store_true')
parser.set_defaults(removeonly=False)
# Parse the command line arguments
(options, args) = parser.parse_args()
# sanity check
if not options.entry:
print "--entry is required"
sys.exit(1)
if (not options.value) and (not options.removeonly):
print "Select either --value or --removeonly"
sys.exit(1)
return options
示例10: parseargs
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def parseargs():
global allocation_rate, memory_split, cpu_split
parser = OptParser(option_class=OptChecker)
parser.remove_option('-h')
parser.add_option('-h', '-?', '--help', action='store_true')
parser.add_option('-s', '--seghosts', type='int')
parser.add_option('-d', '--segdbs', type='int')
parser.add_option('-p', '--primarydirs', type='string')
parser.add_option('-m', '--mirrordirs', type='string')
parser.add_option('-o', '--outfile', type='string')
parser.add_option('-i', '--initsystem', action='store_true')
parser.add_option('-e', '--expansion', action='store_true')
parser.add_option('-a', '--added', type='int')
parser.add_option('-C', '--maxcontent', type='int')
parser.add_option('-D', '--maxdbid', type='int')
(options, args) = parser.parse_args()
if options.help:
print """
Script generates the segment placement map for Greenplum initialization.
By default the primary segment directories are /data1/primary and /data2/primary
and the mirror directories are /data1/mirror and /data2/mirror. Output file is
by default located in the working directory and is called gpinitsystem_map_<timestamp>
Usage:
python generate_segment_map.py -s number_of_segment_hosts -d number_of_dbs_per_host
[-o outfile]
[-p directories_for_primaries -m directories_for_mirrors]
[-i | --initsystem]
[-e -a number_of_hosts_added --maxcontent max_content
--maxdbid max_dbid]
-s | --seghosts - Number of segment hosts in the system
-d | --segdbs - Number of segment databases per host
-o | --outfile - Output file
-p | --primarydirs - Colon-separated list of primary segment directories
-m | --mirrordirs - Colon-separated list of mirror segment directories
-i | --initsystem - Generate map file for system initialization
-e | --expansion - Generate map file for system expansion
-a | --added - Number of segment hosts added during expansion
-C | --maxcontent - Maximal number of content in existing GPDB
-D | --maxdbid - Maximal number of dbid in existing GPDB
Examples:
1. Initialize system with 16 segment servers and 4 segments per host:
python generate_segment_map.py -s 16 -d 4 -i > gpinitsystem_map
2. Prepare expansion map to add 8 segment servers to existing system with
16 segment servers and 4 segment databases per host:
python generate_segment_map.py -s 16 -d 4 -e -a 8 --maxcontent 100 --maxdbid 100 > gpexpand_map
"""
sys.exit(0)
if not options.seghosts or not options.segdbs:
raise_err('You must specify both number of segment hosts (-s) and number of segment databases on each host (-d)')
if (options.primarydirs and not options.mirrordirs) or (not options.primarydirs and options.mirrordirs):
raise_err('You must either specify both folders for primaries and mirrors or use defaults for both')
if (not options.initsystem and not options.expansion) or (options.initsystem and options.expansion):
raise_err('You should either specify init system mode ( -i ) or expansion mode ( -e )')
if options.expansion and not options.added:
raise_err('In expansion mode you must specify number of segment servers added')
return options
示例11: parse_command_line
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def parse_command_line():
parser = OptParser(option_class=OptChecker,
description=' '.join(_description.split()))
parser.setHelp(_help)
parser.set_usage('%prog ' + _usage)
parser.remove_option('-h')
parser.add_option('--start', action='store_true',
help='Start the Greenplum Performance Monitor web server.')
parser.add_option('--stop', action='store_true',
help='Stop the Greenplum Performance Monitor web server.')
parser.add_option('--restart', action='store_true',
help='Restart the Greenplum Performance Monitor web server.')
parser.add_option('--status', action='store_true',
help='Display the status of the Gerrnplum Performance Monitor web server.')
parser.add_option('--setup', action='store_true',
help='Setup the Greenplum Performance Monitor web server.')
parser.add_option('--version', action='store_true',
help='Display version information')
parser.add_option('--upgrade', action='store_true',
help='Upgrade a previous installation of the Greenplum Performance Monitors web UI')
parser.set_defaults(verbose=False,filters=[], slice=(None, None))
# Parse the command line arguments
(options, args) = parser.parse_args()
if options.version:
version()
sys.exit(0)
# check for too many options
opt_count = 0
if options.start:
opt_count+=1
if options.stop:
opt_count+=1
if options.setup:
opt_count+=1
if options.upgrade:
opt_count+=1
if options.status:
opt_count+=1
if opt_count > 1:
parser.print_help()
parser.exit()
return options, args
示例12: create_parser
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def create_parser():
"""Create the command line parser object for gpkill"""
help = []
parser = OptParser(option_class=OptChecker,
description='Check or Terminate a Greenplum Database process.',
version='%prog version $Revision: #1 $')
parser.setHelp(help)
addStandardLoggingAndHelpOptions(parser, True)
parser.remove_option('-l')
parser.remove_option('-a')
addTo = OptionGroup(parser, 'Check Options')
parser.add_option_group(addTo)
addTo.add_option('--check', metavar='pid', help='Only returns status 0 if pid may be killed without gpkill, status 1 otherwise.', action='store_true')
return parser
示例13: create_parser
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def create_parser():
parser = OptParser(
option_class=OptChecker, description="Greenplum Package Manager", version="%prog version $Revision: #1 $"
)
parser.setHelp([])
addStandardLoggingAndHelpOptions(parser, includeNonInteractiveOption=True)
parser.remove_option("-q")
parser.remove_option("-l")
add_to = OptionGroup(parser, "General Options")
parser.add_option_group(add_to)
addMasterDirectoryOptionForSingleClusterProgram(add_to)
# TODO: AK: Eventually, these options may need to be flexible enough to accept mutiple packages
# in one invocation. If so, the structure of this parser may need to change.
add_to.add_option("-i", "--install", help="install the given gppkg", metavar="<package>")
add_to.add_option("-u", "--update", help="update the given gppkg", metavar="<package>")
add_to.add_option("-r", "--remove", help="remove the given gppkg", metavar="<name>-<version>")
add_to.add_option("-q", "--query", help="query the gppkg database or a particular gppkg", action="store_true")
add_to.add_option("-b", "--build", help="build a gppkg", metavar="<directory>")
add_to.add_option("-c", "--clean", help="clean the cluster of the given gppkg", action="store_true")
add_to.add_option(
"--migrate",
help="migrate gppkgs from a separate $GPHOME",
metavar="<from_gphome> <to_gphome>",
action="store_true",
default=False,
)
add_to = OptionGroup(parser, "Query Options")
parser.add_option_group(add_to)
add_to.add_option(
"--info", action="store_true", help="print information about the gppkg including name, version, description"
)
add_to.add_option("--list", action="store_true", help="print all the files present in the gppkg")
add_to.add_option("--all", action="store_true", help="print all the gppkgs installed by gppkg")
return parser
示例14: parseargs
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def parseargs():
global allocation_rate, memory_split, cpu_split
parser = OptParser(option_class=OptChecker)
parser.remove_option('-h')
parser.add_option('-h', '-?', '--help', action='store_true')
parser.add_option('-f', '--force', action='store_true')
parser.add_option('-s', '--memsplit', type='float')
parser.add_option('-a', '--allocrate', type='float')
parser.add_option('-c', '--cpusplit', type='float')
(options, args) = parser.parse_args()
if options.help:
print """
Script configures memory and CPU allocation for GPText and GPDB. GPDB should be running when
the script is started. The script should work on master server. Local GPDB connection under
gpadmin to template1 database should be passwordless.
Usage:
python gptext_tune_settings.py [-s memory_split] [-a allocation_rate] [-c cpu_split] [-f | --force]
memory_split - [0.1 .. 0.9] - split of the memory between GPText and GPDB. Greater value - more memory for GPText
allocation_rate - [0.1 .. 0.9] - part of the system memory available to GPText and GPDB
cpu_split - [0.3 .. 2.0] - part of the CPU dedicated to GPDB. Over utilization is allowed
force - do not ask for confirmation of changing the memory settings
"""
sys.exit(0)
if options.allocrate:
if not (options.allocrate >= 0.1 and options.allocrate <= 0.9):
logger.error('Correct values for --allocrate are [0.1 .. 0.9]')
sys.exit(3)
allocation_rate = options.allocrate
if options.memsplit:
if not (options.memsplit >= 0.1 and options.memsplit <= 0.9):
logger.error('Correct values for --memsplit are [0.1 .. 0.9]')
sys.exit(3)
memory_split = options.memsplit
if options.cpusplit:
if not (options.cpusplit >= 0.3 and options.cpusplit <= 2.0):
logger.error('Correct values for --cpusplit are [0.3 .. 2.0]')
sys.exit(3)
cpu_split = options.cpusplit
return options
示例15: parseargs
# 需要导入模块: from gppylib.gpparseopts import OptParser [as 别名]
# 或者: from gppylib.gpparseopts.OptParser import remove_option [as 别名]
def parseargs():
parser = OptParser(option_class=OptChecker)
parser.remove_option('-h')
parser.add_option('-h', '-?', '--help', action='store_true')
parser.add_option('-i', '--index', type='string')
(options, args) = parser.parse_args()
if options.help:
print """
Script is calling Solr commit with the expungeDeletes flag to cause
all the index segments with deletes in them to clean up their segments
from the deleted records
Usage:
python gptext_expunge_deletes.py -i index_name
-i | --index - Name of the index to expunge
Examples:
python gptext_expunge_deletes.py -i test.public.test_table
"""
sys.exit(0)
if not options.index:
logger.error('You must specify index name with -i or --index key')
sys.exit(3)
return options