def StartUp():
debug("Startup")
if os.path.exists(SCRIPTHOME):
os.chdir(SCRIPTHOME)
oscmd = "git pull -f"
debug(oscmd)
os.system(oscmd)
botname = "stallmanbot.py"
debug(oscmd)
# For debugging outside of the Raspberry Pi
# oscmd = "diff -q %s %s/homemadescripts/%s" % (botname, HOME, botname)
# Original Raspberry Pi command
oscmd = "diff -q %s %s/bin/%s" % (botname, HOME, botname)
res = os.system(oscmd)
if res:
# new version detected
res = os.system("%s %s check" % (sys.executable, sys.argv[0]))
if res != 0:
debug("Versão bugada")
sys.exit(os.EX_OSERR)
debug("Updating bot...")
shutil.copy(botname, "%s/bin/%s" % (HOME, botname))
debug("Bot version updated.")
# check first
debug("Calling restart")
python = sys.executable
os.execl(python, python, *sys.argv)
# Update the foodporn.json file
run_foodporn_update()
评论列表
文章目录