Python Forum
multiple values as parameters to POST command..
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
multiple values as parameters to POST command..
#16
(Feb-23-2018, 11:58 AM)buran Wrote: You construct the Message out of the loop, so it has info only for last Instances (why plural by the way?) and last tag_name
I guess when print, you print to screen you do so from within the loop

msg_list = []
for reservation in desc['Reservations']:
    for instance in reservation['Instances']:
        public_ip_address = instance.get('PublicIpAddress', "-") or '-'
        private_ip_address = instance.get('PrivateIpAddress', "-") or '-'
        public_dns_name = instance.get('PublicDnsName', "-") or '-'
        private_dns_name = instance.get('PrivateDnsName', "-") or '-'
        status = instance['State']['Name']
        for tag in instance['Tags']:
            if tag['Key'] == 'Name':
                tag_name = tag["Value"]
                break
        msg_text = '{} is {}'.format(tag_name, status)
        msg_list.append(msg_text)
MESSAGE = {'text': '\n'.join(msg_list)}
Note that the problem still valid for ip addresses - you don't store them anywhere, so out of the loop you will have only last values

Dance

Beautiful...it works like charm now :) I see both messages in Slack...

How can I just print OK if status is running if other status then its Failed.. within the loop it self ?

Thank you Buran..Much gratitude, Hope to become expert like you soon :)
Reply


Messages In This Thread
RE: multiple values as parameters to POST command.. - by onenessboy - Feb-23-2018, 12:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  __init__() got multiple values for argument 'schema' dawid294 4 2,338 Jan-03-2024, 09:42 AM
Last Post: buran
  How to combine multiple column values into 1? cubangt 15 2,835 Aug-11-2022, 08:25 PM
Last Post: cubangt
  Substitue multiple substrings in one command Pavel_47 0 838 Jul-18-2022, 01:24 PM
Last Post: Pavel_47
  function accepts infinite parameters and returns a graph with those values edencthompson 0 863 Jun-10-2022, 03:42 PM
Last Post: edencthompson
  Function - Return multiple values tester_V 10 4,449 Jun-02-2021, 05:34 AM
Last Post: tester_V
  How to input & output parameters from command line argument shantanu97 1 2,565 Apr-13-2021, 02:12 PM
Last Post: Larz60+
  Xlsxwriter: Create Multiple Sheets Based on Dataframe's Sorted Values KMV 2 3,498 Mar-09-2021, 12:24 PM
Last Post: KMV
  Looking for help in Parse multiple XMLs and update key node values and generate Out.. rajesh3383 0 1,874 Sep-15-2020, 01:42 PM
Last Post: rajesh3383
  Assigning multiple values using tuple sivacg 2 2,273 Aug-06-2020, 10:29 PM
Last Post: perfringo
  Function parameters and values as string infobound 1 1,764 Jul-24-2020, 04:28 AM
Last Post: scidam

Forum Jump:

User Panel Messages

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