+def modulesWithPaths():
+ mods = []
+ for modline in open("/proc/modules", "r"):
+ modName, _ = modline.split(" ", 1)
+ modInfo = os.popen("modinfo -F filename '%s'" % (modName,)).readlines()
+ modPaths = [ line.strip() for line in modInfo if line!="" ]
+ mods.extend(modPaths)
+ return mods
+
def driveUsesModule(device, modules):
"""Returns true if a drive is using a prticular module. Only works
for SCSI devices right now."""
--
1.6.4.4
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
12-17-2009, 03:35 PM
Peter Jones
Add a function to get paths to loaded modules
On 12/17/2009 10:47 AM, Martin Sivak wrote:
> + modName, _ = modline.split(" ", 1)
"tmp" might be a better name for a temporary variable than "_".
--
Peter
I'd like to start a religion. That's where the money is.
-- L. Ron Hubbard to Lloyd Eshbach, in 1949;
quoted by Eshbach in _Over My Shoulder_.
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
12-17-2009, 03:45 PM
Chris Lumens
Add a function to get paths to loaded modules
> > + modName, _ = modline.split(" ", 1)
>
> "tmp" might be a better name for a temporary variable than "_".
Coming from an SML background, using _ as a temporary name doesn't
bother me at all. If you wanted to do things in a more pythonic style,
you'd probably do:
modName = modline.split(" ", 1)[0]
My only other comment would be that it'd be nice to use execWithCapture
here, but because we want the first column of output, it's going to
involve just as much processing. So, not worth it.
- Chris
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
+def modulesWithPaths():
+ mods = []
+ for modline in open("/proc/modules", "r"):
+ modName = modline.split(" ", 1)[0]
+ modInfo = os.popen("modinfo -F filename '%s'" % (modName,)).readlines()
+ modPaths = [ line.strip() for line in modInfo if line!="" ]
+ mods.extend(modPaths)
+ return mods
+
def driveUsesModule(device, modules):
"""Returns true if a drive is using a prticular module. Only works
for SCSI devices right now."""
--
1.6.4.4
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
01-05-2010, 08:59 AM
Ales Kozumplik
Add a function to get paths to loaded modules
+ modName = modline.split(" ", 1)[0]
+ modInfo = os.popen("modinfo -F filename '%s'" % (modName,)).readlines()
+ modPaths = [ line.strip() for line in modInfo if line!="" ]
I accidentally found out that os.popen is obsolete. So I would be
against using it in a new code.
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
01-05-2010, 02:10 PM
Chris Lumens
Add a function to get paths to loaded modules
> >+ modName = modline.split(" ", 1)[0]
> >+ modInfo = os.popen("modinfo -F filename '%s'" % (modName,)).readlines()
> >+ modPaths = [ line.strip() for line in modInfo if line!="" ]
>
> I accidentally found out that os.popen is obsolete. So I would be
> against using it in a new code.
They likely want you to use subprocess, which execWithCapture in
iutil.py uses.
- Chris
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
01-08-2010, 12:06 PM
Martin Sivak
Add a function to get paths to loaded modules
But making isys dependend on iutil, does it seem wise? It should be the other way around, shouldn't it?
Martin
----- "Chris Lumens" <clumens@redhat.com> wrote:
> > >+ modName = modline.split(" ", 1)[0]
> > >+ modInfo = os.popen("modinfo -F filename '%s'" %
> (modName,)).readlines()
> > >+ modPaths = [ line.strip() for line in modInfo if line!=""
> ]
> >
> > I accidentally found out that os.popen is obsolete. So I would be
> > against using it in a new code.
>
> They likely want you to use subprocess, which execWithCapture in
> iutil.py uses.
>
> - Chris
>
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@redhat.com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
01-08-2010, 01:47 PM
Chris Lumens
Add a function to get paths to loaded modules
> But making isys dependend on iutil, does it seem wise? It should be
> the other way around, shouldn't it?
Wise or not, isys already depends on iutil:
clumens@localhost:~/src/anaconda$ grep iutil isys/isys.py
import iutil
if not iutil.isX86():
if iutil.isS390():
if not iutil.isX86():
- Chris
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
+def modulesWithPaths():
+ mods = []
+ for modline in open("/proc/modules", "r"):
+ modName = modline.split(" ", 1)[0]
+ modInfo = iutil.execWithCapture("modinfo",
+ ["-F", "filename", modName]).splitlines()
+ modPaths = [ line.strip() for line in modInfo if line!="" ]
+ mods.extend(modPaths)
+ return mods
+
def driveUsesModule(device, modules):
"""Returns true if a drive is using a prticular module. Only works
for SCSI devices right now."""
--
1.6.4.4
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
01-08-2010, 02:50 PM
Chris Lumens
Add a function to get paths to loaded modules
> diff --git a/isys/isys.py b/isys/isys.py
> index 449aded..4fd0b93 100755
> --- a/isys/isys.py
> +++ b/isys/isys.py
> @@ -390,6 +390,16 @@ def ext2HasJournal(device):
> hasjournal = _isys.e2hasjournal(device);
> return hasjournal
>
> +def modulesWithPaths():
> + mods = []
> + for modline in open("/proc/modules", "r"):
> + modName = modline.split(" ", 1)[0]
> + modInfo = iutil.execWithCapture("modinfo",
> + ["-F", "filename", modName]).splitlines()
> + modPaths = [ line.strip() for line in modInfo if line!="" ]
> + mods.extend(modPaths)
> + return mods
> +
> def driveUsesModule(device, modules):
> """Returns true if a drive is using a prticular module. Only works
> for SCSI devices right now."""
Looks okay to me. Unless anyone has any other objections, I say push
it.
- Chris
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list