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


Python platform.system方法代码示例

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


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

示例1: gpt_part_table

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def gpt_part_table(usb_disk):
    """
    Check if selected USB contain GPT or MBR partition table
    :return: True if GPT else False
    """
    if platform.system() == "Linux":
        _cmd_out = subprocess.check_output("parted  " + usb_disk[:-1] + " print", shell=True)
        if b'msdos' in _cmd_out:
            return False
        elif b'gpt' in _cmd_out:
            return True
    elif platform.system() == 'Windows':
        if config.usb_gpt is True:
            return True
        elif config.usb_gpt is False:
            return False 
开发者ID:mbusb,项目名称:multibootusb,代码行数:18,代码来源:syslinux.py

示例2: __init__

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def __init__(self, model_nm, logfile=None, props=None,
                 loglevel=logging.INFO):
        self.model_nm = model_nm
        self.graph = nx.Graph()
        if props is None:
            self.props = {}
        else:
            self.props = props
            logfile = self.get("log_fname")
        self.logger = Logger(self, model_name=model_nm,logfile=logfile)
        self.graph.add_edge(self, self.logger)
        self["OS"] = platform.system()
        self["model"] = model_nm
        # process command line args and set them as properties:
        prop_nm = None
        for arg in sys.argv:
            # the first arg (-prop) names the property
            if arg.startswith(SWITCH):
                prop_nm = arg.lstrip(SWITCH)
            # the second arg is the property value
            elif prop_nm is not None:
                self[prop_nm] = arg
                prop_nm = None 
开发者ID:gcallah,项目名称:indras_net,代码行数:25,代码来源:prop_args.py

示例3: _init_dimensions

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def _init_dimensions(self):
        current_os = platform.system().lower()
        dimensions = None

        if current_os.lower() == "windows":
            dimensions = self._get_terminal_size_windows()
            if dimensions is None:
                dimensions = self._get_terminal_size_tput()
        elif current_os.lower() in ["linux", "darwin"] or current_os.startswith(
            "cygwin"
        ):
            dimensions = self._get_terminal_size_linux()

        if dimensions is None:
            dimensions = 80, 25

        # Ensure we have a valid width
        if dimensions[0] <= 0:
            dimensions = 80, dimensions[1]

        self._width, self._height = dimensions 
开发者ID:sdispater,项目名称:clikit,代码行数:23,代码来源:terminal.py

示例4: ensure_session_manager_plugin

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def ensure_session_manager_plugin():
    session_manager_dir = os.path.join(config.user_config_dir, "bin")
    PATH = os.environ.get("PATH", "") + ":" + session_manager_dir
    if shutil.which("session-manager-plugin", path=PATH):
        subprocess.check_call(["session-manager-plugin"], env=dict(os.environ, PATH=PATH))
    else:
        os.makedirs(session_manager_dir, exist_ok=True)
        target_path = os.path.join(session_manager_dir, "session-manager-plugin")
        if platform.system() == "Darwin":
            download_session_manager_plugin_macos(target_path=target_path)
        elif platform.linux_distribution()[0] == "Ubuntu":
            download_session_manager_plugin_linux(target_path=target_path)
        else:
            download_session_manager_plugin_linux(target_path=target_path, pkg_format="rpm")
        os.chmod(target_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
        subprocess.check_call(["session-manager-plugin"], env=dict(os.environ, PATH=PATH))
    return shutil.which("session-manager-plugin", path=PATH) 
开发者ID:kislyuk,项目名称:aegea,代码行数:19,代码来源:ssm.py

示例5: test_memcached_storage_access_token

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def test_memcached_storage_access_token(self):
        if platform.system() == "Windows":
            return

        from pymemcache.client import Client
        from wechatpy.session.memcachedstorage import MemcachedStorage

        servers = ("127.0.0.1", 11211)
        memcached = Client(servers)
        session = MemcachedStorage(memcached)
        client = WeChatClient(self.app_id, self.secret, session=session)
        with HTTMock(wechat_api_mock):
            token = client.fetch_access_token()
            self.assertEqual("1234567890", token["access_token"])
            self.assertEqual(7200, token["expires_in"])
            self.assertEqual("1234567890", client.access_token) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:18,代码来源:test_session.py

示例6: build_user_agent

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def build_user_agent():
	"""Build a Mozilla/5.0 compatible User-Agent string"""

	global USER_AGENT
	if USER_AGENT:
		return USER_AGENT

	ua_tuple = (
		'Mozilla/5.0',
		'(%s; U; %s; en-us)' % (platform.system(), platform.architecture()[0]),
		'Python/%s' % platform.python_version(),
		'(KHTML, like Gecko)',
		'speedtest-cli/%s' % __version__
	)
	USER_AGENT = ' '.join(ua_tuple)
	printer(USER_AGENT, debug=True)
	return USER_AGENT 
开发者ID:NatanaelAntonioli,项目名称:L.E.S.M.A,代码行数:19,代码来源:L.E.S.M.A. - Fabrica de Noobs Speedtest.py

示例7: format_string

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def format_string(cls, old_contents):
        """Format file for use with task queue."""
        # cmd_root is assigned to formatter inside format_task... ugly!
        style_config = os.path.join(cls.cmd_root, cls.config_file)
        # It might be tempting to use the "inplace" option to FormatFile, but
        # it doesn't do an atomic replace, which is dangerous, so don't use
        # it unless you submit a fix to yapf.
        (new_contents, changed) = FormatCode(
            old_contents, style_config=style_config)

        if platform.system() == 'Windows':
            # yapf screws up line endings on windows
            new_contents = new_contents.replace("\r\n", "\n")

            if len(old_contents) == 0:
                # Windows yapf seems to force a newline? I dunno
                new_contents = ""
        return old_contents, new_contents, 'utf-8' 
开发者ID:ContinuumIO,项目名称:ciocheck,代码行数:20,代码来源:formatters.py

示例8: is_block

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def is_block(usb_disk):
    """
    Function to detect if the USB is block device
    :param usb_disk: USB disk path
    :return: True is devie is block device else False
    """
    import stat
    if platform.system() == 'Linux':
        if len(usb_disk) != 9:
            return False
    elif platform.system() == 'Windows':
        if len(usb_disk) != 2:
            return False
        else:
            return True
    try:
        mode = os.stat(usb_disk).st_mode
        gen.log(mode)
        gen.log(stat.S_ISBLK(mode))
    except:
        return False

    return stat.S_ISBLK(mode) 
开发者ID:mbusb,项目名称:multibootusb,代码行数:25,代码来源:usb.py

示例9: copy_iso

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def copy_iso(src, dst):
    """
    A simple wrapper for copying larger files. This is necessary as
    shutil copy files is much slower under Windows platform
    :param src: Path to source file
    :param dst: Destination directory
    :return:
    """
    if platform.system() == "Windows":
        # Note that xcopy asks if the target is a file or a directory when
        # source filename (or dest filename) contains space(s) and the target
        # does not exist.
        assert os.path.exists(dst)
        subprocess.call(['xcopy', '/Y', src, dst], shell=True)
    elif platform.system() == "Linux":
        shutil.copy(src, dst) 
开发者ID:mbusb,项目名称:multibootusb,代码行数:18,代码来源:install.py

示例10: find_qemu

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def find_qemu():
        """
        Check if QEMU is available on host system and return path of the binary
        :return: path to QEMU program or None otherwise.
        """
        if platform.system() == "Linux":
            if subprocess.call('which qemu-system-x86_64', shell=True) == 0:
                qemu = "qemu-system-x86_64"
            elif subprocess.call('which qemu', shell=True) == 0:
                qemu = "qemu"
            else:
                qemu = ""

        elif platform.system() == "Windows":
            qemu = find_qemu_exe()

        if qemu:
            log("QEMU: using " + qemu)
        else:
            log("QEMU: ERROR: not found!")

        return qemu 
开发者ID:mbusb,项目名称:multibootusb,代码行数:24,代码来源:qemu.py

示例11: detect_missing_tools

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def detect_missing_tools(distro):
    tools_dir = os.path.join('data', 'tools')
    if platform.system() == 'Windows':
        _7zip_exe = gen.resource_path(
            os.path.join(tools_dir, '7zip', '7z.exe'))
        e2fsck_exe = gen.resource_path(os.path.join(tools_dir, 'cygwin', 'e2fsck.exe'))
        resize2fs_exe = gen.resource_path(os.path.join(tools_dir, 'cygwin', 'resize2fs.exe'))
    else:
        _7zip_exe = '7z'
        e2fsck_exe = 'e2fsck'
        resize2fs_exe = 'resize2fs'
    if distro not in creator_dict or \
       creator_dict[distro][0] is not create_persistence_using_resize2fs:
        return None
    try:
        with open(os.devnull) as devnull:
            for tool in [e2fsck_exe, resize2fs_exe]:
                p = subprocess.Popen([tool], stdout=devnull, stderr=devnull)
                p.communicate()
    except FileNotFoundError:  # Windows
        return "'%s.exe' is not installed or not available for use." % tool
    except OSError:            # Linux
        return "'%s' is not installed or not available for use." % tool
    return None 
开发者ID:mbusb,项目名称:multibootusb,代码行数:26,代码来源:persistence.py

示例12: isUserAdmin

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def isUserAdmin():
    """
    @return: True if the current user is an 'Admin' whatever that means
    (root on Unix), otherwise False.

    Warning: The inner function fails unless you have Windows XP SP2 or
    higher. The failure causes a traceback to be gen.loged and this
    function to return False.
    """

    if platform.system() == "Windows":
        import ctypes
        # WARNING: requires Windows XP SP2 or higher!
        try:
            return ctypes.windll.shell32.IsUserAnAdmin()
        except:
            traceback.print_exc()
            gen.log("Admin check failed, assuming not an admin.")
            return False
    elif platform.system() == "Linux":
        return os.getuid() == 0
    else:
        raise RuntimeError("Unsupported operating system for this module: %s" % (os.name,)) 
开发者ID:mbusb,项目名称:multibootusb,代码行数:25,代码来源:admin.py

示例13: parse_args

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def parse_args():
    """Parse arguments."""
    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
        description='Diagnose script for checking the current system.')
    choices = ['python', 'pip', 'mxnet', 'os', 'hardware', 'network']
    for choice in choices:
        parser.add_argument('--' + choice, default=1, type=int,
                            help='Diagnose {}.'.format(choice))
    parser.add_argument('--region', default='', type=str,
                        help="Additional sites in which region(s) to test. \
                        Specify 'cn' for example to test mirror sites in China.")
    parser.add_argument('--timeout', default=10, type=int,
                        help="Connection test timeout threshold, 0 to disable.")
    args = parser.parse_args()
    return args 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:18,代码来源:diagnose.py

示例14: get_os_type

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def get_os_type():
	os_type = platform.system()
	if os_type == "Linux":
		return OS_LINUX

	if os_type == "Darwin":
		return OS_MACOSX

	if os_type == "Windows":
		return OS_WINDOWS

	if os_type == "FreeBSD":
		return OS_FREEBSD

	if os_type == "OpenBSD":
		return OS_OPENBSD

	return OS_UNKNOWN

# get the release of the OS 
开发者ID:earthquake,项目名称:XFLTReaT,代码行数:22,代码来源:common.py

示例15: enable_color_logging

# 需要导入模块: import platform [as 别名]
# 或者: from platform import system [as 别名]
def enable_color_logging(debug_lvl=logging.DEBUG):
    if platform.system() == 'Windows':
        # Windows does not support ANSI escapes and we are using API calls to set the console color
        logging.StreamHandler.emit = add_coloring_to_emit_windows(logging.StreamHandler.emit)
    else:
        # all non-Windows platforms are supporting ANSI escapes so we use them
        logging.StreamHandler.emit = add_coloring_to_emit_ansi(logging.StreamHandler.emit)

    root = logging.getLogger()
    root.setLevel(debug_lvl)

    ch = logging.StreamHandler(sys.stdout)
    ch.setLevel(debug_lvl)

    # FORMAT from https://github.com/xolox/python-coloredlogs
    FORMAT = '%(asctime)s %(name)s[%(process)d] \033[1m%(levelname)s\033[0m %(message)s'
    formatter = logging.Formatter(FORMAT, "%Y-%m-%d %H:%M:%S")

    ch.setFormatter(formatter) 
开发者ID:ShailChoksi,项目名称:lichess-bot,代码行数:21,代码来源:ColorLogger.py


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