本文整理汇总了Python中shell_tools.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: flush_ad_cache
def flush_ad_cache():
"""
flush_ad_cache()
Flush the local AD cache
"""
shell_tools.run("dscacheutil -flushcache")
示例2: flush_policies
def flush_policies():
"""
flush_policies()
Flush all Casper policies. Requires root priviledges.
"""
shell_tools.run("jamf flushPolicyHistory")
示例3: configure
def configure(username):
"""
configure(ad_account)
Basic jamf enrollment
"""
shell_tools.run("jamf recon -realname '%s'" % username)
示例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\"")
示例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)
示例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)
)
示例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)
示例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)
)
示例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))
示例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']
示例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"]
示例12: status
def status():
"""
status()
Returns whether or not filevault is active
"""
return shell_tools.run("fdesetup isactive")["success"]
示例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)
示例14: get_os_version
def get_os_version():
"""
get_os_version()
Returns the operating system version
"""
return shell_tools.run("sw_vers -productVersion")["stdout"]
示例15: get_computer_name
def get_computer_name():
"""
get_hostname()
Returns the machine's hostname
"""
return shell_tools.run("scutil --get ComputerName")["stdout"]