diff options
author | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-11-28 01:04:15 (GMT) |
---|---|---|
committer | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-11-28 01:04:15 (GMT) |
commit | e571d1d525359f562074d6922ac06e35ac49b48c (patch) | |
tree | bbb6dbba110c44de83455b0cd49836642b898cea /devbot/run.py | |
parent | 016dea75191a76c01362850d4874d27fa0fb13e0 (diff) |
Refactor to use sugar-runner
Diffstat (limited to 'devbot/run.py')
-rw-r--r-- | devbot/run.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/devbot/run.py b/devbot/run.py index 1bbe695..451da96 100644 --- a/devbot/run.py +++ b/devbot/run.py @@ -1,9 +1,29 @@ #!/usr/bin/python -u import os +import string +import random from devbot import environ +from devbot import config -def run_command(args): +def run(args): environ.setup() os.execlp(args[0], *args) + +def run_sugar(): + profile_env = os.environ.get("SUGAR_PROFILE", None) + profile_pref = config.get_pref("PROFILE") + + if profile_env is not None: + if profile_pref is None: + config.set_pref("PROFILE", _get_random_id()) + elif profile_pref == profile_env: + print "Cannot run two instances with the same profile." + return + + run(["sugar-runner"]) + +def _get_random_id(): + return ''.join(random.choice(string.letters) for i in xrange(8)) + |