-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlinux.py
76 lines (59 loc) · 2.35 KB
/
linux.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
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
#!/usr/bin/env python
import os
import os.path
import subprocess
import oshelper
class LinuxHelper(oshelper.OsHelper):
# Directory related tools
class dir_helper(oshelper.DirectoryHelper):
def default(self):
return '/usr/local/ps3dev2'
def exists(self, directory):
return os.path.isdir(directory)
def toplevel(self, directory):
return os.path.basename(directory)
def base(self, directory):
return os.path.dirname(directory)
def current(self):
return os.getcwd()
def create(self, directory):
os.makedirs(directory, 0775)
def change(self, directory):
os.chdir(directory)
def at_home(self, path):
return os.path.join(os.path.expanduser('~'), path)
# File related tools
class file_helper(oshelper.FileHelper):
def exists(self, filename):
return os.path.isfile(filename)
# File/Dir helpers
dirs = dir_helper()
files = file_helper()
def config_user(self, directory):
try:
fd = open(at_home('.bashrc'), 'a')
except:
return False
fd.write('# Added by Ps3Builder\n')
fd.write('export PS3DEV=' + directory + '\n')
fd.write('export PSL1GHT=' + os.path.join(directory, 'psl1ght') + '\n')
fd.write('export PATH=$PATH:$PS3DEV/bin\n')
fd.write('export PATH=$PATH:$PS3DEV/ppu/bin\n')
fd.write('export PATH=$PATH:$PS3DEV/spu/bin\n')
fd.write('# End modifications by Ps3Builder\n')
fd.close()
return True
def set_environment(self, directory):
os.environ['PS3DEV'] = directory
os.environ['PSL1GHT'] = os.path.join(directory, 'psl1ght')
os.environ['PATH'] = os.environ['PATH'] + ':' + os.path.join(directory,
'bin')
os.environ['PATH'] = os.environ['PATH'] + ':' + os.path.join(directory,
'ppu/bin')
os.environ['PATH'] = os.environ['PATH'] + ':' + os.path.join(directory,
'spu/bin')
def run(command):
pid = subprocess.Popen(command)
pid.wait()
def run_nowait(command):
pid = subprocess.Popen(command)