怎么在python中调用npm?
迷茫
迷茫 2017-04-18 10:20:26
0
2
624

想写一个部署的脚本,
顺序是npm run build > mv something > ssh login && upload
因为需要登录远程主机,需要一些交互,发现python的pexpect挺不错的,可是问题是。
怎么完成第一步的在python中调用npm run build

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
Ty80

Use the paramiko module

        import paramiko
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect(ip,22,username,passwd,timeout=5)
        stdin, stdout, stderr = ssh.exec_command("npm run build")
        out = stdout.readlines()
        stdin, stdout, stderr = ssh.exec_command("mv something")
        out = stdout.readlines()
        ...............
        ssh.close()

Assume npm has been added to the path environment variable

洪涛

os.system + fabric or directly fabric

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template