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