Exemplo n.º 1
0
def jenkins_server():
    runcmd.run(["wget", "-O", "jenkins-ci.org.key", "http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key"])
    runcmd.check_sudo(["apt-key", "add", "jenkins-ci.org.key"])
    runcmd.install_files("/etc/apt/sources.list.d", ["jenkins.list"])
    runcmd.apt_get(["update"])
    runcmd.apt_get(["install", "openjdk-6-jdk", "jenkins", "libcobertura-java"])
    runcmd.install_files("/etc/default", ["jenkins"])
Exemplo n.º 2
0
def mysql_secure_db():
    with open(runcmd.rsrc_path("mysql_securedb.sql.in")) as sql_in:
        with open(runcmd.rsrc_path("mysql_secure_db.sql"), "w") as sql_out:
            sql_out.write(sql_in.read())

    with open(runcmd.rsrc_path("mysql_secure_db.sql")) as sql_cmd:
        runcmd.run(["/usr/local/mysql/bin/mysql", "--user=root", "--batch"], 
                   stdin=sql_cmd)
Exemplo n.º 3
0
def checkout_site():
    setup_known_hosts()

    if not opath.exists(opath.expanduser("~/memrise")):
        os.mkdir(opath.expanduser("~/memrise"))

    log.info("Checking out memrise site from unfuddle")

    rc.run(["git", "clone", "[email protected]:memrise/memrise-django.git", "memrise"],
           cwd=opath.expanduser("~/memrise"))
Exemplo n.º 4
0
def update(path, image):
    """update icon"""
    if not image:
        return rm(path)
    if sys.version_info[0] == 2:
        _cocoa_seticon(path, image)
    else:
        args = ["osascript", "-e", APPLESCRIPT, path, image]
        runcmd.run(args).exc()
    os.utime(path, None)
    if os.path.isdir(path):
        subprocess.Popen(
            ["chflags", "hidden", "%s/Icon\r" % path],
            stderr=subprocess.PIPE).communicate()
Exemplo n.º 5
0
def get(path=None):
    """return `git status` string"""
    if not path:
        path = os.getcwd()
    cmd = ["git", "status", "-s"]
    r = runcmd.run(cmd, cwd=path)._raise()
    return r.out
Exemplo n.º 6
0
def run(applescript, background=False):
    path = applescript
    if not os.path.exists(applescript):  # source code
        path = temp.tempfile()
        open(path, "w").write(applescript)
    args = ["osascript", path]
    return runcmd.run(args, background=background)
Exemplo n.º 7
0
def app(appname, applescript, background=False):
    code = """tell application "%s"
    %s
end tell
""" % (appname, applescript)
    path = _tempfile(code)
    args = ["osascript", path]
    return runcmd.run(args, background=background)
Exemplo n.º 8
0
def voices(lang=None):
    """return a list of installed voices (name, lang, description)"""
    cmd = ["/usr/bin/say", "-v", "?"]
    out = runcmd.run(cmd).out
    for l in out.splitlines():
        _name, _lang, _description = _voice_info(l)
        if not lang or (lang and lang in _lang):
            yield _name, _lang, _description
Exemplo n.º 9
0
def _run(args):
    if not os.path.exists("/usr/local/bin/tag"):
        raise OSError("""/usr/local/bin/tag NOT INSTALLED

https://github.com/jdberry/tag
brew install tag
""")
    args = ["/usr/local/bin/tag"] + list(args)
    return runcmd.run(args)._raise().out
Exemplo n.º 10
0
def run(applescript, background=False):
    """run applescript file/code"""
    if os.path.exists(applescript):
        path = applescript
    else:
        path = temp.tempfile()
        open(path, "w").write(applescript)
    cmd = ["osascript", path]
    r = runcmd.run(cmd, background=background)
    return r.code, r.out, r.err
Exemplo n.º 11
0
def install_mysql():
    log.info("Downloading MySQL 5.5.19 Source")
    runcmd.run(["wget", "-O", "mysql-5.5.19.tar.gz",
                "http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.19.tar.gz/from/http://mysql.he.net/"])

    log.info("Unpacking MySQL 5.5.19 Source")
    runcmd.run(["tar", "xzf", "mysql-5.5.19.tar.gz"])

    log.info("Configuring MySQL 5.5.19 Source")
    runcmd.run(["cmake", "."], cwd="mysql-5.5.19")

    log.info("Building MySQL 5.5.19 Source")
    runcmd.run(["make", "-j", "4"], cwd="mysql-5.5.19")

    log.info("Installing MySQL 5.5.19 Source to /usr/local/mysql")
    runcmd.check_sudo(["make" ,"install"], cwd="mysql-5.5.19")

    runcmd.install_files("/etc/profile.d", ["mysql.sh"])
    runcmd.install_files("/etc/ld.so.conf.d", ["mysql-ld.so.conf"])
    runcmd.check_sudo(['ldconfig'])
Exemplo n.º 12
0
def mkalias(src, dst):
    """make MacOS Finder alias"""
    cmd = ["mkalias", _fullpath(src), _fullpath(dst)]
    runcmd.run(cmd)._raise()
    """refresh icon"""
    os.utime(os.path.dirname(_fullpath(dst)), None)
Exemplo n.º 13
0
#!/usr/bin/env python
import runcmd

runcmd.run(["ls"]).exc()  # ok

try:
    runcmd.run(["mkdir", "/"]).exc()
except OSError:  # mkdir: /: Is a directory
    pass
Exemplo n.º 14
0
#!/usr/bin/env python
import runcmd

r = runcmd.run(["echo", "hello world"])
print(r)
print("code = %s" % r.code)
print("out = %s" % r.out)
print("err = %s" % r.err)

out = runcmd.run(["echo", "hello world"]).exc().out
Exemplo n.º 15
0
def setup_venv():
    rc.run(["pip", "install", "-E", "../venv", "-r", "requirements.txt"], 
           cwd=opath.expanduser("~/memrise/memrise"))
    os.chmod('/home/memrise/memrise/', 0755)
    os.chmod('/home/memrise/', 0755)
Exemplo n.º 16
0
def get_weather():
    w = runcmd.run(["weather", "80007"])
    if (w.code == 0):
        return w.out
    return "Unable to connect to weather report"
Exemplo n.º 17
0
#!/usr/bin/env python
import time
import runcmd

r = runcmd.run(["sleep", "5"], background=True)
print("pid: %s" % r.pid)
counter = 0
while r.running:
    print("running %s" % counter)
    counter += 1
    time.sleep(1)
    if counter > 2:
        r.kill()
Exemplo n.º 18
0
def run(args):
    """run `open` with arguments"""
    runcmd.run(["open"] + args)._raise()
Exemplo n.º 19
0
def rm():
    """`git remote rm name`"""
    _name = name()
    if _name:
        runcmd.run(["git", "remote", "rm", _name])
Exemplo n.º 20
0
def update(path, image):
    """update icon"""
    if sys.version_info[0] == 2:
        return _cocoa_seticon(path, image)
    args = ["osascript", "-e", APPLESCRIPT, path, image]
    runcmd.run(args)._raise()
Exemplo n.º 21
0
def sleep():
    """put your display to sleep"""
    cmd = ["/usr/bin/pmset", "displaysleepnow"]
    runcmd.run(cmd)
Exemplo n.º 22
0
def run(args):
    """run `git remote` with args and return output"""
    return runcmd.run(["git", "remote"] + list(args))._raise().out
Exemplo n.º 23
0
def say(args, background=False):
    """run `say` with given args"""
    r = runcmd.run(["say"] + values.get(args), background=background)
    if not background:
        r._raise()
    return r
Exemplo n.º 24
0
def sleeping():
    """return True if display is sleeping"""
    out = runcmd.run(["/usr/sbin/ioreg", "-n",
                      "IODisplayWrangler"])._raise().out
    state = int(out.split('"DevicePowerState"=')[1][0])  # 0-4
    return state in [0, 1]
Exemplo n.º 25
0
def wake():
    """wake from sleep"""
    cmd = ["/usr/bin/caffeinate", "-u", "-t", "1"]
    runcmd.run(cmd)
Exemplo n.º 26
0
def chmod(args):
    """run chmod with arguments"""
    cmd = ["chmod"] + list(args)
    return runcmd.run(cmd)._raise().out
Exemplo n.º 27
0
def _rm_file_icon(path):
    args = ["xattr", "-d", "com.apple.ResourceFork", path]
    runcmd.run(args)
Exemplo n.º 28
0
def run(args):
    """run `/usr/local/bin/tag` with arguments and return output"""
    if not os.path.exists(bin):
        raise OSError("%s NOT EXISTS\nrun `brew install tag`" % bin)
    return runcmd.run([bin] + values.get(args))._raise().out
Exemplo n.º 29
0
def update(path, image):
    """update icon"""
    if sys.version_info[0] == 2:
        return _cocoa_seticon(path, image)
    args = ["osascript", "-e", APPLESCRIPT, path, image]
    runcmd.run(args)._raise()
Exemplo n.º 30
0
def add(name, url):
    """`git remote add name url`"""
    runcmd.run(["git", "remote", "add", name, url])._raise()
Exemplo n.º 31
0
def mdfind(args):
    """execute mdfind with arguments"""
    cmd = ["mdfind"] + list(args)
    return runcmd.run(cmd).exc().out
Exemplo n.º 32
0
def _rm_file_icon(path):
    args = ["xattr", "-d", "com.apple.ResourceFork", path]
    runcmd.run(args)
Exemplo n.º 33
0
def read():
    """return string with `hwmonitor` output"""
    return runcmd.run([BIN])._raise().out
Exemplo n.º 34
0
def _run(args):
    return runcmd.run(["google-chrome"] + list(args))._raise().out
Exemplo n.º 35
0
def setup_jenkins_as_memrise():
    setup_known_hosts()
    rc.run(["git", "clone", "[email protected]:Memrise/jenkins.git"], cwd=opath.expanduser("~"))