@@ -1629,69 +1629,60 @@ def settings_pi_mod(form):
1629
1629
action_str = "Change Hostname to '{host}'" .format (
1630
1630
host = form .hostname .data )
1631
1631
elif form .change_pigpiod_sample_rate .data :
1632
- if form .pigpiod_sample_rate .data not in ['low' , 'high' ,
1633
- 'disabled' , 'uninstalled' ]:
1632
+ if form .pigpiod_sample_rate .data not in ['low' , 'high' , 'disabled' , 'uninstalled' ]:
1634
1633
error .append (
1635
1634
"Valid pigpiod options: Uninstall, Disable, 1 ms, or 5 ms. "
1636
1635
"Invalid option: {op}" .format (
1637
1636
op = form .pigpiod_sample_rate .data ))
1638
1637
else :
1639
1638
# Stop the Mycodo daemon
1640
- cmd = "{pth}/mycodo/scripts/mycodo_wrapper daemon_stop" \
1641
- " | ts '[%Y-%m-%d %H:%M:%S]' 2>&1" .format (
1642
- pth = INSTALL_DIRECTORY )
1639
+ cmd = f"{ INSTALL_DIRECTORY } /mycodo/scripts/mycodo_wrapper daemon_stop" \
1640
+ f" | ts '[%Y-%m-%d %H:%M:%S]' 2>&1"
1643
1641
stop_daemon = subprocess .Popen (cmd , shell = True )
1644
1642
stop_daemon .wait ()
1645
1643
1646
1644
if (form .pigpiod_sample_rate .data != 'uninstalled' and
1647
1645
form .pigpiod_state .data == 'uninstalled' ):
1648
1646
# Install pigpiod (sample rate of 1 ms)
1649
- cmd = "{pth}/mycodo/scripts/mycodo_wrapper install_pigpiod" \
1650
- " | ts '[%Y-%m-%d %H:%M:%S]' 2>&1" .format (
1651
- pth = INSTALL_DIRECTORY )
1647
+ cmd = f"{ INSTALL_DIRECTORY } /mycodo/scripts/mycodo_wrapper install_pigpiod" \
1648
+ f" | ts '[%Y-%m-%d %H:%M:%S]' 2>&1"
1652
1649
install_pigpiod = subprocess .Popen (cmd , shell = True )
1653
1650
install_pigpiod .wait ()
1654
1651
1655
1652
# Disable pigpiod
1656
- cmd = "{pth}/mycodo/scripts/mycodo_wrapper disable_pigpiod" \
1657
- " | ts '[%Y-%m-%d %H:%M:%S]' 2>&1" .format (
1658
- pth = INSTALL_DIRECTORY )
1653
+ cmd = f"{ INSTALL_DIRECTORY } /mycodo/scripts/mycodo_wrapper disable_pigpiod" \
1654
+ f" | ts '[%Y-%m-%d %H:%M:%S]' 2>&1"
1659
1655
disable_pigpiod = subprocess .Popen (cmd , shell = True )
1660
1656
disable_pigpiod .wait ()
1661
1657
1662
1658
if form .pigpiod_sample_rate .data == 'low' :
1663
1659
# Install pigpiod (sample rate of 1 ms)
1664
- cmd = "{pth}/mycodo/scripts/mycodo_wrapper enable_pigpiod_low" \
1665
- " | ts '[%Y-%m-%d %H:%M:%S]' 2>&1" .format (
1666
- pth = INSTALL_DIRECTORY )
1660
+ cmd = f"{ INSTALL_DIRECTORY } /mycodo/scripts/mycodo_wrapper enable_pigpiod_low" \
1661
+ f" | ts '[%Y-%m-%d %H:%M:%S]' 2>&1"
1667
1662
enable_pigpiod_1ms = subprocess .Popen (cmd , shell = True )
1668
1663
enable_pigpiod_1ms .wait ()
1669
1664
elif form .pigpiod_sample_rate .data == 'high' :
1670
1665
# Install pigpiod (sample rate of 5 ms)
1671
- cmd = "{pth}/mycodo/scripts/mycodo_wrapper enable_pigpiod_high" \
1672
- " | ts '[%Y-%m-%d %H:%M:%S]' 2>&1" .format (
1673
- pth = INSTALL_DIRECTORY )
1666
+ cmd = f"{ INSTALL_DIRECTORY } /mycodo/scripts/mycodo_wrapper enable_pigpiod_high" \
1667
+ f" | ts '[%Y-%m-%d %H:%M:%S]' 2>&1"
1674
1668
enable_pigpiod_5ms = subprocess .Popen (cmd , shell = True )
1675
1669
enable_pigpiod_5ms .wait ()
1676
1670
elif form .pigpiod_sample_rate .data == 'disabled' :
1677
1671
# Disable pigpiod (user selected disable)
1678
- cmd = "{pth}/mycodo/scripts/mycodo_wrapper enable_pigpiod_disabled" \
1679
- " | ts '[%Y-%m-%d %H:%M:%S]' 2>&1" .format (
1680
- pth = INSTALL_DIRECTORY )
1672
+ cmd = f"{ INSTALL_DIRECTORY } /mycodo/scripts/mycodo_wrapper enable_pigpiod_disabled" \
1673
+ f" | ts '[%Y-%m-%d %H:%M:%S]' 2>&1"
1681
1674
disable_pigpiod = subprocess .Popen (cmd , shell = True )
1682
1675
disable_pigpiod .wait ()
1683
1676
elif form .pigpiod_sample_rate .data == 'uninstalled' :
1684
1677
# Uninstall pigpiod (user selected disable)
1685
- cmd = "{pth}/mycodo/scripts/mycodo_wrapper uninstall_pigpiod" \
1686
- " | ts '[%Y-%m-%d %H:%M:%S]' 2>&1" .format (
1687
- pth = INSTALL_DIRECTORY )
1678
+ cmd = f"{ INSTALL_DIRECTORY } /mycodo/scripts/mycodo_wrapper uninstall_pigpiod" \
1679
+ f" | ts '[%Y-%m-%d %H:%M:%S]' 2>&1"
1688
1680
uninstall_pigpiod = subprocess .Popen (cmd , shell = True )
1689
1681
uninstall_pigpiod .wait ()
1690
1682
1691
1683
# Start the Mycodo daemon
1692
- cmd = "{pth}/mycodo/scripts/mycodo_wrapper daemon_start" \
1693
- " | ts '[%Y-%m-%d %H:%M:%S]' 2>&1" .format (
1694
- pth = INSTALL_DIRECTORY )
1684
+ cmd = f"{ INSTALL_DIRECTORY } /mycodo/scripts/mycodo_wrapper daemon_start" \
1685
+ f" | ts '[%Y-%m-%d %H:%M:%S]' 2>&1"
1695
1686
start_daemon = subprocess .Popen (cmd , shell = True )
1696
1687
start_daemon .wait ()
1697
1688
0 commit comments