On 30 Jul 2012, at 23:56, Dan Stromberg wrote:
>
> On Mon, Jul 30, 2012 at 9:26 PM, Barry Scott wrote:
> lspci gets all its information from the files in /sys/bus/pci/devices.
>
> You can use os.listdir() to list all the files in the folder and then open
> the files you want to get the data
Mark Lawrence於 2012年7月31日星期二UTC+8下午3時15分32秒寫道:
> On 31/07/2012 02:20, Dennis Lee Bieber wrote:
>
> > On Mon, 30 Jul 2012 22:56:48 +, Dan Stromberg
>
> > declaimed the following in gmane.comp.python.general:
>
> >
>
> >
>
> >> Sigh, and I'm also not keen on multi-line list comprehensions,
On Tue, 31 Jul 2012 08:15:32 +0100, Mark Lawrence wrote:
> On 31/07/2012 02:20, Dennis Lee Bieber wrote:
>> On Mon, 30 Jul 2012 22:56:48 +, Dan Stromberg
>> declaimed the following in gmane.comp.python.general:
>>
>>
>>> Sigh, and I'm also not keen on multi-line list comprehensions,
>>> speci
On Tue, Jul 31, 2012 at 5:15 PM, Mark Lawrence wrote:
> On 31/07/2012 02:20, Dennis Lee Bieber wrote:
>>
>> should be pecked to death by a dead parrot.
>>
>
> Any particular species?
I'm sure that, if you're in Norway, you could find an appropriate
bird. But for those of us for whom that's not an
On 31/07/2012 02:20, Dennis Lee Bieber wrote:
On Mon, 30 Jul 2012 22:56:48 +, Dan Stromberg
declaimed the following in gmane.comp.python.general:
Sigh, and I'm also not keen on multi-line list comprehensions, specifically
because I think they tend to make less readable code. It also beco
On Mon, Jul 30, 2012 at 11:14 PM, Emile van Sebille wrote:
> On 7/30/2012 3:56 PM Dan Stromberg said...
>
>
>> On Mon, Jul 30, 2012 at 9:26 PM, Barry Scott >
>
> And of course you can write list comprehensions on as many lines as
>> it take to make the code maintainable.
>>
>> Sigh, and
On 7/30/2012 3:56 PM Dan Stromberg said...
On Mon, Jul 30, 2012 at 9:26 PM, Barry Scott
And of course you can write list comprehensions on as many lines as
it take to make the code maintainable.
Sigh, and I'm also not keen on multi-line list comprehensions,
specifically because I thi
On Mon, Jul 30, 2012 at 9:26 PM, Barry Scott wrote:
> lspci gets all its information from the files in /sys/bus/pci/devices.
>
> You can use os.listdir() to list all the files in the folder and then open
> the files you want to get the data you need.
>
Gee, wouldn't it be more portable to parse
lspci gets all its information from the files in /sys/bus/pci/devices.
You can use os.listdir() to list all the files in the folder and then open
the files you want to get the data you need.
And of course you can write list comprehensions on as many lines as
it take to make the code maintainable.
You can do this with one subprocess.Popen and some python commands.
The alternative is to pipe some subprocess.Popen commands together.
Or for the quick way out (but I think you better stick with bash scripting
then): http://pypi.python.org/pypi/sarge/
Don't know about it's stability/ubs/etc, n
On 07/30/2012 01:31 PM, Jürgen A. Erhard wrote:
> On Mon, Jul 30, 2012 at 12:35:38PM +0200, Philipp Hagemeister wrote:
>> import subprocess
>> [ l.partition(' ')[0] # or l[:7], if you want to copy it verbatim
>> for l in subprocess.check_output(['lspci']).splitlines()
>> if 'Q' in l and is
Vikas Kumar Choudhary wrote:
> let me know if someone has tried to implement (grep and PIPE) shell
> commands in python `lspci | grep Q | grep "$isp_str1" | grep "$isp_str2"
> | cut -c1-7'
>
> I tried to use python subprocess and OS.Popen modules.
subprocess is the way to go.
> I was trying
On Mon, Jul 30, 2012 at 12:35:38PM +0200, Philipp Hagemeister wrote:
> On 07/30/2012 09:05 AM, Vikas Kumar Choudhary wrote:
> > `lspci | grep Q | grep "$isp_str1" | grep "$isp_str2" | cut -c1-7'
>
> The rough Python equivalent would be
>
> import subprocess
> [ l.partition(' ')[0] # or l[:7
you can use commands.getstatusoutput(command), the shell command special
charactor (like "$ and so on )should be escaped!
在 2012年7月30日星期一UTC+8下午3时40分04秒,Chris Angelico写道:
> On Mon, Jul 30, 2012 at 5:05 PM, Vikas Kumar Choudhary
>
> wrote:
>
> >
>
> > I was trying porting from bash shell to
On 07/30/2012 09:05 AM, Vikas Kumar Choudhary wrote:
> `lspci | grep Q | grep "$isp_str1" | grep "$isp_str2" | cut -c1-7'
The rough Python equivalent would be
import subprocess
[ l.partition(' ')[0] # or l[:7], if you want to copy it verbatim
for l in subprocess.check_output(['lspci']).sp
On Mon, Jul 30, 2012 at 5:05 PM, Vikas Kumar Choudhary
wrote:
>
> I was trying porting from bash shell to python.
>
> let me know if someone has tried to implement (grep and PIPE) shell commands
> in python `lspci | grep Q | grep "$isp_str1" | grep "$isp_str2" | cut -c1-7'
Welcome!
While it's
16 matches
Mail list logo