Repository: spyder-ide/spyder

Issue:
Error when reporting inotify message
## Problem Description

SpyderIDE freezes on startup and stops responding

### What I've done
Running SpyderIDE with `--debug` flag shown me a reason:

```
2019-11-09 15:18:46,085 [DEBUG] [urllib3.connectionpool] -> http://127.0.0.1:46624 "POST /clientapi/editor/event HTTP/1.1" 200 0
inotify_add_watch(/home/kai/Projects/solbeg/papi-aiohttp) failed: (No space left on device)
Traceback (most recent call last):
  File "/home/kai/Projects/spyder/git/spyder/spyder/plugins/projects/utils/watcher.py", line 100, in start
    self.observer.start()
  File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/api.py", line 255, in start
    emitter.start()
  File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/utils/__init__.py", line 110, in start
    self.on_thread_start()
  File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/inotify.py", line 121, in on_thread_start
    self._inotify = InotifyBuffer(path, self.watch.is_recursive)
  File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/inotify_buffer.py", line 35, in __init__
    self._inotify = Inotify(path, recursive)
  File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/inotify_c.py", line 199, in __init__
    self._add_dir_watch(path, recursive, event_mask)
  File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/inotify_c.py", line 380, in _add_dir_watch
    self._add_watch(path, mask)
  File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/inotify_c.py", line 401, in _add_watch
    Inotify._raise_error()
  File "/home/kai/Projects/spyder/git/venv/lib/python3.7/site-packages/watchdog/observers/inotify_c.py", line 413, in _raise_error
    raise OSError("inotify watch limit reached")
OSError: inotify watch limit reached

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/kai/Projects/spyder/git/spyder/spyder/app/mainwindow.py", line 3657, in main
    mainwindow = run_spyder(app, options, args)
  File "/home/kai/Projects/spyder/git/spyder/spyder/app/mainwindow.py", line 3508, in run_spyder
    main.post_visible_setup()
  File "/home/kai/Projects/spyder/git/spyder/spyder/app/mainwindow.py", line 1416, in post_visible_setup
    self.projects.reopen_last_project()
  File "/home/kai/Projects/spyder/git/spyder/spyder/plugins/projects/plugin.py", line 404, in reopen_last_project
    save_previous_files=False)
  File "/home/kai/Projects/spyder/git/spyder/spyder/plugins/projects/plugin.py", line 322, in open_project
    self.watcher.start(path)
  File "/home/kai/Projects/spyder/git/spyder/spyder/plugins/projects/utils/watcher.py", line 102, in start
    if u'inotify' in e:
TypeError: argument of type 'OSError' is not iterable
```

So, I got that root of problem: inotify watch limit reached
This exception is a reason of the second exception
Running `sudo sysctl fs.inotify.max_user_watches=524288` solved it both

In my oppinion the most difficult thing for me was clean stdout/stderr. After a week trying to use another IDE I  guessed to run spyder with `--help` and then `--debug` flags


Discussion:

Resolving patch:
diff --git a/spyder/plugins/projects/utils/watcher.py b/spyder/plugins/projects/utils/watcher.py
--- a/spyder/plugins/projects/utils/watcher.py
+++ b/spyder/plugins/projects/utils/watcher.py
@@ -18,6 +18,7 @@
 
 # Local imports
 from spyder.config.base import _
+from spyder.py3compat import to_text_string
 
 logger = logging.getLogger(__name__)
 
@@ -99,7 +100,7 @@ def start(self, workspace_folder):
                 self.event_handler, workspace_folder, recursive=True)
             self.observer.start()
         except OSError as e:
-            if u'inotify' in e:
+            if u'inotify' in to_text_string(e):
                 QMessageBox.warning(
                     self.parent(),
                     "Spyder",


Test patch: