本文整理匯總了Python中vital.ConfigBlock.from_file方法的典型用法代碼示例。如果您正苦於以下問題:Python ConfigBlock.from_file方法的具體用法?Python ConfigBlock.from_file怎麽用?Python ConfigBlock.from_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vital.ConfigBlock
的用法示例。
在下文中一共展示了ConfigBlock.from_file方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: cli_main
# 需要導入模塊: from vital import ConfigBlock [as 別名]
# 或者: from vital.ConfigBlock import from_file [as 別名]
def cli_main():
"""
Returns:
0 - Success
1 - Configuration invalid
2 - Tracking failed
"""
import optparse
logging.getLogger().setLevel(logging.INFO)
log = logging.getLogger("cli_main")
parser = optparse.OptionParser()
parser.add_option("-c", "--config",
help="Path to the configuration file to use.")
parser.add_option("-o", "--output-config",
help="Output a configuration file for the current "
"configuration to the specified file path.")
opts, args = parser.parse_args()
if opts.config:
opts.config = os.path.abspath(os.path.expanduser(opts.config))
if opts.output_config:
opts.output_config = os.path.abspath(os.path.expanduser(opts.output_config))
tft = TrackFeaturesTool()
if opts.config:
log.info("Setting configuration file: %s", opts.config)
tft.set_configuration(ConfigBlock.from_file(opts.config))
if opts.output_config:
log.info("Writing output configuration file: %s", opts.output_config)
tft.get_configuration().write(opts.output_config)
if not tft.validate_configuration():
log.warning("Current configuration insufficient for running the "
"tool")
return 0
# Error out if current configuration not valid
if not tft.validate_configuration():
log.error("Current configuration insufficient for running the tool")
return 1
if tft.track_images():
return 0
else:
return 2