comparison cagou/plugins/plugin_wid_file_sharing.py @ 213:423d462ea739

file sharing: catch OS errors while trying to list files on a local dir
author Goffi <goffi@goffi.org>
date Fri, 25 May 2018 15:10:37 +0200
parents 38b43ed18bb5
children 6a98d70a3a66
comparison
equal deleted inserted replaced
212:38b43ed18bb5 213:423d462ea739
388 self.header_input.hint_text = self.current_dir 388 self.header_input.hint_text = self.current_dir
389 389
390 if self.mode == MODE_LOCAL: 390 if self.mode == MODE_LOCAL:
391 filepath = os.path.join(self.local_dir, u'..') 391 filepath = os.path.join(self.local_dir, u'..')
392 self.layout.add_widget(LocalPathWidget(sharing_wid=self, filepath=filepath)) 392 self.layout.add_widget(LocalPathWidget(sharing_wid=self, filepath=filepath))
393 files = sorted(os.listdir(self.local_dir)) 393 try:
394 files = sorted(os.listdir(self.local_dir))
395 except OSError as e:
396 msg = _(u"can't list files in \"{local_dir}\": {msg}").format(
397 local_dir=self.local_dir,
398 msg=e)
399 G.host.addNote(
400 _(u"shared folder error"),
401 msg,
402 level=C.XMLUI_DATA_LVL_WARNING)
403 self.local_dir = expanduser(u'~')
404 return
394 for f in files: 405 for f in files:
395 filepath = os.path.join(self.local_dir, f) 406 filepath = os.path.join(self.local_dir, f)
396 self.layout.add_widget(LocalPathWidget(sharing_wid=self, filepath=filepath)) 407 self.layout.add_widget(LocalPathWidget(sharing_wid=self, filepath=filepath))
397 elif self.mode == MODE_VIEW: 408 elif self.mode == MODE_VIEW:
398 if not self.remote_entity: 409 if not self.remote_entity: