forked from jma127/pcu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.py
More file actions
executable file
·80 lines (67 loc) · 2.01 KB
/
install.py
File metadata and controls
executable file
·80 lines (67 loc) · 2.01 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
#!/usr/bin/env python
import os
import shutil
# Variables
dir = os.path.dirname(os.path.abspath(__file__))
defaulttemplatefolder = os.path.join(dir, 'defaulttemplates')
templatefolder = os.path.join(dir, 'templates')
defaultsettings = os.path.join(dir, 'defaultsettings.py')
settings = os.path.join(dir, 'settings.py')
path = os.environ['PATH'].split(os.pathsep)
script = """# PCU Launcher (place this script in path)
python '{}' $@
""".format(os.path.join(dir, 'main.py'))
installed = False
# Installer
print 'PCU Installer'
# Launcher Installation
print
print 'Installing launcher...'
for folder in path:
try:
file = open(os.path.join(folder, 'pcu'), 'wb')
file.write(script)
file.close()
os.chmod(os.path.join(folder, 'pcu'), 0755)
print 'Launcher installed in ' + folder
installed = True
break
except IOError as error:
pass
if not installed:
print 'Could not install launcher to system path'
# Template Installation
print
print 'Installing default templates...'
try:
shutil.rmtree(templatefolder, ignore_errors=True)
shutil.copytree(defaulttemplatefolder,
templatefolder)
os.chmod(templatefolder, 0777)
for file in os.listdir(templatefolder):
os.chmod(os.path.join(templatefolder, file), 0666)
print 'Templates installed'
except shutil.Error as err:
print 'Could not install templates: ' + repr(err)
installed = False
# Settings Installation
print
print 'Installing settings file...'
try:
if os.path.isfile(settings):
os.remove(settings)
shutil.copy(defaultsettings,
os.path.join(settings))
os.chmod(settings, 0666)
print 'settings.py installed'
except shutil.Error as err:
print 'Could not install settings file: ' + repr(err)
installed = False
# User Instructions
print
if installed:
print 'Install successful, you may now use pcu'
print 'See the README for more info'
else:
print 'Install failed'
print '(try running sudo python install.py)'