switch

2009-12-08 Thread hong zhang
List,

Python does not have switch statement. Any other option does similar work?
Thanks for help.

--henry


  
-- 
http://mail.python.org/mailman/listinfo/python-list


IndentationError

2009-12-10 Thread hong zhang
List,

I got error says IndentationError in end of line.
I could not figure out why. See following:

$ ./cont-mcs 
  File "./cont-mcs", line 264
mcs1 = ht_val+cck_val+green_val+fat_val+sgi_val
  ^
IndentationError: unindent does not match any outer indentation level


Thanks for help.

--henry


  
-- 
http://mail.python.org/mailman/listinfo/python-list


menu and file

2009-12-25 Thread hong zhang
List,

I want to read a file that has a list of data into a menu. User can pick up a 
line of data and execute it. For example, file has data like following

1   23   0x4530
2   42   0x8790
3   75   0x7684
.

User can select line # and then execute hex data in that line.
Any sample codes will be appreciated.

Thanks!

--henry


  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: menu and file

2009-12-26 Thread hong zhang
> > List,
> > 
> > I want to read a file that has a list of data into a
> menu. User can pick
> > up a line of data and execute it. For example, file
> has data like
> > following
> > 
> > 1   23   0x4530
> > 2   42   0x8790
> > 3   75   0x7684
> > .
> > 
> > User can select line # and then execute hex data in
> that line. Any
> > sample codes will be appreciated.
> 
> 
> This may help. Be sure to read it all.
> 
> http://www.catb.org/~esr/faqs/smart-questions.html
> 

I have read the link and get text menu. The question is I want to load a text 
file and bring it to screen like
1   23   0x4530
2   42   0x8790
3   75   0x7684

Then if I want to select 0x4530, then I simple select 1 and a handler should 
get 0x4530 as input to process.

Thanks.

henry


  
-- 
http://mail.python.org/mailman/listinfo/python-list


python with echo

2009-11-11 Thread hong zhang
List,

I have a question of python using echo.

POWER = 14
return_value = os.system('echo 14 > /sys/class/net/wlan1/device/tx_power')

can assign 14 to tx_power

But 
return_value = os.system('echo $POWER > /sys/class/net/wlan1/device/tx_power')

return_value is 256 not 0. It cannot assign 14 to tx_power.

What problem is it?

os.system("echo $POWER") returns 0 but
os.system("echo $POWER > /sys/class/net/wlan1/device/tx_power") returns 256.

Appreciate any help!

Thanks.

---henry


  
-- 
http://mail.python.org/mailman/listinfo/python-list


directory wildcard

2009-11-16 Thread hong zhang
List,

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?

Thanks.

--henry




  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: directory wildcard

2009-11-16 Thread hong zhang


--- On Mon, 11/16/09, Jeff McNeil  wrote:

> From: Jeff McNeil 
> Subject: Re: directory wildcard
> To: python-list@python.org
> Date: Monday, November 16, 2009, 3:01 PM
> On Nov 16, 3:33 pm, hong zhang
> 
> wrote:
> > List,
> >
> > 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?
> >
> > Thanks.
> >
> > --henry
> 
> I'd ditch the echo business altogether. 2.x. Not tested.
> 
> import glob
> 
> mcs = get_mcs_from_somewhere()
> for i in
> glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/
> force_mcs'):
>     with open(i, 'w') as f:
>         print >>f, mcs

This assigns decimal value, how can I assign Hex here to mcs?
> 


  
-- 
http://mail.python.org/mailman/listinfo/python-list


IOError: [Errno 28] No space left on device

2009-11-17 Thread hong zhang
List,

My python script has a strange error.

cont_tx = 1
for i in 
glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
with open(i, 'w') as f:
print >>f, cont_tx

work perfectly.

But following get error like:
print >>f, cont_tx
IOError: [Errno 28] No space left on device

def do_cont_tx( is_start):
global cont_tx_started, stdscr
if is_start == START and not cont_tx_started:
cont_tx = 1
for i in 
glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
with open(i, 'w') as f:
print >>f, cont_tx

Too many layers?
Thanks for help.

---henry


  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IOError: [Errno 28] No space left on device

2009-11-17 Thread hong zhang


--- On Tue, 11/17/09, Lie Ryan  wrote:

> From: Lie Ryan 
> Subject: Re: IOError: [Errno 28] No space left on device
> To: python-list@python.org
> Date: Tuesday, November 17, 2009, 6:59 PM
> hong zhang wrote:
> > List,
> > 
> > My python script has a strange error.
> > 
> > cont_tx = 1
> > for i in
> glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
> >     with open(i, 'w') as f:
> >         print >>f,
> cont_tx
> > 
> > work perfectly.
> > 
> > But following get error like:
> > print >>f, cont_tx
> > IOError: [Errno 28] No space left on device
> > 
> > def do_cont_tx( is_start):
> >     global cont_tx_started, stdscr
> >     if is_start == START and not
> cont_tx_started:
> >         cont_tx = 1
> >         for i in
> glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
> >        
>     with open(i, 'w') as f:
> >        
>         print >>f,
> cont_tx
> > 
> > Too many layers?
> > Thanks for help.
> 
> Apparently the harddisk where you stored the file is full?
I have plenty space see:
$ df -l
Filesystem   1K-blocks  Used Available Use% Mounted on
/dev/sda1 74027808   4910016  65357380   7% /

but following is good.

cont_tx = 1
for i in 
glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
 with open(i, 'w') as f:
 print >>f, cont_tx


> -- http://mail.python.org/mailman/listinfo/python-list
> 


  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IOError: [Errno 28] No space left on device

2009-11-17 Thread hong zhang


--- On Tue, 11/17/09, Tim Chase  wrote:

> From: Tim Chase 
> Subject: Re: IOError: [Errno 28] No space left on device
> To: "Lie Ryan" 
> Cc: python-list@python.org
> Date: Tuesday, November 17, 2009, 7:47 PM
> >> for i in
> glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
> >>     with open(i, 'w') as f:
> >>         print
> >>f, cont_tx
> >> 
> >> work perfectly.
> >> 
> >> But following get error like:
> >> print >>f, cont_tx
> >> IOError: [Errno 28] No space left on device
> > 
> > Apparently the harddisk where you stored the file is
> full?
> 
> Likely a misinterpretation of the error.  I'm guessing
> either one needs to be root to write to this [likely
> virtual] file, or a member of an associated group.  It
> would help to have the output of
> 
> bash$ whoami
> bash$ id
> 
> and
> 
> bash$ ls -lsF
> /sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx

It is root. see following. 

  File "./henry-cont-tx", line 186, in do_cont_tx
print >>f, cont_tx
IOError: [Errno 28] No space left on device
r...@tester-laptop:/home/tester/Desktop/sv-project/scripts/scripts# whoami
root
r...@tester-laptop:/home/tester/Desktop/sv-project/scripts/scripts# id
uid=0(root) gid=0(root) groups=0(root)
r...@tester-laptop:/home/tester/Desktop/sv-project/scripts/scripts# ls -lsF 
/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx
0 -rw--- 1 root root 0 2009-11-17 17:51 
/sys/kernel/debug/ieee80211/phy2/iwlagn/data/continuous_tx


> 
> I'd be particularly interested in the group association and
> the permission bits.
> 
> -tkc
> 
> 
> 
> 
> 
> 
> -- http://mail.python.org/mailman/listinfo/python-list
> 


  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread hong zhang


--- On Wed, 11/18/09, Grant Edwards  wrote:

> From: Grant Edwards 
> Subject: Re: IOError: [Errno 28] No space left on device
> To: python-list@python.org
> Date: Wednesday, November 18, 2009, 9:22 AM
> On 2009-11-18, hong zhang 
> wrote:
> 
> >> Apparently the harddisk where you stored the file
> is full?
> 
> It's not a real file, and takes up no space.
> 
> > I have plenty space see:
> > $ df -l
> > Filesystem       
>    1K-blocks      Used
> Available Use% Mounted on
> > /dev/sda1         
>    74027808   4910016 
> 65357380   7% /
> 
> That doesn't matter.  /sys doesn't contain real
> files.  It's an
> API to access kernel internals.
> 
> > but following is good.
> >
> > cont_tx = 1
> > for i in
> glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
> >      with open(i, 'w') as f:
> >          print >>f,
> cont_tx
> 
> Well, if that works, then what's your problem?

But error comes from following, above is good. That is point here.

def do_cont_tx( is_start):
global cont_tx_started, stdscr
if is_start == START and not cont_tx_started:
cont_tx = 1
for i in 
glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
with open(i, 'w') as f:
print >>f, cont_tx -- 

>                
>            
>    visi.com         
>   PREVIOUS LIFE as a COMPLETE
>                
>                
>                
>    STRANGER?
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 


  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread hong zhang


--- On Wed, 11/18/09, Grant Edwards  wrote:

> From: Grant Edwards 
> Subject: Re: IOError: [Errno 28] No space left on device
> To: python-list@python.org
> Date: Wednesday, November 18, 2009, 9:22 AM
> On 2009-11-18, hong zhang 
> wrote:
> 
> >> Apparently the harddisk where you stored the file
> is full?
> 
> It's not a real file, and takes up no space.
> 
> > I have plenty space see:
> > $ df -l
> > Filesystem       
>    1K-blocks      Used
> Available Use% Mounted on
> > /dev/sda1         
>    74027808   4910016 
> 65357380   7% /
> 
> That doesn't matter.  /sys doesn't contain real
> files.  It's an
> API to access kernel internals.
> 
> > but following is good.
> >
> > cont_tx = 1
> > for i in
> glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
> >      with open(i, 'w') as f:
> >          print >>f,
> cont_tx
> 
> Well, if that works, then what's your problem?

But error comes from following, above is good. That is point here.

def do_cont_tx( is_start):
global cont_tx_started, stdscr
if is_start == START and not cont_tx_started:
cont_tx = 1
for i in 
glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
with open(i, 'w') as f:
print >>f, cont_tx 


  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread hong zhang


--- On Wed, 11/18/09, Diez B. Roggisch  wrote:

> From: Diez B. Roggisch 
> Subject: Re: IOError: [Errno 28] No space left on device
> To: python-list@python.org
> Date: Wednesday, November 18, 2009, 12:11 PM
> hong zhang wrote:
> 
> > 
> > 
> > --- On Wed, 11/18/09, Grant Edwards 
> wrote:
> > 
> >> From: Grant Edwards 
> >> Subject: Re: IOError: [Errno 28] No space left on
> device
> >> To: python-list@python.org
> >> Date: Wednesday, November 18, 2009, 9:22 AM
> >> On 2009-11-18, hong zhang 
> >> wrote:
> >> 
> >> >> Apparently the harddisk where you stored
> the file
> >> is full?
> >> 
> >> It's not a real file, and takes up no space.
> >> 
> >> > I have plenty space see:
> >> > $ df -l
> >> > Filesystem
> >> 1K-blocks      Used
> >> Available Use% Mounted on
> >> > /dev/sda1
> >> 74027808   4910016
> >> 65357380   7% /
> >> 
> >> That doesn't matter.  /sys doesn't contain real
> >> files.  It's an
> >> API to access kernel internals.
> >> 
> >> > but following is good.
> >> >
> >> > cont_tx = 1
> >> > for i in
> >>
> glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
> >> >with open(i, 'w') as f:
> >> >print >>f,
> >> cont_tx
> >> 
> >> Well, if that works, then what's your problem?
> > 
> > But error comes from following, above is good. That is
> point here.
> > 
> > def do_cont_tx( is_start):
> > global cont_tx_started, stdscr
> > if is_start == START and not cont_tx_started:
> > cont_tx = 1
> > for i in
> >
> glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
> > with open(i, 'w') as f: print >>f, cont_tx --
> 
> "cont_x --" doesn't work. So the above can't be the actual
> code.

Sorry, -- is typo.


  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IOError: [Errno 28] No space left on device

2009-11-18 Thread hong zhang


--- On Wed, 11/18/09, Grant Edwards  wrote:

> From: Grant Edwards 
> Subject: Re: IOError: [Errno 28] No space left on device
> To: python-list@python.org
> Date: Wednesday, November 18, 2009, 2:00 PM
> On 2009-11-18, Diez B. Roggisch
> 
> wrote:
> > hong zhang wrote:
> >>> 
> >>> > but following is good.
> >>> >
> >>> > cont_tx = 1
> >>> > for i in
> >>>
> glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
> >>> >with open(i, 'w') as f:
> >>> >print >>f,
> >>> cont_tx
> >>> 
> >>> Well, if that works, then what's your
> problem?
> >> 
> >> But error comes from following, above is good.
> That is point here.
> >> 
> >> def do_cont_tx( is_start):
> >> global cont_tx_started, stdscr
> >> if is_start == START and not cont_tx_started:
> >> cont_tx = 1
> >> for i in
> >>
> glob.glob('/sys/kernel/debug/ieee80211/phy*/iwlagn/data/continuous_tx'):
> >> with open(i, 'w') as f: print >>f, cont_tx
> --
> >
> > "cont_x --" doesn't work. So the above can't be the
> actual code.
> 
> You never want to post the actual code you're
> running.  That
> would make it too easy for people to help.
> 
> -- 

It is typo.

> http://mail.python.org/mailman/listinfo/python-list
> 


  
-- 
http://mail.python.org/mailman/listinfo/python-list


hex

2009-11-18 Thread hong zhang
List,

I want to input hex number instead of int number. in type="int" in following,

parser.add_option("-F", "--forcemcs", dest="force_mcs", type="int", default=0, 
help="index of 11n mcs table. Default: 0.")

How can I do it?
Thanks.

--henry


  
-- 
http://mail.python.org/mailman/listinfo/python-list