import os
import string
from fabric import Connection
import configparser
import socket
config = configparser.RawConfigParser(allow_no_value=True)
configFilePath = r'/root/config.ini'
config.read(configFilePath)
puser = config.get('Server', 'user')
#print (puser)
db_server = list(config.items('Database'))
#print (db_server)
def host_connect():
for key in db_server:
print (key[0])
conn = Connection(host="puser@{0}".format(key[0]))
conn.run('ps -ef | grep postgres')
I am trying to run this code and getting error as Traceback (most recent call last): File "psql_cleanlogs.py", line 6, in from fabric import Connection ImportError: cannot import name 'Connection'
The same procedure I have done in different codes and it ran fine but here is it is creating troubles. I am using python3 virtual env
I was facing a similar issue, I checked the downloaded fabric
package contents, it didn't have Connection.py
(maybe the wrong repo from where I downloaded the package). I installed fabric2
from the correct repository (https://pypi.python.org/simple
) and it worked.
from fabric2 import Connection
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With