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


Python SystemConfiguration.SCDynamicStoreCopyConsoleUser方法代码示例

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


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

示例1: send_installed_uptodate

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def send_installed_uptodate(item_display_name):
    ''' Notify if item that install was requested for is uptodate, check username again incase
        user logged out during execution '''

    username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]
    if os.path.exists(NOTIFIER_PATH) and username:
        #    item_name  - example: OracleJava8
        #    item_display_name - example: Oracle Java 8
        #    item_version - example: 1.8.111.14
        if DATAJAR_NOTIFIER:
            notifier_args = ['/usr/bin/su', '-l', username, '-c', '"{0}" --messageaction "{1}" \
        --message "{2}" --title "{3}" --type banner'.format(NOTIFIER_PATH, NOTIFIER_SENDER_ID, \
                            NOTIFIER_MSG_UPTODATE % (item_display_name), NOTIFIER_MSG_TITLE,)]
        else:
            notifier_args = ['su', '-l', username, '-c', '"{0}" -sender "{1}" -message "{2}" \
                                     -title "{3}"'.format(NOTIFIER_PATH, NOTIFIER_SENDER_ID, \
                                                NOTIFIER_MSG_UPTODATE % (item_display_name), \
                                                                       NOTIFIER_MSG_TITLE,)]
        # Send notification
        subprocess.call(notifier_args, close_fds=True) 
开发者ID:dataJAR,项目名称:jamJAR,代码行数:22,代码来源:jamJAR.py

示例2: fact

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def fact():
    """Returns the user profiles"""
    profiles = []
    console_user = SCDynamicStoreCopyConsoleUser(None, None, None)[0]

    if os.getuid() == 0:
        cmd = ["sudo", "-u", console_user, "/usr/bin/profiles", "-Lo", "stdout-xml"]
    else:
        cmd = ["/usr/bin/profiles", "-Lo", "stdout-xml"]
    task = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out = task.stdout.read()

    if out:
        d = plistlib.readPlistFromString(out)
        if d:
            for i in d[console_user]:
                profiles.append(i["ProfileDisplayName"])

    return {factoid: profiles} 
开发者ID:chilcote,项目名称:unearth,代码行数:21,代码来源:profiles_user.py

示例3: fact

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def fact():
    """Returns the icloud desktop sync status"""

    result = False

    console_user = SCDynamicStoreCopyConsoleUser(None, None, None)[0]
    plist = "/Users/%s/Library/Preferences/MobileMeAccounts.plist" % console_user
    if os.path.exists(plist):
        d = CFPreferencesCopyAppValue("Accounts", plist)[0]["Services"][2]
        sync_active = d.get("Enabled", False)
        files = glob.glob(
            "/Users/%s/Library/Mobile Documents/com~apple~CloudDocs/*" % console_user
        )
        if sync_active and files:
            for f in files:
                if os.path.islink(f):
                    result = True
                    break

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:22,代码来源:icloud_sync.py

示例4: get_console_user

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def get_console_user():
    cfuser = SCDynamicStoreCopyConsoleUser(None, None, None)
    console_user = cfuser[0]
    print "console user:", console_user or "-"
    return console_user 
开发者ID:zentralopensource,项目名称:zentral,代码行数:7,代码来源:run_once.py

示例5: getconsoleuser

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def getconsoleuser():
    cfuser = SCDynamicStoreCopyConsoleUser(None, None, None)
    return cfuser 
开发者ID:macadmins,项目名称:installapplications,代码行数:5,代码来源:installapplications.py

示例6: fact

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def fact():
    """Gets the AD groups from the nomad plist"""
    result = ""

    username = SCDynamicStoreCopyConsoleUser(None, None, None)[0]
    if username:
        result = CFPreferencesCopyAppValue(
            "Groups",
            "/Users/%s/Library/Preferences/com.trusourcelabs.NoMAD.plist" % username,
        )

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:14,代码来源:nomad_groups.py

示例7: fact

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def fact():
    """Returns whether current console user is an admin"""
    result = False

    cmd = ["/usr/bin/dscl", "-plist", ".", "read", "/Groups/admin"]
    output = subprocess.check_output(cmd)
    d = plistlib.readPlistFromString(output)["dsAttrTypeStandard:GroupMembership"]

    console_user = SCDynamicStoreCopyConsoleUser(None, None, None)[0]
    if console_user in d:
        result = True

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:15,代码来源:console_user_is_admin.py

示例8: fact

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def fact():
    """Gets the date of last password change"""
    password_changed = "None"

    # for 10.10+ or non-migrated accounts
    username = SCDynamicStoreCopyConsoleUser(None, None, None)[0]
    if username:
        task = subprocess.check_output(
            ["/usr/bin/dscl", ".", "read", "Users/" + username, "accountPolicyData"]
        )
        plist = plistlib.readPlistFromString("\n".join(task.split()[1:]))
        if "passwordLastSetTime" in plist.keys():
            password_changed = datetime.datetime.utcfromtimestamp(
                plist["passwordLastSetTime"]
            ).date()
        else:
            # for 10.9.x and lower, or migrated accounts
            task = subprocess.Popen(
                [
                    "/usr/bin/dscl",
                    ".",
                    "read",
                    "Users/" + username,
                    "PasswordPolicyOptions",
                ],
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE,
            )
            (out, err) = task.communicate()
            if not err:
                plist = plistlib.readPlistFromString("\n".join(out.split()[1:]))
                if "passwordLastSetTime" in plist.keys():
                    password_changed = plist["passwordLastSetTime"].date()

    return {factoid: str(password_changed)} 
开发者ID:chilcote,项目名称:unearth,代码行数:37,代码来源:password_changed.py

示例9: fact

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def fact():
    """Gets the ADSite from the nomad plist"""
    result = ""

    username = SCDynamicStoreCopyConsoleUser(None, None, None)[0]
    if username:
        result = CFPreferencesCopyAppValue(
            "ADSite",
            "/Users/%s/Library/Preferences/com.trusourcelabs.NoMAD.plist" % username,
        )

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:14,代码来源:nomad_adsite.py

示例10: fact

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def fact():
    """Returns the icloud account"""
    result = "None"

    console_user = SCDynamicStoreCopyConsoleUser(None, None, None)[0]
    plist = "/Users/%s/Library/Preferences/MobileMeAccounts.plist" % console_user
    if os.path.exists(plist):
        d = CFPreferencesCopyAppValue("Accounts", plist)
        result = d[0]["AccountID"] if d else False

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:13,代码来源:icloud_account.py

示例11: fact

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def fact():
    """Returns the icloud drive status"""
    result = "None"
    console_user = SCDynamicStoreCopyConsoleUser(None, None, None)[0]
    plist = "/Users/%s/Library/Preferences/MobileMeAccounts.plist" % console_user
    if os.path.exists(plist):
        d = CFPreferencesCopyAppValue("Accounts", plist)[0]["Services"][2]
        if d:
            result = d.get("Enabled", False)

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:13,代码来源:icloud_drive.py

示例12: fact

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def fact():
    """Gets the LastPasswordExpireDate value from the nomad plist"""
    result = ""

    username = SCDynamicStoreCopyConsoleUser(None, None, None)[0]
    if username:
        result = CFPreferencesCopyAppValue(
            "LastPasswordExpireDate",
            "/Users/%s/Library/Preferences/com.trusourcelabs.NoMAD.plist" % username,
        )

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:14,代码来源:nomad_lastpasswordexpiredate.py

示例13: fact

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def fact():
    """Gets the assigned user from the nomad plist"""
    result = ""

    username = SCDynamicStoreCopyConsoleUser(None, None, None)[0]
    if username:
        result = CFPreferencesCopyAppValue(
            "UserShortName",
            "/Users/%s/Library/Preferences/com.trusourcelabs.NoMAD.plist" % username,
        )

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:14,代码来源:nomad_user.py

示例14: fact

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def fact():
    """Returns the current console user"""
    result = SCDynamicStoreCopyConsoleUser(None, None, None)[0]

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:7,代码来源:console_user.py

示例15: fact

# 需要导入模块: import SystemConfiguration [as 别名]
# 或者: from SystemConfiguration import SCDynamicStoreCopyConsoleUser [as 别名]
def fact():
    """Returns the iCloud disk optimization status"""

    result = "None"

    console_user = SCDynamicStoreCopyConsoleUser(None, None, None)[0]
    plist = "/Users/%s/Library/Preferences/com.apple.bird.plist" % console_user

    if os.path.exists(plist):
        result = CFPreferencesCopyAppValue("optimize-storage", plist)

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:14,代码来源:icloud_optimization.py


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