@@ -113,8 +113,8 @@ def get_reboot_cause_from_platform():
113113 chassis = platform .get_chassis ()
114114 hardware_reboot_cause_major , hardware_reboot_cause_minor = chassis .get_reboot_cause ()
115115 sonic_logger .log_info ("Platform api returns reboot cause {}, {}" .format (hardware_reboot_cause_major , hardware_reboot_cause_minor ))
116- except (ImportError , FileNotFoundError ):
117- sonic_logger .log_warning ("sonic_platform package not installed. Unable to detect hardware reboot causes." )
116+ except (ImportError , FileNotFoundError , NotImplementedError ):
117+ sonic_logger .log_warning ("sonic_platform package not installed or not implemented . Unable to detect hardware reboot causes." )
118118 hardware_reboot_cause_major , hardware_reboot_cause_minor = REBOOT_CAUSE_NON_HARDWARE , "N/A"
119119
120120 return hardware_reboot_cause_major , hardware_reboot_cause_minor
@@ -143,7 +143,7 @@ def get_reboot_cause_dict(previous_reboot_cause, comment, gen_time):
143143 If user issued a command to reboot device, then user, command and time will be
144144 stored into a dictionary.
145145
146- If device was rebooted due to the kernel panic, then the string `Kernel Panic`
146+ If device was rebooted due to the kernel panic, then the string `Kernel Panic`
147147 and time will be stored into a dictionary.
148148 """
149149 reboot_cause_dict = {}
@@ -165,7 +165,7 @@ def get_reboot_cause_dict(previous_reboot_cause, comment, gen_time):
165165 if match is not None :
166166 reboot_cause_dict ['cause' ] = "Kernel Panic"
167167 reboot_cause_dict ['time' ] = match .group (1 )
168-
168+
169169 return reboot_cause_dict
170170
171171def determine_reboot_cause ():
@@ -185,12 +185,12 @@ def determine_reboot_cause():
185185 software_reboot_cause = find_software_reboot_cause ()
186186
187187 # The main decision logic of the reboot cause:
188- # If there is a valid hardware reboot cause indicated by platform API,
188+ # If there is a valid hardware reboot cause indicated by platform API,
189189 # check the software reboot cause to add additional reboot cause.
190190 # If there is a reboot cause indicated by /proc/cmdline, and/or warmreboot/fastreboot/softreboot
191191 # the software_reboot_cause which is the content of /hosts/reboot-cause/reboot-cause.txt
192192 # will be treated as the additional reboot cause
193- # Elif there is a cmdline reboot cause,
193+ # Elif there is a cmdline reboot cause,
194194 # the software_reboot_cause will be treated as the reboot cause if it's not unknown
195195 # otherwise, the cmdline_reboot_cause will be treated as the reboot cause if it's not none
196196 # Else the software_reboot_cause will be treated as the reboot cause
@@ -266,7 +266,7 @@ def main():
266266 # Write the previous reboot cause to REBOOT_CAUSE_HISTORY_FILE as a JSON format
267267 with open (REBOOT_CAUSE_HISTORY_FILE , "w" ) as reboot_cause_history_file :
268268 json .dump (reboot_cause_dict , reboot_cause_history_file )
269-
269+
270270 # Remove stale PREVIOUS_REBOOT_CAUSE_FILE if it exists
271271 if os .path .exists (PREVIOUS_REBOOT_CAUSE_FILE ) or os .path .islink (PREVIOUS_REBOOT_CAUSE_FILE ):
272272 os .remove (PREVIOUS_REBOOT_CAUSE_FILE )
0 commit comments