Before this line you need to check that the directory exists, something like
```
if os.path.exists(theme.app_dir)
   ...
else
   os.makedirs(theme.app_dir)
```