31 | def restart(time=0,force=False): |
32 | |
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 |