Skip to content

Commit 28ce7ba

Browse files
authored
Merge pull request #313 from Z-Bolt/2.7.4-dev
2.7.4 dev into master
2 parents b073bbe + 43bc5d2 commit 28ce7ba

9 files changed

+79
-17
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ JESSIE_GO_TAGS := gtk_3_14
3232

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

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ There are two ways to install OctoScreen: the recommended and supported way is t
8383

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

9090
Or to update an existing version of OctoScreen:
9191
```sh
92-
wget https://github.com/Z-Bolt/OctoScreen/releases/download/v2.7.3/octoscreen_2.7.3_armhf.deb
92+
wget https://github.com/Z-Bolt/OctoScreen/releases/download/v2.7.4/octoscreen_2.7.4_armhf.deb
9393
sudo dpkg -r octoscreen
94-
sudo dpkg -i octoscreen_2.7.3_armhf.deb
94+
sudo dpkg -i octoscreen_2.7.4_armhf.deb
9595
sudo reboot now
9696
```
9797

octoprintApis/client.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ func (this *Client) handleResponse(
140140
) ([]byte, error) {
141141
logger.TraceEnter("Client.handleResponse()")
142142

143-
defer httpResponse.Body.Close()
143+
defer func() {
144+
io.Copy(ioutil.Discard, httpResponse.Body)
145+
httpResponse.Body.Close()
146+
}()
144147

145148
if statusMapping != nil {
146149
if err := statusMapping.Error(httpResponse.StatusCode); err != nil {

ui/IdleStatusPanel.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package ui
33
import (
44
// "encoding/json"
55
// "fmt"
6+
"os"
7+
"strconv"
68
// "sync"
79
"time"
810

@@ -31,7 +33,23 @@ func IdleStatusPanel(ui *UI) *idleStatusPanel {
3133
instance := &idleStatusPanel{
3234
CommonPanel: NewTopLevelCommonPanel("IdleStatusPanel", ui),
3335
}
34-
instance.backgroundTask = utils.CreateBackgroundTask(time.Second * 2, instance.update)
36+
37+
// Default timeout of 20 seconds.
38+
durration := time.Second * 20
39+
40+
// Experimental, set the timeout based on config setting, but only if the config is pressent.
41+
updateFrequency := os.Getenv("EXPERIMENTAL_IDLE_UPDATE_FREQUENCY")
42+
if updateFrequency != "" {
43+
logger.Infof("Ui.New() - EXPERIMENTAL_IDLE_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency)
44+
val, err := strconv.Atoi(updateFrequency)
45+
if err == nil {
46+
durration = time.Second * time.Duration(val)
47+
} else {
48+
logger.LogError("Ui.New()", "strconv.Atoi()", err)
49+
}
50+
}
51+
52+
instance.backgroundTask = utils.CreateBackgroundTask(durration, instance.update)
3553
instance.initialize()
3654

3755
idleStatusPanelInstance = instance

ui/NetworkPanel.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package ui
33
import (
44
"fmt"
55
"net"
6+
"os"
7+
"strconv"
68
"time"
79

810
"pifke.org/wpasupplicant"
@@ -33,7 +35,23 @@ func NetworkPanel(
3335
CommonPanel: NewCommonPanel("NetworkPanel", ui),
3436
}
3537
instance.initialize()
36-
instance.backgroundTask = utils.CreateBackgroundTask(time.Second * 3, instance.update)
38+
39+
// Default timeout of 30 seconds.
40+
durration := time.Second * 30
41+
42+
// Experimental, set the timeout based on config setting, but only if the config is pressent.
43+
updateFrequency := os.Getenv("EXPERIMENTAL_NETWORK_UPDATE_FREQUENCY")
44+
if updateFrequency != "" {
45+
logger.Infof("Ui.New() - EXPERIMENTAL_NETWORK_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency)
46+
val, err := strconv.Atoi(updateFrequency)
47+
if err == nil {
48+
durration = time.Second * time.Duration(val)
49+
} else {
50+
logger.LogError("Ui.New()", "strconv.Atoi()", err)
51+
}
52+
}
53+
54+
instance.backgroundTask = utils.CreateBackgroundTask(durration, instance.update)
3755
networkPanelInstance = instance
3856
}
3957

ui/PrintStatusPanel.go

+18-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package ui
22

33
import (
44
"fmt"
5+
"os"
6+
"strconv"
57
"strings"
68
"time"
79

@@ -43,9 +45,24 @@ func PrintStatusPanel(ui *UI) *printStatusPanel {
4345
CommonPanel: NewTopLevelCommonPanel("PrintStatusPanel", ui),
4446
}
4547

48+
// Default timeout of 20 seconds.
49+
durration := time.Second * 20
50+
51+
// Experimental, set the timeout based on config setting, but only if the config is pressent.
52+
updateFrequency := os.Getenv("EXPERIMENTAL_PRINT_UPDATE_FREQUENCY")
53+
if updateFrequency != "" {
54+
logger.Infof("Ui.New() - EXPERIMENTAL_PRINT_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency)
55+
val, err := strconv.Atoi(updateFrequency)
56+
if err == nil {
57+
durration = time.Second * time.Duration(val)
58+
} else {
59+
logger.LogError("Ui.New()", "strconv.Atoi()", err)
60+
}
61+
}
62+
4663
// TODO: revisit... some set the background task and then initialize
4764
// and others initialize and then set the background task
48-
instance.backgroundTask = utils.CreateBackgroundTask(time.Second * 2, instance.update)
65+
instance.backgroundTask = utils.CreateBackgroundTask(durration, instance.update)
4966
instance.initialize()
5067
printStatusPanelInstance = instance
5168
}

ui/ui.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ func New(endpoint, key string, width, height int) *UI {
107107
durration := time.Second * 20
108108

109109
// Experimental, set the timeout based on config setting, but only if the config is pressent.
110-
updateFrequency := os.Getenv("EXPERIMENTAL_UPDATE_FREQUENCY")
110+
updateFrequency := os.Getenv("EXPERIMENTAL_UI_UPDATE_FREQUENCY")
111111
if updateFrequency != "" {
112-
logger.Infof("Ui.New() - EXPERIMENTAL_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency)
112+
logger.Infof("Ui.New() - EXPERIMENTAL_UI_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency)
113113
val, err := strconv.Atoi(updateFrequency)
114114
if err == nil {
115115
durration = time.Second * time.Duration(val)

utils/environment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212

1313
// OctoScreenVersion is set during compilation.
14-
var OctoScreenVersion = "2.7.3"
14+
var OctoScreenVersion = "2.7.4"
1515

1616
const MISSING_ENV_TOKEN = ">>MISSING<<"
1717
const INVALID_ENV_TOKEN = "!!!INVALID!!!"

utils/gtk.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"bytes"
55
"errors"
66
"fmt"
7+
"io"
8+
"io/ioutil"
79
"net/http"
810
"path/filepath"
911

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

264-
response, getErr:= http.Get(imageUrl)
266+
httpResponse, getErr:= http.Get(imageUrl)
265267
if getErr != nil {
266268
return nil, getErr
267269
}
268-
defer response.Body.Close()
269270

270-
buf := new(bytes.Buffer)
271-
readLength, readErr := buf.ReadFrom(response.Body)
271+
defer func() {
272+
io.Copy(ioutil.Discard, httpResponse.Body)
273+
httpResponse.Body.Close()
274+
}()
275+
276+
buffer := new(bytes.Buffer)
277+
readLength, readErr := buffer.ReadFrom(httpResponse.Body)
272278
if readErr != nil {
273279
return nil, readErr
274280
} else if readLength < 1 {
@@ -281,7 +287,7 @@ func ImageFromUrl(imageUrl string) (*gtk.Image, error) {
281287
}
282288
defer pixbufLoader.Close()
283289

284-
writeLength, writeErr := pixbufLoader.Write(buf.Bytes())
290+
writeLength, writeErr := pixbufLoader.Write(buffer.Bytes())
285291
if writeErr != nil {
286292
return nil, writeErr
287293
} else if writeLength < 1 {

0 commit comments

Comments
 (0)