[Tutor] Python script errors

2018-12-12 Thread Ravi Kumar
Hi,

I have developed a python script to get api calls for meraki
clientlogevents Thanks for all the help previously  I am facing few errors
such as

Json_string=r.json()

raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1)
>>>

'{0:20}   {1:30}   {2:16}   {3:18}   {4:10} {5:11} '.format(
deviceserial, type, macaddress,occurredAt, details))
TypeError: unsupported format string passed to NoneType.__format__

I know this occurs when the api response is nulls but how do I handle this?

Thanks
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Regarding Python api script

2018-12-06 Thread Ravi Kumar
  '.format(r.content))
**>

OUTPUT


Network:Room, ID:  N_631140260
Network:Ofce, ID:  N_639540739

***>>Querying Meraki for Access Points(Devices) on Network:N_639511050

Switch NameMAC Address

Serial Number

HA e0:cb:b:3e:95  Q2XD-USN6  172.16.172.

AB.  e0:cb:7:01:f4  Q2XD-G8Q8  172.16.172.


***>>Querying Meraki for clients on Access Points:HR (Q2XD-USN6)

Client NameMAC Address
Kiosk55:77:6a:5
Chphone.   44:91:60:a2:0

*>>Querying Meraki for clients on Access Points:DerbyRoom
(Q2XD--GQ8)

Client Name   MAC Address
iPhone      f0:98:9d:2c:   arphone
c8:21:58:79:b
it-mine:05:a4:c9:

Querying Meraki for clientlogevents on Devices: e0:cb:b::3e:95 (HA)

Not looping the devices to get api calls for this access point

Querying Meraki for clientlogevents on Devices: e0:cb:7:01:f4 (AB)
Getting api calls for list of devices in the access point
***

I know I am asking a lot but I hit a road block on this i am assuming One
small change in my last for loop I can get this working for all devices and
I have hardcoded for one network how do I use the same code for different
networks as well
You help is really appreciated  Thank you all!








On Wed, Dec 5, 2018, 2:32 AM Alan Gauld  CCing the list, please use Reply All when responding to the tutor list.
>
>
> On 05/12/2018 03:44, Ravi Kumar wrote:
> > Yes  thats right I want to extract the xml and store into database(SQL
> > Server) and I will have to cteate a new table
> >
> > Here is the sample output I am getting similarly there bulk data which
> > I want to store in database format is as shown below
> >
> >
> >
> b'[{"deviceSerial":"Q2XD-333X-G8Q8","occurredAt":1537565.640085,"type":"802.11
> >
> association","details":{"radio":"1","vap":"0","clientMac":"C8:21:6679:B6:16","channel":"44","rssi":"57","aid":"31645681"}},{"deviceSerial":"Q2XD-97gX-G8Q8","occurredAt":153765.700095,"type":"WPA
> >
> deauthentication","details":{"radio":"1","vap":"0","clientMac":"C621:58:79:B6:16","aid":"316681"}},{"deviceSerial":"Q2XD-97gX-G8Q8","occurredAt":1563369.780085,"type":"WPA
> >
> deauthentication","details":{"radio":"1","vap":"0","clientMac":"C8:21:58:9:B6:16","aid":"31645681"}},{"deviceSerial":"Q297JX-G8Q8"
> >
> >
> > Please let me whether this can be formatted into json in the code
>
> It looks to me like it is already in JSON format.
>
> It is a list of objects.
>
> The json module will let you extract the objects into Python data objects.
>
>
> > and also any other tips or links to refer if available  to store in
> > database
>
> Do you know SQL?
>
> If so using the Python DBAPI is very easy.
>
> If not you will need to learn some basic SQL.
>
> You can try reading the database topic in my Python tutorial(see below)
> which is based on SQLite rather than SQL Server but should be 90%
> compatible.
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Regarding Python api script

2018-12-04 Thread Ravi Kumar
My output api calls in python is in xml so I want the output to be in the
database

So is there a way where I can alter my code to get api responses in json
format in python and then later   move the output   to  the database

Basically at the end of it I want the all the data to be in database

Thanks
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Regarding Python api script

2018-12-03 Thread Ravi Kumar
Hi,

I have developed a python script to get api calls for meraki
clientlogevents I am wanting the output of apicalls which is in xml format
integrated to sql server management  studio how do i do that?

Thanks
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor