source: n4d-shutdowner-client/trunk/fuentes/install-files/usr/share/n4d/python-plugins/ShutdownerClient.py @ 5412

Last change on this file since 5412 was 5412, checked in by hectorgh, 20 months ago

wip

File size: 790 bytes
Line 
1import os
2
3
4class ShutdownerClient:
5
6        def __init__(self):
7               
8                pass
9
10        #def init
11       
12        def startup(self,options):
13               
14                self.shutdowner_var=objects["VariablesManager"].get_variable("SHUTDOWNER")
15                self.server_trigger(self.shutdowner_var)
16               
17                objects["VariablesManager"].register_trigger("SHUTDOWNER","ShutdownerClient",self.server_trigger)
18               
19        #def startup
20       
21        def server_trigger(self,value):
22
23                if value["cron_enabled"]:
24                        if value["cron_content"]!=None:
25                                f=open(ShutdownerClient.cronfile,"w")
26                                f.write(value["cron_content"])
27                                f.close()
28                else:
29                        os.remove(ShutdownerClient.cronfile)
30               
31                if value["shutdown_signal"] > self.shutdowner_var["shutdown_signal"]:
32                        self.shutdown()
33               
34        #def server_trigger
35       
36       
37        def shutdown(self):
38               
39                os.system('shutdown -h now')
40               
41        #def shutdownlist
Note: See TracBrowser for help on using the repository browser.