for path in paths:
values = []
items = []
- if path.count(b'*') > 0:
- all_items = get_all_possible_paths(path)
- if len(all_items) == 0:
- continue
- path = all_items[0].rsplit(b'/', 1)[0]
- if path == b'':
- path = b'/'
- dirs = []
- for i in all_items:
- for item in ls(path):
- d_name = item.d_name
- if os.path.basename(i) == d_name:
- if item.is_dir():
- dirs.append(os.path.join(path, d_name))
- else:
- items.append(item)
- if dirs:
- paths.extend(dirs)
- else:
- poutput(path.decode('utf-8'), end=':\n')
- items = sorted(items, key=lambda item: item.d_name)
- else:
- if path != b'' and path != cephfs.getcwd() and len(paths) > 1:
- poutput(path.decode('utf-8'), end=':\n')
- items = sorted(ls(path),
- key=lambda item: item.d_name)
- if not args.all:
- items = [i for i in items if not i.d_name.startswith(b'.')]
-
- if args.S:
- items = sorted(items, key=lambda item: cephfs.stat(
- path + b'/' + item.d_name, follow_symlink=(not item.is_symbol_file())).st_size)
-
- if args.reverse:
- items = reversed(items)
- for item in items:
- filepath = item.d_name
- is_dir = item.is_dir()
- is_sym_lnk = item.is_symbol_file()
-
- if args.long and args.H:
- print_long(os.path.join(cephfs.getcwd(), path, filepath),
- is_dir, is_sym_lnk, True)
- elif args.long:
- print_long(os.path.join(cephfs.getcwd(), path, filepath),
- is_dir, is_sym_lnk, False)
- elif is_sym_lnk or is_dir:
- values.append(style_listing(filepath.decode('utf-8'), is_dir, is_sym_lnk))
+ try:
+ if path.count(b'*') > 0:
+ all_items = get_all_possible_paths(path)
+ if len(all_items) == 0:
+ continue
+ path = all_items[0].rsplit(b'/', 1)[0]
+ if path == b'':
+ path = b'/'
+ dirs = []
+ for i in all_items:
+ for item in ls(path):
+ d_name = item.d_name
+ if os.path.basename(i) == d_name:
+ if item.is_dir():
+ dirs.append(os.path.join(path, d_name))
+ else:
+ items.append(item)
+ if dirs:
+ paths.extend(dirs)
+ else:
+ poutput(path.decode('utf-8'), end=':\n')
+ items = sorted(items, key=lambda item: item.d_name)
else:
- values.append(filepath)
- if not args.long:
- print_list(values, shutil.get_terminal_size().columns)
- if path != paths[-1]:
- poutput('')
+ if path != b'' and path != cephfs.getcwd() and len(paths) > 1:
+ poutput(path.decode('utf-8'), end=':\n')
+ items = sorted(ls(path), key=lambda item: item.d_name)
+ if not args.all:
+ items = [i for i in items if not i.d_name.startswith(b'.')]
+ if args.S:
+ items = sorted(items, key=lambda item: cephfs.stat(
+ path + b'/' + item.d_name, follow_symlink=(
+ not item.is_symbol_file())).st_size)
+ if args.reverse:
+ items = reversed(items)
+ for item in items:
+ filepath = item.d_name
+ is_dir = item.is_dir()
+ is_sym_lnk = item.is_symbol_file()
+ try:
+ if args.long and args.H:
+ print_long(os.path.join(cephfs.getcwd(), path, filepath), is_dir,
+ is_sym_lnk, True)
+ elif args.long:
+ print_long(os.path.join(cephfs.getcwd(), path, filepath), is_dir,
+ is_sym_lnk, False)
+ elif is_sym_lnk or is_dir:
+ values.append(style_listing(filepath.decode('utf-8'), is_dir,
+ is_sym_lnk))
+ else:
+ values.append(filepath)
+ except libcephfs.Error as e:
+ set_exit_code_msg(msg=e)
+ if not args.long:
+ print_list(values, shutil.get_terminal_size().columns)
+ if path != paths[-1]:
+ poutput('')
+ except libcephfs.Error as e:
+ set_exit_code_msg(msg=e)
def complete_rmdir(self, text, line, begidx, endidx):
"""