Boots: A Modular Drizzle CLI Client and More

Merge lp:~cboylan/boots/boots_source into lp:boots

Proposed by Clark Boylan on 2010-03-03
Status: Merged
Merged at revision: not available
Proposed branch: lp:~cboylan/boots/boots_source
Merge into: lp:boots
Diff against target: 74 lines (+23/-10) 1 file modified
To merge this branch: bzr merge lp:~cboylan/boots/boots_source
Reviewer Review Type Date Requested Status
Boots Developers 2010-03-03 Pending
Review via email: mp+20507@code.launchpad.net
To post a comment you must log in.
Clark Boylan (cboylan) wrote :

Implemented the source metacommand. Tested with the employees DB. Tested sourcing a single file and a list of files.

Preview Diff

1=== modified file 'boots/lib/console.py'
2--- boots/lib/console.py 2010-02-28 22:37:03 +0000
3+++ boots/lib/console.py 2010-03-03 00:54:14 +0000
4@@ -65,7 +65,9 @@
5 '\quit': self.quit,
6 '\help': self.show_help,
7 '\h': self.show_help,
8- 'help': self.show_help})
9+ 'help': self.show_help,
10+ 'source': self.meta_source,
11+ '\.': self.meta_source,})
12 self.metacommandmanager.add(self.metacommands)
13
14 self.servers = []
15@@ -76,12 +78,13 @@
16
17 self.ui = PlainUI(self)
18 self.presenter = self.ui
19+ self.driver_stack = []
20 if self.config["script"]:
21- self.driver = ScriptDriver(self, self.config["script"], self.config["lingo"])
22+ self.driver_stack.insert(0, ScriptDriver(self, self.config["script"], self.config["lingo"]))
23 elif self.config["command"]:
24- self.driver = StringDriver(self, self.config["command"], self.config["lingo"])
25+ self.driver_stack.insert(0, StringDriver(self, self.config["command"], self.config["lingo"]))
26 else:
27- self.driver = self.ui
28+ self.driver_stack.insert(0, self.ui)
29
30 if hasattr(self.ui, "metacommands"):
31 self.metacommandmanager.add(self.ui.metacommands)
32@@ -159,7 +162,7 @@
33 self.connect(self.config["host"], self.config["port"], self.config["database"])
34
35 def _welcome_message(self):
36- if self.welcome_msg and self.driver.is_interactive:
37+ if self.welcome_msg and self.driver_stack[0].is_interactive:
38 server_lines = []
39 for server in self.servers:
40 line_format = "{0.hostname}:{0.port} (server v{0.server_version})"
41@@ -174,14 +177,20 @@
42 self._load_servers()
43 self._welcome_message()
44
45- for command, lingo in self.driver.get_input():
46- if not self.metacommands.execute(command):
47- result = self.run(command, lingo)
48-
49+ while self.driver_stack:
50+ driver = self.driver_stack[0]
51+ try:
52+ command, lingo = driver.get_input().next()
53+ if not self.metacommands.execute(command):
54+ result = self.run(command, lingo)
55+ except StopIteration:
56+ last_driver = self.driver_stack.pop(0)
57+
58+ self.driver_stack.insert(0, last_driver)
59 self.quit()
60
61 def quit(self, exitcode = 0):
62- if self.driver.is_interactive:
63+ if self.driver_stack[0].is_interactive:
64 self.presenter.presenter_graph.put("Boots quit.")
65
66 self.hooks["unload"].call()
67@@ -225,3 +234,7 @@
68 port = int(port)
69
70 self.disconnect(host, port)
71+
72+ def meta_source(self, *file_list):
73+ for x in range(0, len(file_list)):
74+ self.driver_stack.insert(x, ScriptDriver(self, file_list[x], self.config["lingo"]))

Subscribers

People subscribed via source and target branches

to status/vote changes: