@@ -706,7 +706,7 @@ def __init__(self, user=None, host=None, port=22, password=None, key=None,
706
706
707
707
if self .sftp :
708
708
with context .quiet :
709
- self .cwd = packing ._decode (self .pwd ())
709
+ self .cwd = packing ._decode (self .pwd (tty = False ))
710
710
else :
711
711
self .cwd = '.'
712
712
@@ -1140,7 +1140,7 @@ def run_to_end(self, process, tty = False, cwd = None, env = None, wd = None):
1140
1140
cwd = wd
1141
1141
1142
1142
with context .local (log_level = 'ERROR' ):
1143
- c = self .run (process , tty , cwd = cwd , env = env , timeout = Timeout .default )
1143
+ c = self .system (process , tty , cwd = cwd , env = env , timeout = Timeout .default )
1144
1144
data = c .recvall ()
1145
1145
retcode = c .wait ()
1146
1146
c .close ()
@@ -1203,7 +1203,7 @@ def __getitem__(self, attr):
1203
1203
>>> print(repr(s['echo hello']))
1204
1204
b'hello'
1205
1205
"""
1206
- return self .run (attr ).recvall ().strip ()
1206
+ return self .system (attr ).recvall ().strip ()
1207
1207
1208
1208
def __call__ (self , attr ):
1209
1209
"""Permits function-style access to run commands over SSH
@@ -1214,10 +1214,12 @@ def __call__(self, attr):
1214
1214
>>> print(repr(s('echo hello')))
1215
1215
b'hello'
1216
1216
"""
1217
- return self .run (attr ).recvall ().strip ()
1217
+ return self .system (attr ).recvall ().strip ()
1218
1218
1219
1219
def __getattr__ (self , attr ):
1220
- """Permits member access to run commands over SSH
1220
+ """Permits member access to run commands over SSH.
1221
+
1222
+ Supports other keyword arguments which are passed to :meth:`.system`.
1221
1223
1222
1224
Examples:
1223
1225
@@ -1228,6 +1230,8 @@ def __getattr__(self, attr):
1228
1230
b'travis'
1229
1231
>>> s.echo(['huh','yay','args'])
1230
1232
b'huh yay args'
1233
+ >>> s.echo('value: $MYENV', env={'MYENV':'the env'})
1234
+ b'value: the env'
1231
1235
"""
1232
1236
bad_attrs = [
1233
1237
'trait_names' , # ipython tab-complete
@@ -1239,7 +1243,7 @@ def __getattr__(self, attr):
1239
1243
raise AttributeError
1240
1244
1241
1245
@LocalContext
1242
- def runner (* args ):
1246
+ def runner (* args , ** kwargs ):
1243
1247
if len (args ) == 1 and isinstance (args [0 ], (list , tuple )):
1244
1248
command = [attr ]
1245
1249
command .extend (args [0 ])
@@ -1248,7 +1252,7 @@ def runner(*args):
1248
1252
command .extend (args )
1249
1253
command = b' ' .join (packing ._need_bytes (arg , min_wrong = 0x80 ) for arg in command )
1250
1254
1251
- return self .run (command ).recvall ().strip ()
1255
+ return self .system (command , ** kwargs ).recvall ().strip ()
1252
1256
return runner
1253
1257
1254
1258
def connected (self ):
@@ -1348,7 +1352,7 @@ def update(has, total):
1348
1352
1349
1353
with context .local (log_level = 'ERROR' ):
1350
1354
cmd = 'cat < ' + sh_string (remote )
1351
- c = self .run (cmd )
1355
+ c = self .system (cmd )
1352
1356
data = b''
1353
1357
1354
1358
while True :
@@ -1369,7 +1373,7 @@ def update(has, total):
1369
1373
def _download_to_cache (self , remote , p , fingerprint = True ):
1370
1374
1371
1375
with context .local (log_level = 'error' ):
1372
- remote = self .readlink ('-f' ,remote )
1376
+ remote = self .readlink ('-f' , remote , tty = False )
1373
1377
if not hasattr (remote , 'encode' ):
1374
1378
remote = remote .decode ('utf-8' )
1375
1379
@@ -1534,7 +1538,7 @@ def upload_data(self, data, remote):
1534
1538
1535
1539
with context .local (log_level = 'ERROR' ):
1536
1540
cmd = 'cat > ' + sh_string (remote )
1537
- s = self .run (cmd , tty = False )
1541
+ s = self .system (cmd , tty = False )
1538
1542
s .send (data )
1539
1543
s .shutdown ('send' )
1540
1544
data = s .recvall ()
@@ -1592,7 +1596,7 @@ def upload_dir(self, local, remote=None):
1592
1596
remote_tar = self .mktemp ('--suffix=.tar.gz' )
1593
1597
self .upload_file (local_tar , remote_tar )
1594
1598
1595
- untar = self .run (b'cd %s && tar -xzf %s' % (sh_string (remote ), sh_string (remote_tar )))
1599
+ untar = self .system (b'cd %s && tar -xzf %s' % (sh_string (remote ), sh_string (remote_tar )))
1596
1600
message = untar .recvrepeat (2 )
1597
1601
1598
1602
if untar .wait () != 0 :
0 commit comments