-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.py
More file actions
94 lines (70 loc) · 2.4 KB
/
Copy pathsetup.py
File metadata and controls
94 lines (70 loc) · 2.4 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from setuptools import setup, find_packages
from codecs import open
from os import path
def remove_line(tfile,sstr):
i2c_list = []
try:
lines=open(tfile,'r').readlines()
flen=len(lines)
for i in range(flen):
if "#" not in lines[i]:
if sstr in lines[i]:
print i, lines[i]
i2c_list.append(i)
for i in range(len(i2c_list)-1, -1, -1):
print i2c_list[i]
lines.remove(lines[i2c_list[i]])
open(tfile,'w').writelines(lines)
except Exception,e:
print 'remove_line:', e
def add_line(tfile,sstr):
try:
lines=open(tfile,'r').readlines()
lines.append(sstr)
open(tfile,'w').writelines(lines)
except Exception,e:
print 'add line:', e
remove_line('/boot/config.txt', 'dtparam=i2c_arm=')
remove_line('/boot/config.txt', 'gpio-poweroff')
remove_line('/etc/rc.local', 'exit 0')
remove_line('/etc/rc.local', '/usr/local/bin/power_switch')
add_line('/boot/config.txt', '\ndtparam=i2c_arm=on')
add_line('/boot/config.txt', '\ndtoverlay=gpio-poweroff:gpiopin=13\n')
add_line('/etc/rc.local', '\nsudo /usr/local/bin/power_switch &')
add_line('/etc/rc.local', '\nexit 0\n')
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='SunFounder_PiSmart',
version='1.0.0',
description='Python package for PiSmart from SunFounder',
long_description=long_description,
url='https://github.com/sunfounder/SunFouner_PiSmart',
author='SunFounder',
author_email='support@sunfounder.com',
license='GPL',
zip_safe=False,
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: GPL License',
'Programming Language :: Python :: 2.7',
],
keywords='RaspberryPi PiSmart setuptools development',
packages=find_packages(exclude=['example', 'docs', 'tests*', 'offset', 'log']),
install_requires=['peppercorn'],
extras_require={
'dev': ['check-manifest'],
'test': ['coverage'],
},
package_data={
'pirobot': ['package_data.dat'],
},
entry_points={
'console_scripts': [
'pismart=pismart:main',
],
},
)