Seite 1 von 2
Verfasst: Montag 30. März 2009, 13:04
von Leonidas
The shell-call is unneccessary.
Code: Alles auswählen
totalmemory = subprocess.Popen(["free', '-m"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()[0].split()[7]
Verfasst: Montag 30. März 2009, 13:10
von CM
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
Verfasst: Montag 30. März 2009, 13:11
von CM
Arrgh, ok, Du meintest:
Code: Alles auswählen
totalmemory = subprocess.Popen(['free', '-m'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()[0].split()[7]
Zu beachten sind die Anführungsstriche.
Verfasst: Montag 30. März 2009, 13:20
von Leonidas
Yes, sorry, I didn't test it myself (therefore also the rather strange indentation).
Verfasst: Montag 30. März 2009, 13:30
von CM
Leonidas hat geschrieben:... (therefore also the rather strange indentation).
The perils of copy & paste ...
Anyway, thanks - I will do a final cleanup, if I get João's permission - or rework the snippet anyway.
Christian
Verfasst: Montag 30. März 2009, 14:40
von JoaoRodrigues
Sure, go ahead and use whatever you need

Just one thing, when you're done with it, give a nod on my blog so I can post your solution as well (if you want of course).
Oh, btw, I don't speak Dutch either, but it's easier to read (and listen)

Verfasst: Montag 30. März 2009, 16:23
von lunar
CM hat geschrieben:Arrgh, ok, Du meintest:
Code: Alles auswählen
totalmemory = subprocess.Popen(['free', '-m'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()[0].split()[7]
Zu beachten sind die Anführungsstriche.
Wofür leitest du den Standardfehlerstrom um, wenn du dessen Ausgabe gar nicht beachtest? Nur damit keine Ausgabe auf der Konsole erscheint? Das ist imho wenig sinnvoll, da im – zugegebenermaßen unwahrscheinlichen – Fall eines Fehlers von "free" keine Diagnose möglich ist, da die Fehlermeldung im Nirvana verschwindet.
Verfasst: Dienstag 31. März 2009, 08:12
von Mad-Marty
@All:
Für Windows ist MS Technet immer eine gute Anlaufstelle:
http://www.microsoft.com/technet/script ... x?mfr=true
(For Windows also take a look at MS Technet)
Verfasst: Dienstag 31. März 2009, 09:37
von CM
lunar hat geschrieben:Wofür leitest du den Standardfehlerstrom um, wenn du dessen Ausgabe gar nicht beachtest?
Bloß, um es hier schnell zu posten - völlig ohne den Anspruch auf Abgerundetheit. Wahrscheinlich wird es ein wenig dauern, bis ich mich wieder dem Code zuwenden kann. Aber es steht auf meiner Hakab-Liste.
@MadMarty: Danke, interessante Quelle - aber ich kann den Code selber bis auf Weiteres nicht testen (s.o.).
Gruß,
Christian