Re: Storage device enumeration script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks TorbjÃrn !

I tend to short the error-checking when I'm putting something together...  Clearly, this script was less baked than I thought.

On 05/26/2011 05:45 AM, TorbjÃrn Skagestad wrote:
> @@ -166,9 +171,12 @@
>  	devpath = os.path.realpath(devpathlink)
>  	if devpath in phydevs:
>  		return phydevs[devpath]
> -	phy = Struct(dpath=devpath, node=nodestr,
> -		vendor=io.FileIO(devpath+'/vendor').read().split("\n",1)[0].strip(),
> -		model=io.FileIO(devpath+'/model').read().split("\n",1)[0].strip())
> +	try:
> +		phy = Struct(dpath=devpath, node=nodestr,
> +			vendor=io.FileIO(devpath+'/vendor').read().split("\n",1)[0].strip(),
> +			model=io.FileIO(devpath+'/model').read().split("\n",1)[0].strip())
> +	except IOError:
> +		return None
>  	if os.path.exists(devpath+'/unique_id'):
>  		phy.serial = io.FileIO(devpath+'/unique_id').read().split("\n",1)[0].strip()
>  	if not phy.serial:

This hunk will have to be done differently.  "phy" needs to be set without vendor & model if they can't be read.  I'll make a helper function to read the first line of a file, or return None.

On 05/26/2011 04:11 AM, CoolCold wrote:
> May be setup some github repo for this?
> 

Yes, I'll do this later today.  Obviously needed. :(

Phil
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux