Skip to content

Commit 1d031bf

Browse files
authored
Pipes output (#10)
* Embedded pipe command returns output as byte string rather than utf-8 * Bug fixes.
1 parent ea4f49a commit 1d031bf

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ that do not require a ctrl-c to terminate.
2525
## Documentation
2626

2727
### Setup
28-
TCLI requires some setup bit can be run straight out of the box using some
28+
TCLI requires some setup but can be run straight out of the box using some
2929
fictictous devices and a limited set of commands that produce canned output:
3030

3131
Devices

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from os import path
2222
from setuptools import setup
2323

24-
__version__ = '0.1.6'
24+
__version__ = '0.1.7'
2525
here = path.abspath(path.dirname(__file__))
2626

2727
# Get the long description from the README file

tcli/tcli_lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ def _Pipe(self, output, pipe=''):
11881188
result, _ = p.communicate(bytes(output, 'utf-8'))
11891189
logging.debug('Output written to pipe:\n%s', output)
11901190
logging.debug('Output read from pipe:\n%s', result)
1191-
return result
1191+
return result.decode('utf-8')
11921192

11931193
except IOError:
11941194
logging.error('IOerror writing/reading from pipe.')

tcli/tcli_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,15 +1293,15 @@ def testPipe(self):
12931293

12941294
# Piped function greps for 'boo' in supplied argument.
12951295
self.tcli_obj.pipe = '/bin/grep boo'
1296-
self.assertEqual(b'boo\nboo\n', self.tcli_obj._Pipe('boo\nboo'))
1296+
self.assertEqual('boo\nboo\n', self.tcli_obj._Pipe('boo\nboo'))
12971297
self.tcli_obj.pipe = '/bin/grep boo'
1298-
self.assertEqual(b'boo\n', self.tcli_obj._Pipe('boo\nhoo'))
1298+
self.assertEqual('boo\n', self.tcli_obj._Pipe('boo\nhoo'))
12991299

13001300
# Tests that pipes are supported within the piping function.
13011301
self.tcli_obj.pipe = '/bin/grep boo | /bin/grep -v hoo'
1302-
self.assertEqual(b'boo\n', self.tcli_obj._Pipe('boo\nhoo'))
1302+
self.assertEqual('boo\n', self.tcli_obj._Pipe('boo\nhoo'))
13031303
self.tcli_obj.pipe = '/bin/grep boo | /bin/grep -v boo'
1304-
self.assertEqual(b'', self.tcli_obj._Pipe('boo\nhoo'))
1304+
self.assertEqual('', self.tcli_obj._Pipe('boo\nhoo'))
13051305

13061306
def testTildeExpandTargets(self):
13071307
"""Tests target expansion."""

0 commit comments

Comments
 (0)