import os import yaml def write_default_config(disk, global_params): home = '/home/tester' params_file = os.path.join(home, '.kpov_params.yaml') default_params = {} for k in [ 'task_name', 'username', 'task_url']: if k in global_params: default_params[k] = global_params[k] disk.write(params_file, yaml.dump(default_params)) disk.chown(1001, 1001, params_file) # write testing script and helper for f in ['test_task.py', 'kpov_util.py']: src = os.path.join(os.path.dirname(os.path.abspath(__file__)), f) dst = os.path.join('/home/tester', f) disk.write(dst, open(src).read()) disk.chown(1001, 1001, dst)