Exemplo n.º 1
0
def main1():
    instruction1 = BasicInstruction()
    instruction3 = Priority_Instruction()
    logger = Logger("../resource/log.txt")
    program = Program('a')
    program.addInstruction(instruction1)
    program.addInstruction(instruction1)
    program.addInstruction(instruction1)
    program.addInstruction(instruction1)
    program.addInstruction(instruction1)
    program.addInstruction(instruction1)
    programb = Program('b')
    programb.addInstruction(instruction3)
    programc = Program('c')
    programc.addInstruction(instruction1)
    programc.addInstruction(instruction1)
    programc.addInstruction(instruction1)
    timer = Timer(2)
    memory = Memory()
    memory.buildMemory(9)
    frame1 = Frame(memory,0,9)
    mmu = MMU()
    mmu.addEmptyFrame(frame1)
    cpu = CPU(None,mmu,None,timer,logger)
    scheduler = Scheduler(PFIFO())
    ioqueue = IOQueue(scheduler,logger)
    disk = Disk(None)
    kernel = Kernel(cpu,ioqueue,scheduler,mmu,disk,logger)
    disk.setKernel(kernel)
    disk.save(program)
    disk.save(programb)
    disk.save(programc)
    cpu.setKernel(kernel)
    kernel.executeProgram('a')   
Exemplo n.º 2
0
def main0():
    instruction1 = BasicInstruction()
    instruction2 = IO_Instruction()
    instruction3 = Priority_Instruction()
    program = Program('a')
    program.addInstruction(instruction1)
    program.addInstruction(instruction1)
    program.addInstruction(instruction1)
    programb = Program('b')
    programb.addInstruction(instruction3)
    programc = Program('c')
    programc.addInstruction(instruction1)
    programc.addInstruction(instruction1)
    programc.addInstruction(instruction1)
    timer = Timer(2)
    memory = Memory()
    memory.buildMemory(9)
    frame1 = Frame(memory,0,9)
    mmu = MMU()
    mmu.addEmptyFrame(frame1)
    cpu = CPU(None,mmu,None,timer)
    scheduler = Scheduler(PFIFO())
    ioqueue = IOQueue(scheduler)
    disk = Disk(None)
    kernel = Kernel(cpu,ioqueue,scheduler,mmu,disk)
    disk.setKernel(kernel)
    cpu.setKernel(kernel)
    kernel.saveProgram(program)
    kernel.saveProgram(programb)
    kernel.saveProgram(programc)
    kernel.start()
    cpu.start()
    ioqueue.start()
Exemplo n.º 3
0
def main():
    args = parse_arguments()
    translation = TranslationFactory.get_translation(args.lang)
    scheduler = Scheduler(args.path)

    app = wx.App()

    # Fix datetime.strptime issue
    locale.setlocale(locale.LC_ALL, 'C')

    _ = WhatsAppAutomationFrame(translation, scheduler)

    app.MainLoop()
Exemplo n.º 4
0
def main3():
    if(1==1):
        instruction1 = BasicInstruction()
        instruction2 = BasicInstruction()      
        memory = Memory()
        memory.buildMemory(5)
        frame1 = Frame(memory,0,1)
        frame2 = Frame(memory,1,2)
        frame3 = Frame(memory,3,1)
        frame4 = Frame(memory,4,1)
        mmu = MMU()
        mmu.fullFrames.append(frame1)
        mmu.fullFrames.append(frame3)
        mmu.emptyFrames.append(frame2)
        mmu.emptyFrames.append(frame4)
        program = Program('a')
        program.addInstruction(instruction1)
        pcbA = PCB('a',0,0,1)
        programb = Program('b')
        pcbB = PCB('b',0,3,1)
        programb.addInstruction(instruction1)
        frame1.load(pcbA,program)
        frame3.load(pcbB,programb)
        programc = Program('c')
        programc.addInstruction(instruction1)
        programc.addInstruction(instruction1)
        programc.addInstruction(instruction1)
        programd = Program('d')
        programd.addInstruction(instruction2)
        programd.addInstruction(instruction2)
        programd.addInstruction(instruction2)
        scheduler = Scheduler(PFIFO())
        disk = Disk(None)
        kernel = Kernel (None,None,scheduler,mmu,disk)
        disk.setKernel(kernel)
        memory.printMemory()
        kernel.saveProgram(programc)
        print( "     ")
        memory.printMemory()
        kernel.saveProgram(programd)
        print( "     ")
        memory.printMemory()
        print(len(disk.programList))
Exemplo n.º 5
0
def main():
    instruction1 = BasicInstruction()
    instruction2 = IO_Instruction()
    instruction3 = Priority_Instruction()
    program = Program('a')
    program.addInstruction(instruction1)
    program.addInstruction(instruction1)
    program.addInstruction(instruction1)
    program.addInstruction(instruction1)
    program.addInstruction(instruction1)
    programd = Program('d')
    programd.addInstruction(instruction1)
    programd.addInstruction(instruction1)
    programd.addInstruction(instruction1)
    programd.addInstruction(instruction1)
    programd.addInstruction(instruction1)
    programb = Program('b')
    programb.addInstruction(instruction3)
    programc = Program('c')
    programc.addInstruction(instruction1)
    programc.addInstruction(instruction1)
    programc.addInstruction(instruction1)
    timer = Timer(2)
    memory = Memory()
    memory.buildMemory(9)
    frame1 = Frame(memory,0,9)
    logger = Logger("/home/matlock/Escritorio/Sistemas Operativos/OSProyect/resource/log.txt")
    mmu = MMU(logger)
    mmu.addEmptyFrame(frame1)
    cpu = CPU(None,mmu,None,timer,logger)
    scheduler = Scheduler(PFIFO())
    ioqueue = IOQueue(scheduler,logger)
    disk = Disk(None)
    kernel = Kernel(cpu,ioqueue,scheduler,mmu,disk,logger)
    disk.setKernel(kernel)
    cpu.setKernel(kernel)
    x = []
    x.append(program)
    x.append(programb)
    x.append(programc)
    x.append(programd)
    kernel.saveOnDisk(x)
    kernel.executeProgram('a')
Exemplo n.º 6
0
import sys

from src.Scheduler import Scheduler

if __name__ == '__main__':
    scheduler = Scheduler(sys.argv[1:2])  # chrome path as an argument.
    scheduler.schedule("22/05/2020-23:48:40", "test", "Selenium-Test")  # TODO - change it.

    # try to cancel the scheduled task.
    scheduler.cancel_scheduled_msg("22/05/2020-23:48:40", "Selenium-Test")
Exemplo n.º 7
0
#!/usr/bin/env python3
import os
from src.Scheduler import Scheduler
import logging

logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
logger = logging.getLogger(__name__)
if __name__ == '__main__':
    scheduler = Scheduler()
    scheduler.main()
Exemplo n.º 8
0
def main():
    scheduler = Scheduler()
    scheduler.run()
Exemplo n.º 9
0
class ENA():
    HOME = expanduser("~")
    # Booleans
    running = False
    # Objects
    edit_users = Edit_Users()
    commands = Commands()
    deploy = Deploy()
    scheduler = Scheduler()

    main_user = None
    ena = None
    # edit_users = None
    # commands = None
    # deploy = None
    # scheduler = None
    id = None
    # Strings
    conn_string = "host='localhost' dbname='enabrain' user='******' password='******'"
    # Array for users
    users = []

    #constructor
    def ena(self, ena):
        self.running = True
        self.ena = ena
        #Creates the commands
        self.edit_users.Edit_Users(ena)
        self.commands.commands(self.ena, self.deploy, self.scheduler)
        try:
            #Checks if there is a table, if so, it loads the users
            self.id = self.edit_users.load_users()
        except:
            #Creates tables then loads empty users and sets the user id to 0
            Create_Tables = create_tables()
            Create_Tables.create_tables(ena)
            self.id = self.edit_users.load_users()
        self.ena.run()

    #this command is used in Commands.py
    def ena_help(self):
        print("=======================================")
        if (self.main_user == None):
            for command in self.commands.commands_array:
                print(command)
        else:
            for command in self.commands.commands_array:
                print(command)
        print("=======================================")

    #Admin function
    def show_users(self):
        for user in self.users:
            print("=======================================")
            user.show_info()
            print("=======================================")

    def change_user_level(self):
        selected_user = input(
            "please enter the user you want to change their level: ")
        real_user = False
        for user in self.users:
            if (user.username == selected_user):
                real_user = True
                check = input("Are you sure you want to change " +
                              selected_user + "'s level: ")
                level = int(input("please enter the user's new level: "))
                if (check.lower() == "yes" or check.lower() == "y"):
                    user.level = level
                    print(user.username + " is now a level " + str(user.level))
                else:
                    print("Authorization cancled")
        if (not real_user):
            print("There is no user with that username.")

    def login(self):
        testing_username = input("username: "******"Password: "******"----ADMIN----")
            print(self.main_user.username + ", You are now logged in")
        #this lets the user know that their password or username is incorrect
        else:
            if (not authenticate):
                false_pass = getpass.getpass("Password: "******"username or password is incorrect")

    def logout(self):
        #this logs them out, as the functions name implies
        for user in self.users:
            user.logged_in = False
        self.main_user = None
        self.commands.load_commands_abstract_user()
        print("You are now logged out")

    def clear(self):
        #check if the user is using windows
        if os.name == 'nt':
            os.system('cls')
        #else it uses linux termianls 'clear'
        else:
            os.system('clear')

    def run(self):
        self.clear()
        #gets commands
        command = input("Hello, my name is Ena, how may I assist you today: ")
        #main running loop
        while (self.running):
            self.commands.test_commands(command)
            command = input("How may I assist you today: ")