I try to assign value to force_mcs sitting in a wildcard
subdirectory /sys/kernel/debug/ieee80211/phy*, but python does
not work for that such as:
os.system("echo %i >
/sys/kernel/debug/ieee80211/phy*/iwlagn/data/force_mcs" % mcs)
Any right way to do it?
I'm not sure your code works if there's more than one phy*
directory in that folder anyways since ">" piping usually only
works for a single destination. Though I'd imagine this is only
a problem for folks that have more than one 802.11 card in their
machine (which I've done...a useless on-board and a PCMCIA on an
older laptop).
I'd use python's built-in glob module to do something like
from glob import glob
def set_force_mcs(mcs):
for fname in glob('/sys/kernel/debug/'
'ieee80211/phy*/iwlagn/data/force_mcs'):
f = open(fname, 'w')
f.write('%i\n' % mcs)
f.close()
#the following should all work
set_force_mcs(True)
set_force_mcs(False)
set_force_mcs(1)
set_force_mcs(0)
(I broke the for/glob line intentionally in a way that python
transparently restores in case mailers munged them between here
in there...normally, I'd just use a single string parameter for
glob() instead of line-breaking it if it fit in 80 chars)
If you're using a more recent version of python that has the
"with" command (I think it was added in 2.6, and available from
2.5's future), it could be tidied to
with open(fname, 'w') as f:
f.write('%i\n' % mcs)
-tkc
--
http://mail.python.org/mailman/listinfo/python-list