Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/release.py
blob: a9f5a643e5bbc8f256739680af697d918f3a5e8e (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
40
41
42
43
44
45
46
47
48
49
import os
import subprocess
import tempfile

upload_host = "shell.sugarlabs.org"
upload_root = "/upload/sources/sucrose/glucose"
download_uri = "http://download.sugarlabs.org/sources/sucrose/glucose"
announce_to = "sugar-devel@lists.sugarlabs.org"

def exists(module, filename):
    release_path = os.path.join(upload_root, module.name, filename)
    result = subprocess.call(["ssh", upload_host, "test", "-f", release_path])
    return result == 0

def upload(module, path):
    upload_path = os.path.join(upload_root, module.name)
    upload_dest = "%s:%s" % (upload_host, upload_path)
    return subprocess.call(["scp", path, upload_dest]) == 0

def announce(module, filename, version, annotation):
    fd, announce_path = tempfile.mkstemp(prefix="announce-")

    with os.fdopen(fd, "w") as f:
        f.write("From: %s\n" % _get_email())
        f.write("To: %s\n" % announce_to)
        f.write("Subject: [RELEASE] %s-%s\n" % (module.name, version))

        f.write("\n%s\n" % annotation)
        f.write("== Source ==\n\n")
        f.write("%s/%s/%s" % (download_uri, module.name, filename))

    result = False

    upload_dest = "%s:~" % upload_host
    if subprocess.call(["scp", announce_path, upload_dest]) == 0:
        announce_basename = os.path.basename(announce_path)
 
        if subprocess.call(["ssh", upload_host, "sendmail", "-t",
                            "<", announce_basename]):
            result = True

        subprocess.check_call(["ssh", upload_host, "rm", announce_basename])

    os.unlink(announce_path)

    return result

def _get_email():
    return subprocess.check_output(['git', 'config', 'user.email']).strip()