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