Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/state.py
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-12-26 23:04:00 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-12-26 23:04:00 (GMT)
commit364a9fa230e59273fd6e789c608d96b1c94b01a7 (patch)
tree0af531fafa0feab44f8ede544920ca1ca99e1b6a /devbot/state.py
parent9fd827f5502216fdb06caedeedabcefb6bf426dc (diff)
Keep public stuff at the top
Diffstat (limited to 'devbot/state.py')
-rw-r--r--devbot/state.py80
1 files changed, 40 insertions, 40 deletions
diff --git a/devbot/state.py b/devbot/state.py
index 4b9af18..40a9c76 100644
--- a/devbot/state.py
+++ b/devbot/state.py
@@ -10,46 +10,6 @@ _FULL_BUILD = "fullbuild"
_SYSTEM_CHECK = "syscheck"
-def _get_state_path(name):
- return os.path.join(config.build_state_dir, "%s.json" % name)
-
-
-def _load_state(name, default=None):
- state = default
-
- try:
- with open(_get_state_path(name)) as f:
- state = json.load(f)
- except IOError:
- pass
-
- return state
-
-
-def _save_state(name, state):
- with open(_get_state_path(name), "w+") as f:
- json.dump(state, f, indent=4)
- f.write('\n')
-
-
-def _get_diff_hash(git_module):
- diff = git_module.diff().strip()
- if diff:
- return hashlib.sha256(diff).hexdigest()
- else:
- return None
-
-
-def _get_root_commit_id():
- git_module = git.get_root_module()
- if git_module:
- commit_id = git_module.get_commit_id()
- else:
- commit_id = "snapshot"
-
- return commit_id
-
-
def built_module_touch(module):
git_module = module.get_git_module()
built_modules = _load_state(_BUILT_MODULES, {})
@@ -113,3 +73,43 @@ def clean(build_only=False):
os.unlink(_get_state_path(name))
except OSError:
pass
+
+
+def _get_state_path(name):
+ return os.path.join(config.build_state_dir, "%s.json" % name)
+
+
+def _load_state(name, default=None):
+ state = default
+
+ try:
+ with open(_get_state_path(name)) as f:
+ state = json.load(f)
+ except IOError:
+ pass
+
+ return state
+
+
+def _save_state(name, state):
+ with open(_get_state_path(name), "w+") as f:
+ json.dump(state, f, indent=4)
+ f.write('\n')
+
+
+def _get_diff_hash(git_module):
+ diff = git_module.diff().strip()
+ if diff:
+ return hashlib.sha256(diff).hexdigest()
+ else:
+ return None
+
+
+def _get_root_commit_id():
+ git_module = git.get_root_module()
+ if git_module:
+ commit_id = git_module.get_commit_id()
+ else:
+ commit_id = "snapshot"
+
+ return commit_id