Corrections de bugs
darcs-hash:20041210181420-d1718-986a3ee42c88c314257ce89569bd5a61f3b79173.gz
This commit is contained in:
parent
dcd11d56f7
commit
d47441f88f
1 changed files with 14 additions and 10 deletions
|
@ -82,20 +82,22 @@ class UpdateProtocol(basic.LineReceiver):
|
|||
self.do_BOOT()
|
||||
elif ligne == 'UPDATE':
|
||||
self.do_UPDATE()
|
||||
elif ligne == 'RESET':
|
||||
self.do_ACKNOWLEDGE()
|
||||
elif ligne == 'RESET' or ligne == 'ACK':
|
||||
self.do_RESET()
|
||||
else:
|
||||
self.sendError("`%s' is an unknown command for this server." % ligne)
|
||||
|
||||
def sendError(self, error):
|
||||
"""Renvoie une erreur sous forme de script."""
|
||||
for ligne in error.getTraceback().split("\n"):
|
||||
if error.__class__.__name__ != 'str':
|
||||
error = error.getTraceback()
|
||||
for ligne in error.split("\n"):
|
||||
self.sendLine("# %s" % ligne)
|
||||
self.sendLine(".")
|
||||
# Le plus simple est de couper la connexion
|
||||
self.transport.loseConnection()
|
||||
# On loggue aussi niveau serveur
|
||||
print error.getTraceback()
|
||||
print error
|
||||
|
||||
def do_BOOT(self):
|
||||
"""Répond à une commande de type BOOT"""
|
||||
|
@ -140,7 +142,7 @@ class UpdateFactory(protocol.ServerFactory):
|
|||
# ETAPE 1
|
||||
# On commence par résoudre "host".
|
||||
d = client.lookupPointer("%s.in-addr.arpa" % '.'.join(host.split('.')[::-1]))
|
||||
d.addCallback(lambda (ans, auth, add) : reset_del(self, ans[0].payload.name),
|
||||
d.addCallback(lambda (ans, auth, add), _ : reset_del(self, ans[0].payload.name),
|
||||
lambda _: reset_del(self, "unknown"))
|
||||
return d
|
||||
|
||||
|
@ -157,12 +159,12 @@ class UpdateFactory(protocol.ServerFactory):
|
|||
os.mkdir('retry')
|
||||
for f in os.listdir('retry'):
|
||||
try:
|
||||
os.remove('retry/%s', f)
|
||||
os.remove('retry/%s' % f)
|
||||
except OSError:
|
||||
pass
|
||||
return "" # Aucun script à retourner
|
||||
|
||||
return self.reset_host(host)
|
||||
return reset_host(self,host)
|
||||
|
||||
def getBootScripts(self, host):
|
||||
"""Retourne les scripts de boot.
|
||||
|
@ -232,19 +234,20 @@ class UpdateFactory(protocol.ServerFactory):
|
|||
# Il ne devrait n'y en avoir qu'un, mais...
|
||||
for f in os.listdir('retry'):
|
||||
result = result + file('retry/%s' % f).read()
|
||||
remove_lock('gen_confs.wifi.conf_wifi')
|
||||
return result
|
||||
else:
|
||||
# Il n'y a rien dans le répertoire retry
|
||||
result = ""
|
||||
delre = filter(lambda f: re.match(getre, f), os.listdir("."))
|
||||
getre = filter(lambda f: re.match(delre, f), os.listdir("."))
|
||||
getre = filter(lambda f: re.match(getre, f), os.listdir("."))
|
||||
delre = filter(lambda f: re.match(delre, f), os.listdir("."))
|
||||
# On s'occupe de mettre ce qu'il faut dans retry
|
||||
both = filter(lambda f: f in delre, getre)
|
||||
both.sort()
|
||||
for f in both:
|
||||
result = result + file(f).read()
|
||||
# On écrit result dans un fichier temporaire dans retry
|
||||
retry = tempfile.mkstemp('','','retry')[0]
|
||||
retry = os.fdopen(tempfile.mkstemp('','','retry')[0],'w')
|
||||
retry.write(result)
|
||||
del result
|
||||
# On s'occupe de construire le résultat
|
||||
|
@ -256,6 +259,7 @@ class UpdateFactory(protocol.ServerFactory):
|
|||
for f in delre:
|
||||
os.remove(f)
|
||||
|
||||
remove_lock('gen_confs.wifi.conf_wifi')
|
||||
return result
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue