

def star_get(cluster, logdir, cmdline, *args):
    'Get a file or files from all enabled hosts'
    save_res = cluster.last_result
    save_mode = cluster.output_mode
    cluster.output_mode = 'off'
    dest = os.path.join(logdir, 'files')
    print(('Collecting files into %s' % os.path.abspath(dest)))
    for filename in args:
        print(('Getting %s...' % filename))
        namepart = os.path.split(filename)[1]
        res = cluster.run_command(('cat %s' % filename))
        for (host, job) in res.items():
            result = job.result
            if (job.completed and (f.return_code == 0)):
                if (not os.path.isdir(os.path.join(dest, str(host)))):
                    os.makedirs(os.path.join(dest, str(host)))
                with open(os.path.join(dest, str(host), namepart), 'wb') as f:
                    f.write(result.stdout)
    cluster.output_mode = save_mode
    cluster.last_result = save_res

dataset/ETHPy150Open radssh/radssh/radssh/star_commands.py star_get/VarMisuse@137/192 `result`->`f`