A fix to bluepin
Fulvio
fulvio at pc.jaring.my
Thu Apr 27 10:57:44 EDT 2006
Hello List,
I'm very beginner on programming, I''m studing some fix on the Bluez's
bluepin, which is rather vague to control the given input.
Code /start:
=========================================
def main(*args):
if len(sys.argv) < 2:
print "ERR"
sys.exit()
dir = sys.argv[1]
bdaddr = sys.argv[2]
if len(sys.argv) > 3:
name = sys.argv[3]
else:
name = ""
title = "Bluetooth PIN Code"
# Bluetooth spec recommends automatic strong random PIN generation.
# So eventually we should implement that.
pin = { "PIN": "" }
if dir == "out":
mesg = "Outgoing connection to "
else:
mesg = "Incoming connection from "
mesg = mesg + name + "[" + bdaddr + "]"
if dialog(title, mesg, pin) == DLG_OK:
pin["PIN"] = string.strip(pin["PIN"])
for i in pin:
if i not in digits:
print "ERR"
break
if len(pin["PIN"]) >= 1 and len(pin["PIN"]) <= 16:
print "PIN:" + pin["PIN"]
else:
print "ERR"
else:
print "ERR"
#
main()
=========================================
Code /end:
Assumed that digits is:
from string import digits (equal to "1234567890")
(Perhaps I could avoid such import ad assigned directly :-) )
Assumed that the purpose would be to don't print ERR but to return back to
main.....
Therefore may I recursively call main() ?
Does it re-open a new window, if I do so?
Does it re-ask new args?
Thanks for the patience to give some input here
PS. sorry the code is in tabs not in space :-(
F
More information about the Python-list
mailing list