From 17674400901d97a8193268b8ec506771a8f8f117 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Mon, 6 May 2019 19:40:12 +0300 Subject: [PATCH 01/14] iniy --- Makefile | 16 ++++++++-------- styles/default/images/logo-white.svg | 12 ++++++++++++ ui/splash.go | 2 +- ui/system.go | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 styles/default/images/logo-white.svg diff --git a/Makefile b/Makefile index f91dbc2..512e500 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ WORKDIR := $(shell pwd) BUILD_PATH := $(WORKDIR)/build DOCKER_IMAGE_BUILD = mcuadros/octoprint-tft-build -DEBIAN_PACKAGES = JESSIE STRETCH +DEBIAN_PACKAGES = STRETCH STRETCH_NAME := stretch STRETCH_IMAGE := golang:1.9-stretch STRETCH_GO_TAGS := gtk_3_22 @@ -26,15 +26,15 @@ JESSIE_GO_TAGS := gtk_3_14 # Build information -GIT_COMMIT = $(shell git rev-parse HEAD | cut -c1-7) -DEV_PREFIX := 0.0 -VERSION ?= $(DEV_PREFIX)~git$(GIT_COMMIT) +#GIT_COMMIT = $(shell git rev-parse HEAD | cut -c1-7) +#DEV_PREFIX := 1.0 +VERSION := 1.2 BUILD_DATE ?= $(shell date --utc +%Y%m%d-%H:%M:%S) -BRANCH = $(shell git rev-parse --abbrev-ref HEAD) +#BRANCH = $(shell git rev-parse --abbrev-ref HEAD) -ifneq ($(BRANCH), master) - VERSION := $(shell echo $(BRANCH)| sed -e 's/v//g') -endif +#ifneq ($(BRANCH), master) +# VERSION := $(shell echo $(BRANCH)| sed -e 's/v//g') +#endif # Package information PACKAGE_NAME = octoprint-tft diff --git a/styles/default/images/logo-white.svg b/styles/default/images/logo-white.svg new file mode 100644 index 0000000..1bd4d0b --- /dev/null +++ b/styles/default/images/logo-white.svg @@ -0,0 +1,12 @@ + + + + Slice + Created with Sketch. + + + + + + + \ No newline at end of file diff --git a/ui/splash.go b/ui/splash.go index c421f57..14ef9d3 100644 --- a/ui/splash.go +++ b/ui/splash.go @@ -14,7 +14,7 @@ func NewSplashPanel(ui *UI) *SplashPanel { } func (m *SplashPanel) initialize() { - logo := MustImageFromFile("octoprint-logo.png") + logo := MustImageFromFile("logo-white.svg") m.Label = MustLabel("Connecting to OctoPrint...") box := MustBox(gtk.ORIENTATION_VERTICAL, 15) diff --git a/ui/system.go b/ui/system.go index 6f51367..0d38b5f 100644 --- a/ui/system.go +++ b/ui/system.go @@ -101,7 +101,7 @@ func (m *systemPanel) createInfoBox() gtk.IWidget { main.SetHExpand(true) main.SetHAlign(gtk.ALIGN_CENTER) main.SetVExpand(true) - main.Add(MustImageFromFileWithSize("octoprint-logo.png", 140, 140)) + main.Add(MustImageFromFileWithSize("logo-white.svg", 140, 140)) info := MustBox(gtk.ORIENTATION_VERTICAL, 0) info.SetVExpand(true) From e40df138f2c3533c7d7cabeab91bfceb4c05cbd6 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Sun, 26 May 2019 11:57:14 +0300 Subject: [PATCH 02/14] added logo, 4 extruder support, info about IP address --- .gitignore | 1 + main.go | 2 ++ ui/common.go | 3 ++- ui/splash.go | 2 +- ui/status.go | 49 ++++++++++++++++++++++++++++------------- ui/system.go | 61 +++++++++++++++++++++++++++++++--------------------- 6 files changed, 76 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 31899a0..2642ee7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build debian/changelog +pkg/ diff --git a/main.go b/main.go index c51de09..510f11b 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( "strings" "github.com/mcuadros/OctoPrint-TFT/ui" + // "github.com/me/OctoPrint-TFT/ui" "github.com/gotk3/gotk3/gtk" "gopkg.in/yaml.v1" @@ -61,6 +62,7 @@ func main() { gtk.Init(nil) settings, _ := gtk.SettingsGetDefault() + settings.SetProperty("gtk-application-prefer-dark-theme", true) width, height := getSize() diff --git a/ui/common.go b/ui/common.go index c0f4dc7..8373be7 100644 --- a/ui/common.go +++ b/ui/common.go @@ -17,7 +17,8 @@ var Version = "0.1.x" var Build = "no-set" const panelW = 4 -const panelH = 2 + +var panelH = 2 type Panel interface { Grid() *gtk.Grid diff --git a/ui/splash.go b/ui/splash.go index 14ef9d3..2114547 100644 --- a/ui/splash.go +++ b/ui/splash.go @@ -15,7 +15,7 @@ func NewSplashPanel(ui *UI) *SplashPanel { func (m *SplashPanel) initialize() { logo := MustImageFromFile("logo-white.svg") - m.Label = MustLabel("Connecting to OctoPrint...") + m.Label = MustLabel("Initializing printer...") box := MustBox(gtk.ORIENTATION_VERTICAL, 15) box.SetVAlign(gtk.ALIGN_CENTER) diff --git a/ui/status.go b/ui/status.go index 5e11611..afb6ea3 100644 --- a/ui/status.go +++ b/ui/status.go @@ -11,14 +11,16 @@ import ( var statusPanelInstance *statusPanel +// var panelH = 3 + type statusPanel struct { CommonPanel step *StepButton pb *gtk.ProgressBar - bed, tool0, tool1 *LabelWithImage - file, left *LabelWithImage - print, pause, stop *gtk.Button + bed, tool0, tool1, tool2, tool3 *LabelWithImage + file, left *LabelWithImage + print, pause, stop *gtk.Button } func StatusPanel(ui *UI, parent Panel) Panel { @@ -34,12 +36,13 @@ func StatusPanel(ui *UI, parent Panel) Panel { } func (m *statusPanel) initialize() { + panelH = 3 defer m.Initialize() - m.Grid().Attach(m.createMainBox(), 1, 0, 4, 1) - m.Grid().Attach(m.createPrintButton(), 1, 1, 1, 1) - m.Grid().Attach(m.createPauseButton(), 2, 1, 1, 1) - m.Grid().Attach(m.createStopButton(), 3, 1, 1, 1) + m.Grid().Attach(m.createMainBox(), 1, 0, 4, 2) + m.Grid().Attach(m.createPrintButton(), 1, 2, 1, 1) + m.Grid().Attach(m.createPauseButton(), 2, 2, 1, 1) + m.Grid().Attach(m.createStopButton(), 3, 2, 1, 1) } func (m *statusPanel) createProgressBar() *gtk.ProgressBar { @@ -86,6 +89,8 @@ func (m *statusPanel) createTemperatureBox() *gtk.Box { m.bed = MustLabelWithImage("bed.svg", "") m.tool0 = MustLabelWithImage("extruder.svg", "") m.tool1 = MustLabelWithImage("extruder.svg", "") + m.tool2 = MustLabelWithImage("extruder.svg", "") + m.tool3 = MustLabelWithImage("extruder.svg", "") temp := MustBox(gtk.ORIENTATION_VERTICAL, 5) temp.SetHAlign(gtk.ALIGN_START) @@ -94,6 +99,8 @@ func (m *statusPanel) createTemperatureBox() *gtk.Box { temp.Add(m.bed) temp.Add(m.tool0) temp.Add(m.tool1) + temp.Add(m.tool2) + temp.Add(m.tool3) return temp } @@ -156,6 +163,9 @@ func (m *statusPanel) updateTemperature() { m.doUpdateState(&s.State) m.tool1.Hide() + m.tool2.Hide() + m.tool3.Hide() + for tool, s := range s.Temperature.Current { text := fmt.Sprintf("%s: %.0f°C / %.0f°C", strings.Title(tool), s.Actual, s.Target) switch tool { @@ -166,6 +176,12 @@ func (m *statusPanel) updateTemperature() { case "tool1": m.tool1.Label.SetLabel(text) m.tool1.Show() + case "tool2": + m.tool2.Label.SetLabel(text) + m.tool2.Show() + case "tool3": + m.tool3.Label.SetLabel(text) + m.tool3.Show() } } } @@ -224,20 +240,23 @@ func (m *statusPanel) updateJob() { case 0: text = "Warming up ..." default: - e := time.Duration(int64(s.Progress.PrintTime) * 1e9) - l := time.Duration(int64(s.Progress.PrintTimeLeft) * 1e9) - text = fmt.Sprintf("Elapsed/Left: %s / %s", e, l) - if l == 0 { - text = fmt.Sprintf("Elapsed: %s", e) - } + text = "Printing in progess ;)" + // e := time.Duration(int64(s.Progress.PrintTime) * 1e9) + // l := time.Duration(int64(s.Progress.PrintTimeLeft) * 1e9) + // // eta := time.Now().Add(l).Format("3:04 PM") + // if l == 0 { + // text = fmt.Sprintf("Elapsed: %s", e) + // } else { + // text = fmt.Sprintf("Elapsed: %s | Left: %s", e, l) + // } } m.left.Label.SetLabel(text) } func filenameEllipsis(name string) string { - if len(name) > 26 { - return name[:23] + "..." + if len(name) > 46 { + return name[:43] + "..." } return name diff --git a/ui/system.go b/ui/system.go index 0d38b5f..7db1b97 100644 --- a/ui/system.go +++ b/ui/system.go @@ -1,9 +1,8 @@ package ui import ( - "bytes" "fmt" - "io/ioutil" + "net" "github.com/dustin/go-humanize" "github.com/gotk3/gotk3/gtk" @@ -101,20 +100,17 @@ func (m *systemPanel) createInfoBox() gtk.IWidget { main.SetHExpand(true) main.SetHAlign(gtk.ALIGN_CENTER) main.SetVExpand(true) - main.Add(MustImageFromFileWithSize("logo-white.svg", 140, 140)) + + img := MustImageFromFileWithSize("logo-white.svg", 140, 112) + img.SetMarginTop(35) + main.Add(img) info := MustBox(gtk.ORIENTATION_VERTICAL, 0) info.SetVExpand(true) info.SetVAlign(gtk.ALIGN_CENTER) - m.addOctoPrintTFT(info) - - title := MustLabel("Versions Information") - title.SetMarginTop(15) - title.SetMarginBottom(5) - info.Add(title) + m.addNetwork(info) m.addOctoPrint(info) - m.addOctoPi(info) m.addSystemInfo(info) main.Add(info) @@ -122,35 +118,50 @@ func (m *systemPanel) createInfoBox() gtk.IWidget { return main } -func (m *systemPanel) addOctoPrintTFT(box *gtk.Box) { - title := MustLabel("OctoPrint-TFT Version") - title.SetMarginBottom(5) +// func (m *systemPanel) addOctoPrintTFT(box *gtk.Box) { +// title := MustLabel("OctoPrint-TFT Version") +// title.SetMarginTop(15) +// title.SetMarginBottom(5) - info := MustBox(gtk.ORIENTATION_VERTICAL, 0) - box.Add(info) +// info := MustBox(gtk.ORIENTATION_VERTICAL, 0) +// box.Add(info) - info.Add(title) - info.Add(MustLabel("%s (%s)", Version, Build)) -} +// info.Add(title) +// info.Add(MustLabel("%s (%s)", Version, Build)) +// } -func (m *systemPanel) addOctoPi(box *gtk.Box) { - v, err := ioutil.ReadFile("/etc/octopi_version") - if err != nil { - Logger.Error(err) - return - } +func (m *systemPanel) addNetwork(box *gtk.Box) { + title := MustLabel("Network Information") + title.SetMarginTop(40) + title.SetMarginBottom(5) + + box.Add(title) + addrs, _ := net.InterfaceAddrs() - box.Add(MustLabel("OctoPi Version: %s", bytes.Trim(v, "\n"))) + for _, address := range addrs { + if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() { + if ipnet.IP.To4() != nil { + box.Add(MustLabel("IP Address %s", ipnet.IP.String())) + } + } + } } func (m *systemPanel) addOctoPrint(box *gtk.Box) { + title := MustLabel("Versions Information") + title.SetMarginTop(15) + title.SetMarginBottom(5) + box.Add(title) + r, err := (&octoprint.VersionRequest{}).Do(m.UI.Printer) if err != nil { Logger.Error(err) return } + box.Add(MustLabel("UI Version: %s (%s)", Version, Build)) box.Add(MustLabel("OctoPrint Version: %s (%s)", r.Server, r.API)) + } func (m *systemPanel) addSystemInfo(box *gtk.Box) { From 70b12f1d60552ddef0eead89728b9835e18f2329 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Tue, 28 May 2019 01:40:45 +0300 Subject: [PATCH 03/14] added folders support, improved scrolling and some more minor things --- main.go | 4 +- styles/default/images/open.svg | 11 ++ styles/default/style.css | 8 ++ ui/common.go | 26 ++-- ui/filament.go | 13 +- ui/files.go | 128 ++++++++++++++---- ui/status.go | 27 ++-- .../mcuadros/go-octoprint/common.go | 5 +- .../github.com/mcuadros/go-octoprint/files.go | 4 + 9 files changed, 166 insertions(+), 60 deletions(-) create mode 100644 styles/default/images/open.svg diff --git a/main.go b/main.go index 510f11b..742c9d2 100644 --- a/main.go +++ b/main.go @@ -9,10 +9,8 @@ import ( "strconv" "strings" - "github.com/mcuadros/OctoPrint-TFT/ui" - // "github.com/me/OctoPrint-TFT/ui" - "github.com/gotk3/gotk3/gtk" + "github.com/mcuadros/OctoPrint-TFT/ui" "gopkg.in/yaml.v1" ) diff --git a/styles/default/images/open.svg b/styles/default/images/open.svg new file mode 100644 index 0000000..7e5b3c8 --- /dev/null +++ b/styles/default/images/open.svg @@ -0,0 +1,11 @@ + + + + open + Created with Sketch. + + + + + + \ No newline at end of file diff --git a/styles/default/style.css b/styles/default/style.css index c847e9e..b928668 100644 --- a/styles/default/style.css +++ b/styles/default/style.css @@ -14,3 +14,11 @@ .error { background-color:rgba(204, 30, 30, 0.7); } + +scrollbar, scrollbar button, scrollbar slider { + -GtkScrollbar-has-backward-stepper: true; + -GtkScrollbar-has-forward-stepper: true; + min-width: 52px; + min-height: 52px; + border-radius: 0px; +} diff --git a/ui/common.go b/ui/common.go index 8373be7..490bf3a 100644 --- a/ui/common.go +++ b/ui/common.go @@ -16,10 +16,6 @@ import ( var Version = "0.1.x" var Build = "no-set" -const panelW = 4 - -var panelH = 2 - type Panel interface { Grid() *gtk.Grid Show() @@ -28,10 +24,12 @@ type Panel interface { } type CommonPanel struct { - UI *UI - g *gtk.Grid - b *BackgroundTask - p Panel + UI *UI + g *gtk.Grid + b *BackgroundTask + p Panel + panelW int + panelH int buttons []gtk.IWidget } @@ -41,14 +39,14 @@ func NewCommonPanel(ui *UI, parent Panel) CommonPanel { g.SetRowHomogeneous(true) g.SetColumnHomogeneous(true) - return CommonPanel{UI: ui, g: g, p: parent} + return CommonPanel{UI: ui, g: g, p: parent, panelW: 4, panelH: 2} } func (p *CommonPanel) Initialize() { - last := panelW * panelH + last := p.panelW * p.panelH if last < len(p.buttons) { - cols := math.Ceil(float64(len(p.buttons)) / float64(panelW)) - last = int(cols) * panelW + cols := math.Ceil(float64(len(p.buttons)) / float64(p.panelW)) + last = int(cols) * p.panelW } for i := len(p.buttons) + 1; i < last; i++ { @@ -63,8 +61,8 @@ func (p *CommonPanel) Parent() Panel { } func (p *CommonPanel) AddButton(b gtk.IWidget) { - x := len(p.buttons) % panelW - y := len(p.buttons) / panelW + x := len(p.buttons) % p.panelW + y := len(p.buttons) / p.panelW p.g.Attach(b, x+1, y, 1, 1) p.buttons = append(p.buttons, b) } diff --git a/ui/filament.go b/ui/filament.go index b1bc6a1..d2aac27 100644 --- a/ui/filament.go +++ b/ui/filament.go @@ -27,7 +27,7 @@ func FilamentPanel(ui *UI, parent Panel) Panel { m := &filamentPanel{CommonPanel: NewCommonPanel(ui, parent), labels: map[string]*LabelWithImage{}, } - + m.panelH = 3 m.b = NewBackgroundTask(time.Second*5, m.updateTemperatures) m.initialize() filamentPanelInstance = m @@ -39,6 +39,9 @@ func FilamentPanel(ui *UI, parent Panel) Panel { func (m *filamentPanel) initialize() { defer m.Initialize() + m.Grid().Attach(m.createExtrudeButton("Load", "extrude.svg", 1), 1, 1, 1, 1) + m.Grid().Attach(m.createExtrudeButton("Unload", "retract.svg", -1), 4, 1, 1, 1) + m.Grid().Attach(m.createExtrudeButton("Extrude", "extrude.svg", 1), 1, 0, 1, 1) m.Grid().Attach(m.createExtrudeButton("Retract", "retract.svg", -1), 4, 0, 1, 1) @@ -46,13 +49,13 @@ func (m *filamentPanel) initialize() { m.box.SetVAlign(gtk.ALIGN_CENTER) m.box.SetMarginStart(10) - m.Grid().Attach(m.box, 2, 0, 2, 1) + m.Grid().Attach(m.box, 2, 0, 2, 2) m.amount = MustStepButton("move-step.svg", Step{"5mm", 5}, Step{"10mm", 10}, Step{"1mm", 1}) - m.Grid().Attach(m.amount, 2, 1, 1, 1) + m.Grid().Attach(m.amount, 2, 2, 1, 1) - m.Grid().Attach(m.createToolButton(), 1, 1, 1, 1) - m.Grid().Attach(m.createFlowrateButton(), 3, 1, 1, 1) + m.Grid().Attach(m.createToolButton(), 1, 2, 1, 1) + m.Grid().Attach(m.createFlowrateButton(), 3, 2, 1, 1) } func (m *filamentPanel) updateTemperatures() { diff --git a/ui/files.go b/ui/files.go index 48baeee..07aca59 100644 --- a/ui/files.go +++ b/ui/files.go @@ -10,17 +10,44 @@ import ( "github.com/mcuadros/go-octoprint" ) +type locationHistory struct { + locations []octoprint.Location +} + +func (l *locationHistory) current() octoprint.Location { + return l.locations[len(l.locations)-1] +} + +func (l *locationHistory) goForward(folder string) { + newLocation := string(l.current()) + "/" + folder + l.locations = append(l.locations, octoprint.Location(newLocation)) +} + +func (l *locationHistory) goBack() { + l.locations = l.locations[0 : len(l.locations)-1] +} + +func (l *locationHistory) isRoot() bool { + if len(l.locations) > 1 { + return false + } else { + return true + } +} + var filesPanelInstance *filesPanel type filesPanel struct { CommonPanel - list *gtk.Box + list *gtk.Box + location locationHistory } func FilesPanel(ui *UI, parent Panel) Panel { if filesPanelInstance == nil { - m := &filesPanel{CommonPanel: NewCommonPanel(ui, parent)} + l := locationHistory{locations: []octoprint.Location{octoprint.Local}} + m := &filesPanel{CommonPanel: NewCommonPanel(ui, parent), location: l} m.initialize() filesPanelInstance = m } @@ -33,6 +60,7 @@ func (m *filesPanel) initialize() { m.list.SetVExpand(true) scroll, _ := gtk.ScrolledWindowNew(nil, nil) + scroll.SetProperty("overlay-scrolling", false) scroll.Add(m.list) box := MustBox(gtk.ORIENTATION_VERTICAL, 0) @@ -53,7 +81,7 @@ func (m *filesPanel) createActionBar() gtk.IWidget { bar.Add(m.createRefreshButton()) bar.Add(m.createInitReleaseSDButton()) - bar.Add(MustButton(MustImageFromFileWithSize("back.svg", 40, 40), m.UI.GoHistory)) + bar.Add(m.createBackButton()) return bar } @@ -62,24 +90,45 @@ func (m *filesPanel) createRefreshButton() gtk.IWidget { return MustButton(MustImageFromFileWithSize("refresh.svg", 40, 40), m.doLoadFiles) } +func (m *filesPanel) createBackButton() gtk.IWidget { + return MustButton(MustImageFromFileWithSize("back.svg", 40, 40), func() { + if m.location.isRoot() { + m.UI.GoHistory() + } else { + m.location.goBack() + m.doLoadFiles() + } + }) + // return MustButton(MustImageFromFileWithSize("refresh.svg", 40, 40), m.doLoadFiles) +} + func (m *filesPanel) doLoadFiles() { - Logger.Info("Refreshing list of files") + var files []*octoprint.FileInformation + + Logger.Info("Loading list of files from: ", string(m.location.current())) + m.doRefreshSD() - local := m.doLoadFilesFromLocation(octoprint.Local) - sdcard := m.doLoadFilesFromLocation(octoprint.SDCard) + r := &octoprint.FilesRequest{Location: m.location.current(), Recursive: false} + folder, err := r.Do(m.UI.Printer) + if err != nil { + Logger.Error(err) + files = []*octoprint.FileInformation{} + } else { + files = folder.Files + } - s := byDate(local) - s = append(s, sdcard...) + s := byDate(files) + // s = append(s, sdcard...) sort.Sort(s) EmptyContainer(&m.list.Container) for _, f := range s { if f.IsFolder() { - continue + m.addFolder(m.list, f) + } else { + m.addFile(m.list, f) } - - m.addFile(m.list, f) } m.list.ShowAll() @@ -91,17 +140,6 @@ func (m *filesPanel) doRefreshSD() { } } -func (m *filesPanel) doLoadFilesFromLocation(l octoprint.Location) []*octoprint.FileInformation { - r := &octoprint.FilesRequest{Location: l, Recursive: true} - files, err := r.Do(m.UI.Printer) - if err != nil { - Logger.Error(err) - return []*octoprint.FileInformation{} - } - - return files.Files -} - func (m *filesPanel) addFile(b *gtk.Box, f *octoprint.FileInformation) { frame, _ := gtk.FrameNew("") @@ -119,7 +157,7 @@ func (m *filesPanel) addFile(b *gtk.Box, f *octoprint.FileInformation) { labels.Add(info) actions := MustBox(gtk.ORIENTATION_HORIZONTAL, 5) - actions.Add(m.createLoadAndPrintButton("load.svg", f, false)) + // actions.Add(m.createLoadAndPrintButton("load.svg", f, false)) actions.Add(m.createLoadAndPrintButton("status.svg", f, true)) file := MustBox(gtk.ORIENTATION_HORIZONTAL, 5) @@ -138,6 +176,41 @@ func (m *filesPanel) addFile(b *gtk.Box, f *octoprint.FileInformation) { b.Add(frame) } +func (m *filesPanel) addFolder(b *gtk.Box, f *octoprint.FileInformation) { + frame, _ := gtk.FrameNew("") + + name := MustLabel(f.Name) + name.SetMarkup(fmt.Sprintf("%s", filenameEllipsis(f.Name))) + name.SetHExpand(true) + + info := MustLabel("") + info.SetMarkup(fmt.Sprintf("Size: %s", + humanize.Bytes(uint64(f.Size)), + )) + + labels := MustBox(gtk.ORIENTATION_VERTICAL, 5) + labels.Add(name) + labels.Add(info) + + actions := MustBox(gtk.ORIENTATION_HORIZONTAL, 5) + actions.Add(m.createOpenFolderButton(f)) + + file := MustBox(gtk.ORIENTATION_HORIZONTAL, 5) + file.SetMarginTop(15) + file.SetMarginEnd(15) + file.SetMarginStart(15) + file.SetMarginBottom(15) + file.SetHExpand(true) + + file.Add(MustImageFromFileWithSize("files.svg", 35, 35)) + + file.Add(labels) + file.Add(actions) + + frame.Add(file) + b.Add(frame) +} + func (m *filesPanel) createLoadAndPrintButton(img string, f *octoprint.FileInformation, print bool) gtk.IWidget { return MustButton( MustImageFromFileWithSize(img, 30, 30), @@ -156,6 +229,15 @@ func (m *filesPanel) createLoadAndPrintButton(img string, f *octoprint.FileInfor ) } +func (m *filesPanel) createOpenFolderButton(f *octoprint.FileInformation) gtk.IWidget { + return MustButton(MustImageFromFileWithSize("open.svg", 30, 30), func() { + m.location.goForward(f.Path) + // m.currentFolder = octoprint.Location(f.Origin + "/" + string()) + // m.parentFolder = octoprint.Location(f.Origin) + m.doLoadFiles() + }) +} + func (m *filesPanel) createInitReleaseSDButton() gtk.IWidget { release := MustImageFromFileWithSize("sd_eject.svg", 40, 40) init := MustImageFromFileWithSize("sd.svg", 40, 40) diff --git a/ui/status.go b/ui/status.go index afb6ea3..5ce7d2c 100644 --- a/ui/status.go +++ b/ui/status.go @@ -11,8 +11,6 @@ import ( var statusPanelInstance *statusPanel -// var panelH = 3 - type statusPanel struct { CommonPanel step *StepButton @@ -26,6 +24,7 @@ type statusPanel struct { func StatusPanel(ui *UI, parent Panel) Panel { if statusPanelInstance == nil { m := &statusPanel{CommonPanel: NewCommonPanel(ui, parent)} + m.panelH = 3 m.b = NewBackgroundTask(time.Second*5, m.update) m.initialize() @@ -36,7 +35,6 @@ func StatusPanel(ui *UI, parent Panel) Panel { } func (m *statusPanel) initialize() { - panelH = 3 defer m.Initialize() m.Grid().Attach(m.createMainBox(), 1, 0, 4, 2) @@ -240,23 +238,26 @@ func (m *statusPanel) updateJob() { case 0: text = "Warming up ..." default: + Logger.Info(s.Progress.PrintTime) + Logger.Info(s.Progress.PrintTimeLeft) text = "Printing in progess ;)" - // e := time.Duration(int64(s.Progress.PrintTime) * 1e9) - // l := time.Duration(int64(s.Progress.PrintTimeLeft) * 1e9) - // // eta := time.Now().Add(l).Format("3:04 PM") - // if l == 0 { - // text = fmt.Sprintf("Elapsed: %s", e) - // } else { - // text = fmt.Sprintf("Elapsed: %s | Left: %s", e, l) - // } + e := time.Duration(int64(s.Progress.PrintTime) * 1e9) + l := time.Duration(int64(s.Progress.PrintTimeLeft) * 1e9) + // eta := time.Now().Add(l).Format("3:04 PM") + if l == 0 { + text = fmt.Sprintf("Elapsed: %s", e) + } else { + text = fmt.Sprintf("Elapsed: %s | Left: %s", e, l) + } } m.left.Label.SetLabel(text) } func filenameEllipsis(name string) string { - if len(name) > 46 { - return name[:43] + "..." + l := len(name) + if l > 35 { + return name[:14] + "..." + name[l-18:l] } return name diff --git a/vendor/github.com/mcuadros/go-octoprint/common.go b/vendor/github.com/mcuadros/go-octoprint/common.go index b3d4cdd..1678b3c 100644 --- a/vendor/github.com/mcuadros/go-octoprint/common.go +++ b/vendor/github.com/mcuadros/go-octoprint/common.go @@ -249,7 +249,8 @@ type Profile struct { type FilesResponse struct { // Files is the list of requested files. Might be an empty list if no files // are available - Files []*FileInformation + Files []*FileInformation + Children []*FileInformation // Free is the amount of disk space in bytes available in the local disk // space (refers to OctoPrint’s `uploads` folder). Only returned if file // list was requested for origin `local` or all origins. @@ -390,7 +391,7 @@ type CommandDefinition struct { // confirmation dialog they have to acknowledge in order to really execute // the command. RawConfirm json.RawMessage `json:"confirm"` - Confirm string `json:"-"` + Confirm string `json:"-"` // Async whether to execute the command asynchronously or wait for its // result before responding to the HTTP execution request. Async bool `json:"async"` diff --git a/vendor/github.com/mcuadros/go-octoprint/files.go b/vendor/github.com/mcuadros/go-octoprint/files.go index 9b694db..fa3b789 100644 --- a/vendor/github.com/mcuadros/go-octoprint/files.go +++ b/vendor/github.com/mcuadros/go-octoprint/files.go @@ -98,6 +98,10 @@ func (cmd *FilesRequest) Do(c *Client) (*FilesResponse, error) { return nil, err } + if len(r.Children) > 0 { + r.Files = r.Children + } + return r, err } From 2de2fdbc639e6cdfd9dfd4d96ade41e0240b17d6 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Wed, 29 May 2019 21:58:58 +0300 Subject: [PATCH 04/14] added support of holding buttons --- ui/common.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/ui/common.go b/ui/common.go index 490bf3a..b67e6e2 100644 --- a/ui/common.go +++ b/ui/common.go @@ -159,6 +159,49 @@ type Step struct { Value interface{} } +func MustPressedButton(label, i string, pressed func(), speed time.Duration) *gtk.Button { + img := MustImageFromFile(i) + released := make(chan bool) + var mutex sync.Mutex + + b, err := gtk.ButtonNewWithLabel(label) + if err != nil { + panic(err) + } + + b.SetImage(img) + b.SetAlwaysShowImage(true) + b.SetImagePosition(gtk.POS_TOP) + b.SetVExpand(true) + b.SetHExpand(true) + + if pressed != nil { + b.Connect("pressed", func() { + go func() { + for { + select { + case <-released: + return + default: + mutex.Lock() + pressed() + time.Sleep(speed * time.Millisecond) + mutex.Unlock() + } + } + }() + }) + } + + if released != nil { + b.Connect("released", func() { + released <- true + }) + } + + return b +} + func MustStepButton(image string, s ...Step) *StepButton { var l string if len(s) != 0 { From d96d3a7566e7152befc5a87493a41fede8d7c5d5 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Wed, 29 May 2019 22:37:24 +0300 Subject: [PATCH 05/14] Added change filament function, improved movement screen, added button press and hold function to temperature, movement and filament screens --- ui/filament.go | 48 +++++++++++++++++++++++++++++++++++++++++++---- ui/files.go | 9 +-------- ui/move.go | 30 +++++++++++++++-------------- ui/status.go | 20 ++++++++++---------- ui/temperature.go | 9 +++++---- 5 files changed, 76 insertions(+), 40 deletions(-) diff --git a/ui/filament.go b/ui/filament.go index d2aac27..9c41585 100644 --- a/ui/filament.go +++ b/ui/filament.go @@ -39,8 +39,8 @@ func FilamentPanel(ui *UI, parent Panel) Panel { func (m *filamentPanel) initialize() { defer m.Initialize() - m.Grid().Attach(m.createExtrudeButton("Load", "extrude.svg", 1), 1, 1, 1, 1) - m.Grid().Attach(m.createExtrudeButton("Unload", "retract.svg", -1), 4, 1, 1, 1) + m.Grid().Attach(m.createLoadButton(), 1, 1, 1, 1) + m.Grid().Attach(m.createUnloadButton(), 4, 1, 1, 1) m.Grid().Attach(m.createExtrudeButton("Extrude", "extrude.svg", 1), 1, 0, 1, 1) m.Grid().Attach(m.createExtrudeButton("Retract", "retract.svg", -1), 4, 0, 1, 1) @@ -137,8 +137,37 @@ func (m *filamentPanel) createFlowrateButton() *StepButton { return b } +func (m *filamentPanel) createLoadButton() gtk.IWidget { + + return MustButtonImage("Load", "extrude.svg", func() { + cmd := &octoprint.CommandRequest{} + cmd.Commands = []string{"G92 E0", "G0 E600 F5000", "G92 E0", "G0 E65 F500"} + + Logger.Info("Sending filament load request") + if err := cmd.Do(m.UI.Printer); err != nil { + Logger.Error(err) + return + } + }) +} + +func (m *filamentPanel) createUnloadButton() gtk.IWidget { + + return MustButtonImage("Unload", "retract.svg", func() { + cmd := &octoprint.CommandRequest{} + cmd.Commands = []string{"G92 E0", "G0 E-800 F5000"} + + Logger.Info("Sending filament unload request") + if err := cmd.Do(m.UI.Printer); err != nil { + Logger.Error(err) + return + } + }) +} + func (m *filamentPanel) createExtrudeButton(label, image string, dir int) gtk.IWidget { - return MustButtonImage(label, image, func() { + + return MustPressedButton(label, image, func() { cmd := &octoprint.ToolExtrudeRequest{} cmd.Amount = m.amount.Value().(int) * dir @@ -147,5 +176,16 @@ func (m *filamentPanel) createExtrudeButton(label, image string, dir int) gtk.IW Logger.Error(err) return } - }) + }, 200) + + // return MustButtonImage(label, image, func() { + // cmd := &octoprint.ToolExtrudeRequest{} + // cmd.Amount = m.amount.Value().(int) * dir + + // Logger.Infof("Sending extrude request, with amount %d", cmd.Amount) + // if err := cmd.Do(m.UI.Printer); err != nil { + // Logger.Error(err) + // return + // } + // }) } diff --git a/ui/files.go b/ui/files.go index 07aca59..b9fc31d 100644 --- a/ui/files.go +++ b/ui/files.go @@ -107,8 +107,7 @@ func (m *filesPanel) doLoadFiles() { Logger.Info("Loading list of files from: ", string(m.location.current())) - m.doRefreshSD() - + // m.doRefreshSD() r := &octoprint.FilesRequest{Location: m.location.current(), Recursive: false} folder, err := r.Do(m.UI.Printer) if err != nil { @@ -134,12 +133,6 @@ func (m *filesPanel) doLoadFiles() { m.list.ShowAll() } -func (m *filesPanel) doRefreshSD() { - if err := (&octoprint.SDRefreshRequest{}).Do(m.UI.Printer); err != nil { - Logger.Error(err) - } -} - func (m *filesPanel) addFile(b *gtk.Box, f *octoprint.FileInformation) { frame, _ := gtk.FrameNew("") diff --git a/ui/move.go b/ui/move.go index b199b94..923672d 100644 --- a/ui/move.go +++ b/ui/move.go @@ -1,8 +1,6 @@ package ui import ( - "strings" - "github.com/gotk3/gotk3/gtk" "github.com/mcuadros/go-octoprint" ) @@ -17,6 +15,8 @@ type movePanel struct { func MovePanel(ui *UI, parent Panel) Panel { if movePanelInstance == nil { m := &movePanel{CommonPanel: NewCommonPanel(ui, parent)} + m.panelH = 3 + m.panelW = 3 m.initialize() movePanelInstance = m } @@ -26,23 +26,24 @@ func MovePanel(ui *UI, parent Panel) Panel { func (m *movePanel) initialize() { defer m.Initialize() + m.Grid().Attach(m.createMoveButton("X-", "move-x-.svg", octoprint.XAxis, -1), 0, 1, 1, 1) + m.Grid().Attach(m.createMoveButton("X+", "move-x+.svg", octoprint.XAxis, 1), 2, 1, 1, 1) + m.Grid().Attach(m.createMoveButton("Y+", "move-y+.svg", octoprint.YAxis, 1), 1, 0, 1, 1) + m.Grid().Attach(m.createMoveButton("Y-", "move-y-.svg", octoprint.YAxis, -1), 1, 2, 1, 1) - m.AddButton(m.createMoveButton("X+", "move-x+.svg", octoprint.XAxis, 1)) - m.AddButton(m.createMoveButton("Y+", "move-y+.svg", octoprint.YAxis, 1)) - m.AddButton(m.createMoveButton("Z+", "move-z+.svg", octoprint.ZAxis, 1)) + m.Grid().Attach(m.createMoveButton("Z+", "move-z+.svg", octoprint.ZAxis, 1), 3, 0, 1, 1) + m.Grid().Attach(m.createMoveButton("Z-", "move-z-.svg", octoprint.ZAxis, -1), 3, 1, 1, 1) m.step = MustStepButton("move-step.svg", Step{"5mm", 5}, Step{"10mm", 10}, Step{"1mm", 1}, ) - m.AddButton(m.step) - m.AddButton(m.createMoveButton("X-", "move-x-.svg", octoprint.XAxis, -1)) - m.AddButton(m.createMoveButton("Y-", "move-y-.svg", octoprint.YAxis, -1)) - m.AddButton(m.createMoveButton("Z-", "move-z-.svg", octoprint.ZAxis, -1)) + m.Grid().Attach(m.step, 2, 2, 1, 1) } func (m *movePanel) createMoveButton(label, image string, a octoprint.Axis, dir int) gtk.IWidget { - return MustButtonImage(label, image, func() { + + return MustPressedButton(label, image, func() { distance := m.step.Value().(int) * dir cmd := &octoprint.PrintHeadJogRequest{} @@ -55,13 +56,14 @@ func (m *movePanel) createMoveButton(label, image string, a octoprint.Axis, dir cmd.Z = distance } - Logger.Warningf("Jogging print head axis %s in %dmm", - strings.ToUpper(string(a)), distance, - ) + // Logger.Warningf("Jogging print head axis %s in %dmm", + // strings.ToUpper(string(a)), distance, + // ) if err := cmd.Do(m.UI.Printer); err != nil { Logger.Error(err) return } - }) + + }, 200) } diff --git a/ui/status.go b/ui/status.go index 5ce7d2c..12fe9b3 100644 --- a/ui/status.go +++ b/ui/status.go @@ -241,14 +241,14 @@ func (m *statusPanel) updateJob() { Logger.Info(s.Progress.PrintTime) Logger.Info(s.Progress.PrintTimeLeft) text = "Printing in progess ;)" - e := time.Duration(int64(s.Progress.PrintTime) * 1e9) - l := time.Duration(int64(s.Progress.PrintTimeLeft) * 1e9) - // eta := time.Now().Add(l).Format("3:04 PM") - if l == 0 { - text = fmt.Sprintf("Elapsed: %s", e) - } else { - text = fmt.Sprintf("Elapsed: %s | Left: %s", e, l) - } + // e := time.Duration(int64(s.Progress.PrintTime) * 1e9) + // l := time.Duration(int64(s.Progress.PrintTimeLeft) * 1e9) + // // eta := time.Now().Add(l).Format("3:04 PM") + // if l == 0 { + // text = fmt.Sprintf("Elapsed: %s", e) + // } else { + // text = fmt.Sprintf("Elapsed: %s | Left: %s", e, l) + // } } m.left.Label.SetLabel(text) @@ -256,8 +256,8 @@ func (m *statusPanel) updateJob() { func filenameEllipsis(name string) string { l := len(name) - if l > 35 { - return name[:14] + "..." + name[l-18:l] + if l > 32 { + return name[:12] + "..." + name[l-17:l] } return name diff --git a/ui/temperature.go b/ui/temperature.go index 4f9f617..7de75ee 100644 --- a/ui/temperature.go +++ b/ui/temperature.go @@ -48,10 +48,10 @@ func (m *temperaturePanel) initialize() { m.Grid().Attach(m.box, 2, 0, 2, 1) m.Grid().Attach(m.createToolButton(), 1, 1, 1, 1) - m.amount = MustStepButton("move-step.svg", Step{"5°C", 5.}, Step{"10°C", 10.}, Step{"1°C", 1.}) + m.amount = MustStepButton("move-step.svg", Step{"10°C", 10.}, Step{"5°C", 5.}, Step{"1°C", 1.}) m.Grid().Attach(m.amount, 2, 1, 1, 1) - m.Grid().Attach(MustButtonImage("Profiles", "heat-up.svg", m.profilePanel), 3, 1, 1, 1) + m.Grid().Attach(MustButtonImage("More", "heat-up.svg", m.profilePanel), 3, 1, 1, 1) } func (m *temperaturePanel) createToolButton() *StepButton { @@ -69,13 +69,14 @@ func (m *temperaturePanel) createToolButton() *StepButton { } func (m *temperaturePanel) createChangeButton(label, image string, value float64) gtk.IWidget { - return MustButtonImage(label, image, func() { + + return MustPressedButton(label, image, func() { target := value * m.amount.Value().(float64) if err := m.increaseTarget(m.tool.Value().(string), target); err != nil { Logger.Error(err) return } - }) + }, 100) } func (m *temperaturePanel) increaseTarget(tool string, value float64) error { From 8fbad894665006e6845e645d32f9d3b853a1f669 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Wed, 29 May 2019 23:43:24 +0300 Subject: [PATCH 06/14] minor style improvements --- styles/default/style.css | 47 +++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/styles/default/style.css b/styles/default/style.css index b928668..78643ee 100644 --- a/styles/default/style.css +++ b/styles/default/style.css @@ -1,3 +1,4 @@ + .dialog { border: 2px solid black; } .notification { @@ -15,10 +16,46 @@ background-color:rgba(204, 30, 30, 0.7); } -scrollbar, scrollbar button, scrollbar slider { - -GtkScrollbar-has-backward-stepper: true; - -GtkScrollbar-has-forward-stepper: true; +scrollbar, scrollbar button { + border: none; + background-color: #000; +} + +window { + background-color: #000; +} + +scrollbar slider { + /* -GtkScrollbar-has-backward-stepper: true; */ + /* -GtkScrollbar-has-forward-stepper: true; */ min-width: 52px; - min-height: 52px; - border-radius: 0px; + border-radius: 8px; +} + +progress, trough { + min-height: 20px; } + + + +/* GtkWindow { + background-color: green; + border-width: 3px; + border-color: blue; +} */ + +/* GtkButton { + background-image: none; + background-color:#1010FF; + margin:2px; + border-radius:0; +} */ + + +/* button, entry { + color: #ff00ea; + font: 12px "Comic Sans"; + background-color: #1010FF; + } */ + + From 8c5f2fab9da3d99795f76bd2c47bfcb727d3fdab Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Fri, 31 May 2019 14:23:20 +0300 Subject: [PATCH 07/14] added confirmation for stop button --- ui/status.go | 65 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/ui/status.go b/ui/status.go index 12fe9b3..5860d22 100644 --- a/ui/status.go +++ b/ui/status.go @@ -105,7 +105,7 @@ func (m *statusPanel) createTemperatureBox() *gtk.Box { func (m *statusPanel) createPrintButton() gtk.IWidget { m.print = MustButtonImage("Print", "status.svg", func() { - defer m.updateTemperature() + // defer m.updateTemperature() Logger.Warning("Starting a new job") if err := (&octoprint.StartRequest{}).Do(m.UI.Printer); err != nil { @@ -119,7 +119,7 @@ func (m *statusPanel) createPrintButton() gtk.IWidget { func (m *statusPanel) createPauseButton() gtk.IWidget { m.pause = MustButtonImage("Pause", "pause.svg", func() { - defer m.updateTemperature() + // defer m.updateTemperature() Logger.Warning("Pausing/Resuming job") cmd := &octoprint.PauseRequest{Action: octoprint.Toggle} @@ -133,16 +133,9 @@ func (m *statusPanel) createPauseButton() gtk.IWidget { } func (m *statusPanel) createStopButton() gtk.IWidget { - m.stop = MustButtonImage("Stop", "stop.svg", func() { - defer m.updateTemperature() - - Logger.Warning("Stopping job") - if err := (&octoprint.CancelRequest{}).Do(m.UI.Printer); err != nil { - Logger.Error(err) - return - } - }) - + m.stop = MustButtonImage("Stop", "stop.svg", + ConfirmStopDialog(m.UI.w, "Are you sure you want to stop current print?", m), + ) return m.stop } @@ -234,12 +227,12 @@ func (m *statusPanel) updateJob() { var text string switch s.Progress.Completion { case 100: - text = fmt.Sprintf("Job Completed in %s", time.Duration(int64(s.Job.LastPrintTime)*1e9)) + text = fmt.Sprintf("Completed in %s", time.Duration(int64(s.Job.LastPrintTime)*1e9)) case 0: text = "Warming up ..." default: - Logger.Info(s.Progress.PrintTime) - Logger.Info(s.Progress.PrintTimeLeft) + // Logger.Info(s.Progress.PrintTime) + Logger.Info("Printing in progess ;)") text = "Printing in progess ;)" // e := time.Duration(int64(s.Progress.PrintTime) * 1e9) // l := time.Duration(int64(s.Progress.PrintTimeLeft) * 1e9) @@ -262,3 +255,45 @@ func filenameEllipsis(name string) string { return name } + +func btou(b bool) uint8 { + if b { + return 1 + } + return 0 +} + +func ConfirmStopDialog(parent *gtk.Window, msg string, ma *statusPanel) func() { + return func() { + win := gtk.MessageDialogNewWithMarkup( + parent, + gtk.DIALOG_MODAL, + gtk.MESSAGE_INFO, + gtk.BUTTONS_YES_NO, + "", + ) + + win.SetMarkup(CleanHTML(msg)) + defer win.Destroy() + + box, _ := win.GetContentArea() + box.SetMarginStart(15) + box.SetMarginEnd(15) + box.SetMarginTop(15) + box.SetMarginBottom(15) + + ctx, _ := win.GetStyleContext() + ctx.AddClass("dialog") + + ergebnis := win.Run() + + if ergebnis == int(gtk.RESPONSE_YES) { + + Logger.Warning("Stopping job") + if err := (&octoprint.CancelRequest{}).Do(ma.UI.Printer); err != nil { + Logger.Error(err) + return + } + } + } +} From c396c3dc12190dde8f9b522e0b411e63ca808057 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Fri, 31 May 2019 17:58:33 +0300 Subject: [PATCH 08/14] updated menu order --- debian/local/octoprint-tft-environment | 3 +++ ui/default.go | 7 ++++--- ui/logger.go | 22 +++++++++++++++++++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/debian/local/octoprint-tft-environment b/debian/local/octoprint-tft-environment index e5c386c..6de059c 100644 --- a/debian/local/octoprint-tft-environment +++ b/debian/local/octoprint-tft-environment @@ -19,3 +19,6 @@ OCTOPRINT_TFT_STYLE_PATH=/opt/octoprint-tft/styles/default/ # Resolution of the application, should be configured to the resolution of your # screen, for example 800x480. By default 480x320. OCTOPRINT_TFT_RESOLUTION= + +# Location of file for logging (Optional) +OCTOPRINT_TFT_LOG_FILE= diff --git a/ui/default.go b/ui/default.go index 12e3e89..da708cf 100644 --- a/ui/default.go +++ b/ui/default.go @@ -21,9 +21,10 @@ func (m *defaultPanel) initialize() { m.Grid().Attach(MustButtonImage("Heat Up", "heat-up.svg", m.showTemperature), 2, 0, 1, 1) m.Grid().Attach(MustButtonImage("Move", "move.svg", m.showMove), 3, 0, 1, 1) m.Grid().Attach(MustButtonImage("Home", "home.svg", m.showHome), 4, 0, 1, 1) - m.Grid().Attach(MustButtonImage("Filament", "filament.svg", m.showFilament), 1, 1, 1, 1) - m.Grid().Attach(MustButtonImage("Control", "control.svg", m.showControl), 2, 1, 1, 1) - m.Grid().Attach(MustButtonImage("Files", "files.svg", m.showFiles), 3, 1, 1, 1) + + m.Grid().Attach(MustButtonImage("Print", "files.svg", m.showFiles), 1, 1, 1, 1) + m.Grid().Attach(MustButtonImage("Filament", "filament.svg", m.showFilament), 2, 1, 1, 1) + m.Grid().Attach(MustButtonImage("Control", "control.svg", m.showControl), 3, 1, 1, 1) m.Grid().Attach(MustButtonImage("System", "settings.svg", m.showSystem), 4, 1, 1, 1) } diff --git a/ui/logger.go b/ui/logger.go index 8d9c705..d6ccc76 100644 --- a/ui/logger.go +++ b/ui/logger.go @@ -1,6 +1,7 @@ package ui import ( + "os" "path" "runtime" "strings" @@ -63,7 +64,22 @@ func (h NotificationsHook) Fire(entry *logrus.Entry) error { var Logger *logrus.Entry func init() { - logrus.AddHook(ContextHook{}) - logrus.SetLevel(logrus.DebugLevel) - Logger = logrus.WithFields(logrus.Fields{}) + var LogFile = os.Getenv("OCTOPRINT_TFT_LOG_FILE") + + var log = logrus.New() + log.AddHook(ContextHook{}) + log.SetLevel(logrus.DebugLevel) + + if LogFile == "" { + log.Out = os.Stdout + } else { + file, err := os.OpenFile(LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) + if err == nil { + log.Out = file + } else { + log.Info("Failed to log to file, using default stderr") + } + } + + Logger = log.WithFields(logrus.Fields{}) } From bd89f1fd84a28149be7e21a4590e9847a1f77eae Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Fri, 31 May 2019 22:24:38 +0300 Subject: [PATCH 09/14] fixed screen sleep time --- debian/local/disablescreenblank.sh | 10 ++++++++++ debian/octoprint-tft.install | 1 + debian/octoprint-tft.postinst | 1 + debian/octoprint-tft.service | 1 + 4 files changed, 13 insertions(+) create mode 100644 debian/local/disablescreenblank.sh diff --git a/debian/local/disablescreenblank.sh b/debian/local/disablescreenblank.sh new file mode 100644 index 0000000..02147a0 --- /dev/null +++ b/debian/local/disablescreenblank.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +screen=${1:-0} + +# wait 20s for the display manager service to start and attach to screen +sleep 20 + +/usr/bin/xset -display :$screen s off # deactivate screen saver +/usr/bin/xset -display :$screen -dpms # disable DPMS +/usr/bin/xset -display :$screen s noblank # disable screen blanking \ No newline at end of file diff --git a/debian/octoprint-tft.install b/debian/octoprint-tft.install index 615c5c9..0837585 100644 --- a/debian/octoprint-tft.install +++ b/debian/octoprint-tft.install @@ -1,2 +1,3 @@ debian/local/octoprint-tft-environment etc debian/local/insserv.conf.d etc +debian/local/disablescreenblank.sh etc \ No newline at end of file diff --git a/debian/octoprint-tft.postinst b/debian/octoprint-tft.postinst index 082bb47..669589d 100755 --- a/debian/octoprint-tft.postinst +++ b/debian/octoprint-tft.postinst @@ -35,6 +35,7 @@ if [ "$1" = configure ] && [ -d /etc/systemd/system/ ]; then echo "Display manager service is masked" >&2 elif [ -e "$SERVICE" ]; then ln -sf "$SERVICE" "$DEFAULT_SERVICE" + chmod +x /etc/disablescreenblank.sh else echo "WARNING: $SERVICE is the selected default display manager but does not exist" >&2 rm -f "$DEFAULT_SERVICE" diff --git a/debian/octoprint-tft.service b/debian/octoprint-tft.service index c4f43fa..1a5730c 100644 --- a/debian/octoprint-tft.service +++ b/debian/octoprint-tft.service @@ -6,6 +6,7 @@ After=systemd-user-sessions.service getty@tty7.service plymouth-quit.service [Service] EnvironmentFile=/etc/octoprint-tft-environment ExecStart=/usr/bin/xinit /usr/bin/OctoPrint-TFT -- :0 -nolisten tcp -nocursor +ExecStartPost=/etc/disablescreenblank.sh 0 StandardOutput=journal Restart=always RestartSec=1s From 8a11833da6ca7c161de35a404ae78228806e6bd9 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Tue, 4 Jun 2019 21:29:19 +0300 Subject: [PATCH 10/14] added watchdog monitoring for service hard reanimation --- debian/local/disablescreenblank.sh | 4 ++-- debian/octoprint-tft.service | 6 +++--- ui/ui.go | 5 +++++ vendor/github.com/coreos/go-systemd | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) create mode 160000 vendor/github.com/coreos/go-systemd diff --git a/debian/local/disablescreenblank.sh b/debian/local/disablescreenblank.sh index 02147a0..d52f01f 100644 --- a/debian/local/disablescreenblank.sh +++ b/debian/local/disablescreenblank.sh @@ -2,8 +2,8 @@ screen=${1:-0} -# wait 20s for the display manager service to start and attach to screen -sleep 20 +# wait 10s for the display manager service to start and attach to screen +sleep 10 /usr/bin/xset -display :$screen s off # deactivate screen saver /usr/bin/xset -display :$screen -dpms # disable DPMS diff --git a/debian/octoprint-tft.service b/debian/octoprint-tft.service index 1a5730c..c992c47 100644 --- a/debian/octoprint-tft.service +++ b/debian/octoprint-tft.service @@ -4,14 +4,14 @@ Conflicts=getty@tty7.service After=systemd-user-sessions.service getty@tty7.service plymouth-quit.service [Service] +Type=notify +NotifyAccess=all EnvironmentFile=/etc/octoprint-tft-environment ExecStart=/usr/bin/xinit /usr/bin/OctoPrint-TFT -- :0 -nolisten tcp -nocursor ExecStartPost=/etc/disablescreenblank.sh 0 StandardOutput=journal Restart=always -RestartSec=1s -TimeoutStopSec=5s -IgnoreSIGPIPE=no +WatchdogSec=10s [Install] WantedBy=graphical.target diff --git a/ui/ui.go b/ui/ui.go index e64d518..dd20a60 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -6,6 +6,7 @@ import ( "sync" "time" + "github.com/coreos/go-systemd/daemon" "github.com/gotk3/gotk3/gdk" "github.com/gotk3/gotk3/gtk" "github.com/mcuadros/go-octoprint" @@ -80,6 +81,8 @@ func (ui *UI) initialize() { ui.g = MustGrid() ui.o.Add(ui.g) ui.o.AddOverlay(ui.Notifications) + + daemon.SdNotify(false, "READY=1") } func (ui *UI) loadStyle() { @@ -97,6 +100,8 @@ func (ui *UI) loadStyle() { var errMercyPeriod = time.Second * 30 func (ui *UI) verifyConnection() { + daemon.SdNotify(false, "WATCHDOG=1") + splash := NewSplashPanel(ui) s, err := (&octoprint.ConnectionRequest{}).Do(ui.Printer) diff --git a/vendor/github.com/coreos/go-systemd b/vendor/github.com/coreos/go-systemd new file mode 160000 index 0000000..95778df --- /dev/null +++ b/vendor/github.com/coreos/go-systemd @@ -0,0 +1 @@ +Subproject commit 95778dfbb74eb7e4dbaf43bf7d71809650ef8076 From 2e5641acf2c5f1dd6412d65220c4719902e46a3e Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Wed, 5 Jun 2019 16:56:16 +0300 Subject: [PATCH 11/14] add returning to the temperature screen after pressing profile button --- ui/temperature.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/temperature.go b/ui/temperature.go index 7de75ee..bb6eff6 100644 --- a/ui/temperature.go +++ b/ui/temperature.go @@ -154,7 +154,7 @@ func (m *temperaturePanel) addNewTool(tool string) { m.tool.AddStep(Step{strings.Title(tool), tool}) m.tool.Callback() - Logger.Infof("New tool detected %s", tool) + Logger.Infof("Tool detected %s", tool) } func (m *temperaturePanel) loadTemperatureData(tool string, d *octoprint.TemperatureData) { @@ -212,6 +212,7 @@ func (m *profilesPanel) createProfileButton(img string, p *octoprint.Temperature if err := m.setProfile(p); err != nil { Logger.Error(err) } + m.UI.GoHistory() }) } From 55025c7ab48d130299a432ec5fa3f56cf315f05d Mon Sep 17 00:00:00 2001 From: Aliaksei Kvitsinski Date: Wed, 5 Jun 2019 23:54:56 +0300 Subject: [PATCH 12/14] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 131387a..693ebe6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -OctoPrint-TFT [![GitHub release](https://img.shields.io/github/release/mcuadros/OctoPrint-TFT.svg)](https://github.com/mcuadros/OctoPrint-TFT/releases) [![license](https://img.shields.io/github/license/mcuadros/OctoPrint-TFT.svg)]() +OctoPrint-TFT [![GitHub release](https://img.shields.io/github/release/Z-Bolt/OctoPrint-TFT.svg)](https://github.com/Z-Bolt/OctoPrint-TFT/releases) [![license](https://img.shields.io/github/license/Z-Bolt/OctoPrint-TFT.svg)]() ============= _OctoPrint-TFT_, a touch interface for TFT touch modules based on GTK+3. From bddfbf00d99717e33cee01c1708de076cba7a48c Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Sat, 8 Jun 2019 08:34:02 +0300 Subject: [PATCH 13/14] added timeouts to API request and some cleanup --- Makefile | 4 +-- ui/status.go | 27 +++++++++---------- .../mcuadros/go-octoprint/client.go | 2 ++ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 512e500..0f574ad 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ JESSIE_GO_TAGS := gtk_3_14 # Build information #GIT_COMMIT = $(shell git rev-parse HEAD | cut -c1-7) #DEV_PREFIX := 1.0 -VERSION := 1.2 +VERSION := 1.3 BUILD_DATE ?= $(shell date --utc +%Y%m%d-%H:%M:%S) #BRANCH = $(shell git rev-parse --abbrev-ref HEAD) @@ -66,7 +66,7 @@ build-internal: prepare-internal cp ../*.deb /build/; prepare-internal: - dch --create -v $(VERSION)-1 --package $(PACKAGE_NAME) empty; \ + dch --create -v $(VERSION) --package $(PACKAGE_NAME) empty; \ cd $(WORKDIR)/..; \ tar -czf octoprint-tft_$(VERSION).orig.tar.gz --exclude-vcs OctoPrint-TFT diff --git a/ui/status.go b/ui/status.go index 5860d22..37081c8 100644 --- a/ui/status.go +++ b/ui/status.go @@ -25,7 +25,7 @@ func StatusPanel(ui *UI, parent Panel) Panel { if statusPanelInstance == nil { m := &statusPanel{CommonPanel: NewCommonPanel(ui, parent)} m.panelH = 3 - m.b = NewBackgroundTask(time.Second*5, m.update) + m.b = NewBackgroundTask(time.Second*2, m.update) m.initialize() statusPanelInstance = m @@ -105,7 +105,7 @@ func (m *statusPanel) createTemperatureBox() *gtk.Box { func (m *statusPanel) createPrintButton() gtk.IWidget { m.print = MustButtonImage("Print", "status.svg", func() { - // defer m.updateTemperature() + defer m.updateTemperature() Logger.Warning("Starting a new job") if err := (&octoprint.StartRequest{}).Do(m.UI.Printer); err != nil { @@ -119,7 +119,7 @@ func (m *statusPanel) createPrintButton() gtk.IWidget { func (m *statusPanel) createPauseButton() gtk.IWidget { m.pause = MustButtonImage("Pause", "pause.svg", func() { - // defer m.updateTemperature() + defer m.updateTemperature() Logger.Warning("Pausing/Resuming job") cmd := &octoprint.PauseRequest{Action: octoprint.Toggle} @@ -231,17 +231,16 @@ func (m *statusPanel) updateJob() { case 0: text = "Warming up ..." default: - // Logger.Info(s.Progress.PrintTime) - Logger.Info("Printing in progess ;)") - text = "Printing in progess ;)" - // e := time.Duration(int64(s.Progress.PrintTime) * 1e9) - // l := time.Duration(int64(s.Progress.PrintTimeLeft) * 1e9) - // // eta := time.Now().Add(l).Format("3:04 PM") - // if l == 0 { - // text = fmt.Sprintf("Elapsed: %s", e) - // } else { - // text = fmt.Sprintf("Elapsed: %s | Left: %s", e, l) - // } + Logger.Info(s.Progress.PrintTime) + + e := time.Duration(int64(s.Progress.PrintTime) * 1e9) + l := time.Duration(int64(s.Progress.PrintTimeLeft) * 1e9) + // eta := time.Now().Add(l).Format("3:04 PM") + if l == 0 { + text = fmt.Sprintf("Print Time: %s", e) + } else { + text = fmt.Sprintf("Print Time: %s | Left: %s", e, l) + } } m.left.Label.SetLabel(text) diff --git a/vendor/github.com/mcuadros/go-octoprint/client.go b/vendor/github.com/mcuadros/go-octoprint/client.go index 50bfa0e..5514374 100644 --- a/vendor/github.com/mcuadros/go-octoprint/client.go +++ b/vendor/github.com/mcuadros/go-octoprint/client.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "net/http" "net/url" + "time" ) // ErrUnauthorized missing or invalid API key @@ -31,6 +32,7 @@ func NewClient(endpoint, apiKey string) *Client { Endpoint: endpoint, APIKey: apiKey, c: &http.Client{ + Timeout: time.Second * 3, Transport: &http.Transport{ DisableKeepAlives: true, }, From 9529d2216bd0d32953d3d75c5669685c525ecb27 Mon Sep 17 00:00:00 2001 From: Aleksei Kvitinskii Date: Sat, 8 Jun 2019 08:41:51 +0300 Subject: [PATCH 14/14] fixed coreos package --- vendor/github.com/coreos/go-systemd | 1 - .../github.com/coreos/go-systemd/.travis.yml | 45 + .../coreos/go-systemd/CONTRIBUTING.md | 77 + vendor/github.com/coreos/go-systemd/DCO | 36 + .../github.com/coreos/go-systemd/Gopkg.toml | 11 + .../github.com/coreos/go-systemd/Jenkinsfile | 38 + vendor/github.com/coreos/go-systemd/LICENSE | 191 ++ vendor/github.com/coreos/go-systemd/NOTICE | 5 + vendor/github.com/coreos/go-systemd/README.md | 71 + .../go-systemd/activation/common_test.go | 31 + .../coreos/go-systemd/activation/files.go | 67 + .../go-systemd/activation/files_test.go | 85 + .../coreos/go-systemd/activation/listeners.go | 103 ++ .../go-systemd/activation/listeners_test.go | 87 + .../go-systemd/activation/packetconns.go | 38 + .../go-systemd/activation/packetconns_test.go | 69 + .../coreos/go-systemd/code-of-conduct.md | 61 + .../coreos/go-systemd/daemon/sdnotify.go | 84 + .../coreos/go-systemd/daemon/sdnotify_test.go | 79 + .../coreos/go-systemd/daemon/watchdog.go | 73 + .../coreos/go-systemd/daemon/watchdog_test.go | 85 + .../github.com/coreos/go-systemd/dbus/dbus.go | 240 +++ .../coreos/go-systemd/dbus/dbus_test.go | 96 + .../coreos/go-systemd/dbus/methods.go | 594 +++++++ .../coreos/go-systemd/dbus/methods_test.go | 1541 +++++++++++++++++ .../coreos/go-systemd/dbus/properties.go | 237 +++ .../github.com/coreos/go-systemd/dbus/set.go | 47 + .../coreos/go-systemd/dbus/set_test.go | 53 + .../coreos/go-systemd/dbus/subscription.go | 333 ++++ .../go-systemd/dbus/subscription_set.go | 57 + .../go-systemd/dbus/subscription_set_test.go | 82 + .../go-systemd/dbus/subscription_test.go | 191 ++ .../examples/activation/activation.go | 60 + .../examples/activation/httpserver/README.md | 19 + .../activation/httpserver/hello.service | 11 + .../activation/httpserver/hello.socket | 5 + .../activation/httpserver/httpserver.go | 42 + .../go-systemd/examples/activation/listen.go | 56 + .../go-systemd/examples/activation/udpconn.go | 78 + .../fixtures/enable-disable.service | 5 + .../go-systemd/fixtures/mask-unmask.service | 5 + .../coreos/go-systemd/fixtures/reload.service | 6 + .../go-systemd/fixtures/start-failed.service | 6 + .../go-systemd/fixtures/start-stop.service | 5 + .../fixtures/subscribe-events-set.service | 5 + .../fixtures/subscribe-events.service | 5 + .../coreos/go-systemd/journal/journal.go | 225 +++ .../coreos/go-systemd/journal/journal_test.go | 121 ++ .../coreos/go-systemd/login1/dbus.go | 260 +++ .../coreos/go-systemd/login1/dbus_test.go | 89 + .../coreos/go-systemd/machine1/dbus.go | 265 +++ .../coreos/go-systemd/machine1/dbus_test.go | 150 ++ .../jenkins/periodic-go-systemd-builder.sh | 24 + .../go-systemd/scripts/travis/pr-test.sh | 109 ++ .../coreos/go-systemd/sdjournal/functions.go | 66 + .../go-systemd/sdjournal/functions_test.go | 36 + .../coreos/go-systemd/sdjournal/journal.go | 1120 ++++++++++++ .../go-systemd/sdjournal/journal_test.go | 508 ++++++ .../coreos/go-systemd/sdjournal/read.go | 272 +++ vendor/github.com/coreos/go-systemd/test | 88 + .../coreos/go-systemd/unit/deserialize.go | 278 +++ .../go-systemd/unit/deserialize_test.go | 381 ++++ .../coreos/go-systemd/unit/end_to_end_test.go | 88 + .../coreos/go-systemd/unit/escape.go | 116 ++ .../coreos/go-systemd/unit/escape_test.go | 211 +++ .../coreos/go-systemd/unit/option.go | 59 + .../coreos/go-systemd/unit/option_test.go | 214 +++ .../coreos/go-systemd/unit/serialize.go | 75 + .../coreos/go-systemd/unit/serialize_test.go | 170 ++ .../github.com/coreos/go-systemd/util/util.go | 90 + .../coreos/go-systemd/util/util_cgo.go | 175 ++ .../coreos/go-systemd/util/util_stub.go | 23 + .../coreos/go-systemd/util/util_test.go | 79 + 73 files changed, 10407 insertions(+), 1 deletion(-) delete mode 160000 vendor/github.com/coreos/go-systemd create mode 100644 vendor/github.com/coreos/go-systemd/.travis.yml create mode 100644 vendor/github.com/coreos/go-systemd/CONTRIBUTING.md create mode 100644 vendor/github.com/coreos/go-systemd/DCO create mode 100644 vendor/github.com/coreos/go-systemd/Gopkg.toml create mode 100644 vendor/github.com/coreos/go-systemd/Jenkinsfile create mode 100644 vendor/github.com/coreos/go-systemd/LICENSE create mode 100644 vendor/github.com/coreos/go-systemd/NOTICE create mode 100644 vendor/github.com/coreos/go-systemd/README.md create mode 100644 vendor/github.com/coreos/go-systemd/activation/common_test.go create mode 100644 vendor/github.com/coreos/go-systemd/activation/files.go create mode 100644 vendor/github.com/coreos/go-systemd/activation/files_test.go create mode 100644 vendor/github.com/coreos/go-systemd/activation/listeners.go create mode 100644 vendor/github.com/coreos/go-systemd/activation/listeners_test.go create mode 100644 vendor/github.com/coreos/go-systemd/activation/packetconns.go create mode 100644 vendor/github.com/coreos/go-systemd/activation/packetconns_test.go create mode 100644 vendor/github.com/coreos/go-systemd/code-of-conduct.md create mode 100644 vendor/github.com/coreos/go-systemd/daemon/sdnotify.go create mode 100644 vendor/github.com/coreos/go-systemd/daemon/sdnotify_test.go create mode 100644 vendor/github.com/coreos/go-systemd/daemon/watchdog.go create mode 100644 vendor/github.com/coreos/go-systemd/daemon/watchdog_test.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/dbus.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/dbus_test.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/methods.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/methods_test.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/properties.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/set.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/set_test.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/subscription.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/subscription_set.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/subscription_set_test.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/subscription_test.go create mode 100644 vendor/github.com/coreos/go-systemd/examples/activation/activation.go create mode 100644 vendor/github.com/coreos/go-systemd/examples/activation/httpserver/README.md create mode 100644 vendor/github.com/coreos/go-systemd/examples/activation/httpserver/hello.service create mode 100644 vendor/github.com/coreos/go-systemd/examples/activation/httpserver/hello.socket create mode 100644 vendor/github.com/coreos/go-systemd/examples/activation/httpserver/httpserver.go create mode 100644 vendor/github.com/coreos/go-systemd/examples/activation/listen.go create mode 100644 vendor/github.com/coreos/go-systemd/examples/activation/udpconn.go create mode 100644 vendor/github.com/coreos/go-systemd/fixtures/enable-disable.service create mode 100644 vendor/github.com/coreos/go-systemd/fixtures/mask-unmask.service create mode 100644 vendor/github.com/coreos/go-systemd/fixtures/reload.service create mode 100644 vendor/github.com/coreos/go-systemd/fixtures/start-failed.service create mode 100644 vendor/github.com/coreos/go-systemd/fixtures/start-stop.service create mode 100644 vendor/github.com/coreos/go-systemd/fixtures/subscribe-events-set.service create mode 100644 vendor/github.com/coreos/go-systemd/fixtures/subscribe-events.service create mode 100644 vendor/github.com/coreos/go-systemd/journal/journal.go create mode 100644 vendor/github.com/coreos/go-systemd/journal/journal_test.go create mode 100644 vendor/github.com/coreos/go-systemd/login1/dbus.go create mode 100644 vendor/github.com/coreos/go-systemd/login1/dbus_test.go create mode 100644 vendor/github.com/coreos/go-systemd/machine1/dbus.go create mode 100644 vendor/github.com/coreos/go-systemd/machine1/dbus_test.go create mode 100755 vendor/github.com/coreos/go-systemd/scripts/jenkins/periodic-go-systemd-builder.sh create mode 100755 vendor/github.com/coreos/go-systemd/scripts/travis/pr-test.sh create mode 100644 vendor/github.com/coreos/go-systemd/sdjournal/functions.go create mode 100644 vendor/github.com/coreos/go-systemd/sdjournal/functions_test.go create mode 100644 vendor/github.com/coreos/go-systemd/sdjournal/journal.go create mode 100755 vendor/github.com/coreos/go-systemd/sdjournal/journal_test.go create mode 100644 vendor/github.com/coreos/go-systemd/sdjournal/read.go create mode 100755 vendor/github.com/coreos/go-systemd/test create mode 100644 vendor/github.com/coreos/go-systemd/unit/deserialize.go create mode 100644 vendor/github.com/coreos/go-systemd/unit/deserialize_test.go create mode 100644 vendor/github.com/coreos/go-systemd/unit/end_to_end_test.go create mode 100644 vendor/github.com/coreos/go-systemd/unit/escape.go create mode 100644 vendor/github.com/coreos/go-systemd/unit/escape_test.go create mode 100644 vendor/github.com/coreos/go-systemd/unit/option.go create mode 100644 vendor/github.com/coreos/go-systemd/unit/option_test.go create mode 100644 vendor/github.com/coreos/go-systemd/unit/serialize.go create mode 100644 vendor/github.com/coreos/go-systemd/unit/serialize_test.go create mode 100644 vendor/github.com/coreos/go-systemd/util/util.go create mode 100644 vendor/github.com/coreos/go-systemd/util/util_cgo.go create mode 100644 vendor/github.com/coreos/go-systemd/util/util_stub.go create mode 100644 vendor/github.com/coreos/go-systemd/util/util_test.go diff --git a/vendor/github.com/coreos/go-systemd b/vendor/github.com/coreos/go-systemd deleted file mode 160000 index 95778df..0000000 --- a/vendor/github.com/coreos/go-systemd +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 95778dfbb74eb7e4dbaf43bf7d71809650ef8076 diff --git a/vendor/github.com/coreos/go-systemd/.travis.yml b/vendor/github.com/coreos/go-systemd/.travis.yml new file mode 100644 index 0000000..cfea999 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/.travis.yml @@ -0,0 +1,45 @@ +dist: trusty +sudo: required +services: + - docker + +language: go +go: + - "1.10.x" + - "1.11.x" +go_import_path: github.com/coreos/go-systemd + +env: + global: + - IMPORTPATH=github.com/coreos/go-systemd + - GOPATH=/opt + - DEP_BINDIR=/tmp + - BUILD_DIR=/opt/src/github.com/coreos/go-systemd + matrix: + - DOCKER_BASE=ubuntu:16.04 + - DOCKER_BASE=ubuntu:18.04 + - DOCKER_BASE=debian:stretch + +before_install: + - sudo apt-get -qq update + - sudo apt-get install -y libsystemd-journal-dev libsystemd-daemon-dev + - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | INSTALL_DIRECTORY=${DEP_BINDIR} sh + - ${DEP_BINDIR}/dep ensure -v + - docker pull ${DOCKER_BASE} + - docker run --privileged -e GOPATH=${GOPATH} --cidfile=/tmp/cidfile ${DOCKER_BASE} /bin/bash -c "apt-get update && apt-get install -y sudo build-essential git golang dbus libsystemd-dev libpam-systemd systemd-container" + - docker commit `cat /tmp/cidfile` go-systemd/container-tests + - rm -f /tmp/cidfile + +install: + - docker run --shm-size=2gb -d --cidfile=/tmp/cidfile --privileged -e GOPATH=${GOPATH} -v ${PWD}:${BUILD_DIR} go-systemd/container-tests /bin/systemd --system + +script: + - ./scripts/travis/pr-test.sh go_fmt + - ./scripts/travis/pr-test.sh build_source + - ./scripts/travis/pr-test.sh build_tests + - docker exec --privileged `cat /tmp/cidfile` /bin/bash -c "cd ${BUILD_DIR} && ./scripts/travis/pr-test.sh run_tests" + - ./scripts/travis/pr-test.sh go_vet + - ./scripts/travis/pr-test.sh license_check + +after_script: + - docker kill `cat /tmp/cidfile` diff --git a/vendor/github.com/coreos/go-systemd/CONTRIBUTING.md b/vendor/github.com/coreos/go-systemd/CONTRIBUTING.md new file mode 100644 index 0000000..0551ed5 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/CONTRIBUTING.md @@ -0,0 +1,77 @@ +# How to Contribute + +CoreOS projects are [Apache 2.0 licensed](LICENSE) and accept contributions via +GitHub pull requests. This document outlines some of the conventions on +development workflow, commit message formatting, contact points and other +resources to make it easier to get your contribution accepted. + +# Certificate of Origin + +By contributing to this project you agree to the Developer Certificate of +Origin (DCO). This document was created by the Linux Kernel community and is a +simple statement that you, as a contributor, have the legal right to make the +contribution. See the [DCO](DCO) file for details. + +# Email and Chat + +The project currently uses the general CoreOS email list and IRC channel: +- Email: [coreos-dev](https://groups.google.com/forum/#!forum/coreos-dev) +- IRC: #[coreos](irc://irc.freenode.org:6667/#coreos) IRC channel on freenode.org + +Please avoid emailing maintainers found in the MAINTAINERS file directly. They +are very busy and read the mailing lists. + +## Getting Started + +- Fork the repository on GitHub +- Read the [README](README.md) for build and test instructions +- Play with the project, submit bugs, submit patches! + +## Contribution Flow + +This is a rough outline of what a contributor's workflow looks like: + +- Create a topic branch from where you want to base your work (usually master). +- Make commits of logical units. +- Make sure your commit messages are in the proper format (see below). +- Push your changes to a topic branch in your fork of the repository. +- Make sure the tests pass, and add any new tests as appropriate. +- Submit a pull request to the original repository. + +Thanks for your contributions! + +### Coding Style + +CoreOS projects written in Go follow a set of style guidelines that we've documented +[here](https://github.com/coreos/docs/tree/master/golang). Please follow them when +working on your contributions. + +### Format of the Commit Message + +We follow a rough convention for commit messages that is designed to answer two +questions: what changed and why. The subject line should feature the what and +the body of the commit should describe the why. + +``` +scripts: add the test-cluster command + +this uses tmux to setup a test cluster that you can easily kill and +start for debugging. + +Fixes #38 +``` + +The format can be described more formally as follows: + +``` +: + + + +