From 8865d93a65461388fb4868c2e74cab7b892f22a8 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Sat, 24 Mar 2018 21:15:21 +0800 Subject: [PATCH] update pkg and version --- robotgo.go | 2 +- vendor/github.com/shirou/gopsutil/cpu/cpu.go | 3 +- .../github.com/shirou/gopsutil/host/host.go | 6 +- .../shirou/gopsutil/host/host_fallback.go | 8 ++ .../shirou/gopsutil/host/host_freebsd.go | 19 +--- .../shirou/gopsutil/host/host_linux.go | 43 +++++-- .../shirou/gopsutil/host/host_solaris.go | 15 +++ vendor/github.com/shirou/gopsutil/mem/mem.go | 6 +- .../shirou/gopsutil/mem/mem_freebsd.go | 105 ++++++++++-------- vendor/github.com/shirou/gopsutil/net/net.go | 6 +- .../shirou/gopsutil/process/process.go | 10 +- .../shirou/gopsutil/process/process_linux.go | 6 +- vendor/github.com/vcaesar/imgo/README.md | 12 +- vendor/github.com/vcaesar/imgo/README_zh.md | 12 +- vendor/vendor.json | 68 ++++++++---- 15 files changed, 188 insertions(+), 133 deletions(-) diff --git a/robotgo.go b/robotgo.go index dd83999..0b2f2e8 100644 --- a/robotgo.go +++ b/robotgo.go @@ -65,7 +65,7 @@ import ( ) const ( - version string = "v0.48.0.534, Ben Nevis!" + version string = "v0.48.0.540, Ben Nevis!" ) type ( diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu.go b/vendor/github.com/shirou/gopsutil/cpu/cpu.go index 049869e..ceaf77f 100644 --- a/vendor/github.com/shirou/gopsutil/cpu/cpu.go +++ b/vendor/github.com/shirou/gopsutil/cpu/cpu.go @@ -54,10 +54,9 @@ type lastPercent struct { } var lastCPUPercent lastPercent -var invoke common.Invoker +var invoke common.Invoker = common.Invoke{} func init() { - invoke = common.Invoke{} lastCPUPercent.Lock() lastCPUPercent.lastCPUTimes, _ = Times(false) lastCPUPercent.lastPerCPUTimes, _ = Times(true) diff --git a/vendor/github.com/shirou/gopsutil/host/host.go b/vendor/github.com/shirou/gopsutil/host/host.go index a256a6c..1e9e9bb 100644 --- a/vendor/github.com/shirou/gopsutil/host/host.go +++ b/vendor/github.com/shirou/gopsutil/host/host.go @@ -6,11 +6,7 @@ import ( "github.com/shirou/gopsutil/internal/common" ) -var invoke common.Invoker - -func init() { - invoke = common.Invoke{} -} +var invoke common.Invoker = common.Invoke{} // A HostInfoStat describes the host status. // This is not in the psutil but it useful. diff --git a/vendor/github.com/shirou/gopsutil/host/host_fallback.go b/vendor/github.com/shirou/gopsutil/host/host_fallback.go index f6537a9..e80d7ea 100644 --- a/vendor/github.com/shirou/gopsutil/host/host_fallback.go +++ b/vendor/github.com/shirou/gopsutil/host/host_fallback.go @@ -55,3 +55,11 @@ func KernelVersion() (string, error) { func KernelVersionWithContext(ctx context.Context) (string, error) { return "", common.ErrNotImplementedError } + +func PlatformInformation() (string, string, string, error) { + return PlatformInformationWithContext(context.Background()) +} + +func PlatformInformationWithContext(ctx context.Context) (string, string, string, error) { + return "", "", "", common.ErrNotImplementedError +} diff --git a/vendor/github.com/shirou/gopsutil/host/host_freebsd.go b/vendor/github.com/shirou/gopsutil/host/host_freebsd.go index 2f51c31..00a8519 100644 --- a/vendor/github.com/shirou/gopsutil/host/host_freebsd.go +++ b/vendor/github.com/shirou/gopsutil/host/host_freebsd.go @@ -8,7 +8,6 @@ import ( "encoding/binary" "io/ioutil" "os" - "os/exec" "runtime" "strings" "sync/atomic" @@ -168,25 +167,17 @@ func PlatformInformation() (string, string, string, error) { } func PlatformInformationWithContext(ctx context.Context) (string, string, string, error) { - platform := "" - family := "" - version := "" - uname, err := exec.LookPath("uname") + platform, err := unix.Sysctl("kern.ostype") if err != nil { return "", "", "", err } - out, err := invoke.Command(uname, "-s") - if err == nil { - platform = strings.ToLower(strings.TrimSpace(string(out))) + version, err := unix.Sysctl("kern.osrelease") + if err != nil { + return "", "", "", err } - out, err = invoke.Command(uname, "-r") - if err == nil { - version = strings.ToLower(strings.TrimSpace(string(out))) - } - - return platform, family, version, nil + return strings.ToLower(platform), "", strings.ToLower(version), nil } func Virtualization() (string, string, error) { diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux.go b/vendor/github.com/shirou/gopsutil/host/host_linux.go index 5324258..098d086 100644 --- a/vendor/github.com/shirou/gopsutil/host/host_linux.go +++ b/vendor/github.com/shirou/gopsutil/host/host_linux.go @@ -109,10 +109,14 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) { if err != nil { return 0, err } + statFile := "stat" if system == "lxc" && role == "guest" { // if lxc, /proc/uptime is used. statFile = "uptime" + } else if system == "docker" && role == "guest" { + // also docker, guest + statFile = "uptime" } filename := common.HostProc(statFile) @@ -120,20 +124,35 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) { if err != nil { return 0, err } - for _, line := range lines { - if strings.HasPrefix(line, "btime") { - f := strings.Fields(line) - if len(f) != 2 { - return 0, fmt.Errorf("wrong btime format") + + if statFile == "stat" { + for _, line := range lines { + if strings.HasPrefix(line, "btime") { + f := strings.Fields(line) + if len(f) != 2 { + return 0, fmt.Errorf("wrong btime format") + } + b, err := strconv.ParseInt(f[1], 10, 64) + if err != nil { + return 0, err + } + t = uint64(b) + atomic.StoreUint64(&cachedBootTime, t) + return t, nil } - b, err := strconv.ParseInt(f[1], 10, 64) - if err != nil { - return 0, err - } - t = uint64(b) - atomic.StoreUint64(&cachedBootTime, t) - return t, nil } + } else if statFile == "uptime" { + if len(lines) != 1 { + return 0, fmt.Errorf("wrong uptime format") + } + f := strings.Fields(lines[0]) + b, err := strconv.ParseInt(f[0], 10, 64) + if err != nil { + return 0, err + } + t = uint64(time.Now().Unix()) - uint64(b) + atomic.StoreUint64(&cachedBootTime, t) + return t, nil } return 0, fmt.Errorf("could not find btime") diff --git a/vendor/github.com/shirou/gopsutil/host/host_solaris.go b/vendor/github.com/shirou/gopsutil/host/host_solaris.go index 2560c06..d5657db 100644 --- a/vendor/github.com/shirou/gopsutil/host/host_solaris.go +++ b/vendor/github.com/shirou/gopsutil/host/host_solaris.go @@ -231,3 +231,18 @@ func KernelVersionWithContext(ctx context.Context) (string, error) { } return "", fmt.Errorf("could not get kernel version") } + +func PlatformInformation() (platform string, family string, version string, err error) { + return PlatformInformationWithContext(context.Background()) +} + +func PlatformInformationWithContext(ctx context.Context) (platform string, family string, version string, err error) { + /* This is not finished yet at all. Please contribute! */ + + version, err = KernelVersion() + if err != nil { + return "", "", "", err + } + + return "solaris", "solaris", version, nil +} diff --git a/vendor/github.com/shirou/gopsutil/mem/mem.go b/vendor/github.com/shirou/gopsutil/mem/mem.go index 87dfb53..bdf15ba 100644 --- a/vendor/github.com/shirou/gopsutil/mem/mem.go +++ b/vendor/github.com/shirou/gopsutil/mem/mem.go @@ -6,11 +6,7 @@ import ( "github.com/shirou/gopsutil/internal/common" ) -var invoke common.Invoker - -func init() { - invoke = common.Invoke{} -} +var invoke common.Invoker = common.Invoke{} // Memory usage statistics. Total, Available and Used contain numbers of bytes // for human consumption. diff --git a/vendor/github.com/shirou/gopsutil/mem/mem_freebsd.go b/vendor/github.com/shirou/gopsutil/mem/mem_freebsd.go index e691227..1fa880b 100644 --- a/vendor/github.com/shirou/gopsutil/mem/mem_freebsd.go +++ b/vendor/github.com/shirou/gopsutil/mem/mem_freebsd.go @@ -5,9 +5,7 @@ package mem import ( "context" "errors" - "os/exec" - "strconv" - "strings" + "unsafe" "golang.org/x/sys/unix" ) @@ -69,53 +67,66 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { } // Return swapinfo -// FreeBSD can have multiple swap devices. but use only first device func SwapMemory() (*SwapMemoryStat, error) { return SwapMemoryWithContext(context.Background()) } -func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) { - swapinfo, err := exec.LookPath("swapinfo") - if err != nil { - return nil, err - } +// Constants from vm/vm_param.h +// nolint: golint +const ( + XSWDEV_VERSION = 1 +) - out, err := invoke.Command(swapinfo) - if err != nil { - return nil, err - } - for _, line := range strings.Split(string(out), "\n") { - values := strings.Fields(line) - // skip title line - if len(values) == 0 || values[0] == "Device" { - continue - } - - u := strings.Replace(values[4], "%", "", 1) - total_v, err := strconv.ParseUint(values[1], 10, 64) - if err != nil { - return nil, err - } - used_v, err := strconv.ParseUint(values[2], 10, 64) - if err != nil { - return nil, err - } - free_v, err := strconv.ParseUint(values[3], 10, 64) - if err != nil { - return nil, err - } - up_v, err := strconv.ParseFloat(u, 64) - if err != nil { - return nil, err - } - - return &SwapMemoryStat{ - Total: total_v, - Used: used_v, - Free: free_v, - UsedPercent: up_v, - }, nil - } - - return nil, errors.New("no swap devices found") +// Types from vm/vm_param.h +type xswdev struct { + Version uint32 // Version is the version + Dev uint32 // Dev is the device identifier + Flags int32 // Flags is the swap flags applied to the device + NBlks int32 // NBlks is the total number of blocks + Used int32 // Used is the number of blocks used +} + +func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) { + // FreeBSD can have multiple swap devices so we total them up + i, err := unix.SysctlUint32("vm.nswapdev") + if err != nil { + return nil, err + } + + if i == 0 { + return nil, errors.New("no swap devices found") + } + + c := int(i) + + i, err = unix.SysctlUint32("vm.stats.vm.v_page_size") + if err != nil { + return nil, err + } + pageSize := uint64(i) + + var buf []byte + s := &SwapMemoryStat{} + for n := 0; n < c; n++ { + buf, err = unix.SysctlRaw("vm.swap_info", n) + if err != nil { + return nil, err + } + + xsw := (*xswdev)(unsafe.Pointer(&buf[0])) + if xsw.Version != XSWDEV_VERSION { + return nil, errors.New("xswdev version mismatch") + } + s.Total += uint64(xsw.NBlks) + s.Used += uint64(xsw.Used) + } + + if s.Total != 0 { + s.UsedPercent = float64(s.Used) / float64(s.Total) * 100 + } + s.Total *= pageSize + s.Used *= pageSize + s.Free = s.Total - s.Used + + return s, nil } diff --git a/vendor/github.com/shirou/gopsutil/net/net.go b/vendor/github.com/shirou/gopsutil/net/net.go index 428e68e..c31f512 100644 --- a/vendor/github.com/shirou/gopsutil/net/net.go +++ b/vendor/github.com/shirou/gopsutil/net/net.go @@ -12,11 +12,7 @@ import ( "github.com/shirou/gopsutil/internal/common" ) -var invoke common.Invoker - -func init() { - invoke = common.Invoke{} -} +var invoke common.Invoker = common.Invoke{} type IOCountersStat struct { Name string `json:"name"` // interface name diff --git a/vendor/github.com/shirou/gopsutil/process/process.go b/vendor/github.com/shirou/gopsutil/process/process.go index e20742a..a4b24f4 100644 --- a/vendor/github.com/shirou/gopsutil/process/process.go +++ b/vendor/github.com/shirou/gopsutil/process/process.go @@ -3,6 +3,7 @@ package process import ( "context" "encoding/json" + "errors" "runtime" "time" @@ -11,11 +12,10 @@ import ( "github.com/shirou/gopsutil/mem" ) -var invoke common.Invoker - -func init() { - invoke = common.Invoke{} -} +var ( + invoke common.Invoker = common.Invoke{} + ErrorNoChildren = errors.New("process does not have children") +) type Process struct { Pid int32 `json:"pid"` diff --git a/vendor/github.com/shirou/gopsutil/process/process_linux.go b/vendor/github.com/shirou/gopsutil/process/process_linux.go index 8f59949..894f268 100644 --- a/vendor/github.com/shirou/gopsutil/process/process_linux.go +++ b/vendor/github.com/shirou/gopsutil/process/process_linux.go @@ -7,7 +7,6 @@ import ( "bytes" "context" "encoding/json" - "errors" "fmt" "io/ioutil" "math" @@ -23,10 +22,7 @@ import ( "golang.org/x/sys/unix" ) -var ( - ErrorNoChildren = errors.New("process does not have children") - PageSize = uint64(os.Getpagesize()) -) +var PageSize = uint64(os.Getpagesize()) const ( PrioProcess = 0 // linux/resource.h diff --git a/vendor/github.com/vcaesar/imgo/README.md b/vendor/github.com/vcaesar/imgo/README.md index 7d866f2..005e8c9 100644 --- a/vendor/github.com/vcaesar/imgo/README.md +++ b/vendor/github.com/vcaesar/imgo/README.md @@ -1,9 +1,9 @@ # img -[![CircleCI Status](https://circleci.com/gh/vcaesar/img.svg?style=shield)](https://circleci.com/gh/vcaesar/img) -[![codecov](https://codecov.io/gh/vcaesar/img/branch/master/graph/badge.svg)](https://codecov.io/gh/vcaesar/img) -[![Build Status](https://travis-ci.org/vcaesar/img.svg)](https://travis-ci.org/vcaesar/img) -[![Go Report Card](https://goreportcard.com/badge/github.com/vcaesar/img)](https://goreportcard.com/report/github.com/vcaesar/img) -[![GoDoc](https://godoc.org/github.com/vcaesar/img?status.svg)](https://godoc.org/github.com/vcaesar/img) -[![Release](https://github-release-version.herokuapp.com/github/vcaesar/img/release.svg?style=flat)](https://github.com/vcaesar/img/releases/latest) +[![CircleCI Status](https://circleci.com/gh/vcaesar/imgo.svg?style=shield)](https://circleci.com/gh/vcaesar/imgo) +[![codecov](https://codecov.io/gh/vcaesar/imgo/branch/master/graph/badge.svg)](https://codecov.io/gh/vcaesar/imgo) +[![Build Status](https://travis-ci.org/vcaesar/imgo.svg)](https://travis-ci.org/vcaesar/imgo) +[![Go Report Card](https://goreportcard.com/badge/github.com/vcaesar/imgo)](https://goreportcard.com/report/github.com/vcaesar/imgo) +[![GoDoc](https://godoc.org/github.com/vcaesar/imgo?status.svg)](https://godoc.org/github.com/vcaesar/imgo) +[![Release](https://github-release-version.herokuapp.com/github/vcaesar/imgo/release.svg?style=flat)](https://github.com/vcaesar/imgo/releases/latest) [![Join the chat at https://gitter.im/go-vgo/robotgo](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-vgo/robotgo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) \ No newline at end of file diff --git a/vendor/github.com/vcaesar/imgo/README_zh.md b/vendor/github.com/vcaesar/imgo/README_zh.md index 7d866f2..005e8c9 100644 --- a/vendor/github.com/vcaesar/imgo/README_zh.md +++ b/vendor/github.com/vcaesar/imgo/README_zh.md @@ -1,9 +1,9 @@ # img -[![CircleCI Status](https://circleci.com/gh/vcaesar/img.svg?style=shield)](https://circleci.com/gh/vcaesar/img) -[![codecov](https://codecov.io/gh/vcaesar/img/branch/master/graph/badge.svg)](https://codecov.io/gh/vcaesar/img) -[![Build Status](https://travis-ci.org/vcaesar/img.svg)](https://travis-ci.org/vcaesar/img) -[![Go Report Card](https://goreportcard.com/badge/github.com/vcaesar/img)](https://goreportcard.com/report/github.com/vcaesar/img) -[![GoDoc](https://godoc.org/github.com/vcaesar/img?status.svg)](https://godoc.org/github.com/vcaesar/img) -[![Release](https://github-release-version.herokuapp.com/github/vcaesar/img/release.svg?style=flat)](https://github.com/vcaesar/img/releases/latest) +[![CircleCI Status](https://circleci.com/gh/vcaesar/imgo.svg?style=shield)](https://circleci.com/gh/vcaesar/imgo) +[![codecov](https://codecov.io/gh/vcaesar/imgo/branch/master/graph/badge.svg)](https://codecov.io/gh/vcaesar/imgo) +[![Build Status](https://travis-ci.org/vcaesar/imgo.svg)](https://travis-ci.org/vcaesar/imgo) +[![Go Report Card](https://goreportcard.com/badge/github.com/vcaesar/imgo)](https://goreportcard.com/report/github.com/vcaesar/imgo) +[![GoDoc](https://godoc.org/github.com/vcaesar/imgo?status.svg)](https://godoc.org/github.com/vcaesar/imgo) +[![Release](https://github-release-version.herokuapp.com/github/vcaesar/imgo/release.svg?style=flat)](https://github.com/vcaesar/imgo/releases/latest) [![Join the chat at https://gitter.im/go-vgo/robotgo](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-vgo/robotgo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) \ No newline at end of file diff --git a/vendor/vendor.json b/vendor/vendor.json index 2ebadf0..b525c08 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -45,40 +45,40 @@ "revisionTime": "2017-07-14T06:33:53Z" }, { - "checksumSHA1": "PHwqGzRGjJ81TtD7aBgcppCjeRg=", + "checksumSHA1": "cspJvF0E9whCLlbX8MlrYemtOzo=", "path": "github.com/shirou/gopsutil/cpu", - "revision": "5776ff9c7c5d063d574ef53d740f75c68b448e53", - "revisionTime": "2018-02-27T22:58:47Z" + "revision": "b99342a9ceb013854c12cfb0b55c2adc57837a29", + "revisionTime": "2018-03-24T06:57:29Z" }, { - "checksumSHA1": "sy4twPdTy18BS0k2PxntChG2FcE=", + "checksumSHA1": "X93ayElJyx5k/xOUSMzMdYIbQ7M=", "path": "github.com/shirou/gopsutil/host", - "revision": "5776ff9c7c5d063d574ef53d740f75c68b448e53", - "revisionTime": "2018-02-27T22:58:47Z" + "revision": "b99342a9ceb013854c12cfb0b55c2adc57837a29", + "revisionTime": "2018-03-24T06:57:29Z" }, { "checksumSHA1": "xPMr7RbEnFd1XxOFpLOSdX4cEO0=", "path": "github.com/shirou/gopsutil/internal/common", - "revision": "5776ff9c7c5d063d574ef53d740f75c68b448e53", - "revisionTime": "2018-02-27T22:58:47Z" + "revision": "b99342a9ceb013854c12cfb0b55c2adc57837a29", + "revisionTime": "2018-03-24T06:57:29Z" }, { - "checksumSHA1": "Cgm7wMq9rJpnUeZFV3OD8qkTKOM=", + "checksumSHA1": "s/McZHJfB9Kt5lyI2VccZ8yUaW0=", "path": "github.com/shirou/gopsutil/mem", - "revision": "5776ff9c7c5d063d574ef53d740f75c68b448e53", - "revisionTime": "2018-02-27T22:58:47Z" + "revision": "b99342a9ceb013854c12cfb0b55c2adc57837a29", + "revisionTime": "2018-03-24T06:57:29Z" }, { - "checksumSHA1": "Z7FjZvR5J5xh6Ne572gD7tRUsc8=", + "checksumSHA1": "cfj8JcHTkICoDEj6AAuniOi48FA=", "path": "github.com/shirou/gopsutil/net", - "revision": "5776ff9c7c5d063d574ef53d740f75c68b448e53", - "revisionTime": "2018-02-27T22:58:47Z" + "revision": "b99342a9ceb013854c12cfb0b55c2adc57837a29", + "revisionTime": "2018-03-24T06:57:29Z" }, { - "checksumSHA1": "l372fZbcjJ2OlVmg0JihEjbtUcE=", + "checksumSHA1": "IkOLZLYKoKuA1rVTJtPcgGGMA0Y=", "path": "github.com/shirou/gopsutil/process", - "revision": "5776ff9c7c5d063d574ef53d740f75c68b448e53", - "revisionTime": "2018-02-27T22:58:47Z" + "revision": "b99342a9ceb013854c12cfb0b55c2adc57837a29", + "revisionTime": "2018-03-24T06:57:29Z" }, { "checksumSHA1": "Nve7SpDmjsv6+rhkXAkfg/UQx94=", @@ -103,15 +103,19 @@ "revisionTime": "2017-06-01T20:57:54Z" }, { - "checksumSHA1": "uZ3mletGtExUozsdwpZ+B4KmFXk=", + "checksumSHA1": "qqYvzeNRTp9tXZwP2IBx/euloqo=", "path": "github.com/vcaesar/imgo", - "revision": "67f0b2002c0030cda52e4cf2bd8b9e5826adf6e5", - "revisionTime": "2018-03-04T12:31:00Z" + "revision": "fece97d8745e9e2299516bf074772fccf03a53a5", + "revisionTime": "2018-03-07T10:09:24Z" }, { "path": "golang.org/x/image/bmp", "revision": "" }, + { + "path": "golang.org/x/sys/plan9", + "revision": "" + }, { "checksumSHA1": "EL5tiYbzPcSM0nhJpvMSDnDNvxI=", "path": "golang.org/x/sys/unix", @@ -123,6 +127,30 @@ "path": "golang.org/x/sys/windows", "revision": "4ed4d404df456f81e878683a0363ed3013a59003", "revisionTime": "2017-06-30T13:23:30Z" + }, + { + "path": "golang.org/x/sys/windows/registry", + "revision": "" + }, + { + "path": "golang.org/x/sys/windows/svc", + "revision": "" + }, + { + "path": "golang.org/x/sys/windows/svc/debug", + "revision": "" + }, + { + "path": "golang.org/x/sys/windows/svc/eventlog", + "revision": "" + }, + { + "path": "golang.org/x/sys/windows/svc/example", + "revision": "" + }, + { + "path": "golang.org/x/sys/windows/svc/mgr", + "revision": "" } ], "rootPath": "github.com/go-vgo/robotgo"