Esempio n. 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
Esempio n. 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
Esempio n. 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)
Esempio n. 4
0
def _delete_proc_lock(run):
    try:
        os.remove(run.guild_path("LOCK"))
    except OSError:
        pass
Esempio n. 5
0
def _write_proc_lock(proc, run):
    with open(run.guild_path("LOCK"), "w") as f:
        f.write(str(proc.pid))
Esempio n. 6
0
File: op.py Progetto: yuanbw/guildai
def _delete_staged(run):
    util.ensure_deleted(run.guild_path("STAGED"))
Esempio n. 7
0
File: op.py Progetto: yuanbw/guildai
def _write_staged(run):
    open(run.guild_path("STAGED"), "w").close()
Esempio n. 8
0
File: op.py Progetto: yuanbw/guildai
def delete_pending(run):
    util.ensure_deleted(run.guild_path("PENDING"))
Esempio n. 9
0
File: op.py Progetto: yuanbw/guildai
def write_pending(run):
    open(run.guild_path("PENDING"), "w").close()
Esempio n. 10
0
def delete_pending(run):
    try:
        os.remove(run.guild_path("PENDING"))
    except OSError:
        pass