@@ 29-47 (lines=19) @@ | ||
26 | return False |
|
27 | else: |
|
28 | return True |
|
29 | except: |
|
30 | return False |
|
31 | def restart(time=0,force=False): |
|
32 | # TODO: solve unix version problem |
|
33 | ''' |
|
34 | ||
35 | :param time: int , Time in second for restart |
|
36 | :param force: bool ,True for Force restart |
|
37 | :return: bool , True (Successfully) False(Unsuccessfully) |
|
38 | ''' |
|
39 | command="shutdown -r " |
|
40 | try: |
|
41 | if force==True: |
|
42 | command+="-f " |
|
43 | response=sub.Popen(command+"-t "+str(time),shell=True,stdin=sub.PIPE,stdout=sub.PIPE,stderr=sub.PIPE) |
|
44 | response = list(response.communicate()) |
|
45 | if len(response[0])!=0 or (str(response[1]).find("1190")!=-1): |
|
46 | return False |
|
47 | else: |
|
48 | return True |
|
49 | except : |
|
50 | return False |
|
@@ 48-65 (lines=18) @@ | ||
45 | if len(response[0])!=0 or (str(response[1]).find("1190")!=-1): |
|
46 | return False |
|
47 | else: |
|
48 | return True |
|
49 | except : |
|
50 | return False |
|
51 | def hibernate(force=False): |
|
52 | # TODO: solve unix version problem |
|
53 | ''' |
|
54 | ||
55 | :param force: bool ,True for Force hibernate |
|
56 | :return: bool , True (Successfully) False(Unsuccessfully) |
|
57 | ''' |
|
58 | command="shutdown -h" |
|
59 | try: |
|
60 | if force==True: |
|
61 | command+=" -f" |
|
62 | response=sub.Popen(command,shell=True,stderr=sub.PIPE,stdout=sub.PIPE,stdin=sub.PIPE) |
|
63 | response = list(response.communicate()) |
|
64 | if len(response[0])!=0 or (str(response[1]).find("1190")!=-1): |
|
65 | return False |
|
66 | else: |
|
67 | return True |
|
68 | except: |
|
@@ 85-99 (lines=15) @@ | ||
82 | response = list(response.communicate()) |
|
83 | if len(response[0]) != 0 or (str(response[1]).find("1190") != -1): |
|
84 | return False |
|
85 | else: |
|
86 | return True |
|
87 | except: |
|
88 | return False |
|
89 | ||
90 | def cancel(): |
|
91 | # TODO: solve unix version problem |
|
92 | ''' |
|
93 | ||
94 | :return: bool , True (Successfully) False(Unsuccessfully) |
|
95 | ''' |
|
96 | command="shutdown -a" |
|
97 | try: |
|
98 | response=sub.Popen(command,shell=True,stderr=sub.PIPE,stdin=sub.PIPE,stdout=sub.PIPE) |
|
99 | response = list(response.communicate()) |
|
100 | if len(response[0]) != 0 or (str(response[1]).find("1116") != -1): |
|
101 | return False |
|
102 | else: |