Skip to content

Commit 0964384

Browse files
committed
minor changes
1 parent 8a56546 commit 0964384

File tree

1 file changed

+17
-26
lines changed

1 file changed

+17
-26
lines changed

mycodo/mycodo_flask/utils/utils_settings.py

+17-26
Original file line numberDiff line numberDiff line change
@@ -1629,69 +1629,60 @@ def settings_pi_mod(form):
16291629
action_str = "Change Hostname to '{host}'".format(
16301630
host=form.hostname.data)
16311631
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']:
16341633
error.append(
16351634
"Valid pigpiod options: Uninstall, Disable, 1 ms, or 5 ms. "
16361635
"Invalid option: {op}".format(
16371636
op=form.pigpiod_sample_rate.data))
16381637
else:
16391638
# 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"
16431641
stop_daemon = subprocess.Popen(cmd, shell=True)
16441642
stop_daemon.wait()
16451643

16461644
if (form.pigpiod_sample_rate.data != 'uninstalled' and
16471645
form.pigpiod_state.data == 'uninstalled'):
16481646
# 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"
16521649
install_pigpiod = subprocess.Popen(cmd, shell=True)
16531650
install_pigpiod.wait()
16541651

16551652
# 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"
16591655
disable_pigpiod = subprocess.Popen(cmd, shell=True)
16601656
disable_pigpiod.wait()
16611657

16621658
if form.pigpiod_sample_rate.data == 'low':
16631659
# 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"
16671662
enable_pigpiod_1ms = subprocess.Popen(cmd, shell=True)
16681663
enable_pigpiod_1ms.wait()
16691664
elif form.pigpiod_sample_rate.data == 'high':
16701665
# 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"
16741668
enable_pigpiod_5ms = subprocess.Popen(cmd, shell=True)
16751669
enable_pigpiod_5ms.wait()
16761670
elif form.pigpiod_sample_rate.data == 'disabled':
16771671
# 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"
16811674
disable_pigpiod = subprocess.Popen(cmd, shell=True)
16821675
disable_pigpiod.wait()
16831676
elif form.pigpiod_sample_rate.data == 'uninstalled':
16841677
# 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"
16881680
uninstall_pigpiod = subprocess.Popen(cmd, shell=True)
16891681
uninstall_pigpiod.wait()
16901682

16911683
# 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"
16951686
start_daemon = subprocess.Popen(cmd, shell=True)
16961687
start_daemon.wait()
16971688

0 commit comments

Comments
 (0)