Skip to content

Commit

Permalink
Merge pull request #313 from Z-Bolt/2.7.4-dev
Browse files Browse the repository at this point in the history
2.7.4 dev into master
  • Loading branch information
JeffB42 authored Aug 8, 2021
2 parents b073bbe + 43bc5d2 commit 28ce7ba
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ JESSIE_GO_TAGS := gtk_3_14

# Build information
#GIT_COMMIT = $(shell git rev-parse HEAD | cut -c1-7)
VERSION := 2.7.3
VERSION := 2.7.4
BUILD_DATE ?= $(shell date --utc +%Y%m%d-%H:%M:%S)
#BRANCH = $(shell git rev-parse --abbrev-ref HEAD)

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ There are two ways to install OctoScreen: the recommended and supported way is t

For example, to install on a new RaspberryPi with OctoPi:
```sh
wget https://github.com/Z-Bolt/OctoScreen/releases/download/v2.7.3/octoscreen_2.7.3_armhf.deb
sudo dpkg -i octoscreen_2.7.3_armhf.deb
wget https://github.com/Z-Bolt/OctoScreen/releases/download/v2.7.4/octoscreen_2.7.4_armhf.deb
sudo dpkg -i octoscreen_2.7.4_armhf.deb
```

Or to update an existing version of OctoScreen:
```sh
wget https://github.com/Z-Bolt/OctoScreen/releases/download/v2.7.3/octoscreen_2.7.3_armhf.deb
wget https://github.com/Z-Bolt/OctoScreen/releases/download/v2.7.4/octoscreen_2.7.4_armhf.deb
sudo dpkg -r octoscreen
sudo dpkg -i octoscreen_2.7.3_armhf.deb
sudo dpkg -i octoscreen_2.7.4_armhf.deb
sudo reboot now
```

Expand Down
5 changes: 4 additions & 1 deletion octoprintApis/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ func (this *Client) handleResponse(
) ([]byte, error) {
logger.TraceEnter("Client.handleResponse()")

defer httpResponse.Body.Close()
defer func() {
io.Copy(ioutil.Discard, httpResponse.Body)
httpResponse.Body.Close()
}()

if statusMapping != nil {
if err := statusMapping.Error(httpResponse.StatusCode); err != nil {
Expand Down
20 changes: 19 additions & 1 deletion ui/IdleStatusPanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package ui
import (
// "encoding/json"
// "fmt"
"os"
"strconv"
// "sync"
"time"

Expand Down Expand Up @@ -31,7 +33,23 @@ func IdleStatusPanel(ui *UI) *idleStatusPanel {
instance := &idleStatusPanel{
CommonPanel: NewTopLevelCommonPanel("IdleStatusPanel", ui),
}
instance.backgroundTask = utils.CreateBackgroundTask(time.Second * 2, instance.update)

// Default timeout of 20 seconds.
durration := time.Second * 20

// Experimental, set the timeout based on config setting, but only if the config is pressent.
updateFrequency := os.Getenv("EXPERIMENTAL_IDLE_UPDATE_FREQUENCY")
if updateFrequency != "" {
logger.Infof("Ui.New() - EXPERIMENTAL_IDLE_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency)
val, err := strconv.Atoi(updateFrequency)
if err == nil {
durration = time.Second * time.Duration(val)
} else {
logger.LogError("Ui.New()", "strconv.Atoi()", err)
}
}

instance.backgroundTask = utils.CreateBackgroundTask(durration, instance.update)
instance.initialize()

idleStatusPanelInstance = instance
Expand Down
20 changes: 19 additions & 1 deletion ui/NetworkPanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package ui
import (
"fmt"
"net"
"os"
"strconv"
"time"

"pifke.org/wpasupplicant"
Expand Down Expand Up @@ -33,7 +35,23 @@ func NetworkPanel(
CommonPanel: NewCommonPanel("NetworkPanel", ui),
}
instance.initialize()
instance.backgroundTask = utils.CreateBackgroundTask(time.Second * 3, instance.update)

// Default timeout of 30 seconds.
durration := time.Second * 30

// Experimental, set the timeout based on config setting, but only if the config is pressent.
updateFrequency := os.Getenv("EXPERIMENTAL_NETWORK_UPDATE_FREQUENCY")
if updateFrequency != "" {
logger.Infof("Ui.New() - EXPERIMENTAL_NETWORK_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency)
val, err := strconv.Atoi(updateFrequency)
if err == nil {
durration = time.Second * time.Duration(val)
} else {
logger.LogError("Ui.New()", "strconv.Atoi()", err)
}
}

instance.backgroundTask = utils.CreateBackgroundTask(durration, instance.update)
networkPanelInstance = instance
}

Expand Down
19 changes: 18 additions & 1 deletion ui/PrintStatusPanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package ui

import (
"fmt"
"os"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -43,9 +45,24 @@ func PrintStatusPanel(ui *UI) *printStatusPanel {
CommonPanel: NewTopLevelCommonPanel("PrintStatusPanel", ui),
}

// Default timeout of 20 seconds.
durration := time.Second * 20

// Experimental, set the timeout based on config setting, but only if the config is pressent.
updateFrequency := os.Getenv("EXPERIMENTAL_PRINT_UPDATE_FREQUENCY")
if updateFrequency != "" {
logger.Infof("Ui.New() - EXPERIMENTAL_PRINT_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency)
val, err := strconv.Atoi(updateFrequency)
if err == nil {
durration = time.Second * time.Duration(val)
} else {
logger.LogError("Ui.New()", "strconv.Atoi()", err)
}
}

// TODO: revisit... some set the background task and then initialize
// and others initialize and then set the background task
instance.backgroundTask = utils.CreateBackgroundTask(time.Second * 2, instance.update)
instance.backgroundTask = utils.CreateBackgroundTask(durration, instance.update)
instance.initialize()
printStatusPanelInstance = instance
}
Expand Down
4 changes: 2 additions & 2 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ func New(endpoint, key string, width, height int) *UI {
durration := time.Second * 20

// Experimental, set the timeout based on config setting, but only if the config is pressent.
updateFrequency := os.Getenv("EXPERIMENTAL_UPDATE_FREQUENCY")
updateFrequency := os.Getenv("EXPERIMENTAL_UI_UPDATE_FREQUENCY")
if updateFrequency != "" {
logger.Infof("Ui.New() - EXPERIMENTAL_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency)
logger.Infof("Ui.New() - EXPERIMENTAL_UI_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency)
val, err := strconv.Atoi(updateFrequency)
if err == nil {
durration = time.Second * time.Duration(val)
Expand Down
2 changes: 1 addition & 1 deletion utils/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (


// OctoScreenVersion is set during compilation.
var OctoScreenVersion = "2.7.3"
var OctoScreenVersion = "2.7.4"

const MISSING_ENV_TOKEN = ">>MISSING<<"
const INVALID_ENV_TOKEN = "!!!INVALID!!!"
Expand Down
16 changes: 11 additions & 5 deletions utils/gtk.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"bytes"
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"path/filepath"

Expand Down Expand Up @@ -261,14 +263,18 @@ func ImageFromUrl(imageUrl string) (*gtk.Image, error) {
return nil, errors.New("imageUrl is empty")
}

response, getErr:= http.Get(imageUrl)
httpResponse, getErr:= http.Get(imageUrl)
if getErr != nil {
return nil, getErr
}
defer response.Body.Close()

buf := new(bytes.Buffer)
readLength, readErr := buf.ReadFrom(response.Body)
defer func() {
io.Copy(ioutil.Discard, httpResponse.Body)
httpResponse.Body.Close()
}()

buffer := new(bytes.Buffer)
readLength, readErr := buffer.ReadFrom(httpResponse.Body)
if readErr != nil {
return nil, readErr
} else if readLength < 1 {
Expand All @@ -281,7 +287,7 @@ func ImageFromUrl(imageUrl string) (*gtk.Image, error) {
}
defer pixbufLoader.Close()

writeLength, writeErr := pixbufLoader.Write(buf.Bytes())
writeLength, writeErr := pixbufLoader.Write(buffer.Bytes())
if writeErr != nil {
return nil, writeErr
} else if writeLength < 1 {
Expand Down

0 comments on commit 28ce7ba

Please sign in to comment.