Beispiel #1
0
def _safe_guild_path(run, path, default):
    try:
        return run.guild_path(path)
    except TypeError:
        # Occurs for run proxies that don't support guild_path - punt
        # with generic descriptor. (TODO: implement explicit behavior
        # in run interface + proxy)
        return default
Beispiel #2
0
def iter_output(run):
    try:
        f = open(run.guild_path("output"), "r")
    except IOError as e:
        if e.errno != 2:
            raise
    else:
        with f:
            for line in f:
                yield line
Beispiel #3
0
def _apply_batch_desc(base_desc, run, seen_protos):
    import guild.run
    try:
        proto_dir = run.guild_path("proto")
    except TypeError:
        # Occurs for run proxies that don't support guild_path - punt
        # with generic descriptor. (TODO: implement explicit behavior
        # in run interface + proxy)
        proto_dir = ""
    if not os.path.exists(proto_dir):
        return base_desc
    if proto_dir in seen_protos:
        # We have a cycle - drop this proto_dir
        return base_desc
    proto_run = guild.run.Run("", proto_dir)
    proto_op_desc = format_op_desc(proto_run, seen_protos)
    parts = [proto_op_desc]
    if not base_desc.startswith("+"):
        parts.append("+")
    parts.append(base_desc)
    return "".join(parts)
Beispiel #4
0
def _delete_proc_lock(run):
    try:
        os.remove(run.guild_path("LOCK"))
    except OSError:
        pass
Beispiel #5
0
def _write_proc_lock(proc, run):
    with open(run.guild_path("LOCK"), "w") as f:
        f.write(str(proc.pid))
Beispiel #6
0
def _delete_staged(run):
    util.ensure_deleted(run.guild_path("STAGED"))
Beispiel #7
0
def _write_staged(run):
    open(run.guild_path("STAGED"), "w").close()
Beispiel #8
0
def delete_pending(run):
    util.ensure_deleted(run.guild_path("PENDING"))
Beispiel #9
0
def write_pending(run):
    open(run.guild_path("PENDING"), "w").close()
Beispiel #10
0
def delete_pending(run):
    try:
        os.remove(run.guild_path("PENDING"))
    except OSError:
        pass