Hoi,
Zum Ermitteln des verfügbaren RAMs habe ich mir dies ergoogelt. Mal abgesehen davon, dass os.popen nicht der letzte Schrei ist: Geht das so? Insbesondere unter Windows, was ich nicht testen kann, ist 'nt' da noch aktuell? Oder wie würdet ihr das machen?
Falls es das Thema schon mal gab: Ich habe es nicht gefunden.
Gruß,
Christian
verfügbaren RAM ermitteln
Na ja, das ist in der Tat erst einmal einfacher als den Aufruf von "free". Danke.
Frage: Ist das auf allen posix-Systemen gleich aufgebaut?
Gruß,
Christian
Frage: Ist das auf allen posix-Systemen gleich aufgebaut?
Gruß,
Christian
Davon würd ich nicht ausgehen, zumindest unter AIX ist es wohl auf "Linux-Norm" gehievt. Für andere Unices müßte das halt getestet werden. Dasselbe gilt aber auch für den "free"-Weg, da sich die Ausgaben der einzelnen Unixvarianten dann doch hin und wieder mal unterscheiden bzw. im Detail anders gelöst sind.Frage: Ist das auf allen posix-Systemen gleich aufgebaut?
Also, bei FreeBSD und Mac OS X geht das so nicht. Dort kenne ich nur die Möglichkeit die Speicherbelegung mit "top" zu erfahren (abgesehen von OS X GUI Tools).CM hat geschrieben:Frage: Ist das auf allen posix-Systemen gleich aufgebaut?
Gruß,
Christian
Oh ja, ich erinnere mich - OSX ist da etwas anders. Danke.kbr hat geschrieben:... Mac OS X geht das so nicht.
-
- Python-Forum Veteran
- Beiträge: 16025
- Registriert: Freitag 20. Juni 2003, 16:30
- Kontaktdaten:
``top`` ist AFAIR platformspezifisch und kein Programm das man auf verschiedene Platformen (also quasi Backends) portiert hat. Linux nutzt procps aber das scheint auch tatsächlich nur dort zu funktionieren.Darii hat geschrieben:Wäre zum Beispiel eine Idee zu gucken, wie das in top gelöst ist...
My god, it's full of CARs! | Leonidasvoice vs (former) Modvoice
Proc ist ja auch OS-Spezifisch und auch nicht Teil es POSIX-Standards(sonst würde OSX es unterstützen). Aber das top platformspezifisch ist sollte eigentlich kein Problem darstellen, dann muss man halt nur an verschiedenen Stellen suchen...
-
- User
- Beiträge: 2
- Registriert: Samstag 28. März 2009, 13:37
- Kontaktdaten:
Hello all After seeing so many visit from the blog coming from here I thought I'd better have a look and maybe learn something. Though, German seems harder to understand than Dutch
The script I wrote works well under my Linux machine and under Windows XP. For others, I honestly don't know because I never had the chance nor the need to try it.
I've been also pointed out to the fact that using the contents of /proc/meminfo might be better. But, since this works for what I need, I'll keep using it
Also, for checking for Vista, since it returns 'nt' as well, it would probably work better if you just go with the platform module (and its release method).
Finally, maybe the API I'm using only works for XP and that's why in Vista it works below expectations!
Cheers all!
The script I wrote works well under my Linux machine and under Windows XP. For others, I honestly don't know because I never had the chance nor the need to try it.
I've been also pointed out to the fact that using the contents of /proc/meminfo might be better. But, since this works for what I need, I'll keep using it
Also, for checking for Vista, since it returns 'nt' as well, it would probably work better if you just go with the platform module (and its release method).
Finally, maybe the API I'm using only works for XP and that's why in Vista it works below expectations!
Cheers all!
Hi,
Thanks for all these replies. And thanks João for you comment.
lunar, as the linked snipped shows the usage of 'free' I sticked with it, although I'm using subprocess.
That would be:
João, you might want to go with subprocess as well and inherit new style classes from 'object', too. As for permissions: May I use your snippet within my code? Of course, I would show the source like that: merit where merit is due!.
As soon as I get a solution for Vista, I'll include that, but so far Windows users aren't in my strongest focus anyway.
Cheers,
Christian
edit:
PS Ik ben het er niet mee eens, dat het lezen van een tekst in het Duits tekst veel moeilijker is, dan van een in het Nederlands - het hangt er gewoon van jouw talenkennis af, hoor .
Thanks for all these replies. And thanks João for you comment.
lunar, as the linked snipped shows the usage of 'free' I sticked with it, although I'm using subprocess.
That would be:
Code: Alles auswählen
totalmemory = subprocess.Popen(["free -m"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True).communicate()[0].split()[7]
As soon as I get a solution for Vista, I'll include that, but so far Windows users aren't in my strongest focus anyway.
Cheers,
Christian
edit:
PS Ik ben het er niet mee eens, dat het lezen van een tekst in het Duits tekst veel moeilijker is, dan van een in het Nederlands - het hangt er gewoon van jouw talenkennis af, hoor .
-
- Python-Forum Veteran
- Beiträge: 16025
- Registriert: Freitag 20. Juni 2003, 16:30
- Kontaktdaten:
The shell-call is unneccessary.
Code: Alles auswählen
totalmemory = subprocess.Popen(["free', '-m"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()[0].split()[7]
My god, it's full of CARs! | Leonidasvoice vs (former) Modvoice
Thanks, but this gives me a traceback:
Code: Alles auswählen
File "test.py", line 4, in <module>
stderr=subprocess.PIPE).communicate()[0].split()[7]
File "/usr/lib/python2.5/subprocess.py", line 594, in __init__
errread, errwrite)
File "/usr/lib/python2.5/subprocess.py", line 1153, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Arrgh, ok, Du meintest:
Zu beachten sind die Anführungsstriche.
Code: Alles auswählen
totalmemory = subprocess.Popen(['free', '-m'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()[0].split()[7]
The perils of copy & paste ...Leonidas hat geschrieben:... (therefore also the rather strange indentation).
Anyway, thanks - I will do a final cleanup, if I get João's permission - or rework the snippet anyway.
Christian