-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·103 lines (79 loc) · 2.76 KB
/
install
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
94
95
96
97
98
99
100
#!/usr/bin/env python3
"""Installation/Update of MikroKam
"""
import os.path
import sys
import shutil
import configparser
import os
import pip
cwd = os.getcwd()
# test for files
if not os.path.isfile(cwd + '/flashman.py'):
print("PANIC: missing flashman.py")
sys.exit()
if not os.path.isfile(cwd + '/launcher'):
print("PANIC: missing launcher")
sys.exit()
if not os.path.isfile(cwd + '/mainpage.py'):
print("PANIC: missing mainpage.py")
sys.exit()
if not os.path.isfile(cwd + '/MikroKam'):
print("PANIC: missing MikroKam")
sys.exit()
if not os.path.isfile(cwd + '/MikroKam.desktop'):
print("PANIC: missing MikroKam.desktop")
sys.exit()
if not os.path.isfile(cwd + '/MikroKam.ini.dist'):
print("PANIC: missing MikroKam.ini.dist")
sys.exit()
if not os.path.isfile(cwd + '/MikroKam.py'):
print("PANIC: missing MikroKam.py")
sys.exit()
if not os.path.isfile(cwd + '/pikamera.py'):
print("PANIC: missing pikamera.py")
sys.exit()
if not os.path.isfile(cwd + '/test.jpg'):
print("PANIC: missing test.jptg")
sys.exit()
if not os.path.isfile(cwd + '/sample.jpg'):
print("PANIC: missing sample.jpg")
sys.exit()
# see if this is a new install or an Update
if not os.path.isfile(cwd + '/MikroKam.ini.dist'):
# we can't even get started
print("PANIC: there is no MikroKam.ini.dist file. Try downloading again.")
sys.exit()
if os.path.isfile(cwd + '/MikroKam.ini'):
# well this looks like an Update
print("This appears to be an update")
shutil.copyfile(cwd+'/MikroKam.ini',cwd + '/MikroKam.ini.save')
current_config = configparser.ConfigParser()
current_config.read(cwd +'/MikroKam.ini')
new_config = configparser.ConfigParser()
new_config.read(cwd+'/MikroKam.ini.dist')
app_values = list(current_config.items('app'))
for parm,val in app_values:
new_config['app'][parm] = val
with open(cwd + '/MikroKam.ini','w') as current:
new_config.write(current)
current.close()
else:
# looks like a new install
#if os.path.isfile('../Desktop/MikroKam.desktop'):
# print("OOPS: there is already a desktop icon. Please remove ../Desktop/MikroKam.desktop and try again")
# sys.exit()
try:
shutil.copyfile(cwd + '/MikroKam.ini.dist',cwd + '/MikroKam.ini')
except:
print("PANIC: failed to copy MikroKam.ini.dist to MikroKam.ini")
sys.exit()
try:
shutil.copyfile(cwd + '/MikroKam.desktop','../Desktop/MikroKam.desktop')
except:
print("PANIC: failed to copy /home/pi/MikroKam.desktop to /home/pi/Desktop/")
sys.exit()
pip.main(['install','pillow'])
pip.main(['install','pyudev'])
pip.main(['install','psutil'])
print("Now you can run your application from the desktop icon or ./MikroKam")