Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/run.py
blob: e6699c8e5948168c45c57956a3e7f3fa2cdbbdab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python -u

import os
import string
import random

from devbot import environ
from devbot import config

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

    args = ["sugar-runner"]

    resolution = config.get_pref("RESOLUTION")
    if resolution:
        args.extend(["--resolution", resolution])

    output = config.get_pref("OUTPUT")
    if output:
        args.extend(["--output", output])

    run(args)

def _get_random_id():
    return ''.join(random.choice(string.letters) for i in xrange(8))