mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Add cdp support for xpath scrapers (#625)
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
6
vendor/github.com/knq/sysutil/.travis.yml
generated
vendored
Normal file
6
vendor/github.com/knq/sysutil/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
dist: bionic
|
||||
language: go
|
||||
go:
|
||||
- 1.13.x
|
||||
script:
|
||||
- go test -v -coverprofile=coverage.out
|
||||
21
vendor/github.com/knq/sysutil/LICENSE
generated
vendored
Normal file
21
vendor/github.com/knq/sysutil/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016-2017 Kenneth Shaw
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
6
vendor/github.com/knq/sysutil/README.md
generated
vendored
Normal file
6
vendor/github.com/knq/sysutil/README.md
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
# About sysutil
|
||||
|
||||
Package sysutil provides some utilities for working with cross platform
|
||||
systems.
|
||||
|
||||
Inspired by the Go version of Sigar, but written to be "idiomatic" Go.
|
||||
3
vendor/github.com/knq/sysutil/go.mod
generated
vendored
Normal file
3
vendor/github.com/knq/sysutil/go.mod
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
module github.com/knq/sysutil
|
||||
|
||||
go 1.13
|
||||
15
vendor/github.com/knq/sysutil/sysutil.go
generated
vendored
Normal file
15
vendor/github.com/knq/sysutil/sysutil.go
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
package sysutil
|
||||
|
||||
import "time"
|
||||
|
||||
var btime time.Time
|
||||
|
||||
// BootTime returns the time the system was started.
|
||||
func BootTime() time.Time {
|
||||
return btime
|
||||
}
|
||||
|
||||
// Uptime returns the duration the system has been up.
|
||||
func Uptime() time.Duration {
|
||||
return time.Now().Sub(btime)
|
||||
}
|
||||
31
vendor/github.com/knq/sysutil/sysutil_bsd.go
generated
vendored
Normal file
31
vendor/github.com/knq/sysutil/sysutil_bsd.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// +build darwin freebsd openbsd netbsd
|
||||
|
||||
package sysutil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
|
||||
// get boot time
|
||||
res, err := syscall.Sysctl("kern.boottime")
|
||||
if err != nil {
|
||||
btime = time.Now()
|
||||
return
|
||||
}
|
||||
|
||||
// decode
|
||||
var t timeval
|
||||
err = binary.Read(bytes.NewBuffer([]byte(res)), binary.LittleEndian, &t)
|
||||
if err != nil {
|
||||
btime = time.Now()
|
||||
return
|
||||
}
|
||||
|
||||
btime = time.Unix(int64(t.Sec), int64(t.Usec))
|
||||
}
|
||||
36
vendor/github.com/knq/sysutil/sysutil_linux.go
generated
vendored
Normal file
36
vendor/github.com/knq/sysutil/sysutil_linux.go
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// +build linux
|
||||
|
||||
package sysutil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
btimePrefix = []byte("btime ")
|
||||
lineEnd = []byte("\n")
|
||||
)
|
||||
|
||||
func init() {
|
||||
buf, err := ioutil.ReadFile("/proc/stat")
|
||||
if err != nil {
|
||||
btime = time.Now()
|
||||
return
|
||||
}
|
||||
|
||||
for _, line := range bytes.SplitN(buf, lineEnd, -1) {
|
||||
if bytes.HasPrefix(line, btimePrefix) {
|
||||
t, err := strconv.ParseInt(string(line[len(btimePrefix):]), 10, 64)
|
||||
if err != nil {
|
||||
btime = time.Now()
|
||||
return
|
||||
}
|
||||
|
||||
btime = time.Unix(t, 0)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
9
vendor/github.com/knq/sysutil/sysutil_other.go
generated
vendored
Normal file
9
vendor/github.com/knq/sysutil/sysutil_other.go
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// +build !linux,!windows,!darwin,!freebsd,!openbsd,!netbsd
|
||||
|
||||
package sysutil
|
||||
|
||||
import "time"
|
||||
|
||||
func init() {
|
||||
btime = time.Now()
|
||||
}
|
||||
23
vendor/github.com/knq/sysutil/sysutil_windows.go
generated
vendored
Normal file
23
vendor/github.com/knq/sysutil/sysutil_windows.go
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// +build windows
|
||||
|
||||
package sysutil
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
kernel32DLL = syscall.MustLoadDLL("kernel32")
|
||||
procGetTickCount64 = kernel32DLL.MustFindProc("GetTickCount64")
|
||||
)
|
||||
|
||||
func init() {
|
||||
res, _, err := syscall.Syscall(procGetTickCount64.Addr(), 0, 0, 0, 0)
|
||||
if err != 0 {
|
||||
btime = time.Now()
|
||||
return
|
||||
}
|
||||
|
||||
btime = time.Now().Add(time.Duration(-res) * time.Millisecond)
|
||||
}
|
||||
9
vendor/github.com/knq/sysutil/timeval.go
generated
vendored
Normal file
9
vendor/github.com/knq/sysutil/timeval.go
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// +build openbsd netbsd
|
||||
|
||||
package sysutil
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
type timeval syscall.Timeval
|
||||
8
vendor/github.com/knq/sysutil/timeval32.go
generated
vendored
Normal file
8
vendor/github.com/knq/sysutil/timeval32.go
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
// +build darwin freebsd
|
||||
|
||||
package sysutil
|
||||
|
||||
type timeval struct {
|
||||
Sec int32
|
||||
Usec int32
|
||||
}
|
||||
Reference in New Issue
Block a user