Skip to content

Commit

Permalink
fix: Homescript backend args
Browse files Browse the repository at this point in the history
  • Loading branch information
MikMuellerDev committed Oct 17, 2024
1 parent 928d4c7 commit 11f7072
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/automation/automationRunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ func AutomationRunnerFunc(id uint, automationCtx types.ExecutionContextAutomatio
false,
&automationCtx.Inner,
nil,
make(map[string]string),
)

if err != nil {
Expand Down
1 change: 1 addition & 0 deletions core/homescript/dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ func (i *InstanceT) allocatingCall(
false,
nil,
nil,
make(map[string]string),
)

res = resTemp
Expand Down
5 changes: 4 additions & 1 deletion core/homescript/dispatcher/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
)

const MqttKeepAlive time.Duration = time.Second * 60
const MqttConnectTimeout time.Duration = time.Second * 3
const MqttPingTimeout time.Duration = time.Second
const MqttDisconnectTimeoutMillis uint = 250
const MqttQOS byte = 0x2
Expand Down Expand Up @@ -192,9 +193,10 @@ func (m *MqttManager) init() error {
}

logger.Debugf(
"Initializing MQTT subsystem for broker `%s@%s`...",
"Initializing MQTT subsystem for broker `%s@%s` (timeout: %v)...",
m.Body.Content.Config.Username,
m.Body.Content.Config.Host,
MqttConnectTimeout,
)

opts := mqtt.NewClientOptions().
Expand All @@ -206,6 +208,7 @@ func (m *MqttManager) init() error {
SetUsername(m.Body.Content.Config.Username).
SetPassword(m.Body.Content.Config.Password)

opts.SetConnectTimeout(MqttConnectTimeout)
opts.SetKeepAlive(MqttKeepAlive)
opts.SetPingTimeout(MqttPingTimeout)
opts.SetDefaultPublishHandler(m.messageHandler)
Expand Down
3 changes: 2 additions & 1 deletion core/homescript/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type InterpreterExecutor struct {
}

func (self InterpreterExecutor) Free() error {
var errRes error = nil
var errRes error

for _, registration := range *self.registrations {
// Return the first error that is found
Expand Down Expand Up @@ -130,6 +130,7 @@ func (self InterpreterExecutor) execHelper(
self.ioWriter,
nil,
self.stdin,
arguments,
)

if err != nil {
Expand Down
9 changes: 8 additions & 1 deletion core/homescript/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ func (m *Manager) RunUserCode(
outputWriter io.Writer,
idChan *chan uint64,
stdin *types.StdinBuffer,
args map[string]string,
) (types.HmsRes, error) {
return m.RunUserCodeTweakable(
code,
Expand All @@ -630,6 +631,7 @@ func (m *Manager) RunUserCode(
true,
nil,
stdin,
args,
)
}

Expand All @@ -642,11 +644,12 @@ func (m *Manager) RunUserCodeTweakable(
processAnnotations bool,
automationContext *types.ExecutionContextAutomationInner,
stdin *types.StdinBuffer,
args map[string]string,
) (types.HmsRes, error) {
userContext := types.NewExecutionContextUser(
filename,
username,
nil,
args,
)
context := types.ExecutionContext(userContext)

Expand Down Expand Up @@ -684,6 +687,7 @@ func (m *Manager) RunUserScriptTweakable(
processAnnotations bool,
automationContext *types.ExecutionContextAutomationInner,
stdin *types.StdinBuffer,
args map[string]string,
) (types.HmsRes, error) {
script, found, err := m.GetPersonalScriptById(programID, username)
if err != nil {
Expand All @@ -704,6 +708,7 @@ func (m *Manager) RunUserScriptTweakable(
processAnnotations,
automationContext,
stdin,
args,
)
}

Expand All @@ -715,6 +720,7 @@ func (m *Manager) RunUserScript(
outputWriter io.Writer,
idChan *chan uint64,
stdin *types.StdinBuffer,
args map[string]string,
) (types.HmsRes, error) {
return m.RunUserScriptTweakable(
programID,
Expand All @@ -726,6 +732,7 @@ func (m *Manager) RunUserScript(
true,
nil,
stdin,
args,
)
}

Expand Down
1 change: 1 addition & 0 deletions core/homescript/managerTrigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func (m *Manager) ExtractTriggerAnnotationArgs(
false,
nil,
nil,
make(map[string]string),
)
case types.ExecutionContextAutomation:
panic("not implemented")
Expand Down
4 changes: 4 additions & 0 deletions core/homescript/types/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type Manager interface {
outputWriter io.Writer,
idChan *chan uint64,
stdin *StdinBuffer,
args map[string]string,
) (HmsRes, error)

RunUserCodeTweakable(
Expand All @@ -84,6 +85,7 @@ type Manager interface {
processAnnotations bool,
automationContext *ExecutionContextAutomationInner,
stdin *StdinBuffer,
args map[string]string,
) (HmsRes, error)

RunUserScript(
Expand All @@ -93,6 +95,7 @@ type Manager interface {
outputWriter io.Writer,
idChan *chan uint64,
stdin *StdinBuffer,
args map[string]string,
) (HmsRes, error)

RunUserScriptTweakable(
Expand All @@ -104,6 +107,7 @@ type Manager interface {
processAnnotations bool,
automationContext *ExecutionContextAutomationInner,
stdin *StdinBuffer,
args map[string]string,
) (HmsRes, error)

RunDriverScript(
Expand Down
1 change: 1 addition & 0 deletions core/scheduler/scheduleRunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func scheduleRunnerFunc(id uint, m *SchedulerManager) {
&bytes.Buffer{},
nil,
nil,
make(map[string]string),
)

if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions server/api/homescript.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func RunHomescriptId(w http.ResponseWriter, r *http.Request) {
&outputBuffer,
nil,
nil,
args,
)

if err != nil {
Expand Down Expand Up @@ -236,6 +237,7 @@ func RunHomescriptString(w http.ResponseWriter, r *http.Request) {
&outputBuffer,
nil,
nil,
args,
)
output := outputBuffer.String()

Expand Down
1 change: 1 addition & 0 deletions server/api/homescriptAsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ func RunHomescriptByIDAsync(w http.ResponseWriter, r *http.Request) {
outWriter,
idChan,
stdin,
args,
)

log.Tracef("WS homescript (%s) finished.", request.HMSID)
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/rooms/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@
top: auto;
}
}
#content {
// On non-widescreen layouts, the room tabs might include a scrollbar which adds additional space
min-height: calc(100vh - 63px);
Expand Down

0 comments on commit 11f7072

Please sign in to comment.