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


Python platform.node方法代码示例

本文整理汇总了Python中platform.node方法的典型用法代码示例。如果您正苦于以下问题:Python platform.node方法的具体用法?Python platform.node怎么用?Python platform.node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在platform的用法示例。


在下文中一共展示了platform.node方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: claim_node

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def claim_node(ctx, token, name):
    """
    Take ownership of a node by using a claim token.

    TOKEN is a hard-to-guess string that the previous owner would have
    configured when setting the node's status as orphaned.
    """
    client = ControllerClient()
    result = client.claim_node(token, name=name)
    if result is not None and 'name' in result:
        click.echo("Claimed node with name {}".format(result['name']))
    elif result is not None and 'message' in result:
        click.echo(result['message'])
    else:
        click.echo("No node was found with that claim token.")
    return result 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:18,代码来源:cloud.py

示例2: edit_node_description

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def edit_node_description(ctx, name):
    """
    Interactively edit the node description and save.

    NAME must be the name of a node that you own.

    Open the text editor specified by the EDITOR environment variable
    with the current node description. If you save and exit, the changes
    will be applied to the node.
    """
    client = ControllerClient()
    node = client.find_node(name)
    if node is None:
        click.echo("Node {} was not found.".format(name))
        return

    description = click.edit(node.get('description', ''))
    if description is None:
        click.echo("No change made.")
    else:
        node['description'] = description
        result = client.save_node(node)
        click.echo(util.format_result(result))
        return result 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:26,代码来源:cloud.py

示例3: rename_node

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def rename_node(ctx, name, new_name):
    """
    Change the name of a node.

    NAME must be the name of a node that you control. NEW_NAME is the
    desired new name. It must adhere to the same naming rules as for
    the create-node command, namely, it must begin with a letter and
    consist of only lowercase letters, numbers, and hyphen.
    """
    client = ControllerClient()
    node = client.find_node(name)
    if node is None:
        click.echo("Node {} was not found.".format(name))
        return
    node['name'] = new_name
    result = client.save_node(node)
    click.echo(util.format_result(result))
    return result 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:20,代码来源:cloud.py

示例4: sync_from_root

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def sync_from_root(sess, variables, comm=None):
    """
    Send the root node's parameters to every worker.
    Arguments:
      sess: the TensorFlow session.
      variables: all parameter variables including optimizer's
    """
    if comm is None: comm = MPI.COMM_WORLD
    rank = comm.Get_rank()
    for var in variables:
        if rank == 0:
            comm.Bcast(sess.run(var))
        else:
            import tensorflow as tf
            returned_var = np.empty(var.shape, dtype='float32')
            comm.Bcast(returned_var)
            sess.run(tf.assign(var, returned_var)) 
开发者ID:MaxSobolMark,项目名称:HardRLWithYoutube,代码行数:19,代码来源:mpi_util.py

示例5: get_local_rank_size

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def get_local_rank_size(comm):
    """
    Returns the rank of each process on its machine
    The processes on a given machine will be assigned ranks
        0, 1, 2, ..., N-1,
    where N is the number of processes on this machine.

    Useful if you want to assign one gpu per machine
    """
    this_node = platform.node()
    ranks_nodes = comm.allgather((comm.Get_rank(), this_node))
    node2rankssofar = defaultdict(int)
    local_rank = None
    for (rank, node) in ranks_nodes:
        if rank == comm.Get_rank():
            local_rank = node2rankssofar[node]
        node2rankssofar[node] += 1
    assert local_rank is not None
    return local_rank, node2rankssofar[this_node] 
开发者ID:MaxSobolMark,项目名称:HardRLWithYoutube,代码行数:21,代码来源:mpi_util.py

示例6: __init__

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def __init__(self):
        self.datetime_format = '%H:%M:%S %d/%m/%Y'
        self.__raw_boot_time = psutil.boot_time()
        self.__boot_time = datetime.fromtimestamp(self.raw_boot_time)
        self.__boot_time = self.__boot_time.strftime(self.datetime_format)
        self.__hostname = platform.node()
        self.__os = Computer.__get_os_name()
        self.__architecture = platform.machine()
        self.__python_version = '{} ver. {}'.format(
            platform.python_implementation(), platform.python_version()
        )
        self.__processor = Cpu(monitoring_latency=1)
        self.__nonvolatile_memory = NonvolatileMemory.instances_connected_devices(monitoring_latency=10)
        self.__nonvolatile_memory_devices = set(
            [dev_info.device for dev_info in self.__nonvolatile_memory]
        )
        self.__virtual_memory = VirtualMemory(monitoring_latency=1)
        self.__swap_memory = SwapMemory(monitoring_latency=1)
        self.__network_interface = NetworkInterface(monitoring_latency=3)
        super().__init__(monitoring_latency=3) 
开发者ID:it-geeks-club,项目名称:pyspectator,代码行数:22,代码来源:computer.py

示例7: handle_event

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def handle_event(self, context: ExecutionContext, event: events.ExecutionEvent) -> None:
        if isinstance(event, events.Initialized):
            self.start_time = event.start_time
        if isinstance(event, events.AfterExecution):
            test_case = TestCase(
                f"{event.result.method} {event.result.path}",
                elapsed_sec=event.elapsed_time,
                allow_multiple_subelements=True,
            )
            if event.status == Status.failure:
                checks = get_unique_failures(event.result.checks)
                for idx, check in enumerate(checks, 1):
                    # `check.message` is always not empty for events with `failure` status
                    test_case.add_failure_info(message=f"{idx}. {check.message}")
            if event.status == Status.error:
                test_case.add_error_info(
                    message=event.result.errors[-1].exception, output=event.result.errors[-1].exception_with_traceback
                )
            self.test_cases.append(test_case)
        if isinstance(event, events.Finished):
            test_suites = [TestSuite("schemathesis", test_cases=self.test_cases, hostname=platform.node())]
            to_xml_report_file(file_descriptor=self.file_handle, test_suites=test_suites, prettyprint=True) 
开发者ID:kiwicom,项目名称:schemathesis,代码行数:24,代码来源:junitxml.py

示例8: get_environment

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def get_environment():
    """
    Returns a dictionary describing the environment in which stdpopsim
    is currently running.
    """
    env = {
        "os": {
            "system": platform.system(),
            "node": platform.node(),
            "release": platform.release(),
            "version": platform.version(),
            "machine": platform.machine(),
        },
        "python": {
            "implementation": platform.python_implementation(),
            "version": platform.python_version(),
        },
        "libraries": {
            "msprime": {"version": msprime.__version__},
            "tskit": {"version": tskit.__version__},
        }
    }
    return env 
开发者ID:popsim-consortium,项目名称:stdpopsim,代码行数:25,代码来源:cli.py

示例9: get_environment

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def get_environment():
    """
    Returns a dictionary describing the environment in which tsinfer
    is currently running.
    """
    env = {
        "libraries": {
            "zarr": {"version": zarr.__version__},
            "numcodecs": {"version": numcodecs.__version__},
            "lmdb": {"version": lmdb.__version__},
            "tskit": {"version": tskit.__version__},
        },
        "os": {
            "system": platform.system(),
            "node": platform.node(),
            "release": platform.release(),
            "version": platform.version(),
            "machine": platform.machine(),
        },
        "python": {
            "implementation": platform.python_implementation(),
            "version": platform.python_version_tuple(),
        },
    }
    return env 
开发者ID:tskit-dev,项目名称:tsinfer,代码行数:27,代码来源:provenance.py

示例10: create_reg_message

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def create_reg_message(self):
        """ Creates a registration message to identify the worker to the interchange
        """
        msg = {'parsl_v': PARSL_VERSION,
               'python_v': "{}.{}.{}".format(sys.version_info.major,
                                             sys.version_info.minor,
                                             sys.version_info.micro),
               'max_worker_count': self.max_worker_count,
               'cores': self.cores_on_node,
               'mem': self.available_mem_on_node,
               'block_id': self.block_id,
               'worker_type': self.worker_type,
               'os': platform.system(),
               'hname': platform.node(),
               'dir': os.getcwd(),
        }
        b_msg = json.dumps(msg).encode('utf-8')
        return b_msg 
开发者ID:funcx-faas,项目名称:funcX,代码行数:20,代码来源:funcx_manager.py

示例11: get_local_rank_size

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def get_local_rank_size(comm):
    """
    Returns the rank of each process on its machine
    The processes on a given machine will be assigned ranks
        0, 1, 2, ..., N-1,
    where N is the number of processes on this machine.
    Useful if you want to assign one gpu per machine
    """
    this_node = platform.node()
    ranks_nodes = comm.allgather((comm.Get_rank(), this_node))
    node2rankssofar = collections.defaultdict(int)
    local_rank = None
    for (rank, node) in ranks_nodes:
        if rank == comm.Get_rank():
            local_rank = node2rankssofar[node]
        node2rankssofar[node] += 1
    assert local_rank is not None
    return local_rank, node2rankssofar[this_node] 
开发者ID:openai,项目名称:lm-human-preferences,代码行数:20,代码来源:core.py

示例12: test_uname_win32_ARCHITEW6432

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def test_uname_win32_ARCHITEW6432(self):
        # Issue 7860: make sure we get architecture from the correct variable
        # on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
        # using it, per
        # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
        try:
            with support.EnvironmentVarGuard() as environ:
                if 'PROCESSOR_ARCHITEW6432' in environ:
                    del environ['PROCESSOR_ARCHITEW6432']
                environ['PROCESSOR_ARCHITECTURE'] = 'foo'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'foo')
                environ['PROCESSOR_ARCHITEW6432'] = 'bar'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'bar')
        finally:
            platform._uname_cache = None 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:test_platform.py

示例13: _init_client

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def _init_client(self):
        """init client will check if the user has defined a bucket that
           differs from the default, use the application credentials to 
           get the bucket, and then instantiate the client.
        """

        # Get storage and compute services
        self._get_services()

        env = "SREGISTRY_GOOGLE_STORAGE_BUCKET"
        self._bucket_name = self._get_and_update_setting(env, self.envars.get(env))

        # If the user didn't set in environment, use default
        if not self._bucket_name:
            fallback_name = os.environ.get("USER", platform.node())
            self._bucket_name = "sregistry-gcloud-build-%s" % fallback_name

        # The build bucket is for uploading .tar.gz files
        self._build_bucket_name = "%s_cloudbuild" % self._bucket_name

        # Main storage bucket for containers, and dependency bucket with targz
        self._bucket = self._get_bucket(self._bucket_name)
        self._build_bucket = self._get_bucket(self._build_bucket_name) 
开发者ID:singularityhub,项目名称:sregistry-cli,代码行数:25,代码来源:__init__.py

示例14: test_uname_win32_ARCHITEW6432

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def test_uname_win32_ARCHITEW6432(self):
        # Issue 7860: make sure we get architecture from the correct variable
        # on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
        # using it, per
        # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
        try:
            with test_support.EnvironmentVarGuard() as environ:
                if 'PROCESSOR_ARCHITEW6432' in environ:
                    del environ['PROCESSOR_ARCHITEW6432']
                environ['PROCESSOR_ARCHITECTURE'] = 'foo'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'foo')
                environ['PROCESSOR_ARCHITEW6432'] = 'bar'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'bar')
        finally:
            platform._uname_cache = None 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:21,代码来源:test_platform.py

示例15: _get_fake_uuid

# 需要导入模块: import platform [as 别名]
# 或者: from platform import node [as 别名]
def _get_fake_uuid(with_hostname=True):
    """
    Generate a uuid based on various system information
    """
    import xbmc
    import platform
    list_values = [xbmc.getInfoLabel('System.Memory(total)')]
    if with_hostname:
        # Note: on linux systems hostname content may change after every system update
        try:
            list_values.append(platform.node())
        except Exception:  # pylint: disable=broad-except
            # Due to OS restrictions on 'ios' and 'tvos' an error happen
            # See python limits in the wiki development page
            pass
    return '_'.join(list_values) 
开发者ID:CastagnaIT,项目名称:plugin.video.netflix,代码行数:18,代码来源:uuid_device.py


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