Is there a function that I can use to find out if a file is a block device? And another for a character device. I'm trying to create a funtion that will build a string the is exactly like the result you get from running ls -l for a slightly larger program I'm working on. Maybe it would save me some time if that function already existed, what would be helpful as well. Thanks.
lewashby
56
Junior Poster
Recommended Answers
Jump to PostI get something in my linux system with module pyudev
>>> from pyudev import Context, Device >>> context = Context() >>> d = Device.from_device_file(context, '/dev/sda') >>> d.subsystem u'block'
Jump to PostYou can also use subprocess to get the results of ls -l. Note the r(epr)
import subprocess output = subprocess.check_output([r'ls', '-l']) print output
All 6 Replies
Gribouillis
1,391
Programming Explorer
Team Colleague
woooee
814
Nearly a Posting Maven
Gribouillis
1,391
Programming Explorer
Team Colleague
lewashby
56
Junior Poster
Gribouillis
1,391
Programming Explorer
Team Colleague
woooee
814
Nearly a Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.