FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Development

 
 
LinkBack Thread Tools
 
Old 12-17-2009, 02:47 PM
Martin Sivak
 
Default Add a function to get paths to loaded modules

---
isys/isys.py | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/isys/isys.py b/isys/isys.py
index 338ca26..551887d 100755
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -393,6 +393,15 @@ def ext2HasJournal(device):
hasjournal = _isys.e2hasjournal(device);
return hasjournal

+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
 
Old 12-17-2009, 03:35 PM
Peter Jones
 
Default 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
 
Old 12-17-2009, 03:45 PM
Chris Lumens
 
Default 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
 
Old 12-21-2009, 02:21 PM
Martin Sivak
 
Default Add a function to get paths to loaded modules

---
isys/isys.py | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/isys/isys.py b/isys/isys.py
index 44f9d3d..1d6e88d 100755
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -390,6 +390,15 @@ 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 = 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
 
Old 01-05-2010, 08:59 AM
Ales Kozumplik
 
Default 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
 
Old 01-05-2010, 02:10 PM
Chris Lumens
 
Default 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
 
Old 01-08-2010, 12:06 PM
Martin Sivak
 
Default 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
 
Old 01-08-2010, 01:47 PM
Chris Lumens
 
Default 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
 
Old 01-08-2010, 02:29 PM
Martin Sivak
 
Default Add a function to get paths to loaded modules

---
isys/isys.py | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)

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."""
--
1.6.4.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 01-08-2010, 02:50 PM
Chris Lumens
 
Default 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
 

Thread Tools




All times are GMT. The time now is 08:42 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org