mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-03-12 23:33:53 +00:00
ask forgiveness not permission
This commit is contained in:
parent
938cc5616e
commit
72f2e25f86
@ -75,13 +75,14 @@ def create(ctx):
|
|||||||
fp = None
|
fp = None
|
||||||
if config_location != '-':
|
if config_location != '-':
|
||||||
fp = FilePath(config_location)
|
fp = FilePath(config_location)
|
||||||
if fp.exists():
|
|
||||||
raise click.ClickException(
|
|
||||||
"The directory '{}' already exists.".format(config_location)
|
|
||||||
)
|
|
||||||
|
|
||||||
gm = create_grid_manager()
|
gm = create_grid_manager()
|
||||||
save_grid_manager(fp, gm)
|
try:
|
||||||
|
save_grid_manager(fp, gm)
|
||||||
|
except OSError as e:
|
||||||
|
raise click.ClickException(
|
||||||
|
"Can't create '{}': {}".format(config_location, e)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@grid_manager.command()
|
@grid_manager.command()
|
||||||
|
@ -269,7 +269,8 @@ def save_grid_manager(file_path, grid_manager):
|
|||||||
if file_path is None:
|
if file_path is None:
|
||||||
print("{}\n".format(data))
|
print("{}\n".format(data))
|
||||||
else:
|
else:
|
||||||
fileutil.make_dirs(file_path.path, mode=0o700)
|
file_path.makedirs()
|
||||||
|
file_path.chmod(0o700)
|
||||||
with file_path.child("config.json").open("w") as f:
|
with file_path.child("config.json").open("w") as f:
|
||||||
f.write("{}\n".format(data))
|
f.write("{}\n".format(data))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user