Re: Storage device enumeration script
From: Phil Turmel <hidden>
Date: 2011-05-26 11:39:29
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:
quoted hunk ↗ jump to hunk
@@ -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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html