paramiko.SSHException: Channel closed
Bonjour,
Possesseur d'un raspberry pi, je cherche à contrôler omxplayer par ssh. Après certaines recherches, j'ai décidé d'utiliser paramiko pour la connexion ssh et des pipes sur le raspberry pour envoyer les informations à omxplayer.
Le code suivant fonctionne : il lance omxplayer sur le raspberry via le script play.sh.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| #!/usr/bin/env python
#-*- coding:utf-8 -*-
import paramiko
hostname="192.168.1.22"
username="pi"
ssh = paramiko.SSHClient() # Creation du client
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # Ajouter les clés automatiquement
ssh.connect(hostname, username=username) # Connection à hostname
selection=self.chemin+self.separateur+nomFichier
aExecuter="sudo play.sh \"ssh/Jean"+selection[18:]+"\" < /home/pi/omxfifo &"
print aExecuter
stdin, stdout, stderr = ssh.exec_command(aExecuter)
print "echo -n . > /home/pi/omxfifo"
stdin, stdout, stderr = ssh.exec_command("echo -n . > /home/pi/omxfifo") |
Cependant, j'essaye maintenant d'intégrer ce bout de code dans une application graphique (pygtk) gérant toute ma bibliothèque (que j'ai fait). J'ai donc relié un bouton à une fonction contenant le code ci-dessus. Cependant maintenant je reçois systématiquement cette erreur :
Code:
1 2 3 4 5 6 7 8 9 10
| Traceback (most recent call last):
File "InterfaceGraphique.py", line 489, in lancerVideo
stdin, stdout, stderr = ssh.exec_command(aExecuter)
File "/usr/lib/python2.7/dist-packages/paramiko/client.py", line 364, in exec_command
chan.exec_command(command)
File "/usr/lib/python2.7/dist-packages/paramiko/channel.py", line 213, in exec_command
self._wait_for_event()
File "/usr/lib/python2.7/dist-packages/paramiko/channel.py", line 1084, in _wait_for_event
raise e
paramiko.SSHException: Channel closed. |
Qu'est ce qui change entre l’exécution du code tout seul, et l’exécution dans la fonction appelée qui pourrait empêcher le fonctionnement normal ?
Merci.