Reader small image

You're reading from  Practical Python Programming for IoT

Product typeBook
Published inNov 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781838982461
Edition1st Edition
Languages
Right arrow

The main program entry point

At the end of the source file, we have the following code:

# Main entry point
if __name__ == '__main__':
signal.signal(signal.SIGINT, signal_handler) # Capture CTRL + C
print_instructions() # (18)

# Initialize LED from last dweet.
latest_dweet = get_latest_dweet() # (19)
if (latest_dweet):
process_dweet(latest_dweet)

print('Waiting for dweets. Press Control+C to exit.')

#Only use one of the following.
#stream_dweets_forever() # Stream dweets real-time.
poll_dweets_forever() # Get dweets by polling. # (20)

On line (8), print_instructions()  is responsible for printing the sweet URLs to the Terminal, while on line (19), we see a call to get_latest_dweet(). This call initializes our LED to the last dweeted state when the program starts. Finally, on line (20), we start polling the dweet.io service to access the latest dweets...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Practical Python Programming for IoT
Published in: Nov 2020Publisher: PacktISBN-13: 9781838982461