Revision c49188b7
b/kamaki/cli/commands/history.py | ||
---|---|---|
168 | 168 |
def _run_from_line(self, line): |
169 | 169 |
terms = split_input(line) |
170 | 170 |
cmd, args = self._cmd_tree.find_best_match(terms) |
171 |
if not cmd.is_command: |
|
172 |
return |
|
173 |
try: |
|
174 |
instance = cmd.cmd_class( |
|
175 |
self.arguments, |
|
176 |
auth_base=getattr(self, 'auth_base', None)) |
|
177 |
instance.config = self.config |
|
178 |
prs = ArgumentParseManager( |
|
179 |
cmd.path.split(), |
|
180 |
dict(instance.arguments)) |
|
181 |
prs.syntax = '%s %s' % ( |
|
182 |
cmd.path.replace('_', ' '), |
|
183 |
cmd.cmd_class.syntax) |
|
184 |
prs.parse(args) |
|
185 |
exec_cmd(instance, prs.unparsed, prs.parser.print_help) |
|
186 |
except (CLIError, ClientError) as err: |
|
187 |
print_error_message(err, self._err) |
|
188 |
except Exception as e: |
|
189 |
self.error('Execution of [ %s ] failed\n\t%s' % (line, e)) |
|
171 |
if cmd.is_command: |
|
172 |
try: |
|
173 |
instance = cmd.cmd_class( |
|
174 |
self.arguments, auth_base=getattr(self, 'auth_base', None)) |
|
175 |
instance.config = self.config |
|
176 |
prs = ArgumentParseManager( |
|
177 |
cmd.path.split(), dict(instance.arguments)) |
|
178 |
prs.syntax = '%s %s' % ( |
|
179 |
cmd.path.replace('_', ' '), cmd.cmd_class.syntax) |
|
180 |
prs.parse(args) |
|
181 |
exec_cmd(instance, prs.unparsed, prs.parser.print_help) |
|
182 |
except (CLIError, ClientError) as err: |
|
183 |
print_error_message(err, self._err) |
|
184 |
except Exception as e: |
|
185 |
self.error('Execution of [ %s ] failed\n\t%s' % (line, e)) |
|
190 | 186 |
|
191 | 187 |
@errors.generic.all |
192 | 188 |
@errors.history._get_cmd_ids |
b/kamaki/cli/history.py | ||
---|---|---|
33 | 33 |
# interpreted as representing official policies, either expressed |
34 | 34 |
# or implied, of GRNET S.A. |
35 | 35 |
|
36 |
import codecs |
|
37 |
|
|
36 | 38 |
|
37 | 39 |
class History(object): |
38 | 40 |
def __init__(self, filepath): |
... | ... | |
49 | 51 |
|
50 | 52 |
def get(self, match_terms=None, limit=0): |
51 | 53 |
limit = int(limit) or 0 |
52 |
with open(self.filepath, 'r') as f:
|
|
53 |
result = ['%s. \t%s' % ( |
|
54 |
with codecs.open(self.filepath, mode='r', encoding='utf-8') as f:
|
|
55 |
result = [u'%s. \t%s' % (
|
|
54 | 56 |
i + 1, line) for i, line in enumerate(f.readlines()) |
55 | 57 |
if self._match(line, match_terms)] |
56 | 58 |
return result[- limit:] |
b/kamaki/cli/utils/__init__.py | ||
---|---|---|
221 | 221 |
item = ('%s' % item).strip() |
222 | 222 |
if item in exclude: |
223 | 223 |
continue |
224 |
out.writelines(u'%s%s\n' % (print_str, item)) |
|
224 |
out.write(u'%s%s\n' % (print_str, item)) |
|
225 |
out.flush() |
|
225 | 226 |
|
226 | 227 |
|
227 | 228 |
def print_items( |
Also available in: Unified diff