juftin / browsr

🗂️ a pleasant file explorer in your terminal supporting all filesystems
http://juftin.com/browsr/
MIT License
225 stars 13 forks source link

Error when opening file on windows (will windows be supported?) #13

Closed Zakaria-ouertani closed 1 year ago

Zakaria-ouertani commented 1 year ago

When I try opning a file i get this error

╭──────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────╮
│ C:\Users\Administrator\AppData\Local\Programs\Python\Python3\Lib\pathlib.py:1020 in owner                 │
│                                                                                                           │
│   1017 │   │   Return the login name of the file owner.                                                   │
│   1018 │   │   """                                                                                        │
│   1019 │   │   try:                                                                                       │
│ ❱ 1020 │   │   │   import pwd                                                                             │
│   1021 │   │   │   return pwd.getpwuid(self.stat().st_uid).pw_name                                        │
│   1022 │   │   except ImportError:                                                                        │
│   1023 │   │   │   raise NotImplementedError("Path.owner() is unsupported on this system")                │
│                                                                                                           │
│ ╭────────────────────────────────────────────── locals ──────────────────────────────────────────────╮    │
│ │ self = WindowsPath('C:/Users/Administrator/Documents/Python/Cryptage_matrice/Cryptage_matrice.py') │    │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯    │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ModuleNotFoundError: No module named 'pwd'

During handling of the above exception, another exception occurred:

╭──────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────╮
│ C:\Users\Administrator\.local\pipx\venvs\browsr\Lib\site-packages\browsr\browsr.py:282 in                 │
│ handle_file_selected                                                                                      │
│                                                                                                           │
│   279 │   │   Called when the user click a file in the directory tree.                                    │
│   280 │   │   """                                                                                         │
│   281 │   │   self.selected_file_path = upath.UPath(message.path)                                         │
│ ❱ 282 │   │   file_info = get_file_info(file_path=self.selected_file_path)                                │
│   283 │   │   self.render_code_page(file_path=upath.UPath(message.path))                                  │
│   284 │   │   self.file_information.file_info = file_info                                                 │
│   285                                                                                                     │
│                                                                                                           │
│ ╭──────────────────────────────── locals ────────────────────────────────╮                                │
│ │ message = FileSelected()                                               │                                │
│ │    self = Browsr(title='browsr', classes={'-dark-mode', '-show-tree'}) │                                │
│ ╰────────────────────────────────────────────────────────────────────────╯                                │
│                                                                                                           │
│ C:\Users\Administrator\.local\pipx\venvs\browsr\Lib\site-packages\browsr\_utils.py:114 in get_file_info   │
│                                                                                                           │
│   111 │   │   │   stat=stat,                                                                              │
│   112 │   │   │   is_local=True,                                                                          │
│   113 │   │   │   is_file=is_file,                                                                        │
│ ❱ 114 │   │   │   owner=file_path.owner(),                                                                │
│   115 │   │   │   group=file_path.group(),                                                                │
│   116 │   │   │   is_cloudpath=is_cloudpath,                                                              │
│   117 │   │   )                                                                                           │
│                                                                                                           │
│ ╭─────────────────────────────────────────────── locals ────────────────────────────────────────────────╮ │
│ │     file_path = WindowsPath('C:/Users/Administrator/Documents/Python/Cryptage_matrice/Cryptage_matri… │ │
│ │  is_cloudpath = False                                                                                 │ │
│ │       is_file = True                                                                                  │ │
│ │ last_modified = datetime.datetime(2022, 11, 20, 22, 36, 33, 670253)                                   │ │
│ │          stat = os.stat_result(st_mode=33206, st_ino=51509920738159180, st_dev=1008994623,            │ │
│ │                 st_nlink=1, st_uid=0, st_gid=0, st_size=2444, st_atime=1684684351,                    │ │
│ │                 st_mtime=1668980193, st_ctime=1668980193)                                             │ │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                           │
│ C:\Users\Administrator\AppData\Local\Programs\Python\Python3\Lib\pathlib.py:1023 in owner                 │
│                                                                                                           │
│   1020 │   │   │   import pwd                                                                             │
│   1021 │   │   │   return pwd.getpwuid(self.stat().st_uid).pw_name                                        │
│   1022 │   │   except ImportError:                                                                        │
│ ❱ 1023 │   │   │   raise NotImplementedError("Path.owner() is unsupported on this system")                │
│   1024 │                                                                                                  │
│   1025 │   def group(self):                                                                               │
│   1026 │   │   """                                                                                        │
│                                                                                                           │
│ ╭────────────────────────────────────────────── locals ──────────────────────────────────────────────╮    │
│ │ self = WindowsPath('C:/Users/Administrator/Documents/Python/Cryptage_matrice/Cryptage_matrice.py') │    │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯    │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
NotImplementedError: Path.owner() is unsupported on this system

image image

juftin commented 1 year ago

Thank you for filing this! Windows will definitely be supported.

Apparently there are some properties of files that exist on Mac/Linux that don't exist on windows. This should be an easy fix, I'll follow up shortly when the resolution is published.

Zakaria-ouertani commented 1 year ago

Thank you for filing this! Windows will definitely be supported.

Apparently there are some properties of files that exist on Mac/Linux that don't exist on windows. This should be an easy fix, I'll follow up shortly when the resolution is published.

Ok thanks

juftin commented 1 year ago

... and there it is @Zakaria-ouertani. browsr v1.10.5 was just released to PyPI. Upgrade browsr and let me know if this works for you

Zakaria-ouertani commented 1 year ago

I Tried it now But new errors appear that are related to textual I'll open in a new issue to keep things separate.