diff options
-rw-r--r-- | util.py | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -3,8 +3,10 @@ import os import yaml -def write_default_config(disk, global_params): - home = '/home/test' +def write_default_config(disk, global_params, user='test', uid=1001, gid=None): + if gid is None: + gid = uid + home = '/home/{}'.format(user) params_file = os.path.join(home, '.kpov_params.yaml') default_params = {} for k in [ @@ -14,13 +16,13 @@ def write_default_config(disk, global_params): 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) + disk.chown(uid, gid, params_file) mydir = os.path.dirname(os.path.abspath(__file__)) # write testing script and helper for f in ['test_task.py', 'kpov_util.py']: src = os.path.join(mydir, f) - dst = os.path.join('/home/test', f) + dst = os.path.join(home, f) disk.write(dst, open(src).read()) disk.chmod(0o755, dst) - disk.copy_in(os.path.join(mydir, 'random_data'), '/home/test') + disk.copy_in(os.path.join(mydir, 'random_data'), home) |