I trying create a script to find a exist folder, if not create this folder.
But when a call find from plone.api the output is AttributeError: 'module' object has no attribute 'find'
Bellow my terminal:
$ bin/instance -O intranet debug
>>> from plone import api
>>> from zope.site.hooks import setSite
>>> portal = app['intranet']
>>> setSite(portal)
>>> folders = api.content.find(context=portal, portal_catalog='Folder')
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'module' object has no attribute 'find'
>>>
What is wrong in my case?
I used this documentation plone.api.content.find
Need update plone.api to a version with support to method find. Like said by #LucaFabbri. In my case the product was update to 1.5.0.
Related
I am trying to scrap specific information from the site but I am receiving an error. Here is the simplified version of the main problem:
import re
b='href="/bp/vendor?vendorCodes=C901U">C901U</a></span></div></div></div><div heyaa'
c=re.search('href="/bp/vendor?vendorCodes=C901U">C901U</a></span></div></div></div><div',b)
If I try to find what is in c I receive this error:
c.group()
Traceback (most recent call last):
File "<pyshell#87>", line 1, in <module>
c.group()
AttributeError: 'NoneType' object has no attribute 'group'
Thanks in advance.
I need to create a simple script for fixing indentation in python scripts of the repository. I found fix_multiple_files in autopep8 module:
import autopep8
autopep8.fix_multiple_files('/home/playrix/work/ci-teamcity/scripts/', options={'recursive': 1})
I'm getting this every time I run the script:
Traceback (most recent call last):
File "/home/playrix/work/ci-teamcity/scripts/1.py", line 4, in <module>
autopep8.fix_multiple_files('/home/playrix/work/ci-teamcity/scripts/', options='')
File "/home/playrix/.local/lib/python2.7/site-packages/autopep8.py", line 3897, in fix_multiple_files
filenames = find_files(filenames, options.recursive, options.exclude)
AttributeError: 'str' object has no attribute 'recursive'
How correctly noticed johnsharpe it was argparse.Namespace. And the best way to get it was:
opt = autopep8.parse_args(arguments=['recursive', '--in-place', '--aggressive'])
I have a file, A.py, it basically looks like this:
import Hasher
hh = Hasher.V2.Cached_V2()
When running, I get the error:
Traceback (most recent call last):
File "./A.py", line 2, in <module>
hh = Hasher.V2.Cached_V2()
AttributeError: 'module' object has no attribute 'V2'
On disk, the files layout is like this:
/A.py
/Hasher/__init__.py
/Hasher/V2.py
V2.py contains multiple classes, among them Cached_V2.
What's going on? Why isn't the object visible as expected?
In your A.py, use from Hasher import V2 Basically, when you are just importing 'Hasher' only the init.py file gets loaded.
Reference: Python error: AttributeError: 'module' object has no attribute
Note: In your Hasher/__init__.py file, if you import V2 using from . import V2, then you can use it by directly calling Hasher.V2 from A.py
i am learning python boto module and i am trying to stop a running instance .
import boto.ec2
conn = boto.ec2.connect_to_region("us-west-2")
conn.stop_instances(instance_ids=['i-0aa5ce441ef7e0e2a'])
but i am getting error which says:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'stop_instances'
i gave AWS_access keys for boto.
can anyone please help me to fix this error ?
As #kindall points out, your conn object is not initialized (it's NoneType). I also see that you're using boto in the example, but I thought that I would provide an example of this using boto3:
import boto3
boto3_session = boto3.Session(profile=some_profile_you_configured)
boto3_client = boto3_session.client('ec2', region_name='us-west-2')
response = boto3_client.stop_instances(InstanceIds=['i-0aa5ce441ef7e0e2a'])
I'm on Debian 7.6. I installed python 2.7 and libguestfs0 and other packages that I need.
This is a sample code that I try to use guestfs, I enter these codes on debian terminal:
debian#debian$ python
>>> import guestfs
>>> g=guestfs.GuestFS (python_return_dict=True)
`Exception AttributeError: "GuestFS instance has no attribute '_o'" in <bound method GuestFS.__del__ of <guestfs.GuestFS instance at 0x203f908>>
ignored
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __init__() got an unexpected keyword argument 'python_return_dict'`
I searched a lot but I can't find solution for this error.
Thanks