error importing modules

R

Rodrick Brown

I'm using the fabric api (fabfile.org)

I’m executing my fab script like the following:

$ fab -H server set_nic_buffers -f set_nic_buffers.py
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/fabric/main.py", line 739, in main
*args, **kwargs
File "/usr/lib/python2.7/site-packages/fabric/tasks.py", line 316, in
execute
multiprocessing
File "/usr/lib/python2.7/site-packages/fabric/tasks.py", line 213, in
_execute
return task.run(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/fabric/tasks.py", line 123, in run
return self.wrapped(*args, **kwargs)
File "/home/rbrown/repos/unix-tools/tools/fabfiles/nb.py", line 5, in
set_nic_buffers
f_exec = modules.Fabexec('set_nic_buffers',
'/var/tmp/unix-tools/tools/set_nic_buffers.sh')
TypeError: 'module' object is not callable

My paths all seem to be fine not sure what’s going on

$ python -c 'import modules.Fabexec; print (modules.Fabexec)'
<module 'modules.Fabexec' from 'modules/Fabexec.pyc'>

Fabfiles

|-- modules
| |-- Fabexec.py
| |-- Fabexec.pyc
| |-- __init__.py
| `-- __init__.pyc
|-- systune.py
|-- systune.pyc
`-- set_nic_buffers.py

--- set_nic_buffers.py ---
import modules
from modules import Fabexec

def set_nic_buffers():
f_exec = modules.Fabexec('set_nic_buffers',
'/var/tmp/unix-tools/tools/set_nic_buffers.sh')
f_exec.run()

--- Fabexec.py ---
from fabric.api import run, cd, sudo, env
from fabric.contrib import files
from fabric.colors import green

class Fabexec(object):

repobase='/var/tmp/unix-tools'

def __init__(self,script_name,install_script):
self.script_name = script_name
self.install_script = install_script

def run(self):
if files.exists(self.install_script):
with cd(self.repobase):
result = sudo(self.install_script + ' %s ' % env.host)
if result.return_code != 0:
print(red('Error occured executing %s' %
self.install_script))
else:
print(green('%s executed successfully'))
else:
print(red('Error no such dir %s try running repo deploy script
to host %s' % (self.repobase, env.host)))
raise SystemExit()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top