Lancer Python depuis Bash : appel de fonction + arguments
A.b.o.91
-
dsy73 Messages postés 9252 Date d'inscription Statut Contributeur Dernière intervention -
dsy73 Messages postés 9252 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
je veux accéder à une application python depuis bash et appeler des fonctions avec leurs arguments sans toucher le code python. comment faire SVP?
j'ai essayé python -c 'import sys,os; sys.path.append(os.getcwd()); from toto import function; function(x,y)' ça marche pas. peut-être j'ai pas su l'utiliser..
je galère depuis des jours je vous en prie de m'aider c'est très urgent! merci
je veux accéder à une application python depuis bash et appeler des fonctions avec leurs arguments sans toucher le code python. comment faire SVP?
j'ai essayé python -c 'import sys,os; sys.path.append(os.getcwd()); from toto import function; function(x,y)' ça marche pas. peut-être j'ai pas su l'utiliser..
je galère depuis des jours je vous en prie de m'aider c'est très urgent! merci
A voir également:
- Fonction bash avec argument
- Fonction si et - Guide
- Bingo bash - Télécharger - Divers Jeux
- Fonction miroir - Guide
- Fonction moyenne excel - Guide
- Bash addition ✓ - Forum Shell
1 réponse
Salut
Quelques pistes :
http://bhfsteve.blogspot.com/2014/07/embedding-python-in-bash-scripts.html
https://stackoverflow.com/questions/14155669/call-python-script-from-bash-with-argument
Sinon quel est le problème initial ? Pourquoi du bash ?
Quelques pistes :
http://bhfsteve.blogspot.com/2014/07/embedding-python-in-bash-scripts.html
https://stackoverflow.com/questions/14155669/call-python-script-from-bash-with-argument
Sinon quel est le problème initial ? Pourquoi du bash ?
merci dsy73 pour les pistes .. le problème c'est que j'ai une application faite avec PyQt déjà implementée que je dois lancer automatiquement et remplir ses formulaires et clicker sur ses différents boutons "automatiquement" sans toucher le code. donc pour cela il faut entrer au code de l'application fait avec python et appeler les différents fonctions "lancer_button_record" "entrer_password".... avec des arguments. j'ai pensé à créer un code bash.
Ectcequ'il y aura une autre possibilité comment faire? c'est mon projet de Fin d'etudes
j'ai mon class Main:
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_main_window()
self.ui.setupUi(self)
self.stop_running = False
self.run_icon = QtGui.QIcon(os.path.expanduser('~') + '/libexec/stbt/icons/ic_play.png')
self.rec_icon = QtGui.QIcon(os.path.expanduser('~') + '/libexec/stbt/icons/ic_record.png')
self.stop_icon = QtGui.QIcon(os.path.expanduser('~') + '/libexec/stbt/icons/ic_stop.png')
self.edit_icon = QtGui.QIcon(os.path.expanduser('~') + '/libexec/stbt/icons/ic_edit.png')
self.tv_icon = QtGui.QIcon(os.path.expanduser('~') + '/libexec/stbt/icons/ic_tv.png')
self.setWindowTitle(QtGui.QApplication.translate("main_window", "STB-Tester Manager " + MANAGER_VERSION, None,
QtGui.QApplication.UnicodeUTF8))
self.ui.run_button.setIcon(self.run_icon)
self.ui.record_button.setIcon(self.rec_icon)......
et la fonction action_record() qui lance un boutton record :
def action_record(self):
global _run_ongoing
global _rec_ongoing
global _rec_spawn
if _run_ongoing == True:
dialog = PopUp("Error", "Run in progress.\nCan't start record at the same time.")
dialog.exec_()
return
if _playlist_ongoing == True:
dialog = PopUp("Error", "Playlist mode is activated\nCan't use this feature at the same time.")...
def action_run(self):
....
comment lancer l'application et puis lancer action_record , et puis lancer d'autres fonctions qui possedent des arguments
Tu peux faire ça avec py.test