Skip to content

Commit 7ef3c02

Browse files
authored
Merge pull request #198 from Z-Bolt/2.6.1-dev
2.6.1 release
2 parents db28333 + 72318f2 commit 7ef3c02

11 files changed

+179
-72
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.6.0
35+
VERSION := 2.6.1
3636
BUILD_DATE ?= $(shell date --utc +%Y%m%d-%H:%M:%S)
3737
#BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
3838

README.md

+6-6
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/2.6.0/octoscreen_2.6.0_armhf.deb
87-
sudo dpkg -i octoscreen_2.6-0_armhf.deb
86+
wget https://github.com/Z-Bolt/OctoScreen/releases/download/2.6.1/octoscreen_2.6.1_armhf.deb
87+
sudo dpkg -i octoscreen_2.6.1_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/2.6.0/octoscreen_2.6.0_armhf.deb
92+
wget https://github.com/Z-Bolt/OctoScreen/releases/download/2.6.1/octoscreen_2.6.1_armhf.deb
9393
sudo dpkg -r octoscreen
94-
sudo dpkg -i octoscreen_2.6.0_armhf.deb
94+
sudo dpkg -i octoscreen_2.6.1_armhf.deb
9595
sudo reboot now
9696
```
9797

@@ -138,14 +138,14 @@ The basic configuration is handled via environment variables, if you are using t
138138

139139
- `OCTOPRINT_HOST` - The URL to the OctoPrint server. Example: `http://octopi.local` or `http://localhost:5000`. Note: the protocol (`http://` or `https://`) is required. If the setting for `OCTOPRINT_HOST` does not contain the protocol, an error will be displayed when OctoScreen starts.
140140

141-
- `OCTOPRINT_APIKEY` - OctoScreen expects an [API key]( http://docs.octoprint.org/en/master/api/general.html) to be supplied. This API key can be either the globally configured key, or a user-specific one if “Access Control” is enabled.
141+
- `OCTOPRINT_APIKEY` - OctoScreen expects an [API key]( http://docs.octoprint.org/en/master/api/general.html) to be supplied. The API key can either be set in OctoScreen's config file, or in OctoPrint's config file (OCTOPRINT_CONFIG_FILE below)
142142

143143
- `OCTOSCREEN_STYLE_PATH` - Several themes are supported, and style configurations can be done through CSS. This variable defines the location of the application theme.
144144

145145

146146
#### Optional Configuration Settings
147147

148-
- `OCTOPRINT_CONFIG_FILE` - The location of the OctoPrint's config.yaml file. If empty, the file path used will be the `pi` home folder of the current user.
148+
- `OCTOPRINT_CONFIG_FILE` - The location of OctoPrint's config.yaml file. If empty, the file path used will be the `pi` home folder of the current user. The OCTOPRINT_APIKEY is required, and if it isn't defined in OctoScreen's config file (see OCTOPRINT_APIKEY above) it needs to be defined in OctoPrint's config file.
149149

150150
- `OCTOSCREEN_LOG_FILE_PATH` - The file path to where the log file will be saved. The file path should be a fully qualified path and not only include the path to the log file, but the name of the log file as well (eg `/home/pi/logs/logfile.txt`). The log file is appended to and is never automatically truncated, and will grow over time. If you turn log file logging on (by specifying a path), be sure to turn it off (by setting the value to "").
151151

debian/local/octoscreen/config

+34-17
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,49 @@
11
# Required Configuration Settings
22

3-
# Location of the OctoPrint's config.yaml file. If empty the file will
4-
# be search at the `pi` home folder or the current user. Only used for locally
5-
# installed OctoPrint servers.
6-
OCTOPRINT_CONFIG_FILE=/home/pi/.octoprint/config.yaml
7-
8-
# OctoPrint HTTP address, example `http://localhost:5000`, if OctoPrint is
9-
# locally installed will be read from the config file.
3+
# The URL to the OctoPrint server.
4+
# Example: http://octopi.local or http://localhost:5000.
5+
# Note: the protocol (http:// or https://) is required.
6+
# If the setting for OCTOPRINT_HOST does not contain the protocol,
7+
# an error will be displayed when OctoScreen starts.
108
OCTOPRINT_HOST=http://localhost:5000
119

12-
# OctoScreen expects an API key to be supplied. This API key can be either
13-
# the globally configured one or a user specific one if “Access Control”.
14-
# http://docs.octoprint.org/en/master/api/general.html, if OctoPrint is
15-
# locally installed will be read from the config file.
10+
11+
# OctoScreen expects an API key to be supplied. The API key can
12+
# either be set in OctoScreen's config file, or in OctoPrint's config
13+
# file (OCTOPRINT_CONFIG_FILE below)
1614
OCTOPRINT_APIKEY=
1715

1816

17+
# Location of the application theme
18+
OCTOSCREEN_STYLE_PATH=/opt/octoscreen/styles/z-bolt/
19+
20+
1921

2022
# Optional Configuration Settings
2123

22-
# Location of file for logging (optional)
23-
OCTOSCREEN_LOG_LEVEL=Warn
24+
# The location of OctoPrint's config.yaml file.
25+
# If empty, the file path used will be the pi home folder of the current user.
26+
# The OCTOPRINT_APIKEY is required, and if it isn't defined in OctoScreen's
27+
# config file (see OCTOPRINT_APIKEY above), it needs to be defined in OctoPrint's
28+
# config file.
29+
OCTOPRINT_CONFIG_FILE=/home/pi/.octoprint/config.yaml
2430

25-
# Location of file for logging (optional)
26-
OCTOSCREEN_LOG_FILE_PATH=logs/logfile.txt
2731

28-
# Location of the application theme (optional)
29-
OCTOSCREEN_STYLE_PATH=/opt/octoscreen/styles/z-bolt/
32+
# The file path to where the log file will be saved.
33+
# The file path should be a fully qualified path and not only include the path
34+
# to the log file, but the name of the log file as well
35+
# (eg /home/pi/logs/logfile.txt).
36+
# The log file is appended to and is never automatically truncated, and
37+
# will grow over time. If you turn log file logging on (by specifying a path),
38+
# be sure to turn it off (by setting the value to "").
39+
OCTOSCREEN_LOG_FILE_PATH=
40+
#OCTOSCREEN_LOG_FILE_PATH=/home/pi/logs/logfile.txt
41+
42+
43+
# Controls the level of logging.
44+
# Accepted values are (with increasing levels): debug, info, warn, and error.
45+
OCTOSCREEN_LOG_LEVEL=Error
46+
3047

3148
# Resolution of the application, and should be configured to the resolution of your
3249
# screen, for example 800x480.

main.go

+30-19
Original file line numberDiff line numberDiff line change
@@ -26,55 +26,56 @@ var (
2626
)
2727

2828
func main() {
29-
utils.Logger.Debug("entering main.main()")
29+
utils.Logger.Debug("OctoScreen - entering main.main()")
3030

3131
gtk.Init(nil)
3232
settings, _ := gtk.SettingsGetDefault()
3333
settings.SetProperty("gtk-application-prefer-dark-theme", true)
3434

3535
utils.DumpEnvironmentVariables()
3636

37-
if utils.RequiredEnvironmentVariablesAreSet() {
37+
if utils.RequiredEnvironmentVariablesAreSet(APIKey) {
3838
width, height := getSize()
3939
// width and height come from EnvResolution/OCTOSCREEN_RESOLUTION
4040
// and aren't required - if not set, ui.New() will use the default
4141
// values (defined in globalVars.go).
4242
_ = ui.New(BaseURL, APIKey, width, height)
4343
} else {
44-
fatalErrorWindow := ui.CreateFatalErrorWindow("Required environment variable is not set:", utils.NameOfMissingRequiredEnvironmentVariable())
44+
fatalErrorWindow := ui.CreateFatalErrorWindow("Required environment variable is not set:", utils.NameOfMissingRequiredEnvironmentVariable(APIKey))
4545
fatalErrorWindow.ShowAll()
4646
}
4747

4848
gtk.Main()
4949

50-
utils.Logger.Debug("leaving main.main()")
50+
utils.Logger.Debug("OctoScreen - leaving main.main()")
5151
}
5252

5353

5454
func init() {
55-
utils.Logger.Debug("entering main.init()")
55+
utils.Logger.Debug("OctoScreen - entering main.init()")
5656

57-
if !utils.RequiredEnvironmentVariablesAreSet() {
58-
utils.Logger.Error("main.init() - RequiredEnvironmentVariablesAreSet() returned false")
57+
ConfigFile = os.Getenv(utils.EnvConfigFile)
58+
if ConfigFile == "" {
59+
ConfigFile = findConfigFile()
60+
}
61+
62+
cfg := readConfig(ConfigFile)
63+
setApiKey(cfg)
64+
65+
if !utils.RequiredEnvironmentVariablesAreSet(APIKey) {
66+
utils.Logger.Error("OctoScreen - main.init() - RequiredEnvironmentVariablesAreSet() returned false")
5967

60-
utils.Logger.Debug("leaving main.init()")
68+
utils.Logger.Debug("OctoScreen - leaving main.init()")
6169
return
6270
}
6371

6472
setLogLevel()
6573

6674
utils.StylePath = os.Getenv(utils.EnvStylePath)
6775
Resolution = os.Getenv(utils.EnvResolution)
68-
ConfigFile = os.Getenv(utils.EnvConfigFile)
69-
if ConfigFile == "" {
70-
ConfigFile = findConfigFile()
71-
}
72-
73-
cfg := readConfig(ConfigFile)
7476
setBaseUrl(cfg)
75-
setApiKey(cfg)
7677

77-
utils.Logger.Debug("leaving main.init()")
78+
utils.Logger.Debug("OctoScreen - leaving main.init()")
7879
}
7980

8081
func setLogLevel() {
@@ -124,13 +125,23 @@ func setBaseUrl(cfg *config) {
124125
}
125126

126127
func setApiKey(cfg *config) {
128+
utils.Logger.Debug("OctoScreen - entering main.setApiKey()")
129+
127130
APIKey = os.Getenv(utils.EnvAPIKey)
128131
if APIKey == "" {
132+
utils.Logger.Debug("main.setApiKey() - APIKey is empty, now using cfg.API.Key")
133+
129134
APIKey = cfg.API.Key
130-
if cfg.API.Key != "" {
131-
utils.Logger.Infof("main.setApiKey() - found API key in file %q", ConfigFile)
132-
}
133135
}
136+
137+
if APIKey == "" {
138+
utils.Logger.Debug("main.setApiKey() - APIKey is empty!")
139+
} else {
140+
obfuscatedApiKey := utils.GetObfuscatedValue(APIKey)
141+
utils.Logger.Debugf("main.setApiKey() - APIKey is %q", obfuscatedApiKey)
142+
}
143+
144+
utils.Logger.Debug("OctoScreen - leaving main.setApiKey()")
134145
}
135146

136147

ui/CommonPanel.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
// OctoScreenVersion - set at compilation time.
18-
var OctoScreenVersion = "2.6.0"
18+
var OctoScreenVersion = "2.6.1"
1919

2020
type CommonPanel struct {
2121
UI *UI

ui/IdleStatusPanel.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (this *idleStatusPanel) initialize() {
4242
utils.Logger.Info(this.UI.Settings)
4343

4444
var menuItems []octoprint.MenuItem
45-
if this.UI.Settings == nil || len(this.UI.Settings.MenuStructure) == 0 {
45+
if this.UI.Settings == nil || this.UI.Settings.MenuStructure == nil || len(this.UI.Settings.MenuStructure) < 1 {
4646
utils.Logger.Info("Loading default menu")
4747
this.UI.Settings.MenuStructure = getDefaultMenuItems(this.UI.Client)
4848
} else {

ui/ui.go

+41-13
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (this *UI) verifyConnection() {
178178
utils.LogError("ui.verifyConnection()", "s.Current.State is IsOffline, and (ConnectRequest)Do(UI.Client)", err)
179179
splashMessage = "Loading..."
180180
} else {
181-
// Use 'Offline' here and 'offline' later. Having different variations may help in
181+
// Use 'Offline.' here and 'offline!' later. Having different variations may help in
182182
// troubleshooting any issues around this state.
183183
splashMessage = "Printer is Offline."
184184
}
@@ -212,14 +212,14 @@ func (this *UI) verifyConnection() {
212212

213213
if strings.Contains(strings.ToLower(errMessage), "deadline exceeded") {
214214
// Use 'offline' here, but no ending period.
215-
splashMessage = "Printer is offline"
215+
splashMessage = "Printer is OFFLINE"
216216
} else {
217217
splashMessage = errMessage
218218
}
219219
} else {
220-
// Use 'offline.' here and 'offline' above. Having different variations may help in
220+
// Use 'offline!' here and 'OFFLINE' above. Having different variations may help in
221221
// troubleshooting any issues around this state.
222-
splashMessage = "Printer is offline."
222+
splashMessage = "Printer is offline!"
223223
}
224224
}
225225

@@ -264,15 +264,15 @@ func (this *UI) verifyConnection() {
264264
func (this *UI) checkNotification() {
265265
utils.Logger.Debug("entering ui.checkNotification()")
266266

267+
if !this.OctoPrintPluginIsAvailable {
268+
utils.Logger.Info("ui.checkNotification() - OctoPrintPluginIsAvailable is false, so not calling GetNotification")
269+
utils.Logger.Debug("leaving ui.checkNotification()")
270+
return
271+
}
272+
267273
notificationRespone, err := (&octoprint.GetNotificationRequest{}).Do(this.Client)
268274
if err != nil {
269-
text := err.Error()
270-
if strings.Contains(strings.ToLower(text), "unexpected status code: 404") {
271-
this.OctoPrintPluginIsAvailable = false
272-
}
273-
274275
utils.LogError("ui.checkNotification()", "Do(GetNotificationRequest)", err)
275-
276276
utils.Logger.Debug("leaving ui.checkNotification()")
277277
return
278278
}
@@ -289,9 +289,22 @@ func (this *UI) loadSettings() {
289289

290290
settingsResponse, err := (&octoprint.GetSettingsRequest{}).Do(this.Client)
291291
if err != nil {
292-
utils.LogError("ui.loadSettings()", "Do(GetSettingsRequest)", err)
293-
utils.Logger.Error("leaving ui.loadSettings() - Do(GetSettingsRequest) returned an error")
292+
text := err.Error()
293+
if strings.Contains(strings.ToLower(text), "unexpected status code: 404") {
294+
// The call to GetSettings is also used to determine whether or not the
295+
// OctoScreen plug-in is available. If calling GetSettings returns
296+
// a 404, the plug-in isn't available.
297+
this.OctoPrintPluginIsAvailable = false
298+
utils.Logger.Info("The OctoPrint plug-in is not available")
299+
} else {
300+
// If we get back any other kind of error, something bad happened, so log an error.
301+
utils.LogError("ui.loadSettings()", "Do(GetSettingsRequest)", err)
302+
}
303+
304+
utils.Logger.Debug("leaving ui.loadSettings()")
294305
return
306+
} else {
307+
utils.Logger.Info("The call to GetSettings succeeded and the OctoPrint plug-in is available")
295308
}
296309

297310
if !this.validateMenuItems(settingsResponse.MenuStructure, "", true) {
@@ -364,9 +377,24 @@ func (this *UI) update() {
364377
this.connectionAttempts = 0
365378
}
366379

380+
if this.Settings == nil {
381+
this.loadSettings()
382+
383+
if this.Settings == nil {
384+
this.Settings = &octoprint.GetSettingsResponse {
385+
FilamentInLength: 750.0,
386+
FilamentOutLength: 800.0,
387+
ToolChanger: false,
388+
XAxisInverted: false,
389+
YAxisInverted: false,
390+
ZAxisInverted: false,
391+
MenuStructure: nil,
392+
}
393+
}
394+
}
395+
367396
if this.OctoPrintPluginIsAvailable {
368397
this.checkNotification()
369-
this.loadSettings()
370398
}
371399

372400
this.verifyConnection()

uiWidgets/SystemInformationInfoBox.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func createStyledLabel() *gtk.Label {
8787
func (this *SystemInformationInfoBox) refreshMemoryLabel() {
8888
virtualMemoryStat, _ := mem.VirtualMemory()
8989
memoryString := fmt.Sprintf(
90-
"Virtual memory: %s (free) / %s (total)",
90+
"Memory: %s (free) / %s (total)",
9191
humanize.Bytes(virtualMemoryStat.Free),
9292
humanize.Bytes(virtualMemoryStat.Total),
9393
)

uiWidgets/TemperatureStatusBox.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ func CreateTemperatureStatusBox(
5454
hotendIndex++
5555

5656
if includeHotends {
57-
strImageFileName := utils.GetNozzleFileName(hotendIndex, hotendCount)
58-
instance.labelWithImages[key] = utils.MustLabelWithImage(strImageFileName, "")
59-
instance.Add(instance.labelWithImages[key])
57+
if hotendIndex <= hotendCount {
58+
strImageFileName := utils.GetNozzleFileName(hotendIndex, hotendCount)
59+
instance.labelWithImages[key] = utils.MustLabelWithImage(strImageFileName, "")
60+
instance.Add(instance.labelWithImages[key])
61+
}
6062
}
6163
}
6264
}

0 commit comments

Comments
 (0)