Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options to disable parts of sequences #368

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/farmbot/celery_script/ast/node/sequence.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ defmodule Farmbot.CeleryScript.AST.Node.Sequence do
allow_args [:version, :is_outdated, :label]

def execute(%{version: _, is_outdated: _, label: name}, body, env) do
Logger.busy 2, "[#{name}] - Sequence init."
if Farmbot.System.ConfigStorage.get_config_value(:bool, "settings", "sequence_init_log") do
Logger.busy 2, "[#{name}] - Sequence init."
end
env = mutate_env(env)
if Farmbot.BotState.locked? do
Logger.error 1, "[#{name}] - Sequence failed. Bot is locked!"
Expand All @@ -16,7 +18,9 @@ defmodule Farmbot.CeleryScript.AST.Node.Sequence do
end

defp do_reduce([ast | rest], env, name) do
Logger.info 2, "[#{name}] - Sequence Executing: #{inspect ast}"
if Farmbot.System.ConfigStorage.get_config_value(:bool, "settings", "sequence_body_log") do
Logger.info 2, "[#{name}] - Sequence Executing: #{inspect ast}"
end
case Farmbot.CeleryScript.execute(ast, env) do
{:ok, new_env} -> do_reduce(rest, new_env, name)
{:error, reason, env} ->
Expand All @@ -31,7 +35,9 @@ defmodule Farmbot.CeleryScript.AST.Node.Sequence do
end

defp do_reduce([], env, name) do
Logger.success 2, "[#{name}] - Sequence complete."
if Farmbot.System.ConfigStorage.get_config_value(:bool, "settings", "sequence_complete_log") do
Logger.success 2, "[#{name}] - Sequence complete."
end
{:ok, env}
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
defmodule Farmbot.System.ConfigStorage.Migrations.AddSequenceCompleteLogOption do
use Ecto.Migration

import Farmbot.System.ConfigStorage.MigrationHelpers

def change do
create_settings_config("sequence_init_log", :bool, true)
create_settings_config("sequence_body_log", :bool, true)
create_settings_config("sequence_complete_log", :bool, true)
end
end