Skip to content

Commit 2b584a1

Browse files
committed
Merge pull request kivy#82 from kived/prompt-fix
fix console prompt, fixes kivy#24
2 parents 6c4235c + e26ed8c commit 2b584a1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

designer/uix/kivy_console.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,17 @@ def __init__(self, **kwargs):
251251
self_change_txtcache = self._change_txtcache
252252
_trig = Clock.create_trigger(self_change_txtcache)
253253
self.bind(textcache=_trig)
254+
self._hostname = 'unknown'
255+
try:
256+
if hasattr(os, 'uname'):
257+
self._hostname = os.uname()[1]
258+
else:
259+
self._hostname = os.environ.get('COMPUTERNAME', 'unknown')
260+
except Exception:
261+
pass
262+
self._username = os.environ.get('USER', '')
263+
if not self._username:
264+
self._username = os.environ.get('USERNAME', 'unknown')
254265

255266
def clear(self, *args):
256267
self.txtinput_history_box.text = ''
@@ -281,13 +292,8 @@ def _deffered_focus(self, widg, t_f, dt):
281292
widg.focus = t_f
282293

283294
def prompt(self, *args):
284-
_platform = ''
285-
if hasattr(os, 'uname'):
286-
_platform = os.uname()
287-
else:
288-
_platform = os.environ.get('COMPUTERNAME')
289295
return "[%s@%s %s]>> " % (
290-
os.environ.get('USERNAME', 'UNKNOWN'), _platform[1],
296+
self._username, self._hostname,
291297
os.path.basename(str(self.cur_dir)))
292298

293299
def _change_txtcache(self, *args):

0 commit comments

Comments
 (0)