"""
return self.complete_filenames(text, line, begidx, endidx)
+ class ModeAction(argparse.Action):
+ def __init__(self, option_strings, dest, nargs=None, **kwargs):
+ if nargs is not None and nargs is not '?':
+ raise ValueError("more than one modes not allowed")
+ super().__init__(option_strings, dest, **kwargs)
+
+ def __call__(self, parser, namespace, values, option_string=None):
+ o_mode = 0
+ try:
+ o_mode = int(values, base=8)
+ except ValueError as e:
+ parser.error("invalid mode: %s\n"
+ "mode must be a numeric octal literal." % values)
+
+ if o_mode < 0:
+ parser.error("invalid mode: %s\n"
+ "mode cannot be negative." % values)
+ if o_mode > 0o777:
+ parser.error("invalid mode: %s\n"
+ "mode cannot be greater than octal 0777" % values)
+ setattr(namespace, self.dest, values)
+
+
mkdir_parser = argparse.ArgumentParser(
description='Create the directory(ies), if they do not already exist.')
mkdir_parser.add_argument('dirs', type=str,
help='Name of new_directory.',
nargs='+')
mkdir_parser.add_argument('-m', '--mode', type=str,
- action='store',
+ action=ModeAction,
help='Sets the access mode for the new directory.')
mkdir_parser.add_argument('-p', '--parent', action='store_true',
help='Create parent directories as necessary. \
if args.parent:
cephfs.mkdirs(path, permission)
else:
- cephfs.mkdir(path, permission)
+ try:
+ cephfs.mkdir(path, permission)
+ except:
+ self.poutput("directory missing in the path; "
+ "you may want to pass the -p argument")
+ return
+
def complete_put(self, text, line, begidx, endidx):
"""