Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #103 from vania-pooh/master
Browse files Browse the repository at this point in the history
Added color support for drivers logic (related to #99)
  • Loading branch information
vania-pooh authored Nov 23, 2017
2 parents 9f6ebd1 + da523d0 commit 2d84bb5
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 105 deletions.
2 changes: 1 addition & 1 deletion cmd/selenoid.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
env string
browserEnv string
port uint16
uiPort uint16
uiPort uint16
)

func init() {
Expand Down
6 changes: 3 additions & 3 deletions cmd/selenoid_cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ func cleanupImpl(configDir string, port uint16, stopAction func(*selenoid.Lifecy

err = stopAction(lifecycle)
if err != nil {
stderr("Failed to stop: %v\n", err)
lifecycle.Errorf("Failed to stop: %v\n", err)
os.Exit(1)
}

err = os.RemoveAll(configDir)
if err != nil {
lifecycle.Printf("Failed to remove configuration directory: %v\n", err)
lifecycle.Errorf("Failed to remove configuration directory: %v\n", err)
os.Exit(1)
}
lifecycle.Printf("Successfully removed configuration directory\n")
lifecycle.Titlef("Successfully removed configuration directory\n")
os.Exit(0)
}
2 changes: 1 addition & 1 deletion cmd/selenoid_configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var selenoidConfigureCmd = &cobra.Command{
}
err = lifecycle.Configure()
if err != nil {
lifecycle.Printf("Failed to configure Selenoid: %v\n", err)
lifecycle.Errorf("Failed to configure Selenoid: %v\n", err)
os.Exit(1)
}
os.Exit(0)
Expand Down
2 changes: 1 addition & 1 deletion cmd/selenoid_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func downloadImpl(configDir string, port uint16, downloadAction func(*selenoid.L
}
err = downloadAction(lifecycle)
if err != nil {
lifecycle.Printf("Failed to download: %v\n", err)
lifecycle.Errorf("Failed to download: %v\n", err)
os.Exit(1)
}
os.Exit(0)
Expand Down
2 changes: 1 addition & 1 deletion cmd/selenoid_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func startImpl(configDir string, port uint16, startAction func(*selenoid.Lifecyc
lifecycle.Force = force
err = startAction(lifecycle)
if err != nil {
lifecycle.Printf("Failed to start: %v\n", err)
lifecycle.Errorf("Failed to start: %v\n", err)
os.Exit(1)
}
os.Exit(0)
Expand Down
2 changes: 1 addition & 1 deletion cmd/selenoid_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func stopImpl(configDir string, port uint16, stopAction func(*selenoid.Lifecycle
}
err = stopAction(lifecycle)
if err != nil {
lifecycle.Printf("Failed to stop: %v\n", err)
lifecycle.Errorf("Failed to stop: %v\n", err)
os.Exit(1)
}
os.Exit(0)
Expand Down
2 changes: 1 addition & 1 deletion render/rewriter/rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
package rewriter

import (
"io"
"bytes"
"fmt"
"io"
)

// ESC is the ASCII code for escape character
Expand Down
6 changes: 3 additions & 3 deletions render/rewriter/rewriter_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ package rewriter

import (
"fmt"
"github.com/mattn/go-isatty"
"io"
"strings"
"syscall"
"unsafe"
"strings"
"github.com/mattn/go-isatty"
)

var kernel32 = syscall.NewLazyDLL("kernel32.dll")
Expand All @@ -22,7 +22,7 @@ var (

type (
short int16
word uint16
word uint16
dword uint32

coord struct {
Expand Down
4 changes: 2 additions & 2 deletions selenoid/base.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package selenoid

import (
"fmt"
"github.com/fatih/color"
"log"
"os"
"os/user"
"path/filepath"
"fmt"
"github.com/fatih/color"
)

type StatusAware interface {
Expand Down
38 changes: 19 additions & 19 deletions selenoid/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import (
"strings"
"time"

"regexp"
"runtime"
. "vbom.ml/util/sortorder"
"github.com/aerokube/cm/render/rewriter"
"github.com/fatih/color"
"net/http"
"path/filepath"
"regexp"
"runtime"
. "vbom.ml/util/sortorder"
)

const (
Expand Down Expand Up @@ -137,37 +137,37 @@ func (c *DockerConfigurator) Close() error {
func (c *DockerConfigurator) Status() {
selenoidImage := c.getSelenoidImage()
if selenoidImage != nil {
c.Printf("Using Selenoid image: %s (%s)", selenoidImage.RepoTags[0], selenoidImage.ID)
c.Pointf("Using Selenoid image: %s (%s)", selenoidImage.RepoTags[0], selenoidImage.ID)
} else {
c.Printf("Selenoid image is not present")
c.Pointf("Selenoid image is not present")
}
configPath := getSelenoidConfigPath(c.ConfigDir)
c.Printf("Selenoid configuration directory is %s", c.ConfigDir)
c.Pointf("Selenoid configuration directory is %s", c.ConfigDir)
if fileExists(configPath) {
c.Printf("Selenoid configuration file is %s", configPath)
c.Pointf("Selenoid configuration file is %s", configPath)
} else {
c.Printf("Selenoid is not configured")
c.Pointf("Selenoid is not configured")
}
selenoidContainer := c.getSelenoidContainer()
if selenoidContainer != nil {
c.Printf("Selenoid container is running: %s (%s)", selenoidContainerName, selenoidContainer.ID)
c.Pointf("Selenoid container is running: %s (%s)", selenoidContainerName, selenoidContainer.ID)
} else {
c.Printf("Selenoid container is not running")
c.Pointf("Selenoid container is not running")
}
}

func (c *DockerConfigurator) UIStatus() {
selenoidUIImage := c.getSelenoidUIImage()
if selenoidUIImage != nil {
c.Printf("Using Selenoid UI image: %s (%s)", selenoidUIImage.RepoTags[0], selenoidUIImage.ID)
c.Pointf("Using Selenoid UI image: %s (%s)", selenoidUIImage.RepoTags[0], selenoidUIImage.ID)
} else {
c.Printf("Selenoid UI image is not present")
c.Pointf("Selenoid UI image is not present")
}
selenoidUIContainer := c.getSelenoidUIContainer()
if selenoidUIContainer != nil {
c.Printf("Selenoid UI container is running: %s (%s)", selenoidUIContainerName, selenoidUIContainer.ID)
c.Pointf("Selenoid UI container is running: %s (%s)", selenoidUIContainerName, selenoidUIContainer.ID)
} else {
c.Printf("Selenoid UI container is not running")
c.Pointf("Selenoid UI container is not running")
}
}

Expand All @@ -190,7 +190,7 @@ func (c *DockerConfigurator) getSelenoidUIImage() *types.ImageSummary {
func (c *DockerConfigurator) getImage(name string) *types.ImageSummary {
images, err := c.docker.ImageList(context.Background(), types.ImageListOptions{})
if err != nil {
c.Errorf("Failed to list images: %v\n", err)
c.Errorf("Failed to list images: %v", err)
return nil
}
for _, img := range images {
Expand Down Expand Up @@ -246,11 +246,11 @@ func (c *DockerConfigurator) Configure() (*SelenoidConfig, error) {
cfg := c.createConfig()
data, err := json.MarshalIndent(cfg, "", " ")
if err != nil {
return nil, fmt.Errorf("failed to marshal json: %v\n", err)
return nil, fmt.Errorf("failed to marshal json: %v", err)
}
err = c.createConfigDir()
if err != nil {
return nil, fmt.Errorf("failed to create output directory: %v\n", err)
return nil, fmt.Errorf("failed to create output directory: %v", err)
}
return &cfg, ioutil.WriteFile(getSelenoidConfigPath(c.ConfigDir), data, 0644)
}
Expand All @@ -268,7 +268,7 @@ func (c *DockerConfigurator) createConfig() SelenoidConfig {
browsersToIterate[rb] = image
continue
}
c.Printf("Unsupported browser: %s\n", rb)
c.Errorf("Unsupported browser: %s", rb)
}
}
}
Expand Down Expand Up @@ -373,7 +373,7 @@ loop:
}

func (c *DockerConfigurator) pullVideoRecorderImage() {
c.Pointf("Pulling video recorder image...")
c.Titlef("Pulling video recorder image...")
c.pullImage(context.Background(), videoRecorderImage)
}

Expand Down
Loading

0 comments on commit 2d84bb5

Please sign in to comment.