##// END OF EJS Templates
factotum: use try/except/finally
Matt Mackall -
r25078:e8348f1c default
parent child Browse files
Show More
@@ -67,21 +67,20 b' def auth_getuserpasswd(self, getkey, par'
67 while True:
67 while True:
68 fd = os.open('%s/rpc' % _mountpoint, os.O_RDWR)
68 fd = os.open('%s/rpc' % _mountpoint, os.O_RDWR)
69 try:
69 try:
70 try:
70 os.write(fd, 'start %s' % params)
71 os.write(fd, 'start %s' % params)
71 l = os.read(fd, ERRMAX).split()
72 l = os.read(fd, ERRMAX).split()
72 if l[0] == 'ok':
73 if l[0] == 'ok':
73 os.write(fd, 'read')
74 os.write(fd, 'read')
74 status, user, passwd = os.read(fd, ERRMAX).split(None, 2)
75 status, user, passwd = os.read(fd, ERRMAX).split(None, 2)
75 if status == 'ok':
76 if status == 'ok':
76 if passwd.startswith("'"):
77 if passwd.startswith("'"):
77 if passwd.endswith("'"):
78 if passwd.endswith("'"):
78 passwd = passwd[1:-1].replace("''", "'")
79 passwd = passwd[1:-1].replace("''", "'")
79 else:
80 else:
80 raise util.Abort(_('malformed password string'))
81 raise util.Abort(_('malformed password string'))
81 return (user, passwd)
82 return (user, passwd)
82 except (OSError, IOError):
83 except (OSError, IOError):
83 raise util.Abort(_('factotum not responding'))
84 raise util.Abort(_('factotum not responding'))
85 finally:
84 finally:
86 os.close(fd)
85 os.close(fd)
87 getkey(self, params)
86 getkey(self, params)
General Comments 0
You need to be logged in to leave comments. Login now