pythonシステムのタイミングダウン
#coding=utf-8
"shutdown at 23:00"
from datetime import *
import os
import win32api
import win32con
from threading import *
tmNow = datetime.now()
d = date.today()
t = time(23,10,0)
shtdownTime = datetime.combine(d,t)
def ShowHint():
while True:
tmNow = datetime.now()
timedDelta = (shtdownTime - tmNow).total_seconds()
if timedDelta < 60:
win32api.MessageBox(win32con.NULL, u' 59s , !', u' ', win32con.MB_OK)
break
else:
continue
def ShutDown():
while True:
tmNow = datetime.now()
timedDelta = (shtdownTime - tmNow).total_seconds()
if timedDelta < 60:
os.system('shutdown -s -f -t 59')
break
else:
continue
if __name__ == '__main__':
threadShowHint = threading.Thread(target=ShowHint)
threadShutDown = threading.Thread(target=ShutDown)
threadShowHint.start()
threadShutDown.start()
#coding=utf-8 "shutdown at 23:00"
from datetime import * import os import win32api import win32con from threading import *
tmNow = datetime.now() d = date.today() t = time(23,10,0) shtdownTime = datetime.combine(d,t)
def ShowHint(): while True: tmNow = datetime.now() timedDelta = (shtdownTime - tmNow).total_seconds() if timedDelta < 60: win32api.MessageBox(win 32 con.NULL,u'はまだ59 s電源を切っているから、早く保存しなさい!',u'暖かい注意',win 32 con.MB_OK)break else:continue def ShutDown():while True:tmNow=datetime.now() timedDelta = (shtdownTime - tmNow).total_seconds() if timedDelta < 60: os.system('shutdown -s -f -t 59') break else: continue if __name__ == '__main__': threadShowHint = threading.Thread(target=ShowHint) threadShutDown = threading.Thread(target=ShutDown) threadShowHint.start() threadShutDown.start()
from datetime import *
import os
tmNow = datetime.now()
d = date.today()
t = time(23,10,0)
shtdownTime = datetime.combine(d,t)
def ShutDown():
while True:
tmNow = datetime.now()
timedDelta = (shtdownTime - tmNow).total_seconds()
if timedDelta < 60:
os.system('shutdown -s -f -t 59')
break
else:
continue
if __name__ == '__main__':
ShutDown()