• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python shell_tools.run函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: flush_ad_cache

def flush_ad_cache():
    """
    flush_ad_cache()

    Flush the local AD cache
    """
    shell_tools.run("dscacheutil -flushcache")
开发者ID:jayceechou,项目名称:IT-CPE,代码行数:7,代码来源:account_tools.py


示例2: flush_policies

def flush_policies():
    """
    flush_policies()

    Flush all Casper policies. Requires root priviledges.
    """
    shell_tools.run("jamf flushPolicyHistory")
开发者ID:jayceechou,项目名称:IT-CPE,代码行数:7,代码来源:casper_tools.py


示例3: configure

def configure(username):
    """
    configure(ad_account)

    Basic jamf enrollment
    """
    shell_tools.run("jamf recon -realname '%s'" % username)
开发者ID:jayceechou,项目名称:IT-CPE,代码行数:7,代码来源:casper_tools.py


示例4: verify_hd_name

def verify_hd_name():
    """
    verify_hd_name()

    Verify that the disk is named "Macintosh HD," otherwise rename it
    """
    if get_hd_name() != "Macintosh HD":
        shell_tools.run("diskutil rename / \"Macintosh\ HD\"")
开发者ID:cgerke,项目名称:IT-CPE,代码行数:8,代码来源:sys_tools.py


示例5: set_machine_name

def set_machine_name(hostname):
    """
    set_hostname(hostname)

    Sets the machine's hostname
    """

    shell_tools.run("scutil --set ComputerName %s" % hostname)
    shell_tools.run("scutil --set LocalHostName %s" % hostname)
开发者ID:cgerke,项目名称:IT-CPE,代码行数:9,代码来源:sys_tools.py


示例6: launchctl_load

def launchctl_load(name_of_daemon):
    """
    load_launch_daemon(name_of_daemon)

    Loads the launch daemon
    """
    shell_tools.run(
        "launchctl load -w %s/%s" %
        (sys_tools.get_sys_path('launchdaemons'), name_of_daemon)
    )
开发者ID:cgerke,项目名称:IT-CPE,代码行数:10,代码来源:sys_tools.py


示例7: create_mobile_account

def create_mobile_account(ad_account):
    """
    create_mobile_account()

    Create a mobile managed AD account for the ad_account
    """

    managed_app = "/System/Library/CoreServices/ManagedClient.app/"
    unix_cma = "Contents/Resources/createmobileaccount"
    shell_tools.run("%s%s -n %s" % (managed_app, unix_cma, ad_account))
    make_admin(ad_account)
开发者ID:jayceechou,项目名称:IT-CPE,代码行数:11,代码来源:account_tools.py


示例8: launchctl_unload

def launchctl_unload(name_of_daemon):
    """
    unload_launch_daemon(name_of_daemon)

    Unloads the name of daemon
    """
    sleep(secs=3)
    shell_tools.run(
        "launchctl unload -w %s/%s" %
        (sys_tools.get_sys_path('launchdaemons'), name_of_daemon)
    )
开发者ID:cgerke,项目名称:IT-CPE,代码行数:11,代码来源:sys_tools.py


示例9: make_admin

def make_admin(username):
    """
    make_admin()

    Add user to the admin group
    """

    dscl_base = "dscl . -append /Local/Default/Groups"
    admin_commands = [
        "/admin GroupMembership",
        "/staff GroupMembership",
        "/_lpadmin GroupMembership",
    ]

    for command in admin_commands:
        shell_tools.run("%s%s %s" % (dscl_base, command, username))
开发者ID:jayceechou,项目名称:IT-CPE,代码行数:16,代码来源:account_tools.py


示例10: is_active

def is_active():
    """
    is_active()

    Returns whether or not the JunosPulse interface is enabled
    """
    return shell_tools.run('route get facebook.com | grep utn')['success']
开发者ID:cgerke,项目名称:IT-CPE,代码行数:7,代码来源:junos_tools.py


示例11: trigger_policy

def trigger_policy(policy):
    """
    trigger_policy(policy)

    Trigger a casper policy by passing the policy name
    """
    return shell_tools.run("jamf policy -trigger %s" % (policy))["success"]
开发者ID:jayceechou,项目名称:IT-CPE,代码行数:7,代码来源:casper_tools.py


示例12: status

def status():
    """
    status()

    Returns whether or not filevault is active
    """
    return shell_tools.run("fdesetup isactive")["success"]
开发者ID:cgerke,项目名称:IT-CPE,代码行数:7,代码来源:encrypt_tools.py


示例13: configure_time

def configure_time():
    """
    configure_time()

    Sync and enable to point to time_server variable
    """
    # Turn the time setting off to force use ntpdate to sync
    time_server = "time.apple.com"
    time_commands = [
        "systemsetup -setusingnetworktime off",
        "ntpdate %s" % time_server,
        "systemsetup -setusingnetworktime on",
        "systemsetup -setnetworktimeserver %s" % time_server,
    ]
    for command in time_commands:
        shell_tools.run(command)
开发者ID:cgerke,项目名称:IT-CPE,代码行数:16,代码来源:sys_tools.py


示例14: get_os_version

def get_os_version():
    """
    get_os_version()

    Returns the operating system version
    """
    return shell_tools.run("sw_vers -productVersion")["stdout"]
开发者ID:cgerke,项目名称:IT-CPE,代码行数:7,代码来源:sys_tools.py


示例15: get_computer_name

def get_computer_name():
    """
    get_hostname()

    Returns the machine's hostname
    """
    return shell_tools.run("scutil --get ComputerName")["stdout"]
开发者ID:cgerke,项目名称:IT-CPE,代码行数:7,代码来源:sys_tools.py


示例16: uninstall_junos

def uninstall_junos(save_config=False):
    """
    uninstall_junos(save_config=False)

    Uninstall JunosPulse, optionally save the configuration files
    """
    uninstall_path = "/Library/Application Support/Juniper Networks/Junos Pulse"
    "Uninstall.app/Contents/Resources/uninstall.sh"

    # Do not continue if uninstall script doesnt exists
    assert not os.path.exists(uninstall_path), "Error: Junos does not exist"

    uninstall_base_command = "sh %s" % uninstall_path
    if not save_config:
        uninstall_base_command = uninstall_base_command + " 0"

    shell_tools.run(uninstall_base_command)
开发者ID:cgerke,项目名称:IT-CPE,代码行数:17,代码来源:junos_tools.py


示例17: get_total_memory

def get_total_memory():
    """
    get_total_memory()

    Returns the total memory in GBs
    """
    total_memory = shell_tools.run('sysctl -a | grep hw.memsize')['stdout']
    return (int(total_memory.split('=')[-1]) / (1024 * 3))
开发者ID:cgerke,项目名称:IT-CPE,代码行数:8,代码来源:sys_tools.py


示例18: create_local_account

def create_local_account(user, full_name, password, admin=False, hidden=False):
    """
    create_local_account(user, full_name, password, admin=False)

    Creates a local account on the computer. If admin is True, This
    account will be able to administer the computer
    hiddden=True will only work if the "hide500users" is set to true in the
    loginwindow plist
    """
    dscl_command = "dscl ."
    home_dir = "/Users/%s" % user

    uids = shell_tools.run(
        "%s -list /Users UniqueID | awk \\'{print $2}\\'" % (dscl_command),
        sanitize=False
    )["stdout"].split()
    next_id = map(int, uids)
    next_id.sort()
    next_id = next_id[-1]

    # UIDs less than 500 are hidden, set it equal to 500 to be incremented
    if next_id < 500:
        if not hidden:
            next_id = 500

    # Increment by 1 for the next free UID
    user_id = next_id + 1

    # Create it manually as not to rely on casper
    create_user_commands = [
        "create %s" % home_dir,
        "create %s UserShell /bin/bash" % home_dir,
        "create %s RealName \\'%s\\'" % (home_dir, full_name),
        "create %s UniqueID %s" % (home_dir, user_id),
        "create %s PrimaryGroupID 1000" % home_dir,
        "create %s NFSHomeDirectory%s" % (home_dir, home_dir),
        "passwd %s \\'%s\\'" % (home_dir, password),
    ]
    if admin:
        create_user_commands.append(
            "append /Groups/admin GroupMembership %s" % user
        )

    for command in create_user_commands:
        shell_tools.run("%s %s" % (dscl_command, command))
开发者ID:cgerke,项目名称:IT-CPE,代码行数:45,代码来源:sys_tools.py


示例19: import_junos_configuration

def import_junos_configuration(config_file):
    """
    import_junos_configuration(config)

    Imports the junos config_file
    """

    jam_path = "/Applications/Junos Pulse.app/Contents/Plugins/JamUI/jamCommand"

    # Import the selected junos configuration file
    import_config = shell_tools.run(
        '%s -importFile %s' % (jam_path, config_file))

    if not import_config["success"]:
        raise Exception("Unable to import config %s" % import_config["stderr"])

    # Kill the PulseTray to show the new configuration
    shell_tools.run("killall PulseTray")
开发者ID:cgerke,项目名称:IT-CPE,代码行数:18,代码来源:junos_tools.py


示例20: get_used_memory

def get_used_memory():
    """
    get_used_memory()

    Returns the machine's used memory in MB
    """
    get_top_memory = shell_tools.run(
        'top -l 1 | grep PhysMem')['stdout'].split()
    return get_top_memory[1]
开发者ID:cgerke,项目名称:IT-CPE,代码行数:9,代码来源:sys_tools.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python shell_utils.run函数代码示例发布时间:2022-05-27
下一篇:
Python shell.Shell类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap