Opened 15 years ago
Closed 15 years ago
#6529 closed defect (fixed)
Mythshutdown return codes not consistent
Reported by: | Owned by: | paulh | |
---|---|---|---|
Priority: | minor | Milestone: | 0.22 |
Component: | MythTV - Mythwelcome & Mythshutdown | Version: | head |
Severity: | low | Keywords: | |
Cc: | Ticket locked: | no |
Description
Hi,
I am using mythwelcome and mythshutdown including the periodic daily wake-up times for my MythTV server. I tried to implement that by using mythshutdown -t for setting the next scheduled startup time and then mythshutdown --shutdown to call a script that writes the next startup time to the ACPI.
Unfortunately this does NOT work without a tweak, as the return code for int setScheduledWakeupTime() is not consistent with the return code of int setWakeupTime(QString sWakeupTime). Instead of returning an integer value it returns a boolean, and the boolean is oppposite to what is expected by the main program to shutdown properly.
Explanation: int setWakeupTime(QString sWakeupTime) returns a 1 if an error occurs or a 0 if the function was able to set the time.
int setScheduledWakeupTime() returns a true (!=0) if it was able to set a new wakeup time or a false (==0) if not setup time was set.
This is conflicting and causing problems with the integration.
Recommended Change:
int setScheduledWakeupTime(): -> remove true/false for return codes -> return 0 if it was able to set a new wakeup time -> return 1 if no scheduled wakeup time was found
So basically:
set the wakeup time for the next scheduled recording
if (!m_nextRecordingStart.isNull()) {
int m_preRollSeconds = gContext->GetNumSetting?("RecordPreRoll?"); QDateTime restarttime = m_nextRecordingStart.addSecs((-1) * m_preRollSeconds);
int add = gContext->GetNumSetting?("StartupSecsBeforeRecording?", 240); if (add) restarttime = restarttime.addSecs((-1) * add); QString wakeup_timeformat = Context->GetSetting?("WakeupTimeFormat?",
"yyyy-MM-ddThh:mm");
return setWakeupTime(restarttime.toString(wakeup_timeformat));
} return 1; }
I don't think it was ever intended that mythshutdown -t should be used in place of mythshutdown -w it was added so people could roll there own scripts see the original ticket #3176. No idea why it's returning inverted return codes though so I'll fix that.