当前位置: 首页>>代码示例>>Python>>正文


Python target.Target类代码示例

本文整理汇总了Python中target.Target的典型用法代码示例。如果您正苦于以下问题:Python Target类的具体用法?Python Target怎么用?Python Target使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Target类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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,代码来源:


注:本文中的target.Target类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。