Try either using 'Fabexec' or importing 'modules.Fabexec' in
set_nic_buffers.py.  Currently you seem to be importing 'Fabexec' but using
'modules.Fabexec'.

For example, in set_nic_buffers.py, change `from modules import Fabexec` to
`import modules.Fabexec`

Alternatively, have modules/__init__.py import Fabexec, so it is present in
the 'modules' namespace when you `import modules`.

Regards,
Todd


On Mon, Apr 22, 2013 at 10:50 AM, Rodrick Brown <[email protected]> wrote:

>  My directory structure looks like the following: ****
>
> ** **
>
> 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()****
>
> ** **
>
> --RB****
>
> _______________________________________________
> Fab-user mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/fab-user
>
>


-- 
Todd DeLuca
http://todddeluca.com
http://wall.hms.harvard.edu/
_______________________________________________
Fab-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to