~ubuntu-branches/debian/experimental/spyder/experimental

« back to all changes in this revision

Viewing changes to spyderlib/utils/system.py

  • Committer: Package Import Robot
  • Author(s): Picca Frédéric-Emmanuel
  • Date: 2014-05-29 09:06:26 UTC
  • mfrom: (1.1.21) (18.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20140529090626-f58t82g0n5iewaxu
Tags: 2.3.0~rc+dfsg-1~experimental2
* Add spyder-common binary package for all the python2,3 common files
* debian/path
  - 0001-fix-documentation-installation.patch (deleted)
  + 0001-fix-spyderlib-path.patch (new)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
def windows_memory_usage():
17
17
    """Return physical memory usage (float)
18
18
    Works on Windows platforms only"""
19
 
    from ctypes import windll, wintypes
20
 
    class MemoryStatus(wintypes.Structure):
21
 
        _fields_ = [('dwLength', wintypes.DWORD),
22
 
                    ('dwMemoryLoad', wintypes.DWORD),
23
 
                    ('ullTotalPhys', wintypes.c_uint64),
24
 
                    ('ullAvailPhys', wintypes.c_uint64),
25
 
                    ('ullTotalPageFile', wintypes.c_uint64),
26
 
                    ('ullAvailPageFile', wintypes.c_uint64),
27
 
                    ('ullTotalVirtual', wintypes.c_uint64),
28
 
                    ('ullAvailVirtual', wintypes.c_uint64),
29
 
                    ('ullAvailExtendedVirtual', wintypes.c_uint64),]
 
19
    from ctypes import windll, Structure, c_uint64, sizeof, byref
 
20
    from ctypes.wintypes import DWORD
 
21
    class MemoryStatus(Structure):
 
22
        _fields_ = [('dwLength', DWORD),
 
23
                    ('dwMemoryLoad',DWORD),
 
24
                    ('ullTotalPhys', c_uint64),
 
25
                    ('ullAvailPhys', c_uint64),
 
26
                    ('ullTotalPageFile', c_uint64),
 
27
                    ('ullAvailPageFile', c_uint64),
 
28
                    ('ullTotalVirtual', c_uint64),
 
29
                    ('ullAvailVirtual', c_uint64),
 
30
                    ('ullAvailExtendedVirtual', c_uint64),]
30
31
    memorystatus = MemoryStatus()
31
32
    # MSDN documetation states that dwLength must be set to MemoryStatus
32
33
    # size before calling GlobalMemoryStatusEx
33
34
    # http://msdn.microsoft.com/en-us/library/aa366770(v=vs.85)
34
 
    memorystatus.dwLength = wintypes.sizeof(memorystatus)
35
 
    windll.kernel32.GlobalMemoryStatusEx(wintypes.byref(memorystatus))
 
35
    memorystatus.dwLength = sizeof(memorystatus)
 
36
    windll.kernel32.GlobalMemoryStatusEx(byref(memorystatus))
36
37
    return float(memorystatus.dwMemoryLoad)
37
38
 
38
39
def psutil_phymem_usage():
49
50
    # Backup plan for Windows platforms
50
51
    memory_usage = windows_memory_usage
51
52
else:
52
 
    raise ImportError, "Feature requires psutil 0.3+ on non Windows platforms"
 
53
    raise ImportError("Feature requires psutil 0.3+ on non Windows platforms")
53
54
 
54
55
 
55
56
if __name__ == '__main__':
56
 
    print "*"*80
57
 
    print memory_usage.__doc__
58
 
    print memory_usage()
59
 
    print "*"*80
60
 
    print windows_memory_usage.__doc__
61
 
    print windows_memory_usage()
 
57
    print("*"*80)
 
58
    print(memory_usage.__doc__)
 
59
    print(memory_usage())
 
60
    if os.name == 'nt':
 
61
        #  windll can only be imported if os.name = 'nt' or 'ce'
 
62
        print("*"*80)
 
63
        print(windows_memory_usage.__doc__)
 
64
        print(windows_memory_usage())
 
 
b'\\ No newline at end of file'