|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Jul 2007
Città: Padova - Latina - Gorizia
Messaggi: 657
|
Aiutino sintassi python "subprocess.Popen"
Ciao a tutti, scrivo xké nell'ambito di un progetto amatoriale scritto al 99% in bash sono costretto ad usare anche qualche script in python, uno di questi è incollato sotto. In pratica monitora 2 variabili e se cambiano in modo significativo lancia uno script bash usandone i relativi valori come argomento:
Codice:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#
import os
import subprocess
import time
#
pid = (os.getpid())
#
with open('/home/pi/logJARVIS/SERVICE/pythonPID.pid', 'w') as f:
f.write('%d' % pid)
#
from dronekit import connect
#
# Connect to the Vehicle (in this case a UDP endpoint)
vehicle = connect('127.0.0.1:14550', wait_ready=True)
#
aOLD = (vehicle.channels['7'])
bOLD = (vehicle.channels['8'])
#
count = 0
while count < 500000000000000000000000000000000000000000000000000000000000000000000000:
a = (vehicle.channels['7'])
b = (vehicle.channels['8'])
ris1 = a-aOLD
ris2 = b-bOLD
#
if (abs(ris1)) > 35 or (abs(ris2)) > 30:
print("<PYTHON> Ch1: %s" % a)
print("<PYTHON> Ch2: %s" % b)
subprocess.Popen(['/home/pi/logJARVIS/SERVICE/twinLT.sh', str(a), str(b)])
#
aOLD = a
bOLD = b
count += 1 # This is the same as count = count + 1
#
time.sleep(0.1)
Codice:
Traceback (most recent call last):
File "camera03mavp.py", line 46, in <module>
subprocess.Popen('/home/pi/logJARVIS/SERVICE/twinLT.sh', str(a))
File "/usr/lib/python2.7/subprocess.py", line 343, in __init__
raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integer
__________________
CPU Intel Q6600 stepping G0 @ 3.2 - MOBO Gigabyte GA-P35C.DS3R rev 2.1 - RAM Corsair C5 XMS2 4X2GB DDR2 PC6400 - VGA Ati Radeon HD 6870 - DISSIPATORE Zalman CNPS 9700 LED - 3 x HD: 1x [storage] Matrox DIAMONDMAX22 500GB SATA 3.5 720 + 2x raid0 [gaming] Barracuda 7200.10 160GB SATA-II 3.5IN - ALI Corsair HX MODULAR PSU 620W CMPSU-620HXEU |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Apr 2005
Messaggi: 3276
|
Sicuro di aver postato il codice giusto?
Perchè dice Codice:
File "camera03mavp.py", line 46, in <module> |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 10:12.



















