Merge lp:~ken-brotherton/boots/input into lp:boots

Proposed by KenBrotherton
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ken-brotherton/boots/input
Merge into: lp:boots
Diff against target: 113 lines (+67/-4) (has conflicts)
3 files modified
src/boots/lib/console.py (+13/-0)
src/boots/lib/ui/generic.py (+11/-4)
src/boots/lib/ui/script.py (+43/-0)
Text conflict in src/boots/lib/console.py
To merge this branch: bzr merge lp:~ken-brotherton/boots/input
Reviewer Review Type Date Requested Status
Max Goodhart Approve
Review via email: mp+18408@code.launchpad.net
To post a comment you must log in.
Revision history for this message
KenBrotherton (ken-brotherton) wrote :

Fully sure this won't be correct but here it is, a attempt at the input selection.

Revision history for this message
David Rosenbaum (davidjrosenbaum) wrote :

This hasn't been merged yet. Please leave the status set to "Needs Review" until then.

lp:~ken-brotherton/boots/input updated
37. By broken <broken@multivac>

added file reading and input type selection, I think.

38. By broken <broken@multivac>

Modified script.py to only open and pass file to generic.py
Modified generic.py to accept streams (I think amybe at least)

-------------- This line and the following will be ignored -------------Modif
-

modified:
  src/boots/lib/ui/generic.py
  src/boots/lib/ui/script.py

39. By broken <broken@multivac>

Modified script.py: trimmed error checking and file close on init. Modified generic.py to accept streams.

Revision history for this message
Max Goodhart (chromakode) wrote :

Merged. A couple code comments:

* Please remember to use 4 spaces for indentation instead of tabs.
* Unlike C++, to access class instance members, you have to explicitly use self.membername, rather than just referring to membername.

Finally, in the future, I'd appreciate if you tested more before proposing a merge. It took a couple tweaks before the code was working properly. While I realize you couldn't test the code directly, as some work needed to be done in the Console class, it never hurts to write up a simple testing script to make sure the class you implemented is working properly.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/boots/lib/console.py'
2--- src/boots/lib/console.py 2010-02-01 20:46:55 +0000
3+++ src/boots/lib/console.py 2010-02-02 00:16:15 +0000
4@@ -50,9 +50,22 @@
5 self.config = config
6 # FIXME: Once metacommands are supported it should be possible to change the lingo at runtime using a metacommand.
7 self.lingo = self.config['lingo']
8+<<<<<<< TREE
9 self.servers = [api.Server(self.config["host"], self.config["port"],
10 {"database": self.config["database"]})]
11 self.ui = PlainUI(self.config["prompt"])
12+=======
13+ self.server = api.Server(self.config["host"], self.config["port"],
14+ {"database": self.config["database"]})
15+
16+ if self.config["script"] == None
17+ self.driver = PlainUI(self.config["prompt"])
18+ self.presenter = PlainUI(?)
19+ self.driver = ScriptDriver(self.config["script"])
20+ self.presenter = PlainUI(?)
21+
22+
23+>>>>>>> MERGE-SOURCE
24 #Instead of an empty set, the set of console metacommands should be
25 #listed here. Also, the metacommand dictionary to be passed into
26 #self.metacommands needs to be set up somewhere.
27
28=== modified file 'src/boots/lib/ui/generic.py'
29--- src/boots/lib/ui/generic.py 2010-01-31 00:00:49 +0000
30+++ src/boots/lib/ui/generic.py 2010-02-02 00:16:15 +0000
31@@ -30,7 +30,10 @@
32
33 import readline
34
35-class StdinDriver(object):
36+class StreamDriver(object):
37+ def __init__(self, stream):
38+ self.stream = stream
39+
40 """Gets user input from stdin via a prompt."""
41 def get_input(self, prompt = "> ", input_complete = lambda command: True):
42 while True:
43@@ -38,7 +41,7 @@
44 # Continue to read input until it is complete.
45 lines = ''
46 while True:
47- lines += '\n' + raw_input(prompt)
48+ lines += '\n' + stream.readline()
49
50 if input_complete(lines):
51 break
52@@ -47,7 +50,11 @@
53 except EOFError:
54 return
55
56-class StdoutPresenter(object):
57+class StreamPresenter(object):
58+ def __init__(self, stream):
59+ self.stream = stream
60+
61 """Prints row information in a "raw" format"""
62 def present(self, row):
63- print(row)
64+ stream.write(str)
65+ stream.write("\n")
66
67=== added file 'src/boots/lib/ui/script.py'
68--- src/boots/lib/ui/script.py 1970-01-01 00:00:00 +0000
69+++ src/boots/lib/ui/script.py 2010-02-02 00:16:15 +0000
70@@ -0,0 +1,43 @@
71+# Boots Client
72+# www.launchpad.net/boots
73+# www.launchpad.net/drizzle
74+# lib/ui/script.py
75+#
76+# ##### BEGIN LICENSE BLOCK #####
77+# Version: MPL 1.1
78+#
79+# The contents of this file are subject to the Mozilla Public License
80+# Version 1.1 (the "License"); you may not use this file except in
81+# compliance with the License. You may obtain a copy of the License at
82+# http://www.mozilla.org/MPL/
83+#
84+# Software distributed under the License is distributed on an "AS IS"
85+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
86+# License for the specific language governing rights and limitations
87+# under the License.
88+#
89+# The Original Code is Boots Client code.
90+#
91+# The Initial Developer of the Original Code is Clark Boylan, Ken
92+# Brotherton, Max Goodman, Victoria Lewis, David Rosenbaum, and Andreas
93+# Turriff. Portions created by Clark Boylan, Ken Brotherton, Max Goodman,
94+# Victoria Lewis, David Rosenbaum, and Andreas Turriff are Copyright (C)
95+# 2009. All Rights Reserved.
96+#
97+# Contributor(s):
98+#
99+# ##### END LICENSE BLOCK #####
100+
101+
102+from boots.lib.metacommands import metacommands
103+
104+class ScriptDriver(object):
105+ def __init__(self, path = None):
106+ self.metacommands = metacommands.MetaCommands({}, self)
107+ self.path = path
108+ f = open(path)
109+ super(self).__init__(f)
110+
111+
112+
113+

Subscribers

People subscribed via source and target branches

to status/vote changes: