Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(224)

Unified Diff: quickstart/utils.py

Issue 51520043: Create a backup copy of the envs file.
Patch Set: Create a backup copy of the envs file. Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « quickstart/tests/test_utils.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: quickstart/utils.py
=== modified file 'quickstart/utils.py'
--- quickstart/utils.py 2014-01-09 11:22:54 +0000
+++ quickstart/utils.py 2014-01-10 15:30:49 +0000
@@ -24,6 +24,7 @@
import collections
import datetime
import errno
+import functools
import httplib
import json
import logging
@@ -326,6 +327,20 @@
return parse_status_output(output, ['machines', '0', 'series'])
+def run_once(function):
+ """Return a decorated version of the given function which runs only once.
+
+ Subsequent runs are just ignored and return None.
+ """
+ @functools.wraps(function)
+ def decorated(*args, **kwargs):
+ if not decorated.called:
+ decorated.called = True
+ return function(*args, **kwargs)
+ decorated.called = False
+ return decorated
+
+
def unit_changes(unit_name, changeset):
"""Parse the changeset and return the change related to the given unit.
« no previous file with comments | « quickstart/tests/test_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b