Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; 'else:': 0.03; 'paths': 0.07; '*args,': 0.09; 'deploy': 0.09; 'executed': 0.09; 'run,': 0.09; 'subject:modules': 0.09; 'api': 0.11; 'python': 0.11; 'def': 0.12; "%s'": 0.16; '**kwargs)': 0.16; '__init__.py': 0.16; 'callable': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; 'skip:f 30': 0.19; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'fine': 0.24; '---': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'host': 0.29; 'raise': 0.29; "i'm": 0.30; "skip:' 10": 0.31; "skip:' 40": 0.31; 'file': 0.32; 'class': 0.32; 'skip:m 30': 0.32; 'run': 0.32; 'running': 0.33; '(most': 0.33; 'received:84': 0.35; 'executing': 0.36; 'module.': 0.36; 'skip:" 50': 0.36; 'url:org': 0.36; 'server': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'skip:_ 40': 0.38; 'recent': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'such': 0.63; 'charset:windows-1252': 0.65; 'within': 0.65; 'header:Reply-To:1': 0.67; 'skip:r 30': 0.69; 'reply-to:no real name:2**0': 0.71; 'env': 0.84; 'fab': 0.84; 'reply-to:addr:python.org': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=JsTI8qIC c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=7AxPfEIvyrUA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=N659UExz7-8A:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=mndYb5jRypwA:10 a=aH78Jsl9AAAA:8 a=Ubkf9IENKU5szETzlNEA:9 a=pILNOxqGKmIA:10 a=ZZ52dLVBzC8A:10 X-AUTH: mrabarnett:2500 Date: Mon, 22 Apr 2013 17:32:22 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: python-list@python.org Subject: Re: error importing modules References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 79 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366648529 news.xs4all.nl 2192 [2001:888:2000:d::a6]:53157 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44094 On 22/04/2013 15:54, Rodrick Brown wrote: > 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)' > > > 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() > 'modules.Fabexec' is the module/script 'Fabexec'. What you want is the 'Fabexec' class within the 'Fabexec' module. > --- 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() > >