本文整理汇总了Python中twitter.pants.base.Config.load方法的典型用法代码示例。如果您正苦于以下问题:Python Config.load方法的具体用法?Python Config.load怎么用?Python Config.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter.pants.base.Config
的用法示例。
在下文中一共展示了Config.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def setUp(self):
with temporary_file() as ini:
ini.write(
'''
[DEFAULT]
answer: 42
scale: 1.2
path: /a/b/%(answer)s
embed: %(path)s::foo
disclaimer:
Let it be known
that.
[a]
fast: True
list: [1, 2, 3, %(answer)s]
[b]
preempt: False
dict: {
'a': 1,
'b': %(answer)s,
'c': ['%(answer)s', %(answer)s]
}
''')
ini.close()
self.config = Config.load(configpath=ini.name)
示例2: __init__
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def __init__(self, target, root_dir, extra_targets=None):
self._config = Config.load()
self._target = target
self._root = root_dir
self._cache = BuildCache(
os.path.join(self._config.get("python-setup", "artifact_cache"), "%s" % PythonIdentity.get())
)
self._extra_targets = list(extra_targets) if extra_targets is not None else []
self._extra_targets.append(self._get_common_python())
cachedir = self._config.get("python-setup", "cache")
safe_mkdir(cachedir)
self._eggcache = cachedir
local_repo = "file://%s" % os.path.realpath(cachedir)
self._repos = [local_repo] + self._config.getlist("python-setup", "repos")
self._fetcher = ReqFetcher(repos=self._repos, cache=cachedir)
self._index = None
for index in self._config.getlist("python-setup", "indices"):
if PythonChroot.can_contact_index(index):
self._index = index
break
self._additional_reqs = set()
distdir = self._config.getdefault("pants_distdir")
distpath = tempfile.mktemp(dir=distdir, prefix=target.name)
self.env = PythonEnvironment(distpath)
示例3: __init__
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def __init__(self, targets):
self._config = Config.load()
self._targets = targets
self._resolver = SilentResolver(
caches = self._config.getlist('python-setup', 'local_eggs') +
[self._config.get('python-setup', 'install_cache')],
install_cache = self._config.get('python-setup', 'install_cache'),
fetcher = fetcher_from_config(self._config))
示例4: _run
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def _run():
version = get_version()
if len(sys.argv) == 2 and sys.argv[1] == _VERSION_OPTION:
_do_exit(version)
root_dir = get_buildroot()
if not os.path.exists(root_dir):
_exit_and_fail('PANTS_BUILD_ROOT does not point to a valid path: %s' % root_dir)
if len(sys.argv) < 2 or (len(sys.argv) == 2 and sys.argv[1] in _HELP_ALIASES):
_help(version, root_dir)
command_class, command_args = _parse_command(root_dir, sys.argv[1:])
parser = optparse.OptionParser(version=version)
RcFile.install_disable_rc_option(parser)
parser.add_option(_LOG_EXIT_OPTION,
action='store_true',
default=False,
dest='log_exit',
help = 'Log an exit message on success or failure.')
config = Config.load()
run_tracker = RunTracker(config)
report = initial_reporting(config, run_tracker)
run_tracker.start(report)
url = run_tracker.run_info.get_info('report_url')
if url:
run_tracker.log(Report.INFO, 'See a report at: %s' % url)
else:
run_tracker.log(Report.INFO, '(To run a reporting server: ./pants server)')
command = command_class(run_tracker, root_dir, parser, command_args)
try:
if command.serialized():
def onwait(pid):
print('Waiting on pants process %s to complete' % _process_info(pid), file=sys.stderr)
return True
runfile = os.path.join(root_dir, '.pants.run')
lock = Lock.acquire(runfile, onwait=onwait)
else:
lock = Lock.unlocked()
try:
result = command.run(lock)
_do_exit(result)
except KeyboardInterrupt:
command.cleanup()
raise
finally:
lock.release()
finally:
run_tracker.end()
# Must kill nailguns only after run_tracker.end() is called, because there may still
# be pending background work that needs a nailgun.
if (hasattr(command.options, 'cleanup_nailguns') and command.options.cleanup_nailguns) \
or config.get('nailgun', 'autokill', default=False):
NailgunTask.killall(None)
示例5: setup_parser
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def setup_parser(self, parser, args):
parser.set_usage("\n"
" %prog build (options) [spec] (build args)\n"
" %prog build (options) [spec]... -- (build args)")
parser.add_option("-t", "--timeout", dest="conn_timeout", type="int",
default=Config.load().getdefault('connection_timeout'),
help="Number of seconds to wait for http connections.")
parser.disable_interspersed_args()
parser.epilog = """Builds the specified Python target(s). Use ./pants goal for JVM and other targets."""
示例6: generate_coverage_config
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def generate_coverage_config(target):
cp = configparser.ConfigParser()
cp.readfp(Compatibility.StringIO(DEFAULT_COVERAGE_CONFIG))
cp.add_section('html')
target_dir = os.path.join(Config.load().getdefault('pants_distdir'), 'coverage',
os.path.dirname(target.address.buildfile.relpath), target.name)
safe_mkdir(target_dir)
cp.set('html', 'directory', target_dir)
return cp
示例7: setUp
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def setUp(self):
with temporary_file() as ini:
ini.write(
'''
[python-setup]
platforms: [
'current',
'linux-x86_64']
''')
ini.close()
self.config = Config.load(configpath=ini.name)
示例8: __init__
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def __init__(self, target, root_dir, extra_targets=None, builder=None, conn_timeout=None):
self._config = Config.load()
self._target = target
self._root = root_dir
self._key_generator = CacheKeyGenerator()
self._extra_targets = list(extra_targets) if extra_targets is not None else []
self._resolver = MultiResolver.from_target(self._config, target, conn_timeout=conn_timeout)
self._builder = builder or PEXBuilder(tempfile.mkdtemp())
# Note: unrelated to the general pants artifact cache.
self._egg_cache_root = os.path.join(self._config.get('python-setup', 'artifact_cache'),
'%s' % PythonIdentity.get())
示例9: __init__
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def __init__(self, target, root_dir, extra_targets=None, builder=None, conn_timeout=None):
self._config = Config.load()
self._target = target
self._root = root_dir
self._key_generator = CacheKeyGenerator()
self._extra_targets = list(extra_targets) if extra_targets is not None else []
self._resolver = MultiResolver.from_target(self._config, target, conn_timeout=conn_timeout)
self._builder = builder or PEXBuilder(tempfile.mkdtemp())
artifact_cache_root = os.path.join(self._config.get('python-setup', 'artifact_cache'),
'%s' % PythonIdentity.get())
self._artifact_cache = FileBasedArtifactCache(None, self._root, artifact_cache_root,
self._builder.add_dependency_file)
示例10: setup_parser
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def setup_parser(self, parser, args):
parser.set_usage("\n"
" %prog py (options) [spec] args\n")
parser.disable_interspersed_args()
parser.add_option("-t", "--timeout", dest="conn_timeout", type="int",
default=Config.load().getdefault('connection_timeout'),
help="Number of seconds to wait for http connections.")
parser.add_option("--pex", dest="pex", default=False, action='store_true',
help="dump a .pex of this chroot")
parser.add_option("--resolve", dest="resolve", default=False, action='store_true',
help="resolve targets instead of building.")
parser.add_option("-v", "--verbose", dest="verbose", default=False, action='store_true',
help="show verbose output.")
parser.epilog = """Interact with the chroot of the specified target."""
示例11: setup_parser
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def setup_parser(self, parser, args):
parser.set_usage("\n"
" %prog build (options) [spec] (build args)\n"
" %prog build (options) [spec]... -- (build args)")
parser.add_option("-t", "--timeout", dest="conn_timeout", type="int",
default=Config.load().getdefault('connection_timeout'),
help="Number of seconds to wait for http connections.")
parser.add_option('-i', '--interpreter', dest='interpreter', default=None,
help='The interpreter requirement for this chroot.')
parser.add_option('-v', '--verbose', dest='verbose', default=False, action='store_true',
help='Show verbose output.')
parser.disable_interspersed_args()
parser.epilog = ('Builds the specified Python target(s). Use ./pants goal for JVM and other '
'targets.')
示例12: compiled_idl
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def compiled_idl(cls, idl_dep, generated_deps=None, compiler=None, language=None, namespace_map=None):
"""Marks a jar as containing IDL files that should be fetched and processed locally.
idl_dep: A dependency resolvable to a single jar library.
generated_deps: Dependencies for the code that will be generated from "idl_dep"
compiler: The thrift compiler to apply to the fetched thrift IDL files.
language: The language to generate code for - supported by some compilers
namespace_map: A mapping from IDL declared namespaces to custom namespaces - supported by some
compilers.
"""
deps = [t for t in idl_dep.resolve() if t.is_concrete]
if not len(deps) == 1:
raise TaskError('Can only arrange for compiled idl for a single dependency at a time, '
'given:\n\t%s' % '\n\t'.join(map(str, deps)))
jar = deps.pop()
if not isinstance(jar, JarDependency):
raise TaskError('Can only arrange for compiled idl from a jar dependency, given: %s' % jar)
request = (jar, compiler, language)
namespace_signature = None
if namespace_map:
sha = hashlib.sha1()
for ns_from, ns_to in sorted(namespace_map.items()):
sha.update(ns_from)
sha.update(ns_to)
namespace_signature = sha.hexdigest()
request += (namespace_signature,)
if request not in cls._PLACEHOLDER_BY_REQUEST:
if not cls._EXTRACT_BASE:
config = Config.load()
cls._EXTRACT_BASE = config.get('idl-extract', 'workdir')
safe_mkdir(cls._EXTRACT_BASE)
SourceRoot.register(cls._EXTRACT_BASE, JavaThriftLibrary)
with ParseContext.temp(cls._EXTRACT_BASE):
# TODO(John Sirois): abstract ivy specific configurations notion away
jar._configurations.append('idl')
jar.with_artifact(configuration='idl', classifier='idl')
target_name = '-'.join(filter(None, (jar.id, compiler, language, namespace_signature)))
placeholder = JavaThriftLibrary(target_name,
sources=None,
dependencies=[jar] + (generated_deps or []),
compiler=compiler,
language=language,
namespace_map=namespace_map)
cls._PLACEHOLDER_BY_REQUEST[request] = placeholder
cls._PLACEHOLDERS_BY_JAR[jar].append(placeholder)
return cls._PLACEHOLDER_BY_REQUEST[request]
示例13: __init__
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def __init__(self, run_tracker, root_dir, parser, argv):
Command.__init__(self, run_tracker, root_dir, parser, argv)
if not self.args:
self.error("A spec argument is required")
self._config = Config.load()
self._root = root_dir
address = Address.parse(root_dir, self.args[0])
self.target = Target.get(address)
if self.target is None:
self.error('%s is not a valid target!' % self.args[0])
if not self.target.provides:
self.error('Target must provide an artifact.')
示例14: profile_classpath
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def profile_classpath(profile, java_runner=None, config=None, ivy_jar=None, ivy_settings=None, workunit_factory=None):
# TODO(John Sirois): consider rework when ant backend is gone and there is no more need to share
# path structure
java_runner = java_runner or runjava_indivisible
config = config or Config.load()
profile_dir = config.get("ivy-profiles", "workdir")
profile_libdir = os.path.join(profile_dir, "%s.libs" % profile)
profile_check = "%s.checked" % profile_libdir
if not os.path.exists(profile_check):
# TODO(John Sirois): refactor IvyResolve to share ivy invocation command line bits
ivy_classpath = [ivy_jar] if ivy_jar else config.getlist("ivy", "classpath")
safe_mkdir(profile_libdir)
ivy_settings = ivy_settings or config.get("ivy", "ivy_settings")
ivy_xml = os.path.join(profile_dir, "%s.ivy.xml" % profile)
ivy_opts = [
"-settings",
ivy_settings,
"-ivy",
ivy_xml,
# TODO(John Sirois): this pattern omits an [organisation]- prefix to satisfy IDEA jar naming
# needs for scala - isolate this hack to idea.py where it belongs
"-retrieve",
"%s/[artifact]-[revision](-[classifier]).[ext]" % profile_libdir,
"-sync",
"-symlink",
"-types",
"jar",
"bundle",
"-confs",
"default",
]
result = java_runner(
classpath=ivy_classpath,
main="org.apache.ivy.Main",
workunit_factory=workunit_factory,
workunit_name="%s:bootstrap" % profile,
opts=ivy_opts,
)
if result != 0:
raise TaskError("Failed to load profile %s, ivy exit code %s" % (profile, str(result)))
touch(profile_check)
return [os.path.join(profile_libdir, jar) for jar in os.listdir(profile_libdir)]
示例15: __init__
# 需要导入模块: from twitter.pants.base import Config [as 别名]
# 或者: from twitter.pants.base.Config import load [as 别名]
def __init__(self, target, root_dir, extra_targets=None, builder=None):
self._config = Config.load()
self._target = target
self._root = root_dir
self._cache = BuildCache(os.path.join(self._config.get('python-setup', 'artifact_cache'),
'%s' % PythonIdentity.get()))
self._extra_targets = list(extra_targets) if extra_targets is not None else []
self._resolver = PythonResolver([self._target] + self._extra_targets)
self._builder = builder or PEXBuilder(tempfile.mkdtemp())
self._platforms = (Platform.current(),)
self._pythons = (sys.version[:3],)
# TODO(wickman) Should this be in the binary builder?
if isinstance(self._target, PythonBinary):
self._platforms = self._target._platforms
self._pythons = self._target._interpreters