Python 101 For Post: Verify Data And Perform Checksums

April 4, 2024

In Part 4 of our Python for Post Professionals series, we add checksum verification and colorful ASCII colors to our media copy script.


Series

Part 4: Building on our Media Management Script with Checksum Verification

In Part 3 we built a custom media management tool, copying files from a source folder into a destination folder. In this Insight we’ll expand upon that script to incorporate checksum verification, plus adding multi-color fonts to make reporting a bit easier to read.

About this Insight

When copying media from set – or between facilities and hard drives – it is important to ensure that each subsequent copy is identical to its source. A checksum creates a hash describing the data as it is stored at a specific location. By creating a checksum for both the source and destination files, after copying has been completed, we can be sure both sets of files are identical.

Our media copying Python script will add checksum verification and report back any failures.

Key Python functions and libraries I’m covering today include:

  • xxhash – a fast and secure way to generate a checksum
  • pip – a package installer for Python

Different ASCII escape sequences:

To improve readability when generating reports check out these color values:

  • Red \33[91m
  • Green \33[92m
  • Blue \33[94m
  • Cyan \33[96m
  • White \33[97m
  • Yellow \33[93m
  • Magenta \33[95m
  • Grey \33[90m
  • Black \33[90m
  • Reset Color \33[0m

Key takeaways from this Insight

By the end of this Insight, you should understand how to:

  • Using lists to store source-destination file path pairs
  • Install external libraries using pip
  • Calculate the checksum of files
  • Check if files exist
  • Color console messages using ASCII escape sequences

Questions or Comments? Leave a comment!

How are your coding skills developing? Do you have questions about the work we’ve done so far? Let me know!

– Kaur


Member Content

Sorry... the rest of this content is for members only. You'll need to login or Join Now to continue (we hope you do!).

Need more information about our memberships? Click to learn more.

Membership options
Member Login

Are you using our app? For the best experience, please login using the app's launch screen


1,200+ Tutorials, Articles, and Webinars To Explore

Get 7-day access to our library of over 1,200+ tutorials - for $5!
Do you like what you see? Maintain access for less than $5 per month.


Start Your Test Drive!
Loading...