Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save diva-D/ccfe244d17da1f8c8e13728204c3f54b to your computer and use it in GitHub Desktop.
Save diva-D/ccfe244d17da1f8c8e13728204c3f54b to your computer and use it in GitHub Desktop.
The script_ids.json file is simply a list of script id strings.
import json
import os
import subprocess
# replace with id of your template
template_id_string = '{ "scriptId": "1emazMPaUkLHXbgbEF0nOKwU275gL7H5cwue909bVMtkp2czm_tB5XYwH" }'
def run_update(id):
new_clasp_string = f'{{ "scriptId": "{id}" }}'
# overwrite the clasp file
with open(os.path.join(os.path.dirname(__file__), ".clasp.json"), "w") as f:
f.write(new_clasp_string)
# push to the script
subprocess.run(["clasp", "push"])
def push_updates(script_id=None):
if script_id:
run_update(script_id)
else:
with open(os.path.join(os.path.dirname(__file__), "script_ids.json")) as f:
ids = json.load(f)
id_count = len(ids)
for i, id in enumerate(ids):
print(id)
print(f'id {i + 1} of {id_count}')
run_update(id)
# revert back to template file id
with open(os.path.join(os.path.dirname(__file__), ".clasp.json"), "w") as f:
f.write(template_id_string)
subprocess.run(["say", "'done updating pricing tool scripts'"])
if __name__ == "__main__":
# single script id
# push_updates("1VNWZZUxr8dUl03SCKqVljPAZGawa711m-VcjAA8DGJnHNdHQ5Igp8daX")
# all
push_updates()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment