Trying to make an install script for Deskpi Pro case

  • I'm having a hard time with this code:

    I'm pretty sure it's a formatting issue, but I can't seem to figure this part out:

    Code
    try:
     while True:
     if ser.isOpen():
     cpu_temp=subprocess.getoutput("/opt/vc/bin/vcgencmd measure_temp" | "sed -e "s/temp=//" -e "s/\..*'/ /")
     cpu_temp=int(cpu_temp.split(.)[0])

    I keep getting errors, regardless of my changes. I get "unsupported operand type(s) for "|:" 'str' and 'str' " "syntax errors"

    Honestly I can barely read this. Can someone please point me in the right direction?
    Anything will help.

    Thanks in advance!

  • Code
    cpu_temp=subprocess.getoutput("/opt/vc/bin/vcgencmd.measure_temp") | "grep" "sed -e s/temp=// -e s/\..*'/ /"
    cpu_temp=float(int(cpu_temp.split('.')[0]) 


    Looks like the error I was getting was because I was trying to take a LITERAL(real number) into an Integer.

    You can't do that, so you have to turn it into a FLOAT.

    Adding "float(" in-front of the other code I had(int(cpu_tempt.split....) "fixed" it.

    But now I'm getting an error here:

    Code
    if cpu_temp < 40:
    
                    ^
    SyntaxError: invalid syntax