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


Python Engine.execute方法代码示例

本文整理汇总了Python中engine.Engine.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.execute方法的具体用法?Python Engine.execute怎么用?Python Engine.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在engine.Engine的用法示例。


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

示例1: TestEngine

# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import execute [as 别名]
class TestEngine(unittest.TestCase):
	def setUp(self):
		accounts = list()

		today = datetime.date(2014, 3, 1)

		allowanceStartDate = datetime.date(2014, 3, 1)

		everyOtherDayRecurrence = DailyRecurrence(allowanceStartDate, 2, 5)

		balanceModifiers = [BalanceModifier("100 Dollar Allowance", 100.0, everyOtherDayRecurrence)]

		self.engine = Engine(accounts, balanceModifiers, today)

	def test_engine(self):
		startDate = datetime.date(2014, 3, 3)
		endDate = datetime.date(2014, 3, 13)

		data = self.engine.execute(startDate, endDate)

		self.assertEqual(data.startDate, startDate)
		self.assertEqual(data.endDate, endDate)

		self.assertEqual(data.balances[datetime.date(2014, 3, 3)], 200.0)
		self.assertEqual(data.balances[datetime.date(2014, 3, 4)], 200.0)
		self.assertEqual(data.balances[datetime.date(2014, 3, 5)], 300.0)
		self.assertEqual(data.balances[datetime.date(2014, 3, 6)], 300.0)
		self.assertEqual(data.balances[datetime.date(2014, 3, 7)], 400.0)
		self.assertEqual(data.balances[datetime.date(2014, 3, 8)], 400.0)
		self.assertEqual(data.balances[datetime.date(2014, 3, 9)], 500.0)
		self.assertEqual(data.balances[datetime.date(2014, 3, 10)], 500.0)
		self.assertEqual(data.balances[datetime.date(2014, 3, 11)], 500.0)
		self.assertEqual(data.balances[datetime.date(2014, 3, 12)], 500.0)
		self.assertEqual(data.balances[datetime.date(2014, 3, 13)], 500.0)
开发者ID:uberska,项目名称:dough,代码行数:36,代码来源:test_engine.py

示例2: Client

# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import execute [as 别名]
class Client(object):
    def __init__(self, host="localhost", port=6379, verbose=False):
        self.engine = Engine(host=host, port=port, verbose=verbose)
        self.lexer = SqlLexer().build()
        self.parser = SqlParser().build()

    def query(self, sql):
        ast = self.parser.parse(sql, lexer=self.lexer)
        if ast:
            result = self.engine.execute(ast)
            return result
开发者ID:xudshen,项目名称:redisql,代码行数:13,代码来源:client.py

示例3: main

# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import execute [as 别名]
def main(args):
    parser = OptionParser(conflict_handler="resolve")
    parser.add_option("-h", "--host", action="store",
                      type="string", dest="host", default="localhost")
    parser.add_option("-p", "--port", action="store",
                      type="int", dest="port", default=9876)
    parser.add_option("-c", "--config", action="store",
                      type="string", dest="config")
    parser.add_option("-q", "--query", action="store",
                      type="string", dest="query")
    parser.add_option("-s", "--server", action="store_true",
                      dest="server", default=False)
    parser.add_option("-u", "--mydigurl", action="store",
                      type="string", dest="mydigurl")
    parser.add_option("-j", "--project", action="store",
                      type="string", dest="project")
    parser.add_option("-e", "--endpoint", action="store",
                      type="string", dest="endpoint")
    parser.add_option("-i", "--index", action="store",
                      type="string", dest="index")
    parser.add_option("-m", "--sample", action="store_true",
                      dest="sample", default=False)
    (c_options, args) = parser.parse_args()

    query_file = c_options.query
    config_file = c_options.config
    server = c_options.server
    host = c_options.host
    port = c_options.port
    mydigurl = c_options.mydigurl
    project = c_options.project
    endpoint = c_options.endpoint
    index = c_options.index
    sample = c_options.sample

    if not config_file:
        parser.error('Config file not specified.  Use -c or --config')

    config = load_json_file(config_file)
    engine = Engine(config)
    if server:
        search_server.set_engine(engine)
        if mydigurl and project:
            search_server.apply_config_from_project(mydigurl, project,
                                                    endpoint, index,
                                                    sample=sample)
        if not host and not port:
            search_server.app.run()
        else:
            search_server.app.run(host, port, threaded=True)
    else:
        query = load_json_file(query_file)
        result = engine.execute(query)
        print result
开发者ID:zigchg,项目名称:dig-sandpaper,代码行数:56,代码来源:main.py

示例4: main

# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import execute [as 别名]
def main():
	parser = argparse.ArgumentParser(description='Get a handle on your personal finances.')

	parser.add_argument(
		'config',
		nargs=1,
		help='A config file specifying your finances.')

	parser.add_argument(
		'-o',
		'--output',
		nargs=1,
		default=["finances.csv"],
		help='Output file to write to.')

	parser.add_argument(
		'-d',
		'--days',
		nargs=1,
		type=int,
		default=[365],
		help='Number of days to calculate ahead of today.')

	args = parser.parse_args()

	configJson = loadConfigJson(args.config[0])

	accounts = loadAccounts(configJson)

	balanceModifiers = loadBalanceModifiers(configJson)

	engine = Engine(accounts, balanceModifiers)

	startDate = datetime.date.today()
	endDate = startDate + datetime.timedelta(days=args.days[0])

	data = engine.execute(startDate, endDate)

	outputData(data, args.output[0])
开发者ID:uberska,项目名称:dough,代码行数:41,代码来源:dough.py

示例5: __init__

# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import execute [as 别名]
class Handler:

	def __init__(self, builder):
		self.queue = Queue.Queue()
		self.debugger = Engine(self.queue)
		self.debugger.start()
		self.builder = builder
		self.codeview = self.setup_codeview()
		self.watchesview = self.setup_watchesview()
		self.open_file = None
		glib.timeout_add(200, self.handle_queue)

	def delete_window(self, *args):
		print "Waiting for socket to close..."
		self.debugger.signal = 'kill'
		Gtk.main_quit(*args)

	def handle_queue(self):
		time.sleep(0.1) #doesn't work without it
		try:
			msg = self.queue.get_nowait()
		except Queue.Empty:
			msg = ''
		if (msg):
			if 'console' in msg:
				self.update_console(msg['console'])
			if 'stack' in msg:
				self.update_stack(msg['stack'])
			if 'code' in msg:
				self.update_codeview(msg['code'])
			if 'watchview' in msg:
				self.update_watchesview(msg['watchview'])

		self.update_buttons()
		self.set_status('Status: ' + str(self.debugger.status))
		return True

	def update_buttons(self):
		listen_button = self.builder.get_object("button_listen")
		status = self.debugger.status
		if (status == 'idle'):
			listen_button.set_sensitive(True)
			listen_button.set_label('Listen')
		elif (status == 'listening'):
			listen_button.set_sensitive(False)
			listen_button.set_label('Listening...')
		elif (status == 'running'):
			listen_button.set_sensitive(True)
			listen_button.set_label('Stop')



# BUTTONS ACTIONS

	def run(self, button):
		self.debugger.xrun()

	def step_over(self, button):
		self.debugger.step_over()

	def step_into(self, button):
		self.debugger.step_into()

	def listen(self, button):
		status = self.debugger.status
		if (status == 'idle'):
			self.debugger.signal = "listen"
		elif (status == 'listening'):
			self.debugger.signal = "stop=listening"
		elif (status == 'running'):
			self.debugger.signal = "stop"



# CONSOLE & STATUS

	def update_console(self, text):
		self.builder.get_object("console").get_buffer().set_text(text)

	def update_stack(self, text):
		s = text.replace('\x00', '')
		stack_iter = list(ElementTree.XML(s).iter())
		stack_str = ''
		for e in stack_iter:
			temp = e.get('filename')
			if temp:
				stack_str += temp + '\n'
		self.builder.get_object("stack").get_buffer().set_text(stack_str)

	def set_status(self, text):
		context_id = Gtk.Statusbar().get_context_id("Connection");
		self.builder.get_object("statusbar_main").push(context_id, text)

	def execute_command(self, widget, event):
		if (event.keyval ==	65293):
			r = self.debugger.execute(widget.get_text())
			self.update_console(r)



#.........这里部分代码省略.........
开发者ID:artbek,项目名称:PyXdebugClient,代码行数:103,代码来源:gui_handler.py


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