Python Forum
AttributeError: 'Namespace' object has no attribute 'brokeName'
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AttributeError: 'Namespace' object has no attribute 'brokeName'
#1
People! Greetings from Suriname!!
I try to get this up. What's the way to run this up?



The piece of code :

#!/usr/bin/python
# -*- coding: utf-8 -*-

import argparse,sys,requests

#parser
parser = argparse.ArgumentParser(description='MOM.')

#diff arguments
parser.add_argument('-q', '--queuenum', type=str, dest='SantQue', action='store', help='un numero de queue')
parser.add_argument('-b', '--brknum',type=str, dest='brokeName', action='store', default='brk01', help='un num de broker')

args = parser.parse_args()

print (args)

queue=requests.get('h..p://localhost:8161/api/...')
brokk=requests.get('h..p://localhost:8161/api/...brokerName={}'.format(args.brokeName),auth=('...'))


if args.SantQue:
       print (queue.json())
else:
       print ("dong error")


#print (queue.json())
#print (queue)

#print (mountain.json())
#print (mountain)
Sorry for my incompetence
Reply
#2
please, post full Traceback in error tags.
Reply
#3
Namespace(SantBrK='brk01', SantQue='P35')
Traceback (most recent call last):
 File "jSonTest02.py", line 18, in <module>
   brokk=requests.get('http://localhost:8161/api/jolokia/read/org.apache.activemq:type=Broker,brokerName={}'.format(args.SantBrk),auth=('admin', 'admin'))
AttributeError: 'Namespace' object has no attribute 'SantBrk'
Reply
#4
That Traceback is not error produced by running the code in the original post. Anyway, there is no SantBrk defined in the above code.


import argparse

parser = argparse.ArgumentParser(description='MOM.')
parser.add_argument('-b', '--brknum',type=str, dest='brokeName', action='store', default='brk01', help='un num de broker')
args = parser.parse_args()
print(args.brokeName)
running without any command line arguments return the default value

Output:
brk01 >>>
Now I noticed that in the Namespace output you have SantBrK with capital K
Reply
#5
You ah chief !!!! I was on this from weeks !!! Wall I just changed the variables to recognize them more easily!!

the namespace was the problem!! thank you buran.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  type object 'man' has no attribute 'centerX' Tempo 7 2,345 Mar-07-2025, 03:47 AM
Last Post: deanhystad
  which namespace? Skaperen 4 1,983 May-28-2024, 05:38 AM
Last Post: Gribouillis
  getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY' EarthAndMoon 4 4,451 Oct-03-2023, 02:00 PM
Last Post: deanhystad
  AttributeError: '_tkinter.tkapp' object has no attribute 'username' Konstantin23 4 8,811 Aug-04-2023, 12:41 PM
Last Post: Konstantin23
  Python: Regex is not good for re.search (AttributeError: 'NoneType' object has no att Melcu54 9 5,284 Jun-28-2023, 11:13 AM
Last Post: Melcu54
  Parallel processing - AttributeError: Can't get attribute 'sktimekmeans' Mohana1983 1 3,154 Jun-22-2023, 02:33 AM
Last Post: woooee
  Python: AttributeError: 'PageObject' object has no attribute 'extract_images' Melcu54 2 8,996 Jun-18-2023, 07:47 PM
Last Post: Melcu54
  Object attribute behavior different in 2 scripts db042190 1 2,821 Jun-14-2023, 12:37 PM
Last Post: deanhystad
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 6,983 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  Pandas AttributeError: 'DataFrame' object has no attribute 'concat' Sameer33 5 12,861 Feb-17-2023, 06:01 PM
Last Post: Sameer33

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020