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

Proposed by Clark Boylan
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
boots/lib/console.py (+23/-10)
To merge this branch: bzr merge lp:~cboylan/boots/boots_source
Reviewer Review Type Date Requested Status
Boots Developers Pending
Review via email: mp+20507@code.launchpad.net
To post a comment you must log in.
Revision history for this message
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'boots/lib/console.py'
--- boots/lib/console.py 2010-02-28 22:37:03 +0000
+++ boots/lib/console.py 2010-03-03 00:54:14 +0000
@@ -65,7 +65,9 @@
65 '\quit': self.quit,65 '\quit': self.quit,
66 '\help': self.show_help,66 '\help': self.show_help,
67 '\h': self.show_help,67 '\h': self.show_help,
68 'help': self.show_help})68 'help': self.show_help,
69 'source': self.meta_source,
70 '\.': self.meta_source,})
69 self.metacommandmanager.add(self.metacommands)71 self.metacommandmanager.add(self.metacommands)
70 72
71 self.servers = []73 self.servers = []
@@ -76,12 +78,13 @@
7678
77 self.ui = PlainUI(self)79 self.ui = PlainUI(self)
78 self.presenter = self.ui80 self.presenter = self.ui
81 self.driver_stack = []
79 if self.config["script"]:82 if self.config["script"]:
80 self.driver = ScriptDriver(self, self.config["script"], self.config["lingo"])83 self.driver_stack.insert(0, ScriptDriver(self, self.config["script"], self.config["lingo"]))
81 elif self.config["command"]:84 elif self.config["command"]:
82 self.driver = StringDriver(self, self.config["command"], self.config["lingo"])85 self.driver_stack.insert(0, StringDriver(self, self.config["command"], self.config["lingo"]))
83 else:86 else:
84 self.driver = self.ui87 self.driver_stack.insert(0, self.ui)
85 88
86 if hasattr(self.ui, "metacommands"):89 if hasattr(self.ui, "metacommands"):
87 self.metacommandmanager.add(self.ui.metacommands)90 self.metacommandmanager.add(self.ui.metacommands)
@@ -159,7 +162,7 @@
159 self.connect(self.config["host"], self.config["port"], self.config["database"])162 self.connect(self.config["host"], self.config["port"], self.config["database"])
160 163
161 def _welcome_message(self):164 def _welcome_message(self):
162 if self.welcome_msg and self.driver.is_interactive:165 if self.welcome_msg and self.driver_stack[0].is_interactive:
163 server_lines = []166 server_lines = []
164 for server in self.servers:167 for server in self.servers:
165 line_format = "{0.hostname}:{0.port} (server v{0.server_version})"168 line_format = "{0.hostname}:{0.port} (server v{0.server_version})"
@@ -174,14 +177,20 @@
174 self._load_servers()177 self._load_servers()
175 self._welcome_message()178 self._welcome_message()
176 179
177 for command, lingo in self.driver.get_input():180 while self.driver_stack:
178 if not self.metacommands.execute(command):181 driver = self.driver_stack[0]
179 result = self.run(command, lingo)182 try:
180 183 command, lingo = driver.get_input().next()
184 if not self.metacommands.execute(command):
185 result = self.run(command, lingo)
186 except StopIteration:
187 last_driver = self.driver_stack.pop(0)
188
189 self.driver_stack.insert(0, last_driver)
181 self.quit()190 self.quit()
182 191
183 def quit(self, exitcode = 0):192 def quit(self, exitcode = 0):
184 if self.driver.is_interactive:193 if self.driver_stack[0].is_interactive:
185 self.presenter.presenter_graph.put("Boots quit.")194 self.presenter.presenter_graph.put("Boots quit.")
186 195
187 self.hooks["unload"].call()196 self.hooks["unload"].call()
@@ -225,3 +234,7 @@
225 port = int(port)234 port = int(port)
226235
227 self.disconnect(host, port)236 self.disconnect(host, port)
237
238 def meta_source(self, *file_list):
239 for x in range(0, len(file_list)):
240 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: