コード例 #1
0
def systemInfo():
    verInfo = r"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
    psKey = r"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine"
    sysPolKey = r"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System"

    sysSummary = printHeader("SYSTEM INFORMATION")
    sysSummary += "{0:<10}: {1}\n".format("Host", Env.MachineName)
    sysSummary += "{0:<10}: {1} {2}\n".format("OS", Registry.GetValue(verInfo, "ProductName", "Windows"), Diagnostics.FileVersionInfo.GetVersionInfo(Env.SystemDirectory + "\\kernel32.dll").ProductVersion)
    sysSummary += "{0:<10}: {1}\n".format("64-Bit", Env.Is64BitOperatingSystem)
    sysSummary += "{0:<10}: {1}\n".format("Date", DateTime.Now.ToString())
    sysSummary += "{0:<10}: {1}\n\n".format("Uptime", DateTimeOffset(DateTime.Now).AddMilliseconds(-Env.TickCount).LocalDateTime)
    
    sysSummary += "{0:<14}: {1}\{2}\n".format("Username", Env.UserDomainName, Env.UserName)
    sysSummary += "{0:<14}: {1}\n\n".format("Logon Server", Env.GetEnvironmentVariable("LOGONSERVER"))

    sysSummary += "{0:<22}: {1}\n".format("PowerShell Version", Registry.GetValue(psKey, "PowerShellVersion", "N/A - Likely 2.0"))
    sysSummary += "{0:<22}: {1}\n".format("PowerShell Compat", Registry.GetValue(psKey, "PSCompatibleVersion", "N/A - Likely 1.0, 2.0"))
    sysSummary += "{0:<22}: {1}\n".format("PS Script Block Log", Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging", "EnableScriptBlockLogging", "N/A"))
    sysSummary += "{0:<22}: {1}\n".format("PS Transcription", Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\PowerShell\Transcription", "EnableTranscripting", "N/A"))
    sysSummary += "{0:<22}: {1}\n".format("PS Transcription Dir", Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\PowerShell\Transcription", "OutputDirectory", "N/A"))
    sysSummary += "{0:<22}: {1}\n\n".format("PS Module Logging", Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ModuleLogging", "EnableModuleLogging", "N/A"))

    sysSummary += "{0:<27}: {1}\n".format("UAC Enabled", Convert.ToBoolean(Registry.GetValue(sysPolKey, "EnableLUA", "N/A")))
    sysSummary += "{0:<27}: {1}\n".format("High Integrity", WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator))
    sysSummary += "{0:<27}: {1}\n".format("UAC Token Filter Disabled", Registry.GetValue(sysPolKey, "LocalAccount", False))
    sysSummary += "{0:<27}: {1}\n".format("UAC Admin Filter Enabled", Registry.GetValue(sysPolKey, "FilterAdministratorToken", False))
    sysSummary += "{0:<27}: {1}\n".format("Local Admin Pass Solution", Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft Services\AdmPwd", "AdmPwdEnabled", "N/A"))
    sysSummary += "{0:<27}: {1}\n".format("LSASS Protection", Registry.GetValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa", "RunAsPPL", "N/A"))
    sysSummary += "{0:<27}: {1}\n".format("Deny RDP Connections", Convert.ToBoolean(Registry.GetValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server", "FDenyTSConnections", "N/A")))

    return sysSummary
コード例 #2
0
def test_comparisons():
    from System import DateTimeOffset
    from Python.Test import ClassTest

    d1 = DateTimeOffset.Parse("2016-11-14")
    d2 = DateTimeOffset.Parse("2016-11-15")

    assert (d1 == d2) == False
    assert (d1 != d2) == True

    assert (d1 < d2) == True
    assert (d1 <= d2) == True
    assert (d1 >= d2) == False
    assert (d1 > d2) == False

    assert (d1 == d1) == True
    assert (d1 != d1) == False

    assert (d1 < d1) == False
    assert (d1 <= d1) == True
    assert (d1 >= d1) == True
    assert (d1 > d1) == False

    assert (d2 == d1) == False
    assert (d2 != d1) == True

    assert (d2 < d1) == False
    assert (d2 <= d1) == False
    assert (d2 >= d1) == True
    assert (d2 > d1) == True

    with pytest.raises(TypeError):
        d1 < None

    with pytest.raises(TypeError):
        d1 < System.Guid()

    # ClassTest does not implement IComparable
    c1 = ClassTest()
    c2 = ClassTest()
    with pytest.raises(TypeError):
        c1 < c2
コード例 #3
0
    def testComparisons(self):
        from System import DateTimeOffset

        d1 = DateTimeOffset.Parse("2016-11-14")
        d2 = DateTimeOffset.Parse("2016-11-15")

        self.assertEqual(d1 == d2, False)
        self.assertEqual(d1 != d2, True)

        self.assertEqual(d1 < d2, True)
        self.assertEqual(d1 <= d2, True)
        self.assertEqual(d1 >= d2, False)
        self.assertEqual(d1 > d2, False)

        self.assertEqual(d1 == d1, True)
        self.assertEqual(d1 != d1, False)

        self.assertEqual(d1 < d1, False)
        self.assertEqual(d1 <= d1, True)
        self.assertEqual(d1 >= d1, True)
        self.assertEqual(d1 > d1, False)

        self.assertEqual(d2 == d1, False)
        self.assertEqual(d2 != d1, True)

        self.assertEqual(d2 < d1, False)
        self.assertEqual(d2 <= d1, False)
        self.assertEqual(d2 >= d1, True)
        self.assertEqual(d2 > d1, True)

        self.assertRaises(TypeError, lambda: d1 < None)
        self.assertRaises(TypeError, lambda: d1 < System.Guid())

        # ClassTest does not implement IComparable
        c1 = ClassTest()
        c2 = ClassTest()
        self.assertRaises(TypeError, lambda: c1 < c2)
コード例 #4
0
import clr
from System import DateTime, DateTimeOffset, TimeSpan
clr.AddReference("WorkTasks")
from WorkTasks import WorkTask

cut_start = DateTimeOffset(1997, 3, 3, 15, 31, 34, 361,
                           TimeSpan.FromMinutes(500))
cut_details = "artio"
account = WorkTask(cut_start, cut_details)

cut_duration = TimeSpan.FromSeconds(25570)
account.Duration = cut_duration

abutting_task = WorkTask(cut_start + cut_duration, "corollarii")
not_abutting_task = WorkTask(cut_start + cut_duration + TimeSpan.FromTicks(1),
                             "poenae")


def test_abutting():
    "Do two WorkTasks abut?"
    return account.IsAbutting(abutting_task)


def test_not_abutting():
    "Do two WorkTasks NOT abut?"
    return account.IsAbutting(not_abutting_task)
コード例 #5
0
ファイル: git.py プロジェクト: chenqianethz/pyRevit
def _make_pull_signature():
    logger.debug('Creating pull signature for username: {}'
                 .format(HOST_APP.username))
    return libgit.Signature(HOST_APP.username,
                            HOST_APP.username,
                            DateTimeOffset(DateTime.Now))
コード例 #6
0
ファイル: dot_net_date.py プロジェクト: mrwizard82d1/ipy_play
def today():
    "Returns today as a .NET type (including offset)."
    local_time = DateTime.Now
    return local_time, DateTimeOffset(
        local_time, TimeZoneInfo.Local.GetUtcOffset(local_time))