运行面料文件重命名为比fabfile.py和密码ssh等命名为、面料、密码、文件

2023-09-11 11:48:39 作者:Le rêve merveilleux 无法逃离

我有一个工作code,现在我无法运行,由于一些问题。

I had a working code, which now I am unable to run due to some issues.

我现在面临以下几个问题:

I am facing the following issues:

提示我输入密码,我使用python运行该文件/path/to/file.py

I am prompted for password, as I run the file using python /path/to/file.py

即使我用晶圆厂-l,这个文件被调用,我再次提示密码。

Even if I use fab -l, this file is invoked and I am again prompted for password.

只是为了让你知道,我有很多的.py(包括fabfile.py),它使用的面料和其他图书馆目录中的文件。

Just to let you know, I have a lot of .py (including fabfile.py) files in the directory which are using fabric and other libraries.

下面是我的code的一个片段:

Here is a snippet of my code:

from fabric.api import *

env.key_filename = /path/to/my/pem/file

def mem_usage():
   '''Check free mem'''
   run('free -m')

execute(mem_usage, host="user@IP_or_hostname")

请帮助我的理解:

我如何使用SSH PEM文件没有通过的路径通过命令行参数

How can I ssh using pem file without passing the path through command-line arguments

我如何可以运行code(文件名为foo.py)

How can I run the code (file named foo.py)

任何指针将是非常美联社preciated。

Any pointers would be highly appreciated.

推荐答案

于是,我找到了解决我的问题。

So, I found the solution to my question.

这只是一个愚蠢的事情不检查我的PEM文件,这是安全与密码。 excel工作表自动命名的问题 如何利用总表来自动重命名工作表名称

It was just a stupid thing not to check my pem file, which was secured with a passphrase.

蟒蛇文件可以被命名为任何东西,只要它有一个执行方法 - 它就像一个普通的Python程序来执行。比方说foo.py,那么它将被使用python foo.py执行

The python file can be named anything, as far as it has an execute method - and it is executed just like a normal python program. Let's say foo.py, then it will be executed using python foo.py