forked from FutureNathan/Habit-Calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rotationControl.py
37 lines (29 loc) · 856 Bytes
/
rotationControl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import subprocess
import os
MYFILE = '/boot/config.txt'
def commandExec(command):
try:
out = subprocess.check_output(command, shell=True)
return out.decode()
except:
return "error"
def GetSetting():
lines = open(MYFILE, 'r').readlines()
lastLine = (lines[-1].rstrip())
return lastLine
def ChangeSettings(entry):
lines = open(MYFILE, 'r').readlines()
lastLine = (lines[-1].rstrip())
lines[-1] = entry
open(MYFILE, 'w').writelines(lines)
rev = commandExec("cat /proc/cpuinfo | grep Revision").replace('\n', '').replace(' ','').split(":")[1]
if(rev=="c03111"):
set = GetSetting()
if(set != "#"):
ChangeSettings("#")
commandExec("reboot")
else:
set = GetSetting()
if(set == "#"):
ChangeSettings("display_hdmi_rotate=1")
commandExec("reboot")