1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

An experimental attempt to kill the zombie processes

This commit is contained in:
Chris Cummer 2018-04-02 11:00:45 -07:00 committed by Chris Cummer
parent 202d5ca95e
commit 62502c24d0
5 changed files with 50 additions and 7 deletions

View File

@ -60,13 +60,13 @@ func (widget *Widget) contentFrom(items []Item) string {
str := ""
for _, item := range items {
str = str + widget.display(item)
str = str + widget.format(item)
}
return str
}
func (widget *Widget) display(item Item) string {
func (widget *Widget) format(item Item) string {
var str string
if item.IsOneDay() {

33
opsgenie/client.go Normal file
View File

@ -0,0 +1,33 @@
package opsgenie
import (
"os"
ogcli "github.com/opsgenie/opsgenie-go-sdk/client"
sch "github.com/opsgenie/opsgenie-go-sdk/schedule"
)
func Fetch() string {
apiKey := os.Getenv("WTF_OPS_GENIE_API_KEY")
cli := new(ogcli.OpsGenieClient)
cli.SetAPIKey(apiKey)
scheduler, err := cli.Schedule()
if err != nil {
panic(err)
}
request := sch.ListSchedulesRequest{}
response, err := scheduler.List(request)
if err != nil {
panic(err)
}
var str string
for _, schedule := range response.Schedules {
str = str + schedule.Name + "\n"
}
return ""
}

View File

@ -1,7 +1,7 @@
package opsgenie
import (
"fmt"
//"fmt"
"time"
"github.com/rivo/tview"
@ -31,11 +31,13 @@ func NewWidget() *Widget {
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
//data := Fetch()
widget.View.SetTitle(" OpsGenie ")
widget.RefreshedAt = time.Now()
widget.View.Clear()
fmt.Fprintf(widget.View, "%s", "opsgenie")
//fmt.Fprintf(widget.View, "%s", widget.contentFrom(data))
}
/* -------------------- Unexported Functions -------------------- */
@ -49,3 +51,7 @@ func (widget *Widget) addView() {
widget.View = view
}
func (widget *Widget) contentFrom(data string) string {
return data
}

View File

@ -7,12 +7,14 @@ import (
)
func Fetch() *owm.CurrentWeatherData {
w, err := owm.NewCurrent("C", "EN", os.Getenv("WTF_OWM_API_KEY"))
apiKey := os.Getenv("WTF_OWM_API_KEY")
weather, err := owm.NewCurrent("C", "EN", apiKey)
if err != nil {
panic(err)
}
w.CurrentByID(6173331)
weather.CurrentByID(6173331)
return w
return weather
}

View File

@ -25,5 +25,7 @@ func ExecuteCommand(cmd *exec.Cmd) string {
str += string(b)
}
cmd.Wait()
return str
}