i have django server, , have upload data through scp. have view:
pathfile = '/home/user1/foo.json' user = 'user1scp' server = 'someserver.com' pathserver = '/var/www/foo.json' os.system("scp %s %s@%s:%s" % (pathfile, user, server, pathserver))
on console window page running (i.e. called command 'runserver') have output shown:
[21/jul/2016 18:55:12] "get /someurl/upload http/1.1" 301 0 foo.json 100% 609 0.6kb/s 00:00
i want able manipulate output, can notify user files (there multiple files upload) upload correctly, or not.
i tried solution in answer how capture stdout output python function call? didn't work. tried popen , subprocess , had no results well. maybe i'm doing wrong?
this doesn't directly answer question, won't raw scp
command in python because output hard parse if have it. should consider using tools fabric
handle this. it's pythonic , have full control on input/output. operation same scp
put
. example check so answer.
almost command line operations can done using fabric
, won't regret learning it.
Comments
Post a Comment