Errno 13 Permission denied when trying to run wkhtmltopdf - django

There are similar questions but my set of configuration is not the
same.I downloaded the wkhtmltopdf from wkhtmltopdf.org, placed on the
project folder, i cant figure out why im still getting access denied.
Trying to point django to run the wkhtmltopdf in order to generate a pdf file.
Running NGINX with UNICORN
Using SUPERVISOR
Ubuntu 16
in my unicorn_supervisor log i got:
Internal Server Error: /invoice/1/pdf
Traceback (most recent call last):emphasized text
File "/home/instantuser/app/lib/python3.5/site-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
File "/home/instantuser/app/lib/python3.5/site-packages/django/core/handlers/base.py", line 217, in _get_respons e
response = self.process_exception_by_middleware(e, request)
File "/home/instantuser/app/lib/python3.5/site-packages/django/core/handlers/base.py", line 215, in _get_respons e
response = response.render()
File "/home/instantuser/app/lib/python3.5/site-packages/django/template/response.py", line 109, in render
self.content = self.rendered_content
File "/home/instantuser/app/lib/python3.5/site-packages/wkhtmltopdf/views.py", line 78, in rendered_content
cmd_options=cmd_options
File "/home/instantuser/app/lib/python3.5/site-packages/wkhtmltopdf/utils.py", line 186, in render_pdf_from_temp late
cmd_options=cmd_options)
File "/home/instantuser/app/lib/python3.5/site-packages/wkhtmltopdf/utils.py", line 124, in convert_to_pdf
return wkhtmltopdf(pages=filename, **cmd_options)
File "/home/instantuser/app/lib/python3.5/site-packages/wkhtmltopdf/utils.py", line 110, in wkhtmltopdf
return check_output(ck_args, **ck_kwargs)
File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
**kwargs).stdout
File "/usr/lib/python3.5/subprocess.py", line 693, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied
The wkhtmltopdf file:
-rwxr-xr-x 1 instantuser instantuser 39804584 Nov 22 10:11 wkhtmltopdf
Unicorn process:
instant+ 2949 0.1 0.5 70344 23216 ? S 18:51 0:00 /home/instantuser/app/bin/python3 ../bin/gunicorn instanthst.wsgi:application --name instanthst --workers 3 --user=instantuser --group=instantuser --bind=unix:/home/instantuser/app/instanthst/run/gunicorn.sock --log-level=debug --log-file=-
instant+ 2954 0.3 1.2 171712 51992 ? S 18:51 0:00 /home/instantuser/app/bin/python3 ../bin/gunicorn instanthst.wsgi:application --name instanthst --workers 3 --user=instantuser --group=instantuser --bind=unix:/home/instantuser/app/instanthst/run/gunicorn.sock --log-level=debug --log-file=-
instant+ 2955 0.3 1.2 171704 51936 ? S 18:51 0:00 /home/instantuser/app/bin/python3 ../bin/gunicorn instanthst.wsgi:application --name instanthst --workers 3 --user=instantuser --group=instantuser --bind=unix:/home/instantuser/app/instanthst/run/gunicorn.sock --log-level=debug --log-file=-
instant+ 2957 0.3 1.2 171568 51960 ? S 18:51 0:00 /home/instantuser/app/bin/python3 ../bin/gunicorn instanthst.wsgi:application --name instanthst --workers 3 --user=instantuser --group=instantuser --bind=unix:/home/instantuser/app/instanthst/run/gunicorn.sock --log-level=debug --log-file=-
ubuntu 2970 0.0 0.0 12944 964 pts/0 S+ 18:53 0:00 grep --color=auto unicorn
NGINX Process
root 3006 0.0 0.0 125112 1460 ? Ss 18:55 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 3007 0.0 0.0 125436 3108 ? S 18:55 0:00 nginx: worker process
www-data 3008 0.0 0.1 125712 5060 ? S 18:55 0:00 nginx: worker process
ubuntu 3104 0.0 0.0 12944 940 pts/0 S+ 19:09 0:00 grep --color=auto nginx
Why am I getting access denied since the wkhtmltopdf file owner is the same running unicorn?
I'm able to run the command in the terminal but python cant run it. why?

I solve this problem by creating an shell script file to call the wkhtmltopdf.
wkhtmltopdf.sh
#!/bin/sh
xvfb-run -a -s "-screen 0 1024x768x16" wkhtmltopdf $*
Thank you all for the help.

Just use
sudo su
or
sudo command
That will run it as superuser and bypass all permissions. I the case that you Don't have access to superuser, I am not sure. This sometimes happens to me when I am trying to run something that is not supposed to be ran. Though I use ubuntu 14.04, so I don't understand this as well as others might.

Related

Dockerizing Django application: ModuleNotFoundError: No module named 'X"

I've been trying to follow this guide to Dockerize a project:
Deploy and Run Django in Dokcer Container
This is the base file structure:
WFMBCM
|-WFMBCM
| |-__init__.py
| |-__pycache__
| |-setting.py
| |-url.py
| |-wsgi.py
|
|-WFMBCM_App
|-WFMBCM_db
|-manage.py
|-Dockerfile
|-requirements.txt
|-runWFMBCM.sh
Dockerfile:
FROM python:3.7
ADD WFMBCM /usr/src/app
ADD WFMBCM_App /usr/src/app
ADD WFMBCM_db /usr/src/app
ADD manage.py /usr/src/app
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 8000
CMD exec gunicorn wfmbcm.wsgi:application --bind 0.0.0.0:8000 --workers 3
requirements.txt:
Django==2.2.1
gunicorn==19.9.0
runWFMBCM.sh:
cd /home/admin/WFMBCM
echo -e "\033[0;34mGo to WFMBCM directory.\n \033[0;37m"
echo -e "\033[0;34mRemove old WFMBCM container\n \033[0;37m"
docker rm -v wfmbcm_container
echo -e "\033[0;34m\nBuild WFMBCM Docker image.\n \033[0;37m"
sudo docker build -t wfmbcm .
echo -e "\033[0;34m\nRun WFMBCM Docker image.\n \033[0;37m"
sudo docker run --name wfmbcm_container -p 8000:8000 -i -t wfmbcm
echo -e "\033[0;34m\n\nWFMBCM run-script ended!.\n \033[0;37m"
When I run runWFMBCM.sh I get the following output:
Go to WFMBCM directory.
Remove old WFMBCM container
Error response from daemon: No such container: wfmbcm_container
Build WFMBCM Docker image.
Sending build context to Docker daemon 265.2kB
Step 1/10 : FROM python:3.7
---> cc971a68c3e4
Step 2/10 : ADD WFMBCM /usr/src/app
---> Using cache
---> 302346d017e2
Step 3/10 : ADD WFMBCM_App /usr/src/app
---> Using cache
---> 18bc8eb69946
Step 4/10 : ADD WFMBCM_db /usr/src/app
---> Using cache
---> 0835393b22dc
Step 5/10 : ADD manage.py /usr/src/app
---> Using cache
---> 3ef5477e4b26
Step 6/10 : WORKDIR /usr/src/app
---> Using cache
---> 2edb019a8257
Step 7/10 : COPY requirements.txt ./
---> Using cache
---> df3ac922b7a0
Step 8/10 : RUN pip install --no-cache-dir -r requirements.txt
---> Using cache
---> ba6cf54e7dcc
Step 9/10 : EXPOSE 8000
---> Using cache
---> 94f3f4fb38c0
Step 10/10 : CMD exec gunicorn wfmbcm.wsgi:application --bind 0.0.0.0:8000 --workers 3
---> Using cache
---> db6cf2149949
Successfully built db6cf2149949
Successfully tagged wfmbcm:latest
Run WFMBCM Docker image.
[2019-05-26 09:59:36 +0000] [1] [INFO] Starting gunicorn 19.9.0
[2019-05-26 09:59:36 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2019-05-26 09:59:36 +0000] [1] [INFO] Using worker: sync
[2019-05-26 09:59:36 +0000] [9] [INFO] Booting worker with pid: 9
[2019-05-26 09:59:36 +0000] [10] [INFO] Booting worker with pid: 10
[2019-05-26 09:59:36 +0000] [9] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
ModuleNotFoundError: No module named 'wfmbcm'
[2019-05-26 09:59:36 +0000] [9] [INFO] Worker exiting (pid: 9)
[2019-05-26 09:59:36 +0000] [11] [INFO] Booting worker with pid: 11
[2019-05-26 09:59:36 +0000] [10] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
ModuleNotFoundError: No module named 'wfmbcm'
[2019-05-26 09:59:36 +0000] [10] [INFO] Worker exiting (pid: 10)
[2019-05-26 09:59:36 +0000] [11] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
ModuleNotFoundError: No module named 'wfmbcm'
[2019-05-26 09:59:36 +0000] [11] [INFO] Worker exiting (pid: 11)
[2019-05-26 09:59:37 +0000] [1] [INFO] Shutting down: Master
[2019-05-26 09:59:37 +0000] [1] [INFO] Reason: Worker failed to boot.
WFMBCM run-script ended!.
Why can't it find wfmbcm module? I've been staring crazy and googling without success and looking at different stack overflow questions.
I can't find any python module named wfmbcm, so I assume that it's an app in your project.
If you are on a case sensitive file system, then your file layout shows all caps for some folders and that might be (part of) the issue.
Does this project run outside of docker?
If it does, then I think that your best bet is to start the docker container and then manually install the entire app inside the container, updating the dockerfile with the steps as you go.
Every time you test a new change, make sure that you build with the --no-cache option or you may not be testing what you think you are.
Changing my DockerFile to this solved my issue:
FROM python:3.7
ADD WFMBCM /usr/src/app/WFMBCM
ADD WFMBCM_App /usr/src/app/WFMBCM_App
ADD WFMBCM_db /usr/src/app/WFMBCM_db
ADD manage.py /usr/src/app
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 8000
CMD manage.py migrate
CMD exec gunicorn WFMBCM.wsgi:application --bind 0.0.0.0:8000 --workers 10
Just Copy WFMBCM/WFMBCM/wsgi.py file in the root of project (so wsgi.py path is WFMBCM/wsgi.py)
and change CMD exec ... to this CMD exec gunicorn wsgi:application --bind 0.0.0.0:8000 --workers 3
and you'll be fine to go.

Postgres to Ubuntu Docker container linking not working

[EDIT]: I'm able to reproduce this without any of my own custom code. I just created a fresh Linode image running Ubuntu 14.04 and installed Docker according to the steps on Docker's website.
I then ran:
docker run -d --name db postgres
and can see it running:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9d335e8fc70b postgres "/docker-entrypoint. 7 minutes ago Up 7 minutes 5432/tcp db
Then I start an interactive Ubuntu container, linked to db, and try to test the link via nc and curl:
$docker run -it --link db ubuntu /bin/bash
root#eb02f4e7b89e:/# apt-get install curl
...
root#eb02f4e7b89e:/# curl http://$DB_PORT_5432_TCP_ADDR:$DB_PORT_5432_TCP_PORT/
curl: (7) Failed to connect to 172.17.0.2 port 5432: Connection timed out
What am I missing?
I'm trying to link a postgres container with an app container running Django but it doesn't seem to be linking properly.
The commands to start the containers were:
$ docker run -d --name db postgres
$ docker run -d --name web --link db -p 8000:80 test_image
Both containers appear to be running fine:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5838047eb14c test_image "/test/.docker/st 40 minutes ago Up 40 minutes 0.0.0.0:8000->80/tcp web
d2d6754430a2 postgres "/docker-entrypoint. 44 minutes ago Up 44 minutes 5432/tcp db
And seem to be correctly linked:
$ docker inspect -f "{{ .HostConfig.Links }}" web
[/db:/web/db]
However, when I try to run "python manage.py migrate" in the web container it doesn't seem to be able to connect to the postgres container:
# python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 93, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 19, in __init__
self.loader = MigrationLoader(self.connection)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 47, in __init__
self.build_graph()
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 180, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 59, in applied_migrations
self.ensure_schema()
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 49, in ensure_schema
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 164, in cursor
cursor = self.make_cursor(self._cursor())
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 135, in _cursor
self.ensure_connection()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 130, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 130, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 119, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 172, in get_new_connection
connection = Database.connect(**conn_params)
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect
connection_factory=connection_factory, async=async)
django.db.utils.OperationalError: could not connect to server: Connection timed out
Is the server running on host "db" (172.17.0.42) and accepting
TCP/IP connections on port 5432?
I'm able to connect to the postgres container directly:
$ docker exec -it db bash
root#d2d6754430a2:/# cat /etc/hosts
172.17.0.42 d2d6754430a2
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
root#d2d6754430a2:/# su postgres
$ psql
psql (9.4.4)
Type "help" for help.
postgres=#
But not from inside the web container:
# curl http://$DB_PORT_5432_TCP_ADDR:$DB_PORT_5432_TCP_PORT/
curl: (7) Failed to connect to 172.17.0.42 port 5432: Connection timed out
My host machine is running Ubuntu 14.04.
Any ideas what I'm missing?
Check that your postgresql.conf has listen_addresses = '*'
The default is listen_addresses = 'localhost', which would behave in the manner you describe.
Edit:
This works for me, does it work for you?
$ docker pull postgres
$ docker pull django
$ docker run -d --name db -d postgres
$ docker run -it --link db:db django bash
root#11c767bd3d09:/# psql -h db -U postgres
psql (9.4.3, server 9.4.4)
Type "help" for help.
postgres=#
Edit (Docker 1.7.1 output)
$ docker rm $(docker ps -a -q)
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
django latest 29755dd6751b 3 days ago 434.5 MB
postgres latest f33438ff9aef 3 days ago 265.5 MB
$ docker -v
Docker version 1.7.1, build 786b29d
$ docker run -d --name db -d postgres
$ docker run -it --link db:db django bash
root#11c767bd3d09:/# psql -h db -U postgres
psql (9.4.3, server 9.4.4)
Type "help" for help.
postgres=#

Apache WSGI permission error using django logging on production server

Here is some software information
Django 1.8.1
Apache2
Fedora 21
error_log output
mod_wsgi (pid=8272): Target WSGI script '/var/www/anime/anime/wsgi.py' cannot be loaded as Python module.
mod_wsgi (pid=8272): Exception occurred processing WSGI script '/var/www/anime/anime/wsgi.py'.
Traceback (most recent call last):
File "/usr/lib64/python3.4/logging/config.py", line 557, in configure
handler = self.configure_handler(handlers[name])
File "/usr/lib64/python3.4/logging/config.py", line 725, in configure_handler
result = factory(**kwargs)
File "/usr/lib64/python3.4/logging/__init__.py", line 999, in __init__
StreamHandler.__init__(self, self._open())
File "/usr/lib64/python3.4/logging/__init__.py", line 1023, in _open
return open(self.baseFilename, self.mode, encoding=self.encoding)
PermissionError: [Errno 13] Permission denied: '/var/www/anime/log/info.log'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/www/anime/anime/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
django.setup()
File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/django/__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/opt/virtualenvs/django_project/lib64/python3.4/site-packages/django/utils/log.py", line 86, in configure_logging
logging_config_func(logging_settings)
File "/usr/lib64/python3.4/logging/config.py", line 789, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib64/python3.4/logging/config.py", line 565, in configure
'%r: %s' % (name, e))
ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/var/www/anime/log/info.log'
Here is the permission mask on the file
drwxrwxrwx. 2 apache apache 21 May 28 15:22 .
drwxr-xr-x. 6 apache apache 90 May 28 14:53 ..
-rwxrwxrwx. 1 apache apache 0 May 28 15:22 info.log
I have already searched SOF on all the possible solutions and none of them works. Therefore I suspect that it has something to do with SELinux setting? If it is, can someone tell me which flag do i need to set to true?
After reading up on SELinux, I have figured out the solution for this permission error. And I hope that it will help the others who have encountered similar situation when deploying on production server under RHEL linux.
Basically running the command ls -Z shows the following
drwxr-xr-x. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 log
the folder is labelled with httpd_sys_content_t which does not allow httpd to have write access the the folder. Therefore we need to change this label to httpd_sys_rw_content_t
Firstly, we need to add an entry to the fcontext to inform SELinux what is the default label for files, that will be created, in this folder.
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/path/to/directory(/.*)?"
This will add an entry to the fcontext file (/etc/selinux/targeted/contexts/files/file_contexts.local)
Next we need to update all the labels of the files in the folder using restorecon.
sudo restorecon -R -v /path/to/directory
And now the permission error related to the django logging will be gone from the httpd error_log =)

Django CMS + uWSGI + virtualenv + socket causing PendingDeprecationWarning error in uWSGI logs

Here's the error:
Traceback (most recent call last):
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
self.load_middleware()
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 45, in load_middleware
mw_class = import_by_path(middleware_path)
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 21, in import_by_path
module = import_module(module_path)
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/middleware/doc.py", line 4, in <module>
warnings.warn(__doc__, PendingDeprecationWarning, stacklevel=2)
TypeError: expected string or buffer
TypeError: expected string or buffer
Tango is the user I created specifically for this project.
I'm using upstart so in /etc/init/tango-wsgi.conf looks like:
exec /var/apps/tango/envs/tango-env/bin/uwsgi \
--uid tango \
--home /var/apps/tango/envs/tango-env \
--pythonpath /var/apps/tango/tango/src \
--wsgi-file /var/apps/tango/tango/src/tango_cms/wsgi.py \
--socket /tmp/tango-uwsgi.sock \
--chmod-socket \
--logdate \
--optimize 2 \
--processes 2 \
--master \
--logto /var/apps/tango/logs/uwsgi.log
UPDATE:
My nginx.conf has following entry:
location / {
uwsgi_pass unix:/tmp/tango-uwsgi.sock;
include /etc/nginx/uwsgi_params;
}
Please help.
Same problem here. I fixed it deleting the following line on tango-wsgi.conf file:
--optimize 2 \
Optimize allows some kind of python optimization: More info
Not sure why it's an error, you could try removing "XViewMiddleware" if it's installed.

database error on upgrading the site

I have installed the reviewboard in virtual environment and have created site reviewboard on ubuntu 13.10 using apache2 with mod_wsgi.
when i hit the
http://localhost
i was asked to upgarde the site
The version of Review Board running does not match the version the
site was last upgraded to. You are running 1.7.20 and the site was
last upgraded to 1.7.21.
Please upgrade your site to fix this by running:
and on upgraded
$ rb-site upgrade /home/naveen/venv-review/reviewboard
got
i got following message:
Updating database. This may take a while.
The log output below, including warnings and errors, can be ignored
unless upgrade fails.
------------------ ------------------ Creating tables ... Installing custom SQL ... Installing indexes ... Installed
0 object(s) from 0 fixture(s) No evolution required.
------------------- -------------------
Resetting in-database caches. Traceback (most recent call last):
File "/home/naveen/venv-review/bin/rb-site", line 9, in
load_entry_point('ReviewBoard==1.7.21', 'console_scripts', 'rb-site')() File
"/home/naveen/venv-review/local/lib/python2.7/site-packages/ReviewBoard-1.7.21-py2.7.egg/reviewboard/cmdline/rbsite.py", line 2027, in main
command.run() File "/home/naveen/venv-review/local/lib/python2.7/site-packages/ReviewBoard-1.7.21-py2.7.egg/reviewboard/cmdline/rbsite.py", line 1860, in run
site.run_manage_command("fixreviewcounts") File "/home/naveen/venv-review/local/lib/python2.7/site-packages/ReviewBoard-1.7.21-py2.7.egg/reviewboard/cmdline/rbsite.py", line 562, in run_manage_command
execute_manager(reviewboard.settings, [file, cmd] + params) File
"/home/naveen/venv-review/local/lib/python2.7/site-packages/Django-1.4.10-py2.7.egg/django/core/management/init.py", line 459, in execute_manager
utility.execute() File "/home/naveen/venv-review/local/lib/python2.7/site-packages/Django-1.4.10-py2.7.egg/django/core/management/init.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/naveen/venv-review/local/lib/python2.7/site-packages/Django-1.4.10-py2.7.egg/django/core/management/base.py",
line 196, in run_from_argv
self.execute(*args, **options.dict) File "/home/naveen/venv-review/local/lib/python2.7/site-packages/Django-1.4.10-py2.7.egg/django/core/management/base.py",
line 232, in execute
output = self.handle(*args, **options) File "/home/naveen/venv-review/local/lib/python2.7/site-packages/Django-1.4.10-py2.7.egg/django/core/management/base.py",
line 371, in handle
return self.handle_noargs(**options) File "/home/naveen/venv-review/local/lib/python2.7/site-packages/ReviewBoard-1.7.21-py2.7.egg/reviewboard/reviews/management/commands/fixreviewcounts.py",
line 16, in handle_noargs
starred_public_request_count=None) File "/home/naveen/venv-review/local/lib/python2.7/site-packages/Django-1.4.10-py2.7.egg/django/db/models/manager.py",
line 185, in update
return self.get_query_set().update(*args, **kwargs) File "/home/naveen/venv-review/local/lib/python2.7/site-packages/Django-1.4.10-py2.7.egg/django/db/models/query.py",
line 536, in update
rows = query.get_compiler(self.db).execute_sql(None) File "/home/naveen/venv-review/local/lib/python2.7/site-packages/Django-1.4.10-py2.7.egg/django/db/models/sql/compiler.py",
line 988, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type) File
"/home/naveen/venv-review/local/lib/python2.7/site-packages/Django-1.4.10-py2.7.egg/django/db/models/sql/compiler.py",
line 818, in execute_sql
cursor.execute(sql, params) File "/home/naveen/venv-review/local/lib/python2.7/site-packages/Django-1.4.10-py2.7.egg/django/db/backends/sqlite3/base.py", line 344, in execute
return Database.Cursor.execute(self, query, params) django.db.utils.DatabaseError: attempt to write a readonly database
the sqlite database directory has been given access to server (www-data) like :
sudo chown www-data /home/naveen/venv-review/reviewboard/data
Does www-data should have read/write access of site , reviewboard, if it is the case ?
Update *
checking apache2 user
ps aux | grep apache2
root 1146 0.0 0.0 84208 3928 ? Ss 11:19 0:00 /usr/sbin/apache2 -k start
www-data 3632 0.1 0.6 698464 51056 ? Sl 11:34 0:01 /usr/sbin/apache2 -k start
www-data 3742 0.1 0.6 698480 51032 ? Sl 11:34 0:01 /usr/sbin/apache2 -k start
naveen 7162 0.0 0.0 13652 940 pts/1 S+ 11:53 0:00 grep apache2
The sqlite3 file, not only the directory, have to be owned and have to be writeable by the user running the web server.
so you may try running, from a terminal shell:
sudo chown -R www-data /home/naveen/venv-review/reviewboard/data
sudo chmod -R u+w /home/naveen/venv-review/reviewboard/data/*
the first command recursively change the owner of the files inside the folder, the second one ensures the users have writing permissions on these files.