예제 #1
0
파일: network.py 프로젝트: nordcz/electrum
 def start_interface(self, server):
     if server in self.interfaces.keys():
         return
     i = interface.Interface({'server':server})
     i.network = self # fixme
     self.interfaces[server] = i
     i.start(self.queue)
예제 #2
0
 def start_interface(self, server):
     if not server in self.interfaces.keys():
         if server == self.default_server:
             self.set_status('connecting')
         i = interface.Interface(server, self.queue, self.config)
         self.interfaces[i.server] = i
         i.start()
예제 #3
0
def cli(views, number, list_only):
    """A simple CLI to answer project questions."""

    if views:
        file_path = path.normpath('/vagrant/news/views.sql')
        with open(file_path, 'r') as f:
            click.echo(utils_news.format_query(f.read()))
        return

    if number not in ['1', '2', '3']:
        err = click.UsageError('question number must be 1, 2 or 3')
        raise err

    question = utils_news.QUESTIONS[number]
    query = utils_news.QUERIES[number]

    click.echo('')
    click.secho(question, bold=True, fg='yellow')
    click.echo('')
    click.echo(utils_news.format_query(query))

    # if "list-only" option is passed than exit
    if list_only:
        return

    db_io = interface.Interface()

    response = db_io.execute_query(query)
    click.echo(utils_news.format_response(response))
    click.echo('')

    db_io.close()
예제 #4
0
파일: filters.py 프로젝트: Untou4able/c2j
 def line(self, line):
   if line.strip() == '!':
     self._intfStarted = False
     if self._intf:
       self._matches[self._intf.name] = self._intf
       self._intf = None
       return True
     return False
   if line.startswith('interface'):
     self._intfStarted = True
     self._intf = interface.Interface()
     self._intf.parameterFromString(line)
     return True
   if self._intfStarted:
     if line.strip().startswith('description'):
       r = self._re.search(line)
       if not r:
         self._intfStarted = False
         self._intf = None
         return True
       else:
         if len(r.groups()[1]) == 9:
           newLine = r.groups()[0] + '1' + r.groups()[1] + r.groups()[2]
           self._intf.parameterFromString(newLine)
           return True
     self._intf.parameterFromString(line)
     return True
   return False
예제 #5
0
 def __init__(self, parent, filename, id_, standard, rule):
     self.original_values = self._compute_values(standard, rule)
     self.ui = interface.Interface(
         parent, filename, id_,
         (interface.StartDateSample, interface.EndDateSample,
          interface.AlarmDateSample, interface.Standard),
         self.original_values)
예제 #6
0
 def start_interface(self, server):
     if server in self.interfaces.keys():
         return
     i = interface.Interface(server, self.config)
     self.pending_servers.add(server)
     i.start(self.queue)
     return i
예제 #7
0
def main():
    args = parse_args()
    logging.basicConfig(
        level=args.loglevel,
        format='%(name)s [%(process)d] %(levelname)s %(message)s')

    if args.loglevel and not args.debug_requests:
        logging.getLogger('requests').setLevel(logging.WARN)

    LOG.info('Starting up')
    LOG.info('Kubernetes is %s', args.kube_endpoint)
    LOG.info('Etcd is %s', args.etcd_endpoint)
    LOG.info('Managing interface %s', args.interface)

    if args.no_driver:
        iface_driver = None
        fw_driver = None
    else:
        iface_driver = interface.Interface(args.interface)
        fw_driver = firewall.Firewall(fwchain=args.fwchain, fwmark=args.fwmark)

    mgr = manager.Manager(etcd_endpoint=args.etcd_endpoint,
                          kube_endpoint=args.kube_endpoint,
                          etcd_prefix=args.etcd_prefix,
                          iface_driver=iface_driver,
                          fw_driver=fw_driver,
                          cidr_ranges=args.cidr_range,
                          refresh_interval=args.refresh_interval,
                          id=args.agent_id)

    LOG.info('My id is: %s', mgr.id)
    mgr.run()
예제 #8
0
def juros():

    #############################
    # INTERFACE VISUAL DE JUROS #
    #############################
    jurosMenu = interface.Interface()
    # Opções de menu
    jurosMenu.setOptions([
        ('1 - Simples - Calcular juros simples', 'simples', 1),
        ('2 - Composto - Calcular juros composto', 'composto', 2),
        ('0 - Voltar', 'voltar', 0)
    ])
    # Título
    jurosMenu.setTitle('JUROS')

    # Loop infinito para escolha de opções
    # até que a opção de voltar seja escolhida
    while 1:
        selected = jurosMenu.getInputOption()
        # Voltar para main menu
        if (selected == 0):
            break
        elif (selected == 1):
            simples()
        elif (selected == 2):
            composto()
예제 #9
0
def main():

    logging.basicConfig(level=logging.DEBUG)

    eva_id = id.Id()
    eva_ego = ego.Ego()
    eva_perception = perception.Perception()
    eva_memory = memory.Memory()
    eva_interface = interface.Interface()

    eva_mind = mind.Mind('Eva', eva_id, eva_ego)

    timer_control = time.time()

    while eva_mind.is_active:

        if timer_control + TIME_CYCLE > time.time():
            continue

        eva_id.Process(eva_mind)
        eva_ego.Process(eva_mind)
        eva_perception.Process(eva_mind)
        eva_mind.Process(eva_memory, eva_perception)

        for response in eva_mind.responses:
            eva_interface.PrintResponse(response)

        eva_mind.responses.clear()

        timer_control = time.time()

    return eva_mind.return_state
예제 #10
0
 def __init__(self, parent, filename, id_, standard, rule):
     self.original_values = self._compute_values(standard, rule)
     self.ui = interface.Interface(
         parent, filename, id_,
         (interface.Months, interface.StartMonthDayInverse,
          interface.EndTime, interface.AlarmTime, interface.Standard),
         self.original_values)
예제 #11
0
def plot_episode(agent, run):
    ''' Plot an example run. '''
    with file('./runs/'+agent.name+'/'+str(run)+'.obj', 'r') as file_handle:
        agent = pickle.load(file_handle)
        sim = simulator.Simulator()
        import interface
        agent.run_episode(sim)
        interface.Interface().draw_episode(sim, 'after')
예제 #12
0
		def __init__(self,chan):
			super(CustomWidgets.voltHandler, self).__init__()
			#QFrame.__init__(self)
			#Ui_Sliding.__init__(self)
			self.I=interface.Interface()
			self.setupUi(self)
			self.name='READ '+chan
			self.button.setText(self.name)
			self.chan=chan
예제 #13
0
		def __init__(self):
			super(CustomWidgets.voltAllHandler, self).__init__()
			#QFrame.__init__(self)
			#Ui_Sliding.__init__(self)
			self.I=interface.Interface()
			self.setupUi(self)
			self.names=['CH1','CH2','CH3','CH4','CH5','CH6','CH7','CH8','CH9','5V','9V','IN1','SEN']
			self.button.setText('Read')
			self.items.addItems(self.names)
예제 #14
0
def plot_episode(agent_class, run):
    ''' Plot an example run. '''
    agent = load(agent_class, run)
    sims = []
    for _ in range(PLOT_EPISODES):
        sim = simulator.Simulator()
        agent.run_episode(sim)
        sims.append(sim)
    import interface
    interface.Interface().draw_episode(sims, 'after', SAVE)
예제 #15
0
 def __init__(self):
     super(CustomWidgets.sineHandler, self).__init__()
     #QtGui.QFrame.__init__(self)
     #Ui_Sliding.__init__(self)
     self.I = interface.Interface()
     self.setupUi(self)
     self.name = 'DDS'
     self.label.setText(self.name)
     self.slider.setMinimum(0)
     self.slider.setMaximum(500000)
예제 #16
0
		def __init__(self,cmd):
			super(CustomWidgets.timingHandler, self).__init__()
			#QFrame.__init__(self)
			#Ui_Sliding.__init__(self)
			self.I=interface.Interface()
			self.setupUi(self)
			self.cmd = getattr(self.I,cmd)
			self.cmdname=cmd
			self.button.setText(cmd)
			self.items.addItems(['ID1','ID2','ID3','ID4','CH4'])
예제 #17
0
    def setup_followup(self):
        setup_dict = {}
        i = interface.Interface()
        question_list = i.get_question_akut()

        for question in question_list:
            setup_dict[question] = "none"
        with open("followup_setup.txt", "w") as f:
            f.write(str(setup_dict))
            print(setup_dict)
예제 #18
0
    def new_followup(self):
        i = interface.Interface()
        question_list = i.get_question_akut()
        setup_dict = eval(open("followup_setup.txt").read())

        for question in question_list:
            followup = input("What would you encurage yourself with")
            setup_dict[question] = followup
        with open("followup_setup.txt", "w") as f:
            f.write(str(setup_dict))
            print(setup_dict)
예제 #19
0
		def __init__(self,chan):
			super(CustomWidgets.sineHandler, self).__init__()
			#QFrame.__init__(self)
			#Ui_Sliding.__init__(self)
			self.I=interface.Interface()
			self.setupUi(self)
			self.name=['SINE1','SINE2'][chan-1]
			self.label.setText(self.name)
			self.chan=chan
			self.slider.setMinimum(0)
			self.slider.setMaximum(500000)
예제 #20
0
파일: example.py 프로젝트: luwangg/ardfmap
def main():
    apiBaseUri = "http://localhost:8083/api/"
    service = interface.Interface(apiBaseUri)

    # Print out all the geometry.
    #printGeometry(service)

    # Create a new line.
    o = service.createLine(points=[(100.0, 0.0), (101.0, 1.0)])

    # This replaces all the points in the line.
    service.updateLine(o, points=[(200.0, 0.0), (101.0, 1.0)])
예제 #21
0
def main():
    config_path = os.path.join(os.path.dirname(__file__), '../conf/bots.yaml')
    config = yaml.load(open(config_path).read())
    client.commands = config.get('common_actions', {}).copy()
    client.commands.update(config.get('discord_actions', {}))
    client.commands.update(config.get('admin_actions', {}))
    client.max_retries = config.get('max_retries', 3)
    client.config = config
    client.interface = interface.Interface(config, client.commands)
    token = config['discord']['token']
    client.loop.create_task(change_status(config))
    client.run(token)
예제 #22
0
		def __init__(self,chan,alternate_name=None):
			super(CustomWidgets.gainHandler, self).__init__()
			self.I=interface.Interface()
			self.setupUi(self)
			self.slider.setMinimum(0)
			self.slider.setMaximum(7)
			self.gaintxt=['1x','2x','4x','5x','8x','10x','16x','32x']
			self.name=chan
			if alternate_name:
				self.labeltxt=alternate_name
			else:
				self.labeltxt=chan
			self.label.setText(self.labeltxt)
예제 #23
0
		def __init__(self,name):
			super(CustomWidgets.sourceHandler, self).__init__()
			self.I=interface.Interface()
			self.setupUi(self)
			self.name=name
			if name=='pvs1':
				self.slider.setRange(0,4095)
			if name=='pvs2':
				self.slider.setRange(0,4095)
			elif name=='pvs3':
				self.slider.setRange(0,31)
			elif name=='pcs':
				self.slider.setRange(0,31)
예제 #24
0
def main():
    client.commands, client.admin_commands, client.no_arg_cmds = [], [], [] # Init
    client.help = {} # Init

    # Pull in a separate config
    config = json_loads(open(os_path.join(os_path.dirname(__file__), 'commands/bots.json')).read())

    # Grab our commands from the json
    commands = list(config.get('common_commands', {}).copy().values())
    commands.extend(config.get('admin_commands', {}).values())
    no_arg_cmds = config.get('no_arg_commands', []).copy()

    # Sort the raw json into the appropriate variables
    # For every entry in commands loop over the child array
    for aliases in commands:
        # For every child in the child array, sort it to the appropriate variable for later
        for alias in aliases:
            # If the child item is the last item(the help message), move on to the next command
            if alias == aliases[-1]:
                break
            # Elif the full command doesn't take args, have the aliases not accept args
            elif aliases[0] in no_arg_cmds:
                client.no_arg_cmds.append(alias.lower())
            # Add the help message for each alias
            client.help.update({alias.lower():aliases[-1]})
            # Add the command and aliases as valid commands
            client.commands.append(alias)

    # Admin commands
    commands = config.get('admin_commands', {}).copy().values()

    # For every admin command in commands loop over the child array
    for aliases in commands:
        # For every child in the child array, sort it to the appropriate variable for later
        for alias in aliases:
            # Add the command and aliases as admin commands
            client.admin_commands.append(alias)

    # Dev commands
    client.dev_commands = list(config.get('dev_commands', []).copy())
    for command in client.dev_commands:
        client.commands.append(command)

    # Start our interface for our commands and Discord
    client.interface = interface.Interface(client.admin_commands, client.dev_commands, client.help)

    # Start loop for status change
    client.loop.create_task(change_status())

    # Start the bot
    client.run(token)
예제 #25
0
    def __init__(self):
        self.interface = interface.Interface()
        self.choices = [
            self.interface.move_right, self.interface.move_left,
            self.interface.move_up, self.interface.move_down
        ]

        self.choices3 = [
            self.interface.move_right, self.interface.move_left,
            self.interface.move_down
        ]

        self.player_type = 0
        self.changeType(RANDOM)
예제 #26
0
def run():
    inter = interface.Interface()
    while True:
        action = inter.get_action()
        if action == "1":
            functions.new_cards()

        elif action == "2":
            functions.show_all_cards()

        elif action == "3":
            functions.query_cards()

        elif action == "0":
            functions.quit_system()
예제 #27
0
 def __init__(self, bot):
     self.bot = bot
     self.nick = self.bot.get_nick()
     config_path = os.path.join(os.path.dirname(__file__),
                                '../conf/bots.yaml')
     self.config = yaml.load(open(config_path).read())
     self.channels = self.config['irc']['channels']
     self.commands = self.config.get('common_actions', {})
     self.commands.update(self.config.get('irc_actions', {}))
     self.commands.update(self.config.get('admin_actions', {}))
     self.url_enabled_channels = self.config.get('youtube', {}).get(
         'url_enabled_channels', [])
     self.interface = interface.Interface(self.config, self.commands)
     self.youtube_regex = '(?:https?://)?(?:www.)?(?:youtube.com|youtu.be)/(?:watch\?)?v=([^\s]+)'
     self.build_youtube_service()
예제 #28
0
 def selected(self, filename):
     """
     Add all selected files to temporary list to be later evaluated
     :param filename: selected file
     :return: None
     """
     interface_obj = interface.Interface()
     select = interface_obj.while_selecting_files(filename)
     if len(self.files) < 5:
         if select is None:
             pass
         elif select is not None:
             self.files.append(select)
     elif len(self.files) == 5 and select is not None:
         PopupMessage('You Only Need Two files\n' 'Remove Some to Proceed')
예제 #29
0
def main(stdscr):
    display = interface.Interface(stdscr)
    load_sprites()
    current_scene = None

    def switch_scene(scene):
        current_scene = scene

    current_scene = StartScene(display)
    key = None
    while key != 'QUIT' and current_scene.game_over != True:
        key = display.get_input()
        current_scene.update(display, key)
        if current_scene.next_scene != None:
            current_scene = current_scene.next_scene
    display.__uninit__()
예제 #30
0
def test_interface():
    A = time.time()

    def weight_func(buyer_pos, buyer_d, seller_pos, seller_d):
        return abs(buyer_pos[0] - seller_pos[0])

    inter = interface.Interface(
        algs.Greedy(),
        simulator.Simulator(weight_func),
        seed=42,
        dep_distr=(
            3, 0),  # to make d constant for all nodes, make variance 0 (duh)
        verbose=True)
    inter.run(10)
    B = time.time()
    print("Interface tests completed successfully in {} sec".format(B - A))