Program runs in all directories, except one..
Theo v. Werkhoven
theo at van-werkhoven.nl.invalid
Sat Apr 28 07:50:55 EDT 2007
Goodday,
Something strange going on here.
A piece of code I wrote bombs out in one of de directories under $HOME,
but not in others.
Here's a snipped:
#v+
def bin2asc(c):
s=''
for i in range(0,8):
if c & 1<<(7-i):
s+='1'
else:
s+='0'
return 'b'+s
def shiftout(numoctets):
os.system('clear')
ser = serial.Serial(0)
from array import array
octarray = [0]
for i in range(0,numoctets-1):
octarray.append(0)
for octet in range(numoctets,0,-1):
octarray[octet-1]=1
for shift in range(0,8):
strg = array("B",octarray).tostring()
for oct in range(len(strg)):
print 'octet%-11s' % oct,
print
for byte in array("B",octarray):
print '%-2s' % bin2asc(int(byte)),
print '%-6s' % hex(int(byte)),
print; print
try:
dummy = raw_input("Druk op een toets om de bytes te verzenden ")
except KeyboardInterrupt, msg:
print; usage("Exiting..")
sys.exit()
ser.write(strg)
octarray[octet-1] = octarray[octet-1] << 1
os.system('clear')
octarray[octet-1]=0
print "done..
#v-
Here's the output from the directory it bombs out in:
#v+
theo:/home/theo/Devel/Python $ python serialLEDtest-cli.py
Hoeveel chips van het type HC595 zitten er op het LED board? 2
0
7865
8162
8220
17307
251430
5886084
5886182
5891527
5892283
5901048
5901062
Traceback (most recent call last):
File "serialLEDtest-cli.py", line 96, in <module>
main()
File "serialLEDtest-cli.py", line 93, in main
shiftout(numoctets)
File "serialLEDtest-cli.py", line 62, in shiftout
strg = array("B",octarray).tostring()
TypeError: 'list' object is not callable
#v-
Where the numbers come from I don't know, python internal?
#v+
theo:/home/theo/Devel/Python$ stat serialLEDtest-cli.py
File: `serialLEDtest-cli.py'
Size: 2641 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 69113 Links: 4
Access: (0644/-rw-r--r--) Uid: ( 1000/ theo) Gid: ( 100/ users)
Access: 2007-04-28 13:28:23.000000000 +0200
Modify: 2007-04-28 13:00:33.000000000 +0200
Change: 2007-04-28 13:22:38.000000000 +0200
#v-
Now i've made hard links to other directories, like $HOME and $HOME/bin
#v+
theo:/home/theo $ stat serialLEDtest-cli.py
File: `serialLEDtest-cli.py'
Size: 2641 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 69113 Links: 4
Access: (0644/-rw-r--r--) Uid: ( 1000/ theo) Gid: ( 100/ users)
Access: 2007-04-28 13:30:02.000000000 +0200
Modify: 2007-04-28 13:00:33.000000000 +0200
Change: 2007-04-28 13:22:38.000000000 +0200
#v-
And when I run (the same script) from that location:
#v+
theo:/home/theo $ python serialLEDtest-cli.py
Hoeveel chips van het type HC595 zitten er op het LED board? 2
octet0 octet1
b00000000 0x0 b00000001 0x1
Druk op een toets om de bytes te verzenden
#v-
Not a problem there, and neither in other directories I made links in,
or copied the file to, only in that one directory..
Anyone have ideas?
Tnx.
Theo
--
theo at van-werkhoven.nl ICQ:277217131 SuSE Linux
linuxcounter.org: 99872 Jabber:muadib at jabber.xs4all.nl AMD XP3000+ 1024MB
"ik _heb_ niets tegen Microsoft, ik heb iets tegen
de uitwassen *van* Microsoft"
More information about the Python-list
mailing list