Exemple #1
0
from program import Program
from programs import register_program


class ProclistProgram(Program):
    long_running = False

    def execute(self):
        if len(self.kernel.proclist) == 0:
            self.stdout.print("No running programs")
            return
        for p in self.kernel.proclist:
            self.stdout.print("{} {:3d}%".format(p.progname, int(p.progress)))


register_program('pl', ProclistProgram)
register_program('proclist', ProclistProgram)
Exemple #2
0
from program import Program
from programs import register_program


class ExitProgram(Program):
    long_running = False

    def execute(self):
        self.stdout.print("{c.red}Shutting down...{c.close_fg_color}")
        self.kernel.shutdown()


register_program('exit', ExitProgram)
Exemple #3
0
from program import Program
from programs import register_program


class MakefileProgram(Program):
    long_running = False

    def execute(self):
        self.kernel.fs.make_file(self.args[0])


register_program('mf', MakefileProgram)
register_program('mkfile', MakefileProgram)
Exemple #4
0
from program import Program
from programs import register_program


class ListDirProgram(Program):
    long_running = False

    def execute(self):
        path = '/'
        if len(self.args) > 0:
            path = self.args[0]
        for it in self.kernel.fs.list_dir(path):
            self.stdout.print(it)


register_program('ls', ListDirProgram)
register_program('list', ListDirProgram)
Exemple #5
0
from program import Program
from programs import register_program


class MakedirProgram(Program):
    long_running = False

    def execute(self):
        self.kernel.fs.make_dir(self.args[0])


register_program('md', MakedirProgram)
register_program('mkdir', MakedirProgram)
Exemple #6
0
from program import Program
from programs import register_program


class ScanProgram(Program):
    long_running = True

    def execute(self, execution_time=0.1):
        self.add_progress(execution_time*10)


register_program('scan', ScanProgram)
Exemple #7
0
from program import Program
from programs import register_program


class ReadfileProgram(Program):
    long_running = False

    def execute(self):
        if len(self.args) < 1:
            self.stdout.error("Please provide file path")
            return
        filnam = self.args[0]
        fil = self.kernel.fs.open(filnam)
        if not fil:
            self.stdout.error("Can not open file: " + filnam)
            return
        self.stdout.print(fil.read())


register_program('rf', ReadfileProgram)
register_program('read', ReadfileProgram)
Exemple #8
0
from program import Program
from programs import register_program


class WritefileProgram(Program):
    long_running = False

    def execute(self):
        if len(self.args) < 2:
            self.stdout.error("Please provide file path and contents")
            return
        data = self.args[1]
        filnam = self.args[0]
        fil = self.kernel.fs.open(filnam)
        if not fil:
            self.stdout.error("Can not open file: " + filnam)
            return
        fil.write(data)


register_program('wf', WritefileProgram)
register_program('write', WritefileProgram)