python guestfs error:Exception AttributeError - python

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

Related

Can not find a specific regular expressions

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.

What kind of object do I need to use the options parameter of fix_multiple_files?

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'])

Python - AttributeError: module 'cssutils' has no attribute 'getUrl'

I am trying to extract URLs from CSS stylesheet using cssutils.getUrls('stylesheet.css')
However when I run the code I get an error complaining about 'getUrls' see below. I am running on python 3.6
import cssutils
cssutils.getUrls('http://4nprofessionals.com/css/style.css')
Traceback (most recent call last):
File "", line 1, in
cssutils.getUrls('http://4nprofessionals.com/css/style.css')
AttributeError: module 'cssutils' has no attribute 'getUrls'

Why plone.api doesn’t have find?

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.

Pydoc not working in Python 3.3 in Windows

I am trying to generate the help text at runtime and i am not able to use the pydoc command in Windows. When i type
>>> pydoc(atexit)
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'pydoc' is not defined
I have already set up the environment variables for pydoc.py file. C:\Python33\Lib\pydoc.py.
This also not works like it works for >>help('atexit')
>>> pydoc('atexit')
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'pydoc' is not defined
Whats the possible reason for it.
Updates:
>>> import pydoc
>>> pydoc(sys)
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: 'module' object is not callable
>>> pydoc('sys')
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: 'module' object is not callable
Like any library in Python, you need to import it before you can use it.
Edit What exactly are you trying to achieve? Modules are indeed not callable. pydoc.help is the function you want, although I don't really know why you need it, since as you note the standalone help function does the same thing already.

Categories