mirror of https://git.48k.eu/ogclient
Add ogProcess and ogOperation for linux
Thoses new classes allows us to process and execute commands from server side sent using HTTP format.more_events
parent
bfdeae840c
commit
ebd640a9c5
|
@ -0,0 +1,3 @@
|
|||
def poweroff():
|
||||
print 'APAGADO'
|
||||
|
|
@ -4,6 +4,7 @@ import socket
|
|||
import time
|
||||
|
||||
from HTTPParser import *
|
||||
from ogProcess import *
|
||||
from enum import Enum
|
||||
|
||||
class State(Enum):
|
||||
|
@ -67,6 +68,7 @@ class ogClient:
|
|||
|
||||
self.data = self.data + data
|
||||
httpparser = HTTPParser()
|
||||
ogprocess = ogProcess()
|
||||
|
||||
if not self.trailer:
|
||||
if self.data.find("\r\n") > 0:
|
||||
|
@ -81,6 +83,9 @@ class ogClient:
|
|||
|
||||
if self.trailer and len(self.data) >= self.content_len:
|
||||
httpparser.parser(self.data)
|
||||
print httpparser.getRequestOP()
|
||||
print httpparser.getURI()
|
||||
ogprocess.processOperation(httpparser.getRequestOP(), httpparser.getURI())
|
||||
|
||||
self.sock.send("HTTP/1.0 200 OK\r\n\r\n")
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import threading
|
||||
import platform
|
||||
import time
|
||||
|
||||
print(platform.system())
|
||||
|
||||
if platform.system() == 'Linux':
|
||||
from linux import ogOperations
|
||||
|
||||
class ogProcess():
|
||||
def processOperation(self, op, URI):
|
||||
if ("poweroff" in URI):
|
||||
self.process_poweroff()
|
||||
|
||||
def process_poweroff(self):
|
||||
# Powering off thread
|
||||
def pwoff():
|
||||
time.sleep(2)
|
||||
ogOperations.poweroff()
|
||||
threading.Thread(target=pwoff).start()
|
Loading…
Reference in New Issue