Pywintypes.error: (32, ошибка GetFileAttributesEx при использовании FileChooser Kivy, Python 3.12, Windows 10, kivy 2.3.Python

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Pywintypes.error: (32, ошибка GetFileAttributesEx при использовании FileChooser Kivy, Python 3.12, Windows 10, kivy 2.3.

Сообщение Anonymous »

Использование Kivy 2.3.0, Python 3.12 на компьютере с Windows 10. При запуске приложения я получаю такие сообщения об ошибках (все они приведены ниже):
[ERROR ] unable to access to
Traceback (most recent call last):
File "C:\Git\......\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')

Я считаю, что это связано с FileCooser. Он обращается к системным файлам, с которыми не может справиться, прежде чем сработает фильтрация этих файлов. В моем файле kv, в FileChooserListView: у меня есть следующие настройки:
FileChooserListView:
id: filechooser
filters: root.filters
filter_dirs: root.filter_dirs # Bind the filter function for directories
filter_func: root.filter_files # Bind the filter function here
dirselect: root.dirselect
multiselect: False
show_hidden: False # Hide hidden and system files
BoxLayout:

И в этом приложении у меня настроена фильтрация файлов и каталогов. Но я не вижу, чтобы к ним обращались, поскольку помещаю в них операторы печати.
class FileChooserScreen(Screen):
filters = ObjectProperty(['*'])
dirselect = BooleanProperty(False)
file_type = None
last_path = StringProperty("")

def filter_files(self, folder, filename):
print(f"filter_files called for: {filename}")
"""Custom filter to exclude specific system files and handle permission errors."""
system_files = ['hiberfil.sys', 'pagefile.sys', 'swapfile.sys', 'DumpStack.log.tmp']
# system_files = os.listdir(folder)

try:
# Exclude system files based on their name
if filename in system_files:
print(f"Excluding system file: {filename}")
return False
return True # Allow the file if it's not a system file
except (OSError, PermissionError) as e:
# Handle permission errors gracefully and skip the file
print(f"Error accessing {filename}: {e}")
return False # Exclude files that raise access errors

def filter_dirs(self, folder, filename):
"""Filter out system directories and handle permission errors."""
system_dirs = ['$Recycle.Bin', 'System Volume Information', 'Config.Msi', 'Windows', 'Program Files',
'Program Files (x86)']

try:
if filename in system_dirs or filename.startswith('$') or filename.startswith('.'):
print(f"Excluding system file: {filename}")
return False # Exclude system directories and hidden ones
return True # Include other directories
except (OSError, PermissionError) as e:
print(f"Error accessing directory {filename}: {e}")
return False # Exclude directories that raise access errors

Я позвонил им в on_entry:
def on_enter(self):
# Set up filters for files and directories when the screen is entered
# print("Setting filters in on_enter for FileChooser")
# self.ids.filechooser.filter_func = self.filter_files
# self.ids.filechooser.filter_dirs = self.filter_dirs

# Set the last path or default to Documents folder
main_screen = self.manager.get_screen('main')
file_type_last_path = main_screen.last_paths.get(self.file_type, "")
self.ids.filechooser.path = file_type_last_path if file_type_last_path else get_documents_path()

И я даже пытался позвонить им гораздо раньше в приложении и увидел распечатку своего сообщения о том, что фильтры установлены, но безуспешно, те же проблемы. Я закомментировал on_start ниже, но попробовал и этот код.
class ImageDownloaderApp(App):
def build(self):
sm = ScreenManager()
sm.add_widget(MainScreen(name='main'))
sm.add_widget(HelpScreen(name='help'))
sm.add_widget(FileChooserScreen(name='filechooser'))
sm.add_widget(RunningScreen(name='running'))
return sm

def on_start(self):
# Access the filechooser screen and set filters after the app starts
file_chooser_screen = self.root.get_screen('filechooser')

# Set the filters for files and directories
file_chooser_screen.ids.filechooser.filter_func = file_chooser_screen.filter_files
file_chooser_screen.ids.filechooser.filter_dirs = file_chooser_screen.filter_dirs

# Optionally set default filters for file types (e.g., CSV, PDF)
# file_chooser_screen.ids.filechooser.filters = ['*.csv', '*.pdf']
file_chooser_screen.ids.filechooser.show_hidden = False # Hide hidden files by default
print("Filters and custom file filtering set after startup!")

# Load the KV file (this should stay as it is)
Builder.load_file('image_downloader.kv')

if __name__ == '__main__':
ImageDownloaderApp().run()

Вот ошибки:
[INFO ] [Logger ] Record log in C:\Users\.....\.kivy\logs\kivy_24-10-10_20.txt
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.4.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.1
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.7.0
[INFO ] [Kivy ] v2.3.0
[INFO ] [Kivy ] Installed at "C:\Git\.....\.venv\Lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Git\.....\.venv\Scripts\python.exe"
[INFO ] [Logger ] Purge log fired. Processing...
[INFO ] [Logger ] Purge finished!
[INFO ] [Factory ] 195 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used
[INFO ] [GL ] OpenGL version
[INFO ] [GL ] OpenGL vendor
[INFO ] [GL ] OpenGL renderer
[INFO ] [GL ] OpenGL parsed version: 4, 6
[INFO ] [GL ] Shading version
[INFO ] [GL ] Texture max size
[INFO ] [GL ] Texture max units
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [GL ] NPOT texture support is available
[INFO ] [Base ] Start application main loop
[ERROR ] unable to access to
Traceback (most recent call last):
File "C:\Git\......\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] unable to access to
Traceback (most recent call last):
File "C:\Git\.....\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] unable to access to
Traceback (most recent call last):
File "C:\Git\......\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] unable to access to
Traceback (most recent call last):
File "C:\Git\.......\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] unable to access to
Traceback (most recent call last):
File "C:\Git\......\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] unable to access to
Traceback (most recent call last):
File "C:\Git\........\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] unable to access to
Traceback (most recent call last):
File "C:\Git\......\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] unable to access to
Traceback (most recent call last):
File "C:\Git\.......\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] [unable to access to
Traceback (most recent call last):
File "C:\Git\......\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] [unable to access to
Traceback (most recent call last):
File "C:\Git\......\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] [unable to access to
Traceback (most recent call last):
File "C:\Git\.......\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] [unable to access to
Traceback (most recent call last):
File "C:\Git\.......\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] [unable to access to
Traceback (most recent call last):
File "C:\Git\........\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] [unable to access to
Traceback (most recent call last):
File "C:\Git\.......\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] [unable to access to
Traceback (most recent call last):
File "C:\Git\........\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[ERROR ] [unable to access to
Traceback (most recent call last):
File "C:\Git\.......\.venv\Lib\site-packages\kivy\uix\filechooser.py", line 180, in is_hidden
return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.error: (32, 'GetFileAttributesEx', 'The process cannot access the file because it is being used by another process.')
[INFO ] [WindowSDL ] Window is now on display 1
[INFO ] [WindowSDL ] Window is now on display 0


Подробнее здесь: https://stackoverflow.com/questions/790 ... hooser-pyt
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Pywintypes.error: (32, ошибка GetFileAttributesEx при использовании FileChooser Kivy, Python 3.12, Windows 10, kivy 2.30
    Anonymous » » в форуме Python
    0 Ответы
    38 Просмотры
    Последнее сообщение Anonymous
  • Pywintypes.error: (32, ошибка GetFileAttributesEx при использовании FileChooser Kivy, Python 3.12, Windows 10, kivy 2.3.
    Anonymous » » в форуме Python
    0 Ответы
    41 Просмотры
    Последнее сообщение Anonymous
  • Plyer FileChooser отлично работает над Windows, но не работает на Android
    Anonymous » » в форуме Python
    0 Ответы
    18 Просмотры
    Последнее сообщение Anonymous
  • Plyer FileChooser отлично работает над Windows, но не работает на Android
    Anonymous » » в форуме Android
    0 Ответы
    14 Просмотры
    Последнее сообщение Anonymous
  • ## React Native Document Ficker Error Error Error: `GuardEdresultAsynctask` не найдена
    Anonymous » » в форуме Android
    0 Ответы
    20 Просмотры
    Последнее сообщение Anonymous

Вернуться в «Python»