import sys import os class ShutdownerClient: cronfile="/etc/cron.d/lliurexshutdown" lliurexshutdown="/usr/bin/lliurexshutdown" def __init__(self): pass #def init def shutdown_cron(self,min,hour,monthday,month,weekday,aux_cronfile=cronfile): try: os.system('echo "%s %s %s %s %s root %s >> /var/log/syslog" > %s' %(min,hour,monthday,month,weekday,self.lliurexshutdown,aux_cronfile)) COMMENT_END = "You have implemented new shutdown file in: %s" %(aux_cronfile) return [True,str(COMMENT_END)] except Exception as e: return [False,str(e)] #def shutdown_cron def noshutdown_cron(self,aux_cronfile=cronfile): try: os.system('mv %s /tmp/' %(aux_cronfile)) COMMENT_END = "You have deactivated shutdown file in: %s (moved to /tmp)" %(aux_cronfile) return [True,str(COMMENT_END)] except Exception as e: return [False,str(e)] #def noshutdown_cron def shutdown(self): os.system('shutdown -h now') #def shutdownlist