本文整理汇总了Python中target.Target类的典型用法代码示例。如果您正苦于以下问题:Python Target类的具体用法?Python Target怎么用?Python Target使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Target类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_agg_key
def test_agg_key():
t = Target({
'variables': {
'foo': 'bar',
'target_type': 'rate',
'region': 'us-east-1'
}})
# catchall bucket
assert t.get_agg_key({'foo': ['']}) == 'foo:__region=us-east-1,target_type=rate'
# non catchall bucket
assert t.get_agg_key({'foo': ['ba', ''], 'bar': ['']}) == 'foo:ba__region=us-east-1,target_type=rate'
struct = {
'n3': ['bucketmatch1', 'bucketmatch2'],
'othertag': ['']
}
# none of the structs applies
assert t.get_agg_key(struct) == '__foo=bar,region=us-east-1,target_type=rate'
struct = {
'target_type': [''],
'region': ['us-east', 'us-west', '']
}
# one catchall, the other matches
assert t.get_agg_key(struct) == 'region:us-east,target_type:__foo=bar'
开发者ID:presto53,项目名称:graph-explorer,代码行数:27,代码来源:test_target.py
示例2: __init__
def __init__(self,
name,
srcs,
deps,
prebuilt,
blade,
kwargs):
"""Init method.
Init the java jar target.
"""
srcs = var_to_list(srcs)
deps = var_to_list(deps)
Target.__init__(self,
name,
'java_jar',
srcs,
deps,
blade,
kwargs)
if prebuilt:
self.type = 'prebuilt_java_jar'
self.data['jar_class_path'] = self._prebuilt_java_jar_src_path()
self.data['java_jars'] = []
self.java_jar_cmd_list = []
self.cmd_var_list = []
self.java_jar_after_dep_source_list = []
self.targets_dependency_map = {}
self.java_jar_dep_vars = {}
开发者ID:AdolphLua,项目名称:Pebble,代码行数:32,代码来源:java_jar_target.py
示例3: __init__
def __init__(self,
name,
srcs,
deps,
outs,
cmd,
blade,
kwargs):
"""Init method.
Init the gen rule target.
"""
srcs = var_to_list(srcs)
deps = var_to_list(deps)
outs = var_to_list(outs)
Target.__init__(self,
name,
'gen_rule',
srcs,
deps,
None,
blade,
kwargs)
self.data['outs'] = outs
self.data['locations'] = []
self.data['cmd'] = location_re.sub(self._process_location_reference, cmd)
开发者ID:project-zerus,项目名称:blade,代码行数:29,代码来源:gen_rule_target.py
示例4: __init__
def __init__(self,
name,
srcs,
deps,
type,
out,
blade,
kwargs):
srcs = var_to_list(srcs)
deps = var_to_list(deps)
Target.__init__(self,
name,
'package',
[],
deps,
None,
blade,
kwargs)
if type not in _package_types:
console.error_exit('%s: Invalid type %s. Types supported '
'by the package are %s' % (
self.fullname, type, ', '.join(sorted(_package_types))))
self.data['type'] = type
self.data['sources'], self.data['locations'] = [], []
self._process_srcs(srcs)
if not out:
out = '%s.%s' % (name, type)
self.data['out'] = out
开发者ID:project-zerus,项目名称:blade,代码行数:31,代码来源:package_target.py
示例5: connectTarget
def connectTarget(ip, port):
target = Target(ip, int(port))
target.secureConnect()
if target.isConnected():
return target
else:
return False
开发者ID:LucaBongiorni,项目名称:CursedScreech,代码行数:7,代码来源:kuro.py
示例6: __init__
def __init__(self,
name,
type,
srcs,
deps,
base,
visibility,
kwargs):
"""Init method. """
srcs = var_to_list(srcs)
deps = var_to_list(deps)
Target.__init__(self,
name,
type,
srcs,
deps,
visibility,
blade.blade,
kwargs)
if base:
if not base.startswith('//'):
console.error_exit('%s: Invalid base directory %s. Option base should '
'be a directory starting with \'//\' from BLADE_ROOT directory.' %
(self.fullname, base))
self.data['python_base'] = base[2:]
self.data['python_sources'] = [self._source_file_path(s) for s in srcs]
开发者ID:project-zerus,项目名称:blade,代码行数:28,代码来源:py_targets.py
示例7: __init__
def __init__(self,
name,
target_type,
srcs,
deps,
warning,
defs,
incs,
export_incs,
optimize,
extra_cppflags,
extra_linkflags,
blade,
kwargs):
"""Init method.
Init the cc target.
"""
srcs_list = var_to_list(srcs)
srcs = []
for item in srcs_list:
if (';' in item):
# file list expanded with asterisk wildcard
file_name_array = string.split(item, ';')
for file_name in file_name_array:
srcs.append(file_name)
else:
srcs.append(item)
deps = var_to_list(deps)
defs = var_to_list(defs)
incs = var_to_list(incs)
export_incs = var_to_list(export_incs)
opt = var_to_list(optimize)
extra_cppflags = var_to_list(extra_cppflags)
extra_linkflags = var_to_list(extra_linkflags)
Target.__init__(self,
name,
target_type,
srcs,
deps,
blade,
kwargs)
self.data['warning'] = warning
self.data['defs'] = defs
# add by zxy([email protected]) 20140929 support absolute include path (/common/gsl/include)
for index, item in enumerate(incs):
if (item.startswith('/')):
incs[index] = find_relative_path(self.path, item)
#end
self.data['incs'] = incs
self.data['export_incs'] = export_incs
self.data['optimize'] = opt
self.data['extra_cppflags'] = extra_cppflags
self.data['extra_linkflags'] = extra_linkflags
self._check_defs()
self._check_incorrect_no_warning()
开发者ID:huzelin,项目名称:blade,代码行数:60,代码来源:cc_targets.py
示例8: test_aggregation
def test_aggregation():
# note: uneven aggregation: we only want 1 resulting metric,
query = Query("")
query["avg_by"] = {"server": [""]}
query["sum_by"] = {"type": [""]}
targets = {
"web1.db": {"id": "web1.db", "tags": {"server": "web1", "type": "db", "n3": "foo"}},
"web1.php": {"id": "web1.php", "tags": {"server": "web1", "type": "php", "n3": "foo"}},
"web2.db": {"id": "web2.db", "tags": {"server": "web2", "type": "db", "n3": "foo"}},
"web2.php": {"id": "web2.php", "tags": {"server": "web2", "type": "php", "n3": "foo"}},
"web2.memcache": {"id": "web2.memcache", "tags": {"server": "web2", "type": "memcache", "n3": "foo"}},
}
from pprint import pprint
for (k, v) in targets.items():
v = Target(v)
v.get_graph_info(group_by={})
targets[k] = v
graphs, _query = build_graphs_from_targets(targets, query)
# TODO: there should be only 1 graph, containing all 5 items
print "Graphs:"
for (k, v) in graphs.items():
print "graph key"
pprint(k)
print "val:"
pprint(v)
assert {} == graphs
开发者ID:Web5design,项目名称:graph-explorer,代码行数:28,代码来源:test_graphs.py
示例9: __init__
def __init__(self,
name,
type,
srcs,
deps,
resources,
source_encoding,
warnings,
kwargs):
"""Init method.
Init the java jar target.
"""
srcs = var_to_list(srcs)
deps = var_to_list(deps)
resources = var_to_list(resources)
Target.__init__(self,
name,
type,
srcs,
deps,
None,
blade.blade,
kwargs)
self._process_resources(resources)
self.data['source_encoding'] = source_encoding
if warnings is not None:
self.data['warnings'] = var_to_list(warnings)
开发者ID:,项目名称:,代码行数:30,代码来源:
示例10: __init__
def __init__(self,
name,
srcs,
deps,
prebuilt,
blade,
kwargs):
"""Init method.
Init the java jar target.
"""
srcs = var_to_list(srcs)
deps = var_to_list(deps)
Target.__init__(self,
name,
'java_jar',
srcs,
deps,
blade,
kwargs)
if prebuilt:
self.data['type'] = 'prebuilt_java_jar'
self.java_jar_cmd_list = []
self.cmd_var_list = []
self.java_jar_after_dep_source_list = []
self.targets_dependency_map = {}
self.java_jar_dep_vars = {}
self.java_jars_map = self.blade.get_java_jars_map()
self.sources_dependency_map = self.blade.get_sources_explict_dependency_map()
开发者ID:abael,项目名称:blade,代码行数:32,代码来源:java_jar_target.py
示例11: test_run
def test_run(self, target, barcode, kernel, rootfs, test, task_id):
"""@todo: Docstring for test_run
:arg1: @todo
:returns: @todo
"""
cmd,timeout,test_case=(
test['cmd'],
test['timeout'],
test['test_case']
)
try:
_, out = target.run(cmd, timeout=20)
except Exception as e:
raise
out = "we hit an exception, reboot the target"
target.vlm.unreserve_target()
target = Target(barcode, kernel, rootfs)
target.login(deploy=False)
finally:
log_dir='logs/{}_{}'.format(barcode,task_id)
if not os.path.exists(log_dir):
os.makedirs(log_dir)
log_file = "{}.log".format(test_case)
log=os.path.join(log_dir,log_file)
log = Logging(log)
log(out)
return out
开发者ID:,项目名称:,代码行数:28,代码来源:
示例12: __init__
def __init__(self,
name,
srcs,
deps,
outs,
cmd,
blade,
kwargs):
"""Init method.
Init the gen rule target.
"""
srcs = var_to_list(srcs)
deps = var_to_list(deps)
outs = var_to_list(outs)
Target.__init__(self,
name,
'gen_rule',
srcs,
deps,
blade,
kwargs)
self.data['outs'] = outs
self.data['cmd'] = cmd
开发者ID:HopLiu,项目名称:typhoon-blade,代码行数:27,代码来源:gen_rule_target.py
示例13: __init__
def __init__(self, fname, *args, **kwargs):
self.pass_filename = kwargs.get('pass_filename', False)
if 'pass_filename' in kwargs:
del kwargs['pass_filename']
Target.__init__(self, *args, **kwargs)
if self.pass_filename:
self.passes = 1
self.filename = fname
开发者ID:jaredly,项目名称:pbj,代码行数:8,代码来源:file.py
示例14: add_process
def add_process(self, **kwargs):
""" Adds a new process to the solver.
Adds a new process to the solver. The process data is passed with
keyword arguments.
Parameters
----------
type : string
one of "EFFECTIVE", "MOMENTUM", "EXCITATION", "IONIZATION"
or "ATTACHMENT".
target : string
the target species of the process (e.g. "O", "O2"...).
ratio : float
the ratio of the electron mass to the mass of the target
(for elastic/momentum reactions only).
threshold : float
the energy threshold of the process in eV (only for
inelastic reactions).
data : array or array-like
cross-section of the process array with two columns: column
0 must contain energies in eV, column 1 contains the
cross-section in square meters for each of these energies.
Returns
-------
process : :class:`process.Process`
The process that has been added.
Examples
--------
>>> import numpy as np
>>> from bolos import solver, grid
>>> grid.LinearGrid(0, 60., 400)
>>> solver = BoltzmannSolver(grid)
>>> # This is an example cross-section that decays exponentially
>>> energy = np.linspace(0, 10)
>>> cross_section = 1e-20 * np.exp(-energy)
>>> solver.add_process(type="EXCITATION", target="Kriptonite",
>>> ratio=1e-5, threshold=10,
>>> data=np.c_[energy, cross_section])
See Also
--------
load_collisions : Add a set of collisions.
"""
proc = Process(**kwargs)
try:
target = self.target[proc.target_name]
except KeyError:
target = Target(proc.target_name)
self.target[proc.target_name] = target
target.add_process(proc)
return proc
开发者ID:lindsayad,项目名称:pythonForBolos,代码行数:57,代码来源:solver.py
示例15: task_run
def task_run(self, barcode, kernel, rootfs, plan, task_id):
"""@todo: Docstring for task_run
:returns: @todo
"""
target = Target(barcode, kernel, rootfs)
target.login(deploy=True)
for test in plan:
self.test_run(target, barcode, kernel, rootfs, test, task_id)
target.vlm.unreserve_target()
开发者ID:,项目名称:,代码行数:9,代码来源:
示例16: main
def main ():
#Introduction
print ("This program uses a cannonball to shoot at a target.")
#Create graphics window
win = GraphWin(200, 200)
win.setCoords(0.0, 0.0, 25.0, 25.0)
target = Target(win)
flag = False
targetHit = False
while not flag:
#Get inputs
print ()
a = eval(input("Enter the launch angle in degrees: "))
v = eval(input("Enter the initial velocity in meters per second: "))
h = eval(input("Enter the initial height in meters: "))
#Create tracker
projectile = Projectile(a, v, h)
tracker = Tracker(win, projectile)
time = 0.0
while projectile.getY() >= -5:
time += .0005
projectile.update(time)
tracker.update()
#Calculate if cannonball hit target
points = target.points()
center = tracker.circ.getCenter()
center_x = center.getX()
center_y = center.getY()
radius = tracker.circ.getRadius()
for point in points:
x = point.getX()
y = point.getY()
square_dist = (center_x-x) ** 2 + (center_y-y) ** 2
if square_dist <= radius ** 2:
targetHit = True
if targetHit:
print ("\nYou hit the target!")
flag = True
else:
flag = False
print ("\nTry again!")
#Close window
win.getMouse()
win.close()
开发者ID:MichelleJaeg,项目名称:Exercises-from-Chapter-10,代码行数:52,代码来源:338.16.py
示例17: main
def main():
# total number of interactions between 1 and infinity
validInter = False # flag for a valid user input
while validInter == False:
try:
totalInter = int(input("Enter total number of interactions (greater than or equal to 1): "))
except ValueError:
print("Do not enter non-numeric values.")
else:
if (totalInter >= 1):
validInter = True
else:
validInteractions = False
print("Input is out of range.")
# Set the target's probability of X or Y
validProb = False # flag for a valid user input
while validProb == False:
try:
probX = int(input("Probability of X-type Interactions for the target (1-100): "))
except ValueError:
print("Do not enter non-numeric values.")
else:
if (1 <= probX <= 100):
validProb = True
else:
validProb = False
print("Input is out of range.")
probY = 100 - probX # probabilty of Y interactions
#DEBUG
DEBUG.dprint("total # interactions: %r" % totalInter)
DEBUG.dprint("probability of X: %r" % probX)
# Pursuer class takes the two probabilities
aPursuer = Pursuer(totalInter)
aTarget = Target(probX, probY)
# Main Loop
i = 0 # flag
while i < totalInter:
# create an interaction for the pursuer and the target
interP = aPursuer.createInteraction()
interT = aTarget.createInteraction()
# DEBUG
DEBUG.dprint("aPursuer Interaction: %r" % interP)
DEBUG.dprint("aTarget Interaction: %r" % interT)
DEBUG.dprint("i: %r" % i)
# record and display the result
result = aPursuer.reportInteraction(interP, interT)
print(result)
i += 1 # update flag
if i >= 2:
aPursuer.adaptBehaviour(interP, interT)
targetX, targetY = aTarget.reportEnd()
aPursuer.reportEnd(targetX, targetY)
开发者ID:lkhedlund,项目名称:python-practice,代码行数:52,代码来源:manager.py
示例18: __init__
def __init__(self,
name,
target_type,
srcs,
deps,
warning,
defs,
incs,
export_incs,
optimize,
extra_cppflags,
extra_linkflags,
install_dir,
extra_cmds,
blade,
kwargs):
"""Init method.
Init the cc target.
"""
srcs = var_to_list(srcs)
deps = var_to_list(deps)
defs = var_to_list(defs)
incs = var_to_list(incs)
export_incs = var_to_list(export_incs)
opt = var_to_list(optimize)
extra_cppflags = var_to_list(extra_cppflags)
extra_linkflags = var_to_list(extra_linkflags)
extra_cmds = var_to_list(extra_cmds)
Target.__init__(self,
name,
target_type,
srcs,
deps,
blade,
kwargs)
self.data['warning'] = warning
self.data['defs'] = defs
self.data['incs'] = incs
self.data['export_incs'] = export_incs
self.data['optimize'] = opt
self.data['extra_cppflags'] = extra_cppflags
self.data['extra_linkflags'] = extra_linkflags
self.data['install_dir'] = install_dir
self.data['extra_cmds'] = extra_cmds
self._check_defs()
self._check_incorrect_no_warning()
开发者ID:merlin82,项目名称:typhoon-blade,代码行数:51,代码来源:cc_targets.py
示例19: getTarget
def getTarget(self, target_name = None, password = None):
# Override self.target_name if set
if not target_name:
target_name = self.target_name
# TODO: Controllare anche che il master sia connesso. Se e' configurato ma non connesso si deve solo connettere. Il problema e' che non c'e' modo di sapere se effettivamente e' connesso
if not self.master:
print("Connecting to master")
# The first parameter as False creates a Master target
self.master = Target(False, self.protocol, self.address, self.port, target_name)
# TODO: Serve lo stato del master per capire se e' gia' connesso (e quindi ci si riconnette) oppure se serve una nuova connessione
if self.master.is_connected or self.master.connect(password):
print("Connected to master")
else:
print("Error while connecting to master")
return False
print("Connecting to slave")
self.slave = self.master.getSlave(target_name)
if self.slave and (not self.slave.is_connected) and self.slave.connect():
print("Connected to slave")
else:
print("Error while connecting to the slave target")
return self.slave
开发者ID:tommyblue,项目名称:pyRTAI,代码行数:28,代码来源:rtai_server.py
示例20: __init__
def __init__(self, *args, **kwargs):
''' Not perfect but the bike uses hardcoded constants
Warning! Lots of opaque physics and math
'''
super(Bike, self).__init__(*args, **kwargs)
# Not ideal to use white as the color key
# Not ideal to hardcode the bike image asset
self.original, self.rect = util.load_image('bike.png', (255,255,255))
self.image = self.original
self.speed = 0
self.max_speed = 5
# Is this bike moving?
self.driving = 0
# Each bike has its own target
self.target = Target()
# start at the origin
self.x, self.y = self.rect.centerx, self.rect.centery
self.angle = 0.0
self.dt = 0.0
# Some physics constants. These and the image ought to be parameters
# F_c = mv*v/r --> v_max = sqrt(F_traction/m) * sqrt(r)
self.ft = 5.0
self.mass = 200.0
self.brake = 0.1
self.accel = 0.05
self.draw_cb = []
开发者ID:cuadue,项目名称:touchmoto,代码行数:33,代码来源:bike.py
注:本文中的target.Target类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论