Repository: mkdocs/mkdocs

Issue:
NoneType object is not callable
I'm not sure if this is my own stupidity, related to #283, or something I've ended up doing myself by accident.

I'm working on developing a mkdocs theme, and `mkdocs build` and `mkdocs build --clean` both run without any issues.

However, if I try and `mkdocs serve` then I get hit by an error.

```
Traceback (most recent call last):
  File "/home/pi/.virtualenvs/face/bin/mkdocs", line 9, in <module>
    load_entry_point('mkdocs==0.11.1', 'console_scripts', 'mkdocs')()
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/mkdocs/main.py", line 60, in run_main
    main(cmd, args=sys.argv[2:], options=dict(opts))
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/mkdocs/main.py", line 33, in main
    serve(config, options=options)
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/mkdocs/serve.py", line 96, in serve
    observer.start()
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/observers/api.py", line 255, in start
    emitter.start()
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/utils/__init__.py", line 111, in start
    self.on_thread_start()
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/observers/polling.py", line 77, in on_thread_start
    self._snapshot = self._take_snapshot()
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/observers/polling.py", line 74, in <lambda>
    self.watch.path, self.watch.is_recursive, stat=stat, listdir=listdir)
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/utils/dirsnapshot.py", line 207, in __init__
    st = stat(path)
OSError: [Errno 2] No such file or directory: '/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/mkdocs/themes/face'
Exception in thread Thread-3 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/observers/api.py", line 146, in run
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/observers/polling.py", line 91, in queue_events
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/observers/polling.py", line 74, in <lambda>
<type 'exceptions.TypeError'>: 'NoneType' object is not callable
```

My `mkdocs.yml` file is simple, and I don't think it is the actual cause, but it might be in my own inept way:

```
site_name: Face Theme
theme_dir: face
theme: face
use_directory_urls: true
repo_url: https://bitbucket.org/shakna-israel/face
dev_addr: 0.0.0.0:8000
```



Discussion:
Yup, that looks like a bug and not your fault. I'll need to take a look further to see what is up.

Sorry, should have included a few other things:

Python is 2.7.3
Pip is 6.0.8

And pip freeze gives:

argh==0.26.1
ghp-import==0.4.1
Jinja2==2.7.3
Markdown==2.4.1
MarkupSafe==0.23
mkdocs==0.11.1
pathtools==0.1.2
PyYAML==3.11
watchdog==0.8.3

This is all running on a Raspberry Pi B+, running Raspbian Debian 7.8 (wheezy)

Thanks - travelling at the moment but should get to this in a few days.

I think something funky is happening when mkdocs tries to split the host and port at the colon([serve.py, Line 107](https://github.com/mkdocs/mkdocs/blob/master/mkdocs/serve.py#L107)).

With some experimentation I got this:

```
File "/home/pi/.virtualenvs/necro/local/lib/python2.7/site-packages/mkdocs/serve.py", line 104, in serve
    host, port = config['dev_addr'].split(':', 1)
AttributeError: 'bool' object has no attribute 'split'
```

Unfortunately, I need mkdocs to serve out to a IP, and not the localhost, so looks like I'll be stuck building and serving for a while... Because I have no idea why `split` isn't working.

How did you resolve your previous error?

I can't see any way that dev_addr would become a boolean, have you changed the code at all? Can I see your latest config?

Seems that using mkvirtualenv meant that mkdocs looked for the "face" theme directory inside mkdocs own theme folder:

```
OSError: [Errno 2] No such file or directory: '/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/mkdocs/themes/face'
```

So I tried to isolate if that was the main error, by dropping the theme lines from my config, and specifying dev_addr from the commandline instead:

```
site_name: Face Theme
use_directory_urls: true
repo_url: https://bitbucket.org/shakna-israel/face
```

So, to run, I ran this command:

```
mkdocs serve --dev-addr 192.168.1.2:8000
```

And instead got this traceback:

```
Traceback (most recent call last):
  File "/home/pi/.virtualenvs/face/bin/mkdocs", line 9, in <module>
    load_entry_point('mkdocs==0.11.1', 'console_scripts', 'mkdocs')()
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/mkdocs/main.py", line 60, in run_main
    main(cmd, args=sys.argv[2:], options=dict(opts))
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/mkdocs/main.py", line 33, in main
    serve(config, options=options)
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/mkdocs/serve.py", line 104, in serve
    host, port = config['dev_addr'].split(':', 1)
AttributeError: 'bool' object has no attribute 'split'
Exception in thread Thread-3 (most likely raised during interpreter shutdown):Exception in thread Thread-4 (most likely raised during interpreter shutdown):Exception in thread Thread-1 (most likely raised during interpreter shutdown):Exception in thread Thread-2 (most likely raised during interpreter shutdown):



Traceback (most recent call last):Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner

  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/observers/api.py", line 146, in run
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/observers/api.py", line 146, in run

  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/observers/api.py", line 200, in run
  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/observers/api.py", line 146, in run  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/observers/polling.py", line 82, in queue_events
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'Empty'

  File "/usr/lib/python2.7/threading.py", line 404, in wait  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/observers/polling.py", line 82, in queue_events  File "/home/pi/.virtualenvs/face/local/lib/python2.7/site-packages/watchdog/observers/polling.py", line 82, in queue_events


  File "/usr/lib/python2.7/threading.py", line 404, in wait
  File "/usr/lib/python2.7/threading.py", line 404, in wait
  File "/usr/lib/python2.7/threading.py", line 259, in wait  File "/usr/lib/python2.7/threading.py", line 259, in wait

<type 'exceptions.TypeError'>: 'NoneType' object is not callable  File "/usr/lib/python2.7/threading.py", line 259, in wait
<type 'exceptions.TypeError'>: 'NoneType' object is not callable
<type 'exceptions.TypeError'>: 'NoneType' object is not callable
```

I believe `split` can return the boolean error if it's not working on a string.

I see, interesting. Thanks. This is an odd one, but I have an idea - will look into it.


Resolving patch:
diff --git a/mkdocs/serve.py b/mkdocs/serve.py
--- a/mkdocs/serve.py
+++ b/mkdocs/serve.py
@@ -94,6 +94,8 @@ def serve(config, options=None):
     observer = PollingObserver()
     observer.schedule(event_handler, config['docs_dir'], recursive=True)
     for theme_dir in config['theme_dir']:
+        if not os.path.exists(theme_dir):
+            continue
         observer.schedule(event_handler, theme_dir, recursive=True)
     observer.schedule(config_event_handler, '.')
     observer.start()


Test patch: