1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-26 13:48:59 +08:00

add NotImplementedError as fixed variable.

This commit is contained in:
WAKAYAMA shirou 2014-08-07 17:11:24 +09:00
parent d08c3d9b78
commit 594816dd1f
7 changed files with 72 additions and 74 deletions

View File

@ -12,8 +12,11 @@ import (
"reflect" "reflect"
"strconv" "strconv"
"strings" "strings"
"errors"
) )
var NotImplementedError = errors.New("not implemented yet")
// readLines read contents from file and split by new line. // readLines read contents from file and split by new line.
func readLines(filename string) ([]string, error) { func readLines(filename string) ([]string, error) {
f, err := os.Open(filename) f, err := os.Open(filename)

View File

@ -3,7 +3,6 @@
package gopsutil package gopsutil
import ( import (
"errors"
"syscall" "syscall"
"unsafe" "unsafe"
) )
@ -83,7 +82,7 @@ func DiskPartitions(all bool) ([]DiskPartitionStat, error) {
} }
func DiskIOCounters() (map[string]DiskIOCountersStat, error) { func DiskIOCounters() (map[string]DiskIOCountersStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
// statinfo->devinfo->devstat // statinfo->devinfo->devstat
// /usr/include/devinfo.h // /usr/include/devinfo.h

View File

@ -4,7 +4,6 @@ package gopsutil
import ( import (
"bytes" "bytes"
"errors"
"syscall" "syscall"
"unsafe" "unsafe"
) )
@ -109,5 +108,5 @@ func DiskPartitions(all bool) ([]DiskPartitionStat, error) {
func DiskIOCounters() (map[string]DiskIOCountersStat, error) { func DiskIOCounters() (map[string]DiskIOCountersStat, error) {
ret := make(map[string]DiskIOCountersStat, 0) ret := make(map[string]DiskIOCountersStat, 0)
return ret, errors.New("not implemented yet") return ret, NotImplementedError
} }

View File

@ -3,7 +3,6 @@
package gopsutil package gopsutil
import ( import (
"errors"
"net" "net"
"os" "os"
"syscall" "syscall"
@ -72,7 +71,7 @@ func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) {
func NetConnections(kind string) ([]NetConnectionStat, error) { func NetConnections(kind string) ([]NetConnectionStat, error) {
var ret []NetConnectionStat var ret []NetConnectionStat
return ret, errors.New("not implemented yet") return ret, NotImplementedError
} }
// borrowed from src/pkg/net/interface_windows.go // borrowed from src/pkg/net/interface_windows.go

View File

@ -5,7 +5,6 @@ package gopsutil
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"errors"
"syscall" "syscall"
"unsafe" "unsafe"
) )
@ -48,19 +47,19 @@ func (p *Process) Name() (string, error) {
return string(k.KiComm[:]), nil return string(k.KiComm[:]), nil
} }
func (p *Process) Exe() (string, error) { func (p *Process) Exe() (string, error) {
return "", errors.New("not implemented yet") return "", NotImplementedError
} }
func (p *Process) Cmdline() (string, error) { func (p *Process) Cmdline() (string, error) {
return "", errors.New("not implemented yet") return "", NotImplementedError
} }
func (p *Process) CreateTime() (int64, error) { func (p *Process) CreateTime() (int64, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) Cwd() (string, error) { func (p *Process) Cwd() (string, error) {
return "", errors.New("not implemented yet") return "", NotImplementedError
} }
func (p *Process) Parent() (*Process, error) { func (p *Process) Parent() (*Process, error) {
return p, errors.New("not implemented yet") return p, NotImplementedError
} }
func (p *Process) Status() (string, error) { func (p *Process) Status() (string, error) {
k, err := p.getKProc() k, err := p.getKProc()
@ -71,7 +70,7 @@ func (p *Process) Status() (string, error) {
return string(k.KiStat[:]), nil return string(k.KiStat[:]), nil
} }
func (p *Process) Username() (string, error) { func (p *Process) Username() (string, error) {
return "", errors.New("not implemented yet") return "", NotImplementedError
} }
func (p *Process) Uids() ([]int32, error) { func (p *Process) Uids() ([]int32, error) {
k, err := p.getKProc() k, err := p.getKProc()
@ -112,23 +111,23 @@ func (p *Process) Terminal() (string, error) {
return termmap[ttyNr], nil return termmap[ttyNr], nil
} }
func (p *Process) Nice() (int32, error) { func (p *Process) Nice() (int32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) IOnice() (int32, error) { func (p *Process) IOnice() (int32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) Rlimit() ([]RlimitStat, error) { func (p *Process) Rlimit() ([]RlimitStat, error) {
var rlimit []RlimitStat var rlimit []RlimitStat
return rlimit, errors.New("not implemented yet") return rlimit, NotImplementedError
} }
func (p *Process) IOCounters() (*IOCountersStat, error) { func (p *Process) IOCounters() (*IOCountersStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) { func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) NumFDs() (int32, error) { func (p *Process) NumFDs() (int32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) NumThreads() (int32, error) { func (p *Process) NumThreads() (int32, error) {
k, err := p.getKProc() k, err := p.getKProc()
@ -140,16 +139,16 @@ func (p *Process) NumThreads() (int32, error) {
} }
func (p *Process) Threads() (map[string]string, error) { func (p *Process) Threads() (map[string]string, error) {
ret := make(map[string]string, 0) ret := make(map[string]string, 0)
return ret, errors.New("not implemented yet") return ret, NotImplementedError
} }
func (p *Process) CPUTimes() (*CPUTimesStat, error) { func (p *Process) CPUTimes() (*CPUTimesStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) CPUPercent() (int32, error) { func (p *Process) CPUPercent() (int32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) CPUAffinity() ([]int32, error) { func (p *Process) CPUAffinity() ([]int32, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) { func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
k, err := p.getKProc() k, err := p.getKProc()
@ -165,30 +164,30 @@ func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
return ret, nil return ret, nil
} }
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) MemoryPercent() (float32, error) { func (p *Process) MemoryPercent() (float32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) Children() ([]*Process, error) { func (p *Process) Children() ([]*Process, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) OpenFiles() ([]OpenFilesStat, error) { func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) Connections() ([]NetConnectionStat, error) { func (p *Process) Connections() ([]NetConnectionStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) IsRunning() (bool, error) { func (p *Process) IsRunning() (bool, error) {
return true, errors.New("not implemented yet") return true, NotImplementedError
} }
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) { func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
var ret []MemoryMapsStat var ret []MemoryMapsStat
return &ret, errors.New("not implemented yet") return &ret, NotImplementedError
} }
func copyParams(k *KinfoProc, p *Process) error { func copyParams(k *KinfoProc, p *Process) error {

View File

@ -4,7 +4,6 @@ package gopsutil
import ( import (
"encoding/json" "encoding/json"
"errors"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -93,7 +92,7 @@ func (p *Process) Cwd() (string, error) {
return p.fillFromCwd() return p.fillFromCwd()
} }
func (p *Process) Parent() (*Process, error) { func (p *Process) Parent() (*Process, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) Status() (string, error) { func (p *Process) Status() (string, error) {
_, status, _, _, _, _, err := p.fillFromStatus() _, status, _, _, _, _, err := p.fillFromStatus()
@ -134,10 +133,10 @@ func (p *Process) Nice() (int32, error) {
return nice, nil return nice, nil
} }
func (p *Process) IOnice() (int32, error) { func (p *Process) IOnice() (int32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) Rlimit() ([]RlimitStat, error) { func (p *Process) Rlimit() ([]RlimitStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) IOCounters() (*IOCountersStat, error) { func (p *Process) IOCounters() (*IOCountersStat, error) {
return p.fillFromIO() return p.fillFromIO()
@ -150,7 +149,7 @@ func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
return numCtxSwitches, nil return numCtxSwitches, nil
} }
func (p *Process) NumFDs() (int32, error) { func (p *Process) NumFDs() (int32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) NumThreads() (int32, error) { func (p *Process) NumThreads() (int32, error) {
_, _, _, _, numThreads, _, err := p.fillFromStatus() _, _, _, _, numThreads, _, err := p.fillFromStatus()
@ -171,10 +170,10 @@ func (p *Process) CPUTimes() (*CPUTimesStat, error) {
return cpuTimes, nil return cpuTimes, nil
} }
func (p *Process) CPUPpercent() (int32, error) { func (p *Process) CPUPpercent() (int32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) CPUAffinity() ([]int32, error) { func (p *Process) CPUAffinity() ([]int32, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) { func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
memInfo, _, err := p.fillFromStatm() memInfo, _, err := p.fillFromStatm()
@ -191,23 +190,23 @@ func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
return memInfoEx, nil return memInfoEx, nil
} }
func (p *Process) MemoryPercent() (float32, error) { func (p *Process) MemoryPercent() (float32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) Children() ([]*Process, error) { func (p *Process) Children() ([]*Process, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) OpenFiles() ([]OpenFilesStat, error) { func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) Connections() ([]NetConnectionStat, error) { func (p *Process) Connections() ([]NetConnectionStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) IsRunning() (bool, error) { func (p *Process) IsRunning() (bool, error) {
return true, errors.New("not implemented yet") return true, NotImplementedError
} }
// MemoryMaps get memory maps from /proc/(pid)/smaps // MemoryMaps get memory maps from /proc/(pid)/smaps

View File

@ -61,7 +61,7 @@ func (p *Process) Ppid() (int32, error) {
} }
func (p *Process) Name() (string, error) { func (p *Process) Name() (string, error) {
name := "" name := ""
return name, errors.New("not implemented yet") return name, NotImplementedError
} }
func (p *Process) Exe() (string, error) { func (p *Process) Exe() (string, error) {
_, _, ret, err := p.getFromSnapProcess(p.Pid) _, _, ret, err := p.getFromSnapProcess(p.Pid)
@ -71,51 +71,51 @@ func (p *Process) Exe() (string, error) {
return ret, nil return ret, nil
} }
func (p *Process) Cmdline() (string, error) { func (p *Process) Cmdline() (string, error) {
return "", errors.New("not implemented yet") return "", NotImplementedError
} }
func (p *Process) Cwd() (string, error) { func (p *Process) Cwd() (string, error) {
return "", errors.New("not implemented yet") return "", NotImplementedError
} }
func (p *Process) Parent() (*Process, error) { func (p *Process) Parent() (*Process, error) {
return p, errors.New("not implemented yet") return p, NotImplementedError
} }
func (p *Process) Status() (string, error) { func (p *Process) Status() (string, error) {
return "", errors.New("not implemented yet") return "", NotImplementedError
} }
func (p *Process) Username() (string, error) { func (p *Process) Username() (string, error) {
return "", errors.New("not implemented yet") return "", NotImplementedError
} }
func (p *Process) Uids() ([]int32, error) { func (p *Process) Uids() ([]int32, error) {
var uids []int32 var uids []int32
return uids, errors.New("not implemented yet") return uids, NotImplementedError
} }
func (p *Process) Gids() ([]int32, error) { func (p *Process) Gids() ([]int32, error) {
var gids []int32 var gids []int32
return gids, errors.New("not implemented yet") return gids, NotImplementedError
} }
func (p *Process) Terminal() (string, error) { func (p *Process) Terminal() (string, error) {
return "", errors.New("not implemented yet") return "", NotImplementedError
} }
func (p *Process) Nice() (int32, error) { func (p *Process) Nice() (int32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) IOnice() (int32, error) { func (p *Process) IOnice() (int32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) Rlimit() ([]RlimitStat, error) { func (p *Process) Rlimit() ([]RlimitStat, error) {
var rlimit []RlimitStat var rlimit []RlimitStat
return rlimit, errors.New("not implemented yet") return rlimit, NotImplementedError
} }
func (p *Process) IOCounters() (*IOCountersStat, error) { func (p *Process) IOCounters() (*IOCountersStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) { func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) NumFDs() (int32, error) { func (p *Process) NumFDs() (int32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) NumThreads() (int32, error) { func (p *Process) NumThreads() (int32, error) {
_, ret, _, err := p.getFromSnapProcess(p.Pid) _, ret, _, err := p.getFromSnapProcess(p.Pid)
@ -126,46 +126,46 @@ func (p *Process) NumThreads() (int32, error) {
} }
func (p *Process) Threads() (map[string]string, error) { func (p *Process) Threads() (map[string]string, error) {
ret := make(map[string]string, 0) ret := make(map[string]string, 0)
return ret, errors.New("not implemented yet") return ret, NotImplementedError
} }
func (p *Process) CPUTimes() (*CPUTimesStat, error) { func (p *Process) CPUTimes() (*CPUTimesStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) CPUPercent() (int32, error) { func (p *Process) CPUPercent() (int32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) CPUAffinity() ([]int32, error) { func (p *Process) CPUAffinity() ([]int32, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) { func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) MemoryPercent() (float32, error) { func (p *Process) MemoryPercent() (float32, error) {
return 0, errors.New("not implemented yet") return 0, NotImplementedError
} }
func (p *Process) Children() ([]*Process, error) { func (p *Process) Children() ([]*Process, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) OpenFiles() ([]OpenFilesStat, error) { func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) Connections() ([]NetConnectionStat, error) { func (p *Process) Connections() ([]NetConnectionStat, error) {
return nil, errors.New("not implemented yet") return nil, NotImplementedError
} }
func (p *Process) IsRunning() (bool, error) { func (p *Process) IsRunning() (bool, error) {
return true, errors.New("not implemented yet") return true, NotImplementedError
} }
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) { func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
ret := make([]MemoryMapsStat, 0) ret := make([]MemoryMapsStat, 0)
return &ret, errors.New("not implemented yet") return &ret, NotImplementedError
} }
func NewProcess(pid int32) (*Process, error) { func NewProcess(pid int32) (*Process, error) {
@ -175,20 +175,20 @@ func NewProcess(pid int32) (*Process, error) {
} }
func (p *Process) SendSignal(sig syscall.Signal) error { func (p *Process) SendSignal(sig syscall.Signal) error {
return errors.New("not implemented yet") return NotImplementedError
} }
func (p *Process) Suspend() error { func (p *Process) Suspend() error {
return errors.New("not implemented yet") return NotImplementedError
} }
func (p *Process) Resume() error { func (p *Process) Resume() error {
return errors.New("not implemented yet") return NotImplementedError
} }
func (p *Process) Terminate() error { func (p *Process) Terminate() error {
return errors.New("not implemented yet") return NotImplementedError
} }
func (p *Process) Kill() error { func (p *Process) Kill() error {
return errors.New("not implemented yet") return NotImplementedError
} }
func (p *Process) getFromSnapProcess(pid int32) (int32, int32, string, error) { func (p *Process) getFromSnapProcess(pid int32) (int32, int32, string, error) {