Skip to content

Commit

Permalink
In UI mode, call mos flash as a subprocess
Browse files Browse the repository at this point in the history
PUBLISHED_FROM=191602fdfaa4b986a303cba6376203d4d0af7249
  • Loading branch information
dimonomid authored and cesantabot committed Feb 23, 2017
1 parent 54d0ba3 commit e14fb35
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion mos/ui.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"bufio"
"bytes"
"context"
"encoding/json"
"flag"
Expand All @@ -9,7 +11,9 @@ import (
"log"
"net/http"
"os"
"os/exec"
"path/filepath"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -143,7 +147,21 @@ func startUI(ctx context.Context, devConn *dev.DevConn) error {
time.Sleep(700 * time.Millisecond)
devConn, _ = reconnectToDevice(ctx)
}()
err := flash(ctx, devConn)

flashArgs := []string{
"flash", "--port", *portFlag, "--firmware", *firmware,
"--v", "4", "--logtostderr",
}
fmt.Println("Flashing: calling ", os.Args[0], strings.Join(flashArgs, " "))
cmd := exec.Command(os.Args[0], flashArgs...)
var buf bytes.Buffer
cmd.Stderr = &buf
cmd.Stdout = &buf
err := cmd.Run()
fscanner := bufio.NewScanner(&buf)
for fscanner.Scan() {
glog.Infof("%s", fscanner.Text())
}
httpReply(w, true, err)
})

Expand Down

0 comments on commit e14fb35

Please sign in to comment.