Jump to content

Informação sobre o sistema


Gust

Recommended Posts

Dá uma vista de olhos no módulo OS.

import statvfs
import os

st = os.statvfs(".")

print "preferred block size", "=>", st[statvfs.F_BSIZE]
print "fundamental block size", "=>", st[statvfs.F_FRSIZE]
print "total blocks", "=>", st[statvfs.F_BLOCKS]
print "total free blocks", "=>", st[statvfs.F_BFREE]
print "available blocks", "=>", st[statvfs.F_BAVAIL]
print "total file nodes", "=>", st[statvfs.F_FILES]
print "total free nodes", "=>", st[statvfs.F_FFREE]
print "available nodes", "=>", st[statvfs.F_FAVAIL]
print "max file name length", "=>", st[statvfs.F_NAMEMAX]

Para obter a RAM podes usar esta função (é preciso o módulo ctypes):

from ctypes import *

kernel32 = windll.kernel32

class MEMORYSTATUS(Structure):
    _fields_ = [
        ('dwLength', c_ulong),
        ('dwMemoryLoad', c_ulong),
        ('dwTotalPhys', c_ulong),
        ('dwAvailPhys', c_ulong),
        ('dwTotalPageFile', c_ulong),
        ('dwAvailPageFile', c_ulong),
        ('dwTotalVirtual', c_ulong),
        ('dwAvailVirtual', c_ulong)
    ]

def getTotalPhysicalBytes():
    memoryStatus = MEMORYSTATUS()
    memoryStatus.dwLength = sizeof(MEMORYSTATUS)
    kernel32.GlobalMemoryStatus(byref(memoryStatus))
    return memoryStatus.dwTotalPhys

if __name__ == '__main__':
    bytes = getTotalPhysicalBytes()
    print "Total physical RAM: %d bytes (%dMB)" % (bytes, bytes / 1024 / 1024)

Explora este link, tem mais formas de fazer. 👍

<3 life

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.