Skip to content

Instantly share code, notes, and snippets.

@stuthedew
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuthedew/10011611 to your computer and use it in GitHub Desktop.
Save stuthedew/10011611 to your computer and use it in GitHub Desktop.
Python script to stop Raspberry Pi Watchdog if settings cause continues rebooting. Must be run from second computer. Attempts to connect to raspberry pi for about a minute. Start as soon as problematic Raspberry Pi begins startup
import spur
import sys
#change to match your setup if different
#/////////////////////////////////
piHostName= 'raspberrypi.local'
piUsername = 'pi'
piPasswd = '' #Enter password
verbose = False
#////////////////////////////////
attempts = 0
while attempts < 120:
try:
print("attempt " + str(attempts) + "...")
shell = spur.SshShell(hostname=piHostName, username=piUsername, password=piPasswd)
print("connected")
with shell:
result = shell.run(['sudo', 'update-rc.d', 'watchdog', 'disable'])
print(result.output)
result = shell.run(['sudo', 'service', 'watchdog', 'stop'])
print(result.output)
break #if successful, leave loop
except Exception, e:
if (verbose):
print e
print("failed")
attempts +=1
time.sleep(0.5)
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment