Exemplo n.º 1
0
 def on_actionOpenConnection_triggered(self, s):
     d = OpenConnection(self)
     if d.exec() != OpenConnection.Accepted:
         return
     t = Terminal(self)
     self.mdiArea.addSubWindow(t)
     t.show()
Exemplo n.º 2
0
    def run_iperf_multi(self, obj, packet_type, update_interval, test_time,
                        address):
        """
        TODO
        :param obj:
        :param packet_type:
        :param update_interval:
        :return:
        """

        self.pool = ThreadPool(1000)

        self.printing(True)

        if obj is not None:
            self.run_packet_script(obj, packet_type)

        result = TestResult(update_interval=update_interval,
                            test_time=test_time,
                            address=address)
        result.run_multi_test()

        Terminal.clear_line()
        self.printing(True)

        return result
Exemplo n.º 3
0
    def run_test_tcp(self, obj, packet_type):
        """
                TODO
                This will run packet loss and return values of TCP retransmissions
                :param obj:
                :param packet_type:
                :return:
                """

        self.pool = ThreadPool(1000)
        self.printing(False)

        self.run_packet_script(obj, packet_type)

        with self.time_limit(self.MAX_TEST_TIME):
            try:
                self.tcp_requests()
            except Exception:

                # If the request timed out
                os.system('rm -rf *.tmp')
                self.force_print(
                    '## Timeout occurred! - Accuracy may be compromised')

        Terminal.clear_line()
        self.printing(True)
Exemplo n.º 4
0
    def printing(printing_on):
        """Used to stop printing when it isn't needed"""

        Terminal.clear_line()

        if printing_on:
            sys.stdout = sys.__stdout__
        else:
            sys.stdout = open(os.devnull, 'w')
Exemplo n.º 5
0
class Ventana(Gtk.Window):

    #__gtype_name__ = 'WindowJAMediaTerminal'

    def __init__(self):

        Gtk.Window.__init__(self)

        self.set_title("JAMediaTerminal")

        self.set_icon_from_file(
            os.path.join(BASE_PATH,
            "Iconos", "jamediaterminal.svg"))

        self.set_resizable(True)
        self.set_size_request(640, 480)
        self.set_border_width(5)
        self.set_position(Gtk.WindowPosition.CENTER)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        toolbar = Toolbar()
        paned = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL)

        box.pack_start(toolbar, False, False, 0)
        box.pack_start(paned, True, True, 0)

        self.jamediaterminal = Terminal()
        self.jamediamantree = JAMediaManTree()

        paned.pack1(self.jamediamantree, resize=True, shrink=False)
        paned.pack2(self.jamediaterminal, resize=False, shrink=False)

        self.add(box)

        self.show_all()

        self.jamediamantree.hide()

        import sys
        toolbar.connect("help", self.__help)
        toolbar.connect("salir", sys.exit)
        self.connect("destroy", sys.exit)

    def __help(self, widget):
        """
        Muestra u oculta el manual.
        """

        if self.jamediamantree.get_visible():
            self.jamediamantree.hide()

        else:
            self.jamediamantree.show()
            self.jamediaterminal.set_size_request(-1, 150)
Exemplo n.º 6
0
class Ventana(Gtk.Window):

    #__gtype_name__ = 'WindowJAMediaTerminal'

    def __init__(self):

        Gtk.Window.__init__(self)

        self.set_title("JAMediaTerminal")

        self.set_icon_from_file(
            os.path.join(BASE_PATH, "Iconos", "jamediaterminal.svg"))

        self.set_resizable(True)
        self.set_size_request(640, 480)
        self.set_border_width(5)
        self.set_position(Gtk.WindowPosition.CENTER)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        toolbar = Toolbar()
        paned = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL)

        box.pack_start(toolbar, False, False, 0)
        box.pack_start(paned, True, True, 0)

        self.jamediaterminal = Terminal()
        self.jamediamantree = JAMediaManTree()

        paned.pack1(self.jamediamantree, resize=True, shrink=False)
        paned.pack2(self.jamediaterminal, resize=False, shrink=False)

        self.add(box)

        self.show_all()

        self.jamediamantree.hide()

        import sys
        toolbar.connect("help", self.__help)
        toolbar.connect("salir", sys.exit)
        self.connect("destroy", sys.exit)

    def __help(self, widget):
        """
        Muestra u oculta el manual.
        """

        if self.jamediamantree.get_visible():
            self.jamediamantree.hide()

        else:
            self.jamediamantree.show()
            self.jamediaterminal.set_size_request(-1, 150)
Exemplo n.º 7
0
 def llamar(self, Terminal, segundosDeLlamada):
     Terminal.llama(self, Terminal, segundosDeLlamada)
     minutos= segundosDeLlamada/60
   
     #Switch para asociar a cada tarifa su precio correspondiente
     if self.tarifa=="rata":
         self.totalTarificado+=minutos*0.06
       
     if self.tarifa=="mono":
         self.totalTarificado+=minutos*0.12
     
     if self.tarifa=="bisonte":
         self.totalTarificado+=minutos*0.30
Exemplo n.º 8
0
 def get_terminals(self, text):
     lexem = ''
     for i in text:
         letter = i
         lexem += i
         if self.search_terminal(lexem):
             pass
         else:
             self.list_of_terminals.append(
                 Terminal(self.search_terminal(lexem[:-1]), lexem[:-1]))
             lexem = lexem[-1]
     if not lexem == '':
         self.list_of_terminals.append(
             Terminal(self.search_terminal(lexem), f'{lexem}'))
Exemplo n.º 9
0
 def __init__(self):
     self.pattern_terminals = [
         Terminal("K_WHILE", "while"),
         Terminal("K_IF", "if"),
         Terminal("K_ELSE", "else"),
         Terminal("VAR", "[a-zA-Zа-яА-Я]+"),
         Terminal("OP", "[-+*/]"),
         Terminal("LBreaket", "[(]"),
         Terminal("RBreaket", "[)]"),
         Terminal("LFBreaket", "[{]"),
         Terminal("RFBreaket", "[}]"),
         Terminal("WS", r"\s+")
     ]
     self.list_of_terminals = []
Exemplo n.º 10
0
def main():
    global production_list, t_list, nt_list
    ctr = 1
    t_regex, nt_regex = r'[a-z\W]', r'[A-Z]'
    while True:
        production_list.append(input().replace(' ', ''))
        if production_list[-1].lower() in ['end', '']:
            del production_list[-1]
            break

        head, body = production_list[ctr - 1].split('->')

        if head not in nt_list.keys():
            nt_list[head] = NonTerminal(head)

        #for all terminals in the body of the production
        for i in finditer(
                t_regex,
                body):  #returns an iterator object in the ordered matched.
            s = i.group(
            )  #since the group argument is empty, it'll return whatever it matched completely
            if s not in t_list.keys():
                t_list[s] = Terminal(s)

        #for all non-terminals in the body of the production
        for i in finditer(nt_regex, body):
            s = i.group()
            if s not in nt_list.keys():
                nt_list[s] = NonTerminal(s)

        ctr += 1
Exemplo n.º 11
0
def main():

    queue = PriorityQueue()

    for x in range(WORKERS):
        w = Worker(queue)
        w.start()

    settings = {"unblock_workers": 5}
    Application(settings)
    PyMongoDriver(host="127.0.0.1",
                  port=27017,
                  user="******",
                  password="******",
                  database="pipeline").register()

    test = False
    if test:
        FrameworkTest().run()
        # FrameworkTestThread().start()

    else:

        port = 9999

        StreamManagement(port)

        web_api = Web(port)
        web_api.start()

        Terminal().start()
Exemplo n.º 12
0
 def createTerminal(self, address):
     conn = sqlite3.connect(Constants.DATABASE_PATH, detect_types=sqlite3.PARSE_DECLTYPES)
     c = conn.cursor()
     generatedUUID = uuid.uuid1()
     c.execute("INSERT INTO terminals VALUES ('{}', '{}', '0')".format(generatedUUID, address))
     conn.commit()
     conn.close()
     return Terminal(generatedUUID, address)
Exemplo n.º 13
0
def user_input_thread(graph_active):
    """This thread is a listener for users input"""
    def reset_cursor(msg):
        """Used to stop input from messing up terminal format
        and displays what command was entered"""

        Terminal.clear_line()
        print('[{}]'.format(msg), end='\r', flush=True)

    while True:

        # HACK: Stops this from looping too fast and soaking up to much performance
        # A better solution would be to introduce events
        time.sleep(0.01)

        try:
            if keyboard.is_pressed('g'):
                # Waits until the key is released
                while keyboard.is_pressed('g'):
                    pass

                if graph_active:
                    # Clears any fragments from the screen including the button pressed
                    Terminal.clear_line()
                    affect_all_objects('graph')
                reset_cursor('Show graph')

            # More degradation
            elif keyboard.is_pressed('e'):
                # Waits until the key is released
                while keyboard.is_pressed('e'):
                    pass
                affect_all_objects('increase')
                reset_cursor('Increase Effect')

            # Less degradation
            elif keyboard.is_pressed('q'):
                # Waits until the key is released
                while keyboard.is_pressed('q'):
                    pass
                affect_all_objects('decrease')
                reset_cursor('Decrease Effect')

        except RuntimeError:
            pass
Exemplo n.º 14
0
 def append_message_service(cls, message_service_string):
     if (message_service_string.lower() == 'twilio'):
         cls.__return_bot = Twilio(cls.__return_bot)
     elif (message_service_string.lower() == 'terminal'):
         cls.__return_bot = Terminal(cls.__return_bot)
     elif (message_service_string.lower() == 'email'):
         cls.__return_bot = Email(cls.__return_bot)
     else:
         raise ValueError
Exemplo n.º 15
0
class PARDg5VPlatform(Platform):
    type = 'PARDg5VPlatform'
    cxx_header = "hyper/dev/pardg5v/platform.hh"
    system = Param.System(Parent.any, "system")

    pciconfig = PciConfigAll()

    south_bridge = PARDg5VSouthBridge()

    # "Non-existant" port used for timing purposes by the linux kernel
    i_dont_exist = IsaFake(pio_addr=x86IOAddress(0x80), pio_size=1)

    # Ports behind the pci config and data regsiters. These don't do anything,
    # but the linux kernel fiddles with them anway.
    behind_pci = IsaFake(pio_addr=x86IOAddress(0xcf8), pio_size=8)

    # Serial port and terminal
    com_1 = Uart8250P5V()
    com_1.pio_addr = x86IOAddress(0x3f8)
    com_1.terminal = Terminal()

    # Serial port#2 and terminal
    com_2 = Uart8250P5V()
    com_2.pio_addr = x86IOAddress(0x2f8)
    com_2.terminal = Terminal()

    # Devices to catch access to non-existant serial ports.
    com_3 = Uart8250P5V(pio_addr=x86IOAddress(0x3e8), terminal=Terminal())
    com_4 = Uart8250P5V(pio_addr=x86IOAddress(0x2e8), terminal=Terminal())

    # A device to catch accesses to the non-existant floppy controller.
    fake_floppy = IsaFake(pio_addr=x86IOAddress(0x3f2), pio_size=2)

    def attachIO(self, bus, dma_ports=[]):
        self.south_bridge.attachIO(bus, dma_ports)
        self.i_dont_exist.pio = bus.master
        self.behind_pci.pio = bus.master
        self.com_1.pio = bus.master
        self.com_2.pio = bus.master
        self.com_3.pio = bus.master
        self.com_4.pio = bus.master
        self.fake_floppy.pio = bus.master
        self.pciconfig.pio = bus.default
        bus.use_default_range = True
Exemplo n.º 16
0
    def __init__(self, proyecto_path):

        Gtk.EventBox.__init__(self)

        archivo = os.path.join(proyecto_path, "proyecto.ide")
        arch = open(archivo, "r")
        self.proyecto = json.load(arch, "utf-8")
        arch.close()

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.install_path = os.path.join(CONFPATH, self.proyecto["nombre"])
        self.widgeticon = WidgetIcon("python", self.install_path)
        self.notebook = Notebook(proyecto_path)
        self.terminal = Terminal()

        label = Gtk.Label(u"Instalador python para: %s versión: %s" %
                          (self.proyecto["nombre"], self.proyecto["version"]))
        label.modify_font(Pango.FontDescription("%s %s" % ("Monospace", 12)))
        label.modify_fg(0, Gdk.Color(0, 0, 65000))

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        image = Gtk.Image()
        arch = os.path.join(BASEPATH, "Iconos", "gandalftux.png")
        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(arch, 100, 100)
        image.set_from_pixbuf(pixbuf)
        hbox.pack_start(image, False, False, 0)
        vbox2 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        vbox2.pack_start(label, False, False, 0)
        vbox2.pack_start(self.widgeticon, False, False, 0)
        hbox.pack_start(vbox2, True, True, 0)
        vbox.pack_start(hbox, False, False, 0)

        vbox.pack_start(self.notebook, True, True, 0)
        vbox.pack_start(self.terminal, True, True, 5)

        self.add(vbox)
        self.connect("realize", self.__realize)
        self.show_all()

        self.widgeticon.connect("iconpath", self.__set_iconpath)
        self.widgeticon.connect("make", self.__make)
Exemplo n.º 17
0
 def create_full_tree(depth):
     if depth == 0:
         terminal = Terminal.random_terminal()
         node = Node("terminal", terminal)
         return Tree(node)
     else:
         function = Function.random_function()
         root_node = Node("function", function)
         result = Tree(root_node)
         for i in range(2):  #function.arity()
             result.add_child(Initializer.create_full_tree(depth - 1))
         return result
Exemplo n.º 18
0
 def create_full_tree(depth):
     if depth == 0:
         terminal = Terminal.random_terminal()
         node = Node("terminal", terminal)
         return Tree(node)
     else:
         function = Function.random_function()
         root_node = Node("function", function)
         result = Tree(root_node)
         for i in range(2):  #function.arity()
             result.add_child(Initializer.create_full_tree(depth - 1))
         return result
Exemplo n.º 19
0
def start_parsing(file_name, table, first_production):
    file = open(file_name, 'r')
    data = file.read()
    data += '\nepsilon'
    data = data.split('\n')
    stack = [Terminal('epsilon', None), NonTerminal(first_production, None)]
    i = 0

    while i <= len(data):
        if data[i] == '' or data[i] == ' ':
            continue
        if len(stack) == 0 and i == len(data) - 1:
            print('Accept')
            return
        elif len(stack) == 0 and i < len(data) or len(stack) > 0 and i == len(
                data):
            print('Reject')
            return

        if top(stack).type == 'T':
            if top(stack).value == 'epsilon':
                stack.pop()
                continue
            if top(stack).value == data[i]:
                stack.pop()
                print('Matched {}'.format(data[i]))
                i += 1
            else:
                print('Error: missing {}, inserted'.format(top(stack).value))
                stack.pop()
        elif top(stack).type == 'N':
            if isinstance(table[top(stack).value][data[i]], Node):
                # pop that node and reverse its production
                top_node = stack.pop()
                production_array = make_array(table[top_node.value][data[i]])
                while len(production_array):
                    stack.append(production_array.pop())
            elif table[top(stack).value][data[i]] == 'synch':
                print('synch found poping {}'.format(top(stack).value))
                stack.pop()
            else:
                print('Error: (illegal {}), discarding {}'.format(
                    top(stack).value, data[i]))
                i += 1
            if len(stack) == 0 and i == len(data) - 1:
                print('Accept')
                return
            elif len(stack) == 0 and i < len(data) or len(
                    stack) > 0 and i == len(data):
                print('Reject')
                return
Exemplo n.º 20
0
    def start(self):
        # Test with a new packet value
        for effect_value in range(self.START_EFFECT_VALUE,
                                  self.MAX_EFFECT_VALUE + 1, self.EFFECT_STEP):

            test_data = []

            # Repeats for that percentage values
            for x in range(0, self.REPEAT_TESTS):

                Terminal.clear_line()
                print('\n## Starting test {}'.format(x))

                # CUSTOM BEHAVIOUR
                self.custom_test_behavior(effect_value, test_data)
                self.stop_pool()

            if test_data is not None:
                test_data.insert(0, effect_value)
                self.save_csv(test_data)

        print('## Tests done!')
        Terminal.clear_line()
Exemplo n.º 21
0
    def run_iperf_local(self, obj, packet_type):
        """
        Runs a iperf test on the localhost. Iperf sends a huge amount of TCP packets and measures
        transfer rate
        :param update_interval: The amount of updates the iperf script gives per time, default 0 is off
        :param obj: - The script object
        :param packet_type: - The target packet
        :return:
        """

        self.pool = ThreadPool(1000)

        self.printing(False)
        self.run_packet_script(obj, packet_type)

        result = TestResult()
        result.run_single_test()

        self.pool.close()

        Terminal.clear_line()
        self.printing(True)

        return result
Exemplo n.º 22
0
 def _parsePrimitive(self, source):
     
     f = source.peek()
     
     if f == "ε":
         return Epsilon.parse(source)
     elif f == "<":
         return NonTerminal.parse(source)
     elif f == "(":
         source.read()
         e = GrammarExpression.parse(source)
         source.match(")")
         return e
     else:
         return Terminal.parse(source)
Exemplo n.º 23
0
    def __init__(self):
        self.quit_game = False
        self.end_game = False
        self.pause_game = True
        self.screen_dimensions = \
            [screen_resolution['w'], screen_resolution['h']]

        pygame.init()
        self.display = pygame.display.set_mode(self.screen_dimensions)
        pygame.display.set_caption('PyMan Game')
        self.clock = pygame.time.Clock()

        self.map = Map()
        self.map_view = MapView(self.map, self.display)

        self.score = 0
        self.level = 0
        self.lives = 3
        self.decision_cycles = 20
        self.current_cycle = 0

        self.terminal = Terminal(0, 800, 800, 100, liberation_serif,
                                 colors['white'], 20, colors['black'],
                                 self.display)
Exemplo n.º 24
0
	def __init__( self, parent ):
		wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 700,500 ), style = wx.DEFAULT_DIALOG_STYLE )
		
		self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
		
		bSizer1 = wx.BoxSizer( wx.VERTICAL )
		
		self.m_panel1 = Terminal( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL|wx.WANTS_CHARS )
		bSizer1.Add( self.m_panel1, 1, wx.EXPAND |wx.ALL, 5 )
		
		
		self.SetSizer( bSizer1 )
		self.Layout()
		
		self.Centre( wx.BOTH )
Exemplo n.º 25
0
class Pc(Platform):
    type = 'Pc'
    cxx_header = "dev/x86/pc.hh"
    system = Param.System(Parent.any, "system")

    south_bridge = SouthBridge()
    pci_host = PcPciHost()

    # "Non-existant" ports used for timing purposes by the linux kernel
    i_dont_exist1 = IsaFake(pio_addr=x86IOAddress(0x80), pio_size=1)
    i_dont_exist2 = IsaFake(pio_addr=x86IOAddress(0xed), pio_size=1)

    # Ports behind the pci config and data regsiters. These don't do anything,
    # but the linux kernel fiddles with them anway.
    behind_pci = IsaFake(pio_addr=x86IOAddress(0xcf8), pio_size=8)

    # Serial port and terminal
    com_1 = Uart8250()
    com_1.pio_addr = x86IOAddress(0x3f8)
    com_1.device = Terminal()

    # Devices to catch access to non-existant serial ports.
    fake_com_2 = IsaFake(pio_addr=x86IOAddress(0x2f8), pio_size=8)
    fake_com_3 = IsaFake(pio_addr=x86IOAddress(0x3e8), pio_size=8)
    fake_com_4 = IsaFake(pio_addr=x86IOAddress(0x2e8), pio_size=8)

    # A device to catch accesses to the non-existant floppy controller.
    fake_floppy = IsaFake(pio_addr=x86IOAddress(0x3f2), pio_size=2)

    # NVMe Interface
    nvme = NVMeInterface(pci_func=0, pci_dev=5, pci_bus=0)

    def attachIO(self, bus, dma_ports=[]):
        self.south_bridge.attachIO(bus, dma_ports)
        self.i_dont_exist1.pio = bus.master
        self.i_dont_exist2.pio = bus.master
        self.behind_pci.pio = bus.master
        self.com_1.pio = bus.master
        self.fake_com_2.pio = bus.master
        self.fake_com_3.pio = bus.master
        self.fake_com_4.pio = bus.master
        self.fake_floppy.pio = bus.master
        self.pci_host.pio = bus.default
        self.nvme.pio = bus.master
        if dma_ports.count(self.nvme.dma) == 0:
            self.nvme.dma = bus.slave
Exemplo n.º 26
0
 def getAllTerminals(cls):
     try:
         with CursorPool() as cursor:
             terminals:list = []
             cursor.execute(cls._SELECT)
             registers:tuple = cursor.fetchall()
             for register in registers:
                 terminal:Terminal = Terminal(
                     idTerminal=register[0],
                     name=register[1],
                     place=register[2],
                     number=register[3]
                 )
                 terminals.append(terminal)
                 log.debug(terminal)
             log.debug("Getting Terminals Succesfully")
             return terminals
     except Exception as e:
         log.error(f"Error while getting terminals: {e}")
Exemplo n.º 27
0
def main():
    """
    This method creates the terminal
    """
    # initial user input
    inputs = ["Dummy variable"]
    terminal = Terminal()

    while (inputs[0] != "exit"):
        cwd = os.getcwd()
        inputs = user_input()

        if inputs[0] in terminal.dic:
            command = inputs[0]
            terminal.dic[command]()
        elif inputs[0] in terminal.dic_args_1:
            if len(inputs) == 2:
                command, arg = inputs
                terminal.dic_args_1[command](arg)
Exemplo n.º 28
0
    def __init__(self, proyecto_path):

        Gtk.EventBox.__init__(self)

        archivo = os.path.join(proyecto_path, "proyecto.ide")
        arch = open(archivo, "r")
        self.proyecto = json.load(arch, "utf-8")
        arch.close()

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.install_path = os.path.join(CONFPATH, self.proyecto["nombre"])
        self.widgeticon = WidgetIcon("python", self.install_path)
        self.notebook = Notebook(proyecto_path)
        self.terminal = Terminal()

        label = Gtk.Label(u"Instalador python para: %s versión: %s" % (
            self.proyecto["nombre"], self.proyecto["version"]))
        label.modify_font(Pango.FontDescription("%s %s" % ("Monospace", 12)))
        label.modify_fg(0, Gdk.Color(0, 0, 65000))

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        image = Gtk.Image()
        arch = os.path.join(BASEPATH, "Iconos", "gandalftux.png")
        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(arch, 100, 100)
        image.set_from_pixbuf(pixbuf)
        hbox.pack_start(image, False, False, 0)
        vbox2 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        vbox2.pack_start(label, False, False, 0)
        vbox2.pack_start(self.widgeticon, False, False, 0)
        hbox.pack_start(vbox2, True, True, 0)
        vbox.pack_start(hbox, False, False, 0)

        vbox.pack_start(self.notebook, True, True, 0)
        vbox.pack_start(self.terminal, True, True, 5)

        self.add(vbox)
        self.connect("realize", self.__realize)
        self.show_all()

        self.widgeticon.connect("iconpath", self.__set_iconpath)
        self.widgeticon.connect("make", self.__make)
Exemplo n.º 29
0
class Pc(Platform):
    type = 'Pc'
    system = Param.System(Parent.any, "system")

    pciconfig = PciConfigAll()

    south_bridge = SouthBridge()

    # "Non-existant" port used for timing purposes by the linux kernel
    i_dont_exist = IsaFake(pio_addr=x86IOAddress(0x80), pio_size=1)

    # Ports behind the pci config and data regsiters. These don't do anything,
    # but the linux kernel fiddles with them anway.
    behind_pci = IsaFake(pio_addr=x86IOAddress(0xcf8), pio_size=8)

    # Serial port and terminal
    terminal = Terminal()
    com_1 = Uart8250()
    com_1.pio_addr = x86IOAddress(0x3f8)
    com_1.terminal = terminal

    # Devices to catch access to non-existant serial ports.
    fake_com_2 = IsaFake(pio_addr=x86IOAddress(0x2f8), pio_size=8)
    fake_com_3 = IsaFake(pio_addr=x86IOAddress(0x3e8), pio_size=8)
    fake_com_4 = IsaFake(pio_addr=x86IOAddress(0x2e8), pio_size=8)

    # A device to catch accesses to the non-existant floppy controller.
    fake_floppy = IsaFake(pio_addr=x86IOAddress(0x3f2), pio_size=2)

    def attachIO(self, bus):
        self.south_bridge.attachIO(bus)
        self.i_dont_exist.pio = bus.port
        self.behind_pci.pio = bus.port
        self.com_1.pio = bus.port
        self.fake_com_2.pio = bus.port
        self.fake_com_3.pio = bus.port
        self.fake_com_4.pio = bus.port
        self.fake_floppy.pio = bus.port
        self.pciconfig.pio = bus.default
        bus.responder_set = True
        bus.responder = self.pciconfig
Exemplo n.º 30
0
class SimpleBoard(Platform):
    type = 'SimpleBoard'
    cxx_header = 'dev/riscv/simpleboard.hh'
    system = Param.System(Parent.any, 'system')

    timer_cpu = TimerCpu(pio_addr=0x02000000)

    term = Terminal()
    uart = Uart8250(pio_addr=0x10013000)

    cust_regs = CustomRegs(pio_addr=0x90000000,
                           regs=[0x90000000,
                                 0x90000004,
                                 0x90000008,
                                 0x9000000c])

    # attach I/O devices to bus
    # call this method after bus is defined at system level
    def attachIO(self, bus):
        self.cust_regs.pio = bus.master
        self.timer_cpu.pio = bus.master
        self.uart.device = self.term
        self.uart.pio = bus.master
Exemplo n.º 31
0
		"""
        maxIndex = len(posts) - 1

        self.__menu__.clearMenu()
        if (index + POSTPERPAGE > maxIndex):
            for post in posts[index:]:
                if isinstance(post, QuestionQuery):
                    self.__menu__.addMenuItem(
                        str(post.title) + " | " + str(post.voteCount) + " | " +
                        str(post.answerCount))
                else:
                    self.__menu__.addMenuItem(
                        str(post.title) + " | " + str(post.voteCount))
            return False
        else:
            for i in range(index, index + POSTPERPAGE):
                if isinstance(posts[i], QuestionQuery):
                    self.__menu__.addMenuItem(
                        str(posts[i].title) + " | " + str(posts[i].voteCount) +
                        " | " + str(posts[i].answerCount))
                else:
                    self.__menu__.addMenuItem(
                        str(posts[i].title) + " | " + str(posts[i].voteCount))
            return True


if __name__ == "__main__":
    from Terminal import Terminal
    searchPostScreen = SearchForPostsScreen(Terminal())
    searchPostScreen.printScreen()
Exemplo n.º 32
0
 def __str__(self):
     Terminal.__str__(self)
     print("Nº ",self.getNumero()," - ",self.getTiempoDeConversacion(),"s de conversación - tarificados",self.totalTarificado, "  euros")
Exemplo n.º 33
0
 def __init__(self, numero, tarifa): 
     Terminal.__init__(self, numero)
     self.tarifa=tarifa
     self.totalTarificado=0
Exemplo n.º 34
0
class PythonWidget(Gtk.EventBox):

    __gtype_name__ = 'JAMediaEditorPythonWidget'

    def __init__(self, proyecto_path):

        Gtk.EventBox.__init__(self)

        archivo = os.path.join(proyecto_path, "proyecto.ide")
        arch = open(archivo, "r")
        self.proyecto = json.load(arch, "utf-8")
        arch.close()

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.install_path = os.path.join(CONFPATH, self.proyecto["nombre"])
        self.widgeticon = WidgetIcon("python", self.install_path)
        self.notebook = Notebook(proyecto_path)
        self.terminal = Terminal()

        label = Gtk.Label(u"Instalador python para: %s versión: %s" % (
            self.proyecto["nombre"], self.proyecto["version"]))
        label.modify_font(Pango.FontDescription("%s %s" % ("Monospace", 12)))
        label.modify_fg(0, Gdk.Color(0, 0, 65000))

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        image = Gtk.Image()
        arch = os.path.join(BASEPATH, "Iconos", "gandalftux.png")
        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(arch, 100, 100)
        image.set_from_pixbuf(pixbuf)
        hbox.pack_start(image, False, False, 0)
        vbox2 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        vbox2.pack_start(label, False, False, 0)
        vbox2.pack_start(self.widgeticon, False, False, 0)
        hbox.pack_start(vbox2, True, True, 0)
        vbox.pack_start(hbox, False, False, 0)

        vbox.pack_start(self.notebook, True, True, 0)
        vbox.pack_start(self.terminal, True, True, 5)

        self.add(vbox)
        self.connect("realize", self.__realize)
        self.show_all()

        self.widgeticon.connect("iconpath", self.__set_iconpath)
        self.widgeticon.connect("make", self.__make)

    def __realize(self, widget):
        self.terminal.hide()

    def __make(self, widget):
        t = "Construyendo el Instalador."
        t = "%s\n%s" % (t, "Por favor espera un momento . . .")
        dialogo = DialogoLoad(self.get_toplevel(), t)
        dialogo.connect("running", self.__run_make)
        dialogo.run()

    def __run_make(self, dialogo):
        self.terminal.reset()
        self.notebook.guardar()
        desktop = os.path.join(self.install_path,
            "%s.desktop" % self.proyecto["nombre"])
        lanzador = os.path.join(self.install_path,
            self.proyecto["nombre"].lower())
        setup = os.path.join(self.install_path, "setup.py")
        for path in [setup, desktop, lanzador]:
            os.chmod(path, 0755)

        python_path = "/usr/bin/python"
        if os.path.exists(os.path.join("/bin", "python")):
            python_path = os.path.join("/bin", "python")
        elif os.path.exists(os.path.join("/usr/bin", "python")):
            python_path = os.path.join("/usr/bin", "python")
        elif os.path.exists(os.path.join("/sbin", "python")):
            python_path = os.path.join("/sbin", "python")
        elif os.path.exists(os.path.join("/usr/local", "python")):
            python_path = os.path.join("/usr/local", "python")

        self.terminal.show_all()
        self.terminal.connect("reset", self.__Informar, dialogo)
        self.terminal.ejecute_script(self.install_path,
            python_path, setup, "sdist")

    def __Informar(self, terminal, dialogo):
        origen = os.path.join(self.install_path, "dist")
        for f in os.listdir(origen):
            arch = os.path.join(origen, f)
            commands.getoutput('mv %s %s' % (arch, CONFPATH))
            destino = os.path.join(CONFPATH, f)
            os.chmod(destino, 0755)
        if os.path.exists(origen):
            shutil.rmtree(origen)
        dialogo.destroy()
        t = "Proceso Concluido."
        t = "%s\n%s" % (t, "El instalador se encuentra en")
        t = "%s: %s" % (t, CONFPATH)
        # FIXME: Pedir para borrar directorio temporal ?
        dialogo = DialogoInformar(self.get_toplevel(), t)
        dialogo.run()
        dialogo.destroy()
        self.terminal.disconnect_by_func(self.__Informar)

    def __set_iconpath(self, widget, iconpath):
        new = iconpath
        if not self.install_path in iconpath:
            new = os.path.join(self.install_path, os.path.basename(iconpath))
            shutil.copyfile(iconpath, new)
        self.notebook.set_icon(new)
Exemplo n.º 35
0
    def __init__(self, terminal, posts):
        """
		Creates an instance of PostMenuScreen

		Parameters:
			terminal:
				A Terminal object allowing the module to interface
				with the OS terminal
		Returns:
				An instance of Tag
		"""
        self.__menu__ = Menu(terminal)
        for post in posts:
            self.__menu__.addMenuItem(post)

    def printScreen(self):
        """
		Prints the menu options of the module
		"""
        self.__menu__.printScreen()


if __name__ == "__main__":
    from Terminal import Terminal
    posts = [
        "How do I make eggs?", "Hello anyone out there?", "Yes I am Here!",
        "Just google it 4head"
    ]
    postScreen = PostMenuScreen(Terminal(), posts)
    postScreen.printScreen()