我很难让这个脚本发挥作用。当我调试这段代码时,它不会读入类或函数中。代码将无法正确执行。有人知道这里的问题吗,谢谢
#!/home/build/test/Python-2.6.4
import os, subprocess
class mks_function:
sandbox="new_sandbox"
def mks_create_sandbox():
try:
retcode=call("si createsandbox" + "--no --hostname=bel --port=70 --user=user --password=1234 --populate --project=e:/project.pj --lineTerminator=lf new_sandbox", shell=True)
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
else:
print >>sys.stderr, "Child returned", retcode
except OSError, e:
print >>sys.stderr, "Execution failed:", e
print "sandbox retVal="+retcode
print "Creating a new sandbox called "+sandbox+" "
###############################################################
尝试将put作为第一行:
如果您确实需要特定版本的Python,请在运行之前设置环境。在
可能的问题:
你的代码永远不会被执行(就像你只定义类一样)。在文件中使用它(名称具有误导性):
if __name__ == '__main__': myObject = mks_function()
告诉我们你是如何执行代码的?您是否更改了运行脚本的权限?在
chmod +x filename.py
或者你想从以下方面开始:
python filename.py
很少有东西可以检查你的代码
call
应该是subprocess.call
/usr/bin/si createsandbox
时最好使用完整路径,您可以使用shell中的which si
进行检查"si createsandbox" + " no ..."
,请使用list["/usr/bin/si","createsandbox no ..."]
sys
,而是使用它sandbox
应该是self.sandbox
,而{相关问题 更多 >
编程相关推荐