How to get namespace details for ecs - python

I want to print namespaces for my ecs-client. When I am using print(client.user_info.whoami()) I am getting the output. But when I am executing the below code I am getting attribute error.
from ecsclient.client import Client
from ecsclient.common.multitenancy import namespace
client = Client('3',
username='root',
password='password',
token_endpoint='https://abc.xyz.com:4443/login',
ecs_endpoint='https://abc.xyz.com:4443')
print(client.namespace.get_namespaces())
Error:
Traceback (most recent call last):
File "test.py", line 12, in <module>
print(client.namespace.get_namespaces())
AttributeError: 'Namespace' object has no attribute 'get_namespaces'

instead of using print(client.namespace.get_namespaces()) I used print(client.namespace.list()) and got the list of namespaces

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.

Python/Json AttributeError: partially initialized module 'json' has no attribute

I am running Windows 10 with MS Code Python 3.7
I get the following message from my simple code block
Traceback (most recent call last):
File "c:/Users/marke/OneDrive/Desktop/Python Tutorial/json.py", line 1, in
module
import json File "c:\Users\marke\OneDrive\Desktop\Python Tutorial\json.py", line 6, in
jsText = json.loads(FileText) AttributeError: partially initialized module 'json' has no attribute 'loads' (most likely due to
a circular import)
My code
import json
jsFile = open("myjson.json","r")
FileText = jsFile.read
jsText = json.loads(FileText)
When you name your script the name of the module you try to import, python tries to imports your script first, which results in the Error

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'

python boto 'NoneType' object has no attribute 'stop_isntances'

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

AttributeError 'module' has no attribute 'Queue"

I am trying to import Queue and I keep getting the following
Traceback (most recent call last):
File "threading.py", line 2, in <module>
import Queue
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/Queue.py", line 5, in <module>
import threading as _threading
File "/Users/zaq/threading.py", line 10, in <module>
queue = Queue.Queue()
AttributeError: 'module' object has no attribute 'Queue'
I am using the code in the link Threading in python using queue
Also, I can import and use Queue in the python interpreter.
What am I doing wrong?
Name of my script was threading.py... Changed it and everthing works fine. Rookie mistake.

Categories