Deluge Script to store custom field setting in Contacts based on presence or stage of Potential

Deluge Script to store custom field setting in Contacts based on presence or stage of Potential

Hi. I have put a Workflow automation rule in place that will update a custom field in Contacts with a value indicating the presence of a potential, but I need a script to retroactively go back and update that field for each person's Potential record (whoever actually has a potential). There appears to be no easy way to do that so a Deluge script appears to be needed.

The field I've created in Contacts is "Potential Exists" and is a checkbox field. I simply want it checked when there is a potential that is not Closed Lost. 

Can you provide the script or a better way to mass update the Contacts?

David