Skip to content

Commit

Permalink
Fixed open_program to check .py files first.
Browse files Browse the repository at this point in the history
  • Loading branch information
crcollins committed Jul 25, 2012
1 parent e8bf58e commit 8c6630a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 1 addition & 4 deletions kernel/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ def open_file(path, mode):
def open_program(path):
x = abs_path(path)
try:
try:
program = imp.load_source('program', '%s.py' % (x, ))
except IOError:
program = imp.load_source('program', x)
program = imp.load_source('program', x)
except IOError:
program = False
return program
Expand Down
6 changes: 6 additions & 0 deletions kernel/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,15 @@ def hist_find(self, value, start=True):

def find_program(self, name):
for x in self.program_paths(name):
if not x.endswith('.py'):
x += '.py'
program = self.syscall.open_program(x)
if program:
break
else:
program = self.syscall.open_program(x[:-3])
if program:
break
return program

def __repr__(self):
Expand Down
4 changes: 2 additions & 2 deletions kernel/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ def run(self):
self.run()

def startup(self):
path = self.filesystem.join_path(KERNELDIR, "startup")
path = self.filesystem.join_path(KERNELDIR, "startup.py")
program = self.new_shell(program=path)
program.run()

def shutdown(self):
path = self.filesystem.join_path(KERNELDIR, "shutdown")
path = self.filesystem.join_path(KERNELDIR, "shutdown.py")
program = self.new_shell(program=path)
program.run()

Expand Down

0 comments on commit 8c6630a

Please sign in to comment.