Skip to content

Commit

Permalink
Fixing bug with wrapping text onto same line.
Browse files Browse the repository at this point in the history
  • Loading branch information
fwkz committed Apr 28, 2016
1 parent bf22987 commit 37840f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions routersploit/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ def load_modules(self):
self.modules.append(module_path.split('.', 2).pop())

def __parse_prompt(self):
raw_prompt_default_template = "\033[4m{host}\033[0m > "
raw_prompt_default_template = "\001\033[4m\002{host}\001\033[0m\002 > "
raw_prompt_template = os.getenv("RSF_RAW_PROMPT", raw_prompt_default_template).replace('\\033', '\033')
self.raw_prompt_template = raw_prompt_template if '{host}' in raw_prompt_template else raw_prompt_default_template

module_prompt_default_template = "\033[4m{host}\033[0m (\033[91m{module}\033[0m) > "
module_prompt_default_template = "\001\033[4m\002{host}\001\033[0m\002 (\001\033[91m\002{module}\001\033[0m\002) > "
module_prompt_template = os.getenv("RSF_MODULE_PROMPT", module_prompt_default_template).replace('\\033', '\033')
self.module_prompt_template = module_prompt_template if all(map(lambda x: x in module_prompt_template, ['{host}', "{module}"])) else module_prompt_default_template

Expand Down
4 changes: 2 additions & 2 deletions routersploit/test/test_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def setUp(self):
RoutersploitInterpreter.setup = mock.Mock()
self.interpreter = RoutersploitInterpreter()
self.interpreter.current_module = mock.MagicMock()
self.raw_prompt_default = "\033[4mrsf\033[0m > "
self.module_prompt_default = lambda x: "\033[4mrsf\033[0m (\033[91m{}\033[0m) > ".format(x)
self.raw_prompt_default = "\001\033[4m\002rsf\001\033[0m\002 > "
self.module_prompt_default = lambda x: "\001\033[4m\002rsf\001\033[0m\002 (\001\033[91m\002{}\001\033[0m\002) > ".format(x)

def prepare_prompt_env_variables(self, raw_prompt=None, module_prompt=None):
if raw_prompt:
Expand Down
10 changes: 5 additions & 5 deletions routersploit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,23 +166,23 @@ def __cprint(*args, **kwargs):
file_ = kwargs.get('file', sys.stdout)
sep = kwargs.get('sep', ' ')
end = kwargs.get('end', '\n')
print('\033[{}m'.format(colors[color]), end='', file=file_, sep=sep)
print('\001\033[{}m\002'.format(colors[color]), end='', file=file_, sep=sep)
print(*args, end='', file=file_, sep=sep) # TODO printing text that starts from newline
print('\033[0m', sep=sep, end=end, file=file_)
print('\001\033[0m\002', sep=sep, end=end, file=file_)
else:
print(*args, **kwargs)


def print_error(*args, **kwargs):
__cprint('\033[91m[-]\033[0m', *args, **kwargs)
__cprint('\001\033[91m\002[-]\001\033[0m\002', *args, **kwargs)


def print_status(*args, **kwargs):
__cprint('\033[94m[*]\033[0m', *args, **kwargs)
__cprint('\001\033[94m\002[*]\001\033[0m\002', *args, **kwargs)


def print_success(*args, **kwargs):
__cprint('\033[92m[+]\033[0m', *args, **kwargs)
__cprint('\001\033[92m\002[+]\001\033[0m\002', *args, **kwargs)


def print_info(*args, **kwargs):
Expand Down

0 comments on commit 37840f3

Please sign in to comment.