From 10b8e5ad55409b82da72e75fc7a5e385c2c4b23e Mon Sep 17 00:00:00 2001 From: AykoPoel Date: Mon, 5 Jan 2015 16:11:35 +0100 Subject: [PATCH] Create touch.py --- autorotate/touch.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 autorotate/touch.py diff --git a/autorotate/touch.py b/autorotate/touch.py new file mode 100644 index 0000000..54f50d3 --- /dev/null +++ b/autorotate/touch.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python2 +import os + +def readFile(path): #self.filename + myDatei = open(path, "r") + myList = [] + #Liste aus Datei erstellen + for Line in myDatei: + Line = Line.rstrip() + #Line = Line.decode('utf8') + myList.append(Line) + myDatei.close() + return(myList) + +def writeFile(path, myList): #self.filename + myDatei = open(path, "w") + #Liste aus Datei erstelle + myDatei.writelines(myList) + myDatei.close() + + +devicename = "NTRG0001:01 1B96:1B05" +penname = "'NTRG0001:01 1B96:1B05 Pen'" +path = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) + +status = readFile(os.path.join(path, 'touch.txt')) +if str(status[0]) == "on": + writeFile(os.path.join(path, 'touch.txt'), ["off"]) +if str(status[0]) == "off": + writeFile(os.path.join(path, 'touch.txt'), ["on"])