当前位置: 首页>>代码示例>>Python>>正文


Python actions.Actions类代码示例

本文整理汇总了Python中actions.Actions的典型用法代码示例。如果您正苦于以下问题:Python Actions类的具体用法?Python Actions怎么用?Python Actions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Actions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_actions

 def get_actions(self, actions, params):
     result = Actions()
     for action in actions:
         name, data = action.popitem()
         steps = self.get_steps(data.get('steps'), self.get_block(data, **params))
         result.add_action(Action(steps, name))
     return result
开发者ID:AHAPX,项目名称:test-rest,代码行数:7,代码来源:loaders.py

示例2: __init__

 def __init__(self):
     Board.__init__(self)
     Actions.__init__(self)
     Rules.__init__(self)
     self.players = {}
     self.turn = 0
     self.game_over = True
开发者ID:ncdesouza,项目名称:GameServer,代码行数:7,代码来源:game.py

示例3: main

 def main():
     action = input("\nChoose an action: (status, move, save, rest, exit) ")
     if action == "status":
         Playerinfo.status()
         Game.main()
     elif action == "move" or action == "m":
         Actions.move()
         if Player.isAlive:
             Game.main()
         else:
             IO.death()
             Game.start()
     elif action == "rest" or action == "r":
         Actions.rest()
         Game.main()
     elif action == "save":
         IO.save()
         print("Game saved!")
         Game.main()
     elif action == "exit" or action == "q" or action == "quit":
         answer = input("Are you sure you want to quit? (y/n) ")
         if answer == "y":
             IO.save()
             IO.quit()
         else:
             Game.main()
     else:
         print("\nTry again!")
         Game.main()
开发者ID:NoYzE1,项目名称:cRPG,代码行数:29,代码来源:game.py

示例4: run

    def run(self):
        self.logger.info("daemon running")

        actions = Actions(self.logger)
        
        try:
            actions.createSessionBus()
            actions.createManager()
            actions.wireEventHandlers()
            actions.openManager()
            
            # MAIN LOOP
            # ---------        
            while True:
                #self.logger.info("start loop")
                
                try:
                    signal.pause()
                    #time.sleep(0.1)
                    #sys.stdin.read()
                except Exception,e:
                    exc=str(e)
                    self.logger.error("error_untrapped", exc=exc)
                    
                #self.logger.info("tail loop")
                
        except Exception,e:
            exc=str(e)
            self.logger.error("error_untrapped", exc=exc)
开发者ID:jldupont,项目名称:pyjld,代码行数:29,代码来源:bonjour_daemon.py

示例5: TPBattStat

class TPBattStat():
  def __init__(self, mode, forceDelay=None, forceIconSize=None):
    self.mode = mode
    self.forceDelay = forceDelay

    self.prefs = Prefs()
    self.battStatus = BattStatus(self.prefs)
    self.actions = Actions(self.prefs, self.battStatus)
    if self.mode == "gtk" or self.mode == "prefs":
      self.gui = Gui(self.prefs, self.battStatus)
    elif self.mode == "json" or self.mode == "dzen":
      self.guiMarkupPrinter = GuiMarkupPrinter(
        self.prefs, self.battStatus, forceIconSize)
      
  def getGui(self):
    return self.gui
  def startUpdate(self):
    self.curDelay = -1
    self.update()
  def update(self):
    try:
      self.prefs.update()
    except Exception as e:
      print 'ignoring prefs'
      print e.message
    if self.forceDelay != None:
      self.prefs['delay'] = self.forceDelay
    self.battStatus.update(self.prefs)

    self.actions.performActions()
    if self.mode == "gtk":
      self.gui.update()
    elif self.mode == "json" or self.mode == "dzen":
      try:
        if self.mode == "json":
          markup = self.guiMarkupPrinter.getMarkupJson()
        elif self.mode == "dzen":
          markup = self.guiMarkupPrinter.getMarkupDzen()
        print markup
        sys.stdout.flush()
      except IOError, e:
        print >> sys.stderr, "STDOUT is broken, assuming external gui is dead"
        sys.exit(1)

    if self.prefs['delay'] != self.curDelay:
      self.curDelay = self.prefs['delay']
      if self.curDelay <= 0:
        self.curDelay = 1000
      gobject.timeout_add(self.curDelay, self.update)
      return False
    else:
      return True
开发者ID:teleshoes,项目名称:tpbattstat,代码行数:52,代码来源:tpbattstat.py

示例6: Listener

class Listener(EventDispatcher):
    """
    listener function that queries kivy for touch events, builds the gesture
    and dispatch it through the actions singleton.
    """
    def __init__(self, config, gestures, el, *args, **kwarg):
        """
        :param config: string containing the path to the action configuration
        :param gestures: string containing the path to the gestures configuration
        """
        super(EventDispatcher, self).__init__(*args, **kwarg)
        self._event_loop = el
        self._gdb = GestureDatabase()
        self._actions = Actions(config, gestures)
        self.update_devices()
        self._multitouches = []

    def update_devices(self):
        log.debug('update_devices()')
        context = pyudev.Context()
        for device in context.list_devices(subsystem='input', ID_INPUT_MOUSE=True):
            if device.sys_name.startswith('event'):
                if 'PRODUCT' in device.parent.keys():
                    self._actions.update_gestures(device.parent['PRODUCT'])
        for gest_n, gest_r in self._actions.get_gestures().iteritems():
            for g in gest_r:
                g = self._gdb.str_to_gesture(g)
                g.normalize()
                g.name = gest_n
                self._gdb.add_gesture(g)

    def on_touch_down(self, touch):
        """
        listening function executed at begining of touch event
        builds the gesture
        """
        self._multitouches.append(touch)
        touch.ud['line'] = Line(points=(touch.sx, touch.sy))
        return True

    def on_touch_move(self, touch):
        """
        listening function executed during touch event
        store points of the gesture
        """
        # store points of the touch movement
        try:
            touch.ud['line'].points += [touch.sx, touch.sy]
            return True
        except (KeyError), e:
            pass
开发者ID:guyzmo,项目名称:kitt,代码行数:51,代码来源:listener.py

示例7: apply_action

    def apply_action(state, action):
        """ Edits the state to reflect the results of the action.
            (State, str) -> None
        """
        if action not in BlackBirdRules.get_legal_actions(state):
            raise Exception("Illegal action " + str(action))
        state.score_change = 0

        next_pos = Actions.get_successor(state.black_bird_position, action)
        state.black_bird_position = next_pos
#        if next_pos == state.red_bird_position :
#            print( "Black moving into Red's position" )


        if next_pos in state.yellow_birds:
            state.score_change -= state.current_yellow_bird_score
            state.yellow_birds = tuple([yb for yb in state.yellow_birds if yb != next_pos])
            state._yellow_bird_eaten = next_pos
            if not state.yellow_birds:
                print("All Birds Eaten")
                state.terminal = True
        if state.red_bird_position == state.black_bird_position :
            state.red_bird_dead = True # Black eats Red
            print("Black EATS Red!")
            state.score_change -= 250
        if state.black_bird_position is not None:
            state.current_yellow_bird_score *= 0.99
        if state.current_yellow_bird_score < 0.5 :
            print("Game Over - All the Yellow Birds Have Flown Away!")
开发者ID:Gin93,项目名称:111,代码行数:29,代码来源:game_rules.py

示例8: __init__

class GUI:
    
    def __init__(self):
       self.wsControlLabels = []
       self.wsControlLabels.append(settings.wireless_switch["ws_1_name"] + " On")
       self.wsControlLabels.append(settings.wireless_switch["ws_1_name"] + " Off")
       self.wsControlLabels.append(settings.wireless_switch["ws_2_name"] + " On")
       self.wsControlLabels.append(settings.wireless_switch["ws_2_name"] + " Off")
       self.wsControlLabels.append(settings.wireless_switch["ws_3_name"] + " On")
       self.wsControlLabels.append(settings.wireless_switch["ws_3_name"] + " Off")
       self.wsControlLabels.append("- - -")
       self.wsControlLabels.append("Toggle Service on/off")
       self.actions = Actions()
     
    def toggleService(self):
        settings.update_general()
        if settings.general["service_enabled"]:
            settings.set("service_enabled", "false")
        else:
            settings.set("service_enabled", "true")
        settings.update_general()    
       
    def show(self):    
        ## main loop ##
        while True:
            if settings.general["service_enabled"]:
                self.wsControlLabels[7] = "Disable Service"
            else:
                self.wsControlLabels[7] = "Enable Service"
                
            idx = Dialog().select(addonname, self.wsControlLabels)
            xbmc.log(msg=self.wsControlLabels[idx], level=xbmc.LOGDEBUG)  
            if idx >= 0 and idx <= 5:
                wsID = str(idx / 2 + 1)
                powerState = "0"
                if idx % 2 == 0:
                    powerState = "1"
                self.actions.ws_control(wsID,powerState)
            elif idx == 7:
                self.toggleService()
            elif idx == 8:
                self.actions.start_settings_server()
            elif idx == -1:
                break
            else:
                break   
        sys.modules.clear()
开发者ID:charky,项目名称:chyfy,代码行数:47,代码来源:gui.py

示例9: __init__

 def __init__(self):
     self.monitor = CE_Monitor(self)
     self.player = xbmc.Player()
     self.actions = Actions()
     self.blue = Bluetooth()
     self.lightIsON=False
     self.deviceFound=False
     self.discoveryIsOn=False
     self.delayToggle = 0
开发者ID:charky,项目名称:chyfy,代码行数:9,代码来源:service.py

示例10: __init__

    def __init__(self):
        self.prevGraph = None

        self.actions = Actions(sendToLiveClients)

        self.rulesN3 = "(not read yet)"
        self.inferred = Graph() # gets replaced in each graphChanged call

        self.inputGraph = InputGraph([], self.graphChanged)      
        self.inputGraph.updateFileData()
开发者ID:,项目名称:,代码行数:10,代码来源:

示例11: __init__

 def __init__(self, config, gestures, el, *args, **kwarg):
     """
     :param config: string containing the path to the action configuration
     :param gestures: string containing the path to the gestures configuration
     """
     super(EventDispatcher, self).__init__(*args, **kwarg)
     self._event_loop = el
     self._gdb = GestureDatabase()
     self._actions = Actions(config, gestures)
     self.update_devices()
     self._multitouches = []
开发者ID:guyzmo,项目名称:kitt,代码行数:11,代码来源:listener.py

示例12: __init__

 def __init__(self, name, backend="auto"):
     self.__name = name
     self.__queue = Queue.Queue()
     self.__filter = None
     if backend == "polling":
         self.__initPoller()
     else:
         try:
             self.__initGamin()
         except ImportError:
             self.__initPoller()
     self.__action = Actions(self)
开发者ID:rhertzog,项目名称:lcs,代码行数:12,代码来源:jail.py

示例13: __init__

  def __init__(self, mode, forceDelay=None, forceIconSize=None):
    self.mode = mode
    self.forceDelay = forceDelay

    self.prefs = Prefs()
    self.battStatus = BattStatus(self.prefs)
    self.actions = Actions(self.prefs, self.battStatus)
    if self.mode == "gtk" or self.mode == "prefs":
      self.gui = Gui(self.prefs, self.battStatus)
    elif self.mode == "json" or self.mode == "dzen":
      self.guiMarkupPrinter = GuiMarkupPrinter(
        self.prefs, self.battStatus, forceIconSize)
开发者ID:teleshoes,项目名称:tpbattstat,代码行数:12,代码来源:tpbattstat.py

示例14: on_scan_finished

 def on_scan_finished(self, scanner):
     # GLib.idle_add(self._on_scan_finished)
     if self.progreso_dialog is not None:
         self.progreso_dialog.destroy()
         self.progreso_dialog = None
     md = Gtk.MessageDialog(parent=self)
     md.set_title('Antiviral')
     md.set_property('message_type', Gtk.MessageType.INFO)
     md.add_button(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)
     md.set_property('text', _('Antiviral'))
     if len(self.infected) > 0:
         md.format_secondary_text(
             _('What a pity!, In this machine there are viruses!'))
         md.run()
         md.destroy()
         actions = Actions(self, self.infected)
         actions.run()
         actions.destroy()
     else:
         md.format_secondary_text(_('Congratulations!!, no viruses found'))
         md.run()
         md.destroy()
开发者ID:atareao,项目名称:antiviral,代码行数:22,代码来源:antiviral.py

示例15: DoTimeStep

 def DoTimeStep(self):
     self.actions.DoGather()
     #transfer
     self.actions.DoSplit()
     self.actions.DoDiscover()
     self.actions.DoTeach()
     #unlearn
     self.actions.DoLeach()
     self.actions.DoMove()
     self.actions.DoSubsist()
     self.actions = Actions(self)
     self.__teamsAccountedFor = set()
     self.t+=1
开发者ID:mphair,项目名称:abstrat,代码行数:13,代码来源:universe.py


注:本文中的actions.Actions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。