當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。