Remove debugging output as it's not part of production releases

This commit is contained in:
KemoNine 2020-09-20 20:20:42 -04:00
parent 35e0032826
commit 39451ec3b3
9 changed files with 1 additions and 61 deletions

View file

@ -33,12 +33,6 @@ func main() {
log.Fatalf("Config file changed! Exiting!") log.Fatalf("Config file changed! Exiting!")
}) })
log.Print("========================================")
pfConfig.Print()
log.Print("========================================")
log.Print(pfConfig.Keys())
log.Print("========================================")
// Get the various fan related config options as local variables // Get the various fan related config options as local variables
speedMap := pfConfig.Float64Map(config.CONFIG_KEY_FAN_SPEEDS) speedMap := pfConfig.Float64Map(config.CONFIG_KEY_FAN_SPEEDS)
POLL_INTERVAL := pfConfig.String(config.CONFIG_KEY_FAN_POLL_INTERVAL) POLL_INTERVAL := pfConfig.String(config.CONFIG_KEY_FAN_POLL_INTERVAL)
@ -48,14 +42,6 @@ func main() {
SPEED_TWENTY_FIVE_PERCENT_TEMP := pfConfig.Float64(config.CONFIG_KEY_FAN_SPEEDS + "." + config.CONFIG_MAP_KEY_FAN_SPEED_25) SPEED_TWENTY_FIVE_PERCENT_TEMP := pfConfig.Float64(config.CONFIG_KEY_FAN_SPEEDS + "." + config.CONFIG_MAP_KEY_FAN_SPEED_25)
SPEED_MINIMUM := pfConfig.Int(config.CONFIG_KEY_FAN_MIN_SPEED) SPEED_MINIMUM := pfConfig.Int(config.CONFIG_KEY_FAN_MIN_SPEED)
log.Print(speedMap)
log.Print(POLL_INTERVAL)
log.Print(SPEED_FULL_TEMP)
log.Print(SPEED_SEVENTY_FIVE_PERCENT_TEMP)
log.Print(SPEED_FIFTY_PERCENT_TEMP)
log.Print(SPEED_TWENTY_FIVE_PERCENT_TEMP)
log.Print(SPEED_MINIMUM)
// Setup fan and bail if we can't see it // Setup fan and bail if we can't see it
fan, err := argonFan.New(ADDRESS, BUS) fan, err := argonFan.New(ADDRESS, BUS)
if err != nil { if err != nil {
@ -90,52 +76,43 @@ func main() {
if cpuTemp >= SPEED_FULL_TEMP || gpuTemp >= SPEED_FULL_TEMP { if cpuTemp >= SPEED_FULL_TEMP || gpuTemp >= SPEED_FULL_TEMP {
if SPEED_MINIMUM > 100 { if SPEED_MINIMUM > 100 {
log.Print("MIN speed in 100")
fan.SetSpeed(SPEED_MINIMUM) fan.SetSpeed(SPEED_MINIMUM)
} else { } else {
log.Print("Speed 100%")
fan.SetSpeed(100) fan.SetSpeed(100)
} }
continue continue
} }
if cpuTemp >= SPEED_SEVENTY_FIVE_PERCENT_TEMP || gpuTemp >= SPEED_SEVENTY_FIVE_PERCENT_TEMP { if cpuTemp >= SPEED_SEVENTY_FIVE_PERCENT_TEMP || gpuTemp >= SPEED_SEVENTY_FIVE_PERCENT_TEMP {
if SPEED_MINIMUM > 75 { if SPEED_MINIMUM > 75 {
log.Print("MIN speed in 75")
fan.SetSpeed(SPEED_MINIMUM) fan.SetSpeed(SPEED_MINIMUM)
} else { } else {
log.Print("Speed 75%")
fan.SetSpeed(75) fan.SetSpeed(75)
} }
continue continue
} }
if cpuTemp >= SPEED_FIFTY_PERCENT_TEMP || gpuTemp >= SPEED_FIFTY_PERCENT_TEMP { if cpuTemp >= SPEED_FIFTY_PERCENT_TEMP || gpuTemp >= SPEED_FIFTY_PERCENT_TEMP {
if SPEED_MINIMUM > 50 { if SPEED_MINIMUM > 50 {
log.Print("MIN speed in 50")
fan.SetSpeed(SPEED_MINIMUM) fan.SetSpeed(SPEED_MINIMUM)
} else { } else {
log.Print("Speed 50%")
fan.SetSpeed(50) fan.SetSpeed(50)
} }
continue continue
} }
if cpuTemp >= SPEED_TWENTY_FIVE_PERCENT_TEMP || gpuTemp >= SPEED_TWENTY_FIVE_PERCENT_TEMP { if cpuTemp >= SPEED_TWENTY_FIVE_PERCENT_TEMP || gpuTemp >= SPEED_TWENTY_FIVE_PERCENT_TEMP {
if SPEED_MINIMUM > 25 { if SPEED_MINIMUM > 25 {
log.Print("MIN speed in 25")
fan.SetSpeed(SPEED_MINIMUM) fan.SetSpeed(SPEED_MINIMUM)
} else { } else {
log.Print("Speed 25%")
fan.SetSpeed(25) fan.SetSpeed(25)
} }
continue continue
} }
if cpuTemp < SPEED_TWENTY_FIVE_PERCENT_TEMP || gpuTemp < SPEED_TWENTY_FIVE_PERCENT_TEMP { if cpuTemp < SPEED_TWENTY_FIVE_PERCENT_TEMP || gpuTemp < SPEED_TWENTY_FIVE_PERCENT_TEMP {
log.Print("MIN SPEED")
fan.SetSpeed(SPEED_MINIMUM) fan.SetSpeed(SPEED_MINIMUM)
continue continue
} }
// We should never get here but... // We should never get here but...
// Maxing fan to be on the safe side // Maxing fan to be on the safe side
log.Print("This should never happen") log.Print("pf-fan : This should never happen")
fan.SetSpeed(100) fan.SetSpeed(100)
} }
} }

View file

@ -15,7 +15,6 @@ import (
) )
func main() { func main() {
log.Print("Starting up")
// Command line flag handler // Command line flag handler
f := flag.NewFlagSet("piframe", flag.ContinueOnError) f := flag.NewFlagSet("piframe", flag.ContinueOnError)
f.Usage = func() { f.Usage = func() {
@ -23,7 +22,6 @@ func main() {
os.Exit(0) os.Exit(0)
} }
// Command line flags // Command line flags
log.Print("Setting up CLI flags")
f.Bool(config.CLI_FLAG_CONFIG_ONLY, false, "Only show the config UI, NOT the slideshow") f.Bool(config.CLI_FLAG_CONFIG_ONLY, false, "Only show the config UI, NOT the slideshow")
cliFlag := f.Lookup(config.CLI_FLAG_CONFIG_ONLY) cliFlag := f.Lookup(config.CLI_FLAG_CONFIG_ONLY)
if cliFlag != nil { if cliFlag != nil {
@ -32,11 +30,8 @@ func main() {
// Process command line flags into handler // Process command line flags into handler
f.Parse(os.Args[1:]) f.Parse(os.Args[1:])
log.Print("Loading config")
// Load the config file // Load the config file
pfConfig, configFileProvider := config.LoadConfig(false) pfConfig, configFileProvider := config.LoadConfig(false)
log.Printf("%v", pfConfig)
pfConfig.Print()
// Watch for config changes and re-load config if needed // Watch for config changes and re-load config if needed
configFileProvider.Watch(func(event interface{}, err error) { configFileProvider.Watch(func(event interface{}, err error) {

View file

@ -18,7 +18,6 @@ const (
func main() { func main() {
// Load the config file // Load the config file
pfConfig, _ := config.LoadConfig(false) pfConfig, _ := config.LoadConfig(false)
pfConfig.Print()
// Read config values // Read config values
hdmiOn := pfConfig.String(config.CONFIG_KEY_HDMI_ON) hdmiOn := pfConfig.String(config.CONFIG_KEY_HDMI_ON)
@ -32,9 +31,6 @@ func main() {
hdmiOff = strings.TrimLeft(hdmiOff, "*-*-* ") hdmiOff = strings.TrimLeft(hdmiOff, "*-*-* ")
hdmiOffSplit := strings.Split(hdmiOff, ":") hdmiOffSplit := strings.Split(hdmiOff, ":")
log.Print(hdmiOnSplit)
log.Print(hdmiOffSplit)
// Parse hdmi on hours/minutes/seconds into ints so they can be used to create real date/time // Parse hdmi on hours/minutes/seconds into ints so they can be used to create real date/time
hdmiOnHour, err := strconv.Atoi(hdmiOnSplit[0]) hdmiOnHour, err := strconv.Atoi(hdmiOnSplit[0])
if err != nil { if err != nil {
@ -68,18 +64,12 @@ func main() {
hdmiOnTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), hdmiOnHour, hdmiOnMinute, hdmiOnSecond, 0, currentTime.Location()) hdmiOnTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), hdmiOnHour, hdmiOnMinute, hdmiOnSecond, 0, currentTime.Location())
hdmiOffTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), hdmiOffHour, hdmiOffMinute, hdmiOffSecond, 0, currentTime.Location()) hdmiOffTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), hdmiOffHour, hdmiOffMinute, hdmiOffSecond, 0, currentTime.Location())
log.Print(currentTime)
log.Print(hdmiOnTime)
log.Print(hdmiOffTime)
// Turn on/off screen depending on current time // Turn on/off screen depending on current time
vcgencmdOnOffFlag := "-1" vcgencmdOnOffFlag := "-1"
if currentTime.After(hdmiOnTime) && currentTime.Before(hdmiOffTime) { if currentTime.After(hdmiOnTime) && currentTime.Before(hdmiOffTime) {
log.Print("Turning ON screen")
vcgencmdOnOffFlag = "1" vcgencmdOnOffFlag = "1"
} }
if currentTime.After(hdmiOffTime) && currentTime.Before(hdmiOnTime) { if currentTime.After(hdmiOffTime) && currentTime.Before(hdmiOnTime) {
log.Print("Turning OFF screen")
vcgencmdOnOffFlag = "0" vcgencmdOnOffFlag = "0"
} }

View file

@ -60,8 +60,6 @@ func main() {
if !ok { if !ok {
return return
} }
// Print out event (this is where logic will go eventually))
log.Printf("event: %#v\n", event)
// [Re]Start timer to restart slideshow after the fs events die down // [Re]Start timer to restart slideshow after the fs events die down
watchdog.Kick() watchdog.Kick()
case err, ok := <-watcher.Errors: case err, ok := <-watcher.Errors:

View file

@ -90,7 +90,6 @@ func main() {
// Doing stuff with the file contents goes here // Doing stuff with the file contents goes here
essid := config[0] essid := config[0]
password := config[1] password := config[1]
log.Printf("Using config: %s / %s for WiFi\n", essid, password)
// Cleanup old wifi configs and apply new one // Cleanup old wifi configs and apply new one
nmWifi := wifi.New(essid, password) nmWifi := wifi.New(essid, password)

View file

@ -28,7 +28,6 @@ func LoadConfig(errFatalOnMissing bool) (*koanf.Koanf, *kfile.File) {
// Bring in /etc/defaults/pf.toml if it exists // Bring in /etc/defaults/pf.toml if it exists
configFileProvider := kfile.Provider(CONFIG_FILE_PATH) configFileProvider := kfile.Provider(CONFIG_FILE_PATH)
log.Print("========================================")
if err := pfConfig.Load(configFileProvider, toml.Parser()); err != nil { if err := pfConfig.Load(configFileProvider, toml.Parser()); err != nil {
if errFatalOnMissing { if errFatalOnMissing {
log.Fatalf("Error loading config : %s", err) log.Fatalf("Error loading config : %s", err)
@ -36,12 +35,6 @@ func LoadConfig(errFatalOnMissing bool) (*koanf.Koanf, *kfile.File) {
log.Printf("Error loading config : %s", err) log.Printf("Error loading config : %s", err)
} }
} }
log.Print("========================================")
log.Print("========================================")
log.Print("Loaded Config")
pfConfig.Print()
log.Print("========================================")
return pfConfig, configFileProvider return pfConfig, configFileProvider
} }

View file

@ -331,7 +331,6 @@ func ConfigGui(pfconfig *koanf.Koanf) {
for _, i := range ifaces { for _, i := range ifaces {
addrs, err := i.Addrs() addrs, err := i.Addrs()
if err != nil { if err != nil {
log.Printf("Error getting interface addresses : %s", err)
continue continue
} }
for _, a := range addrs { for _, a := range addrs {

View file

@ -25,7 +25,6 @@ var fim *exec.Cmd = nil
var stdin io.WriteCloser = nil var stdin io.WriteCloser = nil
func setupFim(PATH_TEMP_FOR_SLIDESHOW string) { func setupFim(PATH_TEMP_FOR_SLIDESHOW string) {
log.Print("Setting up new fim process")
// Prep slideshow command and arguments // Prep slideshow command and arguments
// NOTE: The random flag is seeded with time() ; this is bad as we will be restarting the slideshow at about the same time per the configurd schedule // NOTE: The random flag is seeded with time() ; this is bad as we will be restarting the slideshow at about the same time per the configurd schedule
// We use the non-seeded form to ensure that it's a little more random (or at least hope it's a little more random) // We use the non-seeded form to ensure that it's a little more random (or at least hope it's a little more random)
@ -57,7 +56,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
// /run is a tmpfs so this won't wear on the sd card storage // /run is a tmpfs so this won't wear on the sd card storage
// Create temp folder // Create temp folder
log.Print("Creating temp folder for album selections")
_, err := os.Stat(PATH_TEMP_FOR_SLIDESHOW) _, err := os.Stat(PATH_TEMP_FOR_SLIDESHOW)
if os.IsNotExist(err) { if os.IsNotExist(err) {
errDir := os.MkdirAll(PATH_TEMP_FOR_SLIDESHOW, 0755) errDir := os.MkdirAll(PATH_TEMP_FOR_SLIDESHOW, 0755)
@ -67,7 +65,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
} }
// Cleanup temp folder if it already existed // Cleanup temp folder if it already existed
log.Print("Cleaning up temp folder if it exists")
dirRead, err := os.Open(PATH_TEMP_FOR_SLIDESHOW) dirRead, err := os.Open(PATH_TEMP_FOR_SLIDESHOW)
if err != nil { if err != nil {
log.Fatalf("Error setting up slideshow : %s", err) log.Fatalf("Error setting up slideshow : %s", err)
@ -93,7 +90,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
// Setup symlinks to selected albums to be used with slideshow // Setup symlinks to selected albums to be used with slideshow
// Add albums full paths to command line args for fim // Add albums full paths to command line args for fim
log.Print("Setting up symlinks to selected albums")
albumRootPath := pfconfig.String(config.CONFIG_KEY_ALBUMS_ROOT) albumRootPath := pfconfig.String(config.CONFIG_KEY_ALBUMS_ROOT)
for _, album := range pfconfig.Strings(config.CONFIG_KEY_ALBUMS_SELECTED) { for _, album := range pfconfig.Strings(config.CONFIG_KEY_ALBUMS_SELECTED) {
source := albumRootPath + album source := albumRootPath + album
@ -131,7 +127,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
setupFim(PATH_TEMP_FOR_SLIDESHOW) setupFim(PATH_TEMP_FOR_SLIDESHOW)
// Advance slideshow every interval as defined in const() // Advance slideshow every interval as defined in const()
log.Print("Setting up slideshow advance slide ticker")
slideshowAdvanceDurationString := pfconfig.String(config.CONFIG_KEY_SLIDESHOW_INTERVAL) slideshowAdvanceDurationString := pfconfig.String(config.CONFIG_KEY_SLIDESHOW_INTERVAL)
slideshowAdvanceDuration, err := time.ParseDuration(slideshowAdvanceDurationString) slideshowAdvanceDuration, err := time.ParseDuration(slideshowAdvanceDurationString)
if err != nil { if err != nil {
@ -172,7 +167,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
STOP_SLIDESHOW := false STOP_SLIDESHOW := false
// Goroutine for tracking which keys are pressed and controlling fim if appropriate // Goroutine for tracking which keys are pressed and controlling fim if appropriate
log.Print("Setting up keyboard listener")
keyboardCtx, keyboardCancel := context.WithCancel(context.Background()) keyboardCtx, keyboardCancel := context.WithCancel(context.Background())
go func(keyboardCtx context.Context) { go func(keyboardCtx context.Context) {
for { for {
@ -210,7 +204,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
// Control fim if we received a valid key for next/previous slide // Control fim if we received a valid key for next/previous slide
if fimKey != "" { if fimKey != "" {
log.Printf("Sending key to fim : %s", fimKey)
_, err = io.WriteString(stdin, fimKey) _, err = io.WriteString(stdin, fimKey)
if err != nil { if err != nil {
log.Fatalf("Error controlling fim : %s", err) log.Fatalf("Error controlling fim : %s", err)
@ -222,7 +215,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
}(keyboardCtx) }(keyboardCtx)
// Restart fim after configured timeout ; This is setup as a ticker due to KemoNine not getting CommandWithContext stuff to work properly (lots of pointer related crashes and the like) // Restart fim after configured timeout ; This is setup as a ticker due to KemoNine not getting CommandWithContext stuff to work properly (lots of pointer related crashes and the like)
log.Print("Setting up fim restart ticker")
fimRestartDurationString := pfconfig.String(config.CONFIG_KEY_SLIDESHOW_RESTART_INTERVAL) fimRestartDurationString := pfconfig.String(config.CONFIG_KEY_SLIDESHOW_RESTART_INTERVAL)
fimRestartDuration, err := time.ParseDuration(fimRestartDurationString) fimRestartDuration, err := time.ParseDuration(fimRestartDurationString)
if err != nil { if err != nil {
@ -251,7 +243,6 @@ func Slideshow(pfconfig *koanf.Koanf) {
// Run fim // Run fim
for !STOP_SLIDESHOW { for !STOP_SLIDESHOW {
log.Print("Top of fim slideshow loop")
if err := fim.Run(); err != nil { if err := fim.Run(); err != nil {
// Unwrap the error a bit so we can find out if a signal killed fim or something else // Unwrap the error a bit so we can find out if a signal killed fim or something else
// An exit code of -1 means the program didn't exit in time or was terminated by a signal (per the docs) // An exit code of -1 means the program didn't exit in time or was terminated by a signal (per the docs)

View file

@ -35,14 +35,12 @@ func (w *wifi) ApplyConfig() {
if details[2] != "802-11-wireless" { if details[2] != "802-11-wireless" {
continue continue
} }
log.Printf("Cleaning up WiFi connection %s", details[0])
err := exec.Command(CMD_NMCLI, "connection", "del", details[1]).Run() err := exec.Command(CMD_NMCLI, "connection", "del", details[1]).Run()
if err != nil { if err != nil {
log.Fatalf("Error running %s : %s", CMD_NMCLI, err) log.Fatalf("Error running %s : %s", CMD_NMCLI, err)
} }
} }
// Create new WiFi connection with network manager // Create new WiFi connection with network manager
log.Printf("Connecting to %s with password %s\n", w.essid, w.password)
err = exec.Command(CMD_NMCLI, "d", "wifi", "connect", w.essid, "password", w.password).Run() err = exec.Command(CMD_NMCLI, "d", "wifi", "connect", w.essid, "password", w.password).Run()
if err != nil { if err != nil {
log.Fatalf("Error running %s : %s", CMD_NMCLI, err) log.Fatalf("Error running %s : %s", CMD_NMCLI, err)