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


Python action.Action类代码示例

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


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

示例1: run

 def run(self):
     printer = ActionPrinter()
     loader = Loader(self.logger)
     for json_text in loader.load_func():
         self.logger.trello_json(json_text)
         json_dict = json.loads(json_text)
         actions = []
         if 'boards' in json_dict:
             boards = json_dict['boards']
             for b in boards:
                 actions += b['actions']
         elif 'actions' in json_dict:
             actions += json_dict['actions']
         else:
             stderr('Unknown input format')
             sys.exit(1)
         actions.sort(lambda x,y: cmp(x['date'], y['date']))
         for a in actions:
             action = Action(a)
             loader.saw_action(action)
             msg = printer.get_message(action)
             if msg is None:
                 continue
             self.logger.zulip_msg(msg.replace('\n', '\t'))
             post_params = {
                 'type' : 'stream',
                 'to' : CONFIG.zulip_stream(),
                 'subject' : action.derive_subject(),
                 'content' : msg
             }
             if not ARGS.no_post:
                 r = requests.post(ZULIP_URL, auth=CONFIG.zulip_auth(), data=post_params)
                 if r.status_code != 200:
                     stderr('Error %d POSTing to Zulip: %s' % (r.status_code, r.text))
         sys.stdout.flush()
开发者ID:ysamlan,项目名称:trello-to-zulip,代码行数:35,代码来源:trello-to-zulip.py

示例2: _initToolboxButtons

	def _initToolboxButtons(self):
		""" Sets up and connects buttons related to the toolbox """
		
		self._selectAction = Action(text=u"Select", icon="gui/icons/select_instance.png", checkable=True)
		self._drawAction = Action(text=u"Draw", icon="gui/icons/add_instance.png", checkable=True)
		self._removeAction = Action(text=u"Remove", icon="gui/icons/erase_instance.png", checkable=True)
		self._moveAction = Action(text=u"Move", icon="gui/icons/move_instance.png", checkable=True)
		self._objectpickerAction = Action(text=u"Pick object", icon="gui/icons/objectpicker.png", checkable=True)
		
		self._selectAction.helptext = u"Select cells on layer  (S)"
		self._moveAction.helptext = u"Moves instances   (M)"
		self._drawAction.helptext = u"Adds new instances based on currently selected object   (I)"
		self._removeAction.helptext = u"Deletes instances   (R)"
		self._objectpickerAction.helptext = u"Click an instance to set the current object to the one used by instance"
		
		action.toggled.connect(self._buttonToggled, sender=self._selectAction)
		action.toggled.connect(self._buttonToggled, sender=self._moveAction)
		action.toggled.connect(self._buttonToggled, sender=self._drawAction)
		action.toggled.connect(self._buttonToggled, sender=self._removeAction)
		action.toggled.connect(self._buttonToggled, sender=self._objectpickerAction)
		
		self._toolgroup = ActionGroup(exclusive=True, name=u"Tool group")
		self._toolgroup.addAction(self._selectAction)
		self._toolgroup.addAction(self._moveAction)
		self._toolgroup.addAction(self._drawAction)
		self._toolgroup.addAction(self._removeAction)
		self._toolgroup.addAction(self._objectpickerAction)
		
		self._toolbox.addAction(self._toolgroup)
		self._toolbox.adaptLayout()
		
		self._editor._edit_menu.addAction(self._toolgroup)
开发者ID:LilMouse,项目名称:fifengine,代码行数:32,代码来源:mapeditor.py

示例3: parseATCommand

	def parseATCommand(self, rawATCommand):
	
		action = Action()
		
		#We don't know yet if we have parser implemented for this AT command,
		#set error state for now
		action.noCommand = True
		
		if not isinstance(rawATCommand, str):
			action.isInErrorState = True
			return action
		
		if rawATCommand[:4] == "RING":
			action.incomingCall = True
			action.isInErrorState = False
			action.noCommand = False
			self.log.pushLogMsg("Incoming call")

		if rawATCommand[:10] == "NO CARRIER" or rawATCommand[:9] == "NO ANSWER":
			action.incomingCall = False
			action.isInErrorState = False
			action.noCommand = False
			action.callDisconnected = True
			self.log.pushLogMsg("Call disconnected")
			
		
		if action.noCommand == True:
			self.log.pushLogMsg(("AT parser failed to parse the AT command: " + rawATCommand)) #rawATCommand.toString()))
			
		return action
开发者ID:karrister,项目名称:imx233_gsm,代码行数:30,代码来源:modemATParser.py

示例4: inIgnoreIPList

	def inIgnoreIPList(self, ip):
		for i in self.__ignoreIpList:
			# An empty string is always false
			if i == "":
				continue
			s = i.split('/', 1)
			# IP address without CIDR mask
			if len(s) == 1:
				s.insert(1, '32')
			elif "." in s[1]: # 255.255.255.0 style mask
				s[1] = len(re.search(
					"(?<=b)1+", bin(DNSUtils.addr2bin(s[1]))).group())
			s[1] = long(s[1])
			try:
				a = DNSUtils.cidr(s[0], s[1])
				b = DNSUtils.cidr(ip, s[1])
			except Exception:
				# Check if IP in DNS
				ips = DNSUtils.dnsToIp(i)
				if ip in ips:
					return True
				else:
					continue
			if a == b:
				return True

		if self.__ignoreCommand:
			command = Action.replaceTag(self.__ignoreCommand, { 'ip': ip } )
			logSys.debug('ignore command: ' + command)
			return Action.executeCmd(command)

		return False
开发者ID:Ricky-Wilson,项目名称:fail2ban,代码行数:32,代码来源:filter.py

示例5: test_starts_actions_and_adds_back_to_queue

    def test_starts_actions_and_adds_back_to_queue(self):
        # given
        start_time = 0
        deadline = 10
        action_to_start = Action(start_time, deadline+1)
        action_to_start.agent = Mock(name="agent")
        action_to_start.is_applicable = Mock(return_val=True)
        action_to_start.apply = Mock(name="apply")
        model = Mock(name="model")
        execution_queue = PriorityQueue()
        execution_queue.put(ActionState(action_to_start, start_time, ExecutionState.pre_start))

        # when
        actual, _stalled = simulator.execute_action_queue(model, execution_queue,
            break_on_new_knowledge=False, deadline=deadline)

        # then
        assert_that(execution_queue.queue, has_length(1))
        time, state, action = execution_queue.queue[0]
        assert_that(time, equal_to(action_to_start.end_time))
        assert_that(state, equal_to(ExecutionState.executing))
        assert_that(action, equal_to(action_to_start))
        assert_that(actual.executed, is_(empty()))
        assert_that(is_not(action_to_start.apply.called))
        assert_that(actual.simulation_time, equal_to(start_time))
开发者ID:Dunes,项目名称:janitor,代码行数:25,代码来源:test_simulator.py

示例6: validMoves

	def validMoves(self, config):
		self.player_pieces_pos = config.getPlayerPositions(self.color)
		self.enemy_pieces_pos = config.getEnemyPositions(self.color)

		valid_moves = []
		x,y = self.pos
		# +2, +1 | +2, -1 | -2 + 1 | -2, -1 | +1,+2 | +1, -2| -1, +2| -1,-2
		incx = 1
		incy = 2
		
		for i in range(4):
			for j in range(2):
				if util.isNotOutofBounds(x+incx, y+incy):
					valid_moves.append((x+incx, y+incy))
				incx = -1 * incx
			incy = -1 * incy

			if i == 1: incx, incy = incy, incx

		# Check for collisions
		for (newx,newy) in valid_moves:
			action = Action(self, (newx,newy), config)
			if not action.isValid(): valid_moves.remove((newx,newy))

		return valid_moves
开发者ID:AhanM,项目名称:ChessAI,代码行数:25,代码来源:pieces.py

示例7: __init__

 def __init__(self, key, desc, rev_key):
     Action.__init__(self, (key, desc), self, TARGET_MSG_CLASS)
     self.key = key
     self.desc = desc
     self.rev_key = rev_key
     Direction.actions.add(self)
     Direction.ref_map[key] = self
开发者ID:ldevesine,项目名称:Lampost-Mud,代码行数:7,代码来源:movement.py

示例8: run_test

    def run_test(self):
        """"
        Use selenium to open the proper form and start entering the data.
        Note: This function is called by every child class.

        @TODO: improve exception handling for longitudinal projects
        """
        try:
            # self.goto_form()
            self.goto_form_longitudinal()

            stat = ActionStatistic(self.get_class_name())

            # for every field enter data as needed...
            for action_data in self.data:
                action = Action(self.driver, action_data)
                success = action.execute()
                stat.update(action, success)
                #time.sleep(0.5) # uncomment for debugging in the browser

            logger.warning(stat.to_string())
            self.save_form()

            # for every field check if the value was saved properly...
            if self.do_check:
                logger.info("""\n# Perform data integrity check for form: {}""".format(self.get_display_name()))
                for action_data in self.data:
                    action = Action(self.driver, action_data)
                    action.check_result()

        except UnexpectedAlertPresentException:
            alert = self.driver.switch_to_alert()
            alert.accept()
            logger.warning("skip UnexpectedAlertPresentException {} for {}".format(alert.text, type(self)))
开发者ID:indera,项目名称:redcap-tools,代码行数:34,代码来源:configurable_test_case.py

示例9: __init__

 def __init__(self, cb, logger):
     Action.__init__(self, cb, logger)
     self.stopped = False
     self.bolo = {}
     self.bolo_domains = set()
     self.bolo_searches = []
     self.bolo_lock = threading.Lock()
     threading.Thread.__init__(self)
开发者ID:carbonblack,项目名称:cb-infoblox-connector,代码行数:8,代码来源:api_kill_process.py

示例10: __init__

    def __init__(self,action_id,ports_id,mode=1):
        Action.__init__(self,action_id)
        
#         print "creo setteraction %s" % str(ports_id)
        self.inverted_ports = {}
        if type(ports_id) == dict :
            self.involved_ports_id = ports_id.keys()                
            self.inverted_ports = [ k for k,v in ports_id.items()  if v ]
        else:
            self.involved_ports_id = ports_id
        self.mode = mode
开发者ID:juanchitot,项目名称:domo,代码行数:11,代码来源:setter_action.py

示例11: _process

 def _process(self):
     self.msg = self._receive(True, 10)
     content = None
     if self.msg is not None:
         t.log.info("msg recived")
         content = self.msg.getContent()
         t.log.info(content)
         act = Action(content)
         res  = act.execute()
         reply = self.msg.createReply()
         d = {'action':'reply', 'data':res}
         reply.setContent(d)
         self.myAgent.send(reply)
开发者ID:zodman,项目名称:spade_project,代码行数:13,代码来源:agent_yucatan.py

示例12: main

def main():
    """! @brief Main of the software"""

    ## Qt Application
    app = QtGui.QApplication(sys.argv)
    app.setOrganizationName('Digiclever')
    app.setApplicationName('NFC Golf Ball Dispenser')
    ## Frame instance
    frame = Frame()
    frame.show()
	
    ## PiFaceControl instance
    piface = PiFaceControl()
    ## Action instance
    action = Action(piface)
    ## CardReader instance
    cardReader = CardReader(action)

    # connect signals to slots
    frame.b1.clicked.connect(cardReader.someBalls)
    frame.b2.clicked.connect(cardReader.manyBalls)
    frame.transaction.clicked.connect(lambda: action.getLastTransactions(cardReader.cardUid))
    frame.admin.clicked.connect(frame.toggleAdminView)
    frame.log.clicked.connect(lambda: frame.displayAdmin(frame.adminUsername.text(), frame.adminPassword.text()))
    frame.bRecharge.clicked.connect(lambda: cardReader.recharge(frame.moneyBox.value()))
    frame.bCreateAccount.clicked.connect(lambda: action.addUser(frame.username.text(), frame.name.text(), frame.surname.text()))
    frame.bAddDevice.clicked.connect(lambda: action.addDevice(frame.username2.text(), cardReader.cardUid, cardReader.ATR))

    action.status.connect(frame.displayStatus)
    action.transactionsLoaded.connect(frame.displayTransactions)

    frame.connect(frame.warningTimer, SIGNAL("timeout()"), cardReader.start)
    frame.connect(frame.releaseCardTimer, SIGNAL("timeout()"), cardReader.start)

    cardReader.connect(cardReader.timer, SIGNAL("timeout()"), cardReader.waitForCard)
    cardReader.updateWaiting.connect(frame.update)

    cardReader.cardDetected.connect(frame.displayCard)
    cardReader.warning.connect(frame.displayWarning)
    
    frame.activateButton.connect(piface.activateButtonListener)
    frame.deactivateButton.connect(piface.deactivateButtonListener)
    
    piface.b1.connect(cardReader.someBalls)
    piface.b2.connect(cardReader.manyBalls)
    piface.b3.connect(lambda: action.getLastTransactions(cardReader.cardUid))
    piface.b4.connect(frame.toggleAdminView)

    cardReader.start()
    sys.exit(app.exec_())
开发者ID:acknowledge,项目名称:NFCGolfBallDispenser-UI,代码行数:50,代码来源:main.py

示例13: test_pin_full_example

    def test_pin_full_example(self):
        p = Pin()

        action = Action()
        action.launch_code = 13
        action.title = 'Open in Watchapp'
        action.type = 'openWatchApp'

        self.assertDoesNotRaise(ValidationException, action.validate)

        p.add_action(action)

        reminder = Reminder()
        reminder.time = '2015-08-04T20:00:00+00:00Z'
        reminder.layout.backgroundColor = '#FFFFFF'
        reminder.layout.body = 'Drama about a police unit...'
        reminder.layout.foregroundColor = '#000000'
        reminder.layout.largeIcon = 'system://images/TV_SHOW'
        reminder.layout.smallIcon = 'system://images/TV_SHOW'
        reminder.layout.tinyIcon = 'system://images/TV_SHOW'
        reminder.layout.subtitle = 'New Tricks'
        reminder.layout.title = 'Last Man Standing'
        reminder.layout.type = 'genericReminder'

        self.assertDoesNotRaise(ValidationException, reminder.validate)

        p.add_reminder(reminder)

        p.layout.backgroundColor = '#FFFFFF'
        p.layout.foregroundColor = '#000000'
        p.layout.tinyIcon = 'system://images/TV_SHOW'
        p.layout.title = 'Last Man Standing'
        p.layout.subtitle = 'New Tricks'
        p.layout.type = 'genericPin'
        p.layout.shortTitle = 'Last Man Standing'
        p.layout.body = 'Drama about a police unit...'
        p.layout.add_section('Series', 'New Tricks')

        self.assertDoesNotRaise(ValidationException, p.layout.validate)

        p.duration = 60
        p.id = '101'
        p.time = '2015-08-04T20:00:00+00:00Z'

        self.assertDoesNotRaise(ValidationException, p.validate)

        p.time = ''

        self.assertRaises(ValidationException, p.validate)
开发者ID:hkpeprah,项目名称:television-2.0,代码行数:49,代码来源:tests.py

示例14: __init__

    def __init__(self, action_command, bodyfilter=None, auth_sender=None,
                 quoted_firstline_re=None, quoted_actiontoken_re=None):

        Action.__init__(self, action_command, bodyfilter)

        if quoted_firstline_re is None:
            quoted_firstline_re = self.DEFAULT_QUOTED_FIRSTLINE_RE

        if quoted_actiontoken_re is None:
            quoted_actiontoken_re = self.DEFAULT_QUOTED_ACTIONTOKEN_RE

        self.quoted_firstline_re = quoted_firstline_re
        self.quoted_actiontoken_re = quoted_actiontoken_re

        self.auth_sender = auth_sender
开发者ID:lirazsiri,项目名称:mailpipe,代码行数:15,代码来源:reply.py

示例15: play

    def play(self, trick: Trick, wish=None):
        combination_to_play = self.get_combination_to_play(trick, wish)

        if combination_to_play is not None:
            self.hand -= combination_to_play
            self.hand_size -= combination_to_play.size

            if Mahjong() in combination_to_play.cards:
                return Action.play(player=self, combination=combination_to_play, wish=self.wish)
            else:
                return Action.play(player=self, combination=combination_to_play)

        else:
            # Empty action means passing
            return Action.passes(player=self)
开发者ID:emmanuelameisen,项目名称:ticher,代码行数:15,代码来源:player.py


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