summaryrefslogtreecommitdiff
path: root/foreign/client_handling/system.py
blob: 1dcb26c52b614ddcaac9b4f0ccb3269ab9df05c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import win32gui
import win32con

from foreign.utility.terminal_pipe import *


def system(action_type, extra_data):
  if action_type == 'shutdown':
    return {'message': terminal_pipe('shutdown /p /f', extra_data[0], extra_data[1])}
  elif action_type == 'restart':
    return {'message': terminal_pipe('shutdown /r /f /t 0', extra_data[0], extra_data[1])}    
  elif action_type == 'logout':
    return {'message': terminal_pipe('shutdown /l /f', extra_data[0], extra_data[1])}    
  elif action_type == 'standby':
    win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, win32con.SC_MONITORPOWER, 2)
    return {'message': 'Successfully activated standby mode', 'text_mode': 'success'}
  else:
    raise Exception('Error message')