Can I remove the "sudo" necessity in a django project on OSX - django

I am doing a django project with Sublime Text 2 on OSX-Lion. I have installed virtualenv, so my project is in "/Users/myname/Virtualenvs/"
I need to use a 'sudo' for each command (syncdb, runserver), can I change these rules whithout moving my project and is it normal ?
These are parameters after a "sudo python manage.py startproject"
Chmod infos :
drwxr-xr-x 17 root staff 578 10 jul 23:24 Platform
-rw-r--r-- 1 root staff 155648 10 jul 23:24 database.sqlite3
-rw-r--r-- 1 root staff 251 10 jul 23:09 manage.py
and in Platform :
drwxrwxr-x# 9 Nicolas staff 306 10 jul 23:13 Templates
-rw-r--r--# 1 Nicolas staff 0 4 jul 16:53 __init__.py
-rw-r--r--# 1 Nicolas staff 144 4 jul 16:54 __init__.pyc
-rw-rw-r--# 1 Nicolas staff 123 10 jul 23:13 admin.py
-rw-r--r-- 1 root staff 321 10 jul 23:24 admin.pyc
-rw-rw-r--# 1 Nicolas staff 1706 10 jul 23:13 models.py
-rw-r--r-- 1 root staff 2603 10 jul 23:22 models.pyc
-rw-r--r--# 1 Nicolas staff 5309 10 jul 23:06 settings.py
-rw-r--r-- 1 root staff 3058 10 jul 23:22 settings.pyc
-rw-r--r--# 1 Nicolas staff 639 10 jul 23:06 urls.py
-rw-r--r-- 1 root staff 784 10 jul 23:24 urls.pyc
-rw-rw-r--# 1 Nicolas staff 1895 10 jul 23:06 views.py
-rw-r--r-- 1 root staff 2745 10 jul 23:24 views.pyc
-rw-r--r--# 1 Nicolas staff 1138 10 jul 23:05 wsgi.py
-rw-r--r-- 1 root staff 1047 10 jul 23:24 wsgi.pyc

You'll need to change ownership of all the root-owned files to yourself, but otherwise there shouldn't be any need for sudo here.

Related

Invalid value for "path" parameter: no file exists at

As mentioned at Terraform Resource: Connection Error while executing apply
I changed my code to the the below
provisioner "remote-exec" {
connection {
type = "ssh"
host = aws_eip.nat-eip.public_ip
user = "ubuntu"
private_key = file("/id_rsa.pem")
}
inline = [
"chmod +x /tmp/start_node.sh",
"sudo sed -i -e 's/\r$//' /tmp/start_node.sh", # Remove the spurious CR characters.
"sudo /tmp/start_node.sh",
]
}
But I still get the same error
Error: Invalid function argument
on explorer.tf line 60, in resource "aws_instance" "explorer":
60: private_key = file("/id_rsa.pem")
Invalid value for "path" parameter: no file exists at /id_rsa.pem;
this function works only with files that are distributed as part of the
configuration source code, so if this file will be created by a resource in
this configuration you must instead obtain this result from an attribute of
that resource.
ls -la ooutput
total 156
drwxr-xr-x 10 CORP\mayuresh CORP\domain users 4096 Jan 12 14:29 .
drwxr-xr-x 16 CORP\mayuresh CORP\domain users 4096 Jan 10 13:10 ..
drwxr-xr-x 12 CORP\mayuresh CORP\domain users 4096 Jan 12 09:49 byoc-terraform
drwxr-xr-x 2 CORP\mayuresh CORP\domain users 4096 Jan 11 11:57 controllers
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 188 Jan 10 13:27 .env
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 1582 Jan 10 17:12 fetchUserData.js
drwxr-xr-x 9 CORP\mayuresh CORP\domain users 4096 Jan 12 13:14 .git
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 629 Jan 10 13:27 .gitignore
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 107 Dec 30 06:49 .gitmodules
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 1765 Jan 12 13:21 id_rsa.pem
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 1488 Jan 10 13:27 index.js
drwxr-xr-x 3 CORP\mayuresh CORP\domain users 4096 Jan 10 13:27 models
drwxr-xr-x 221 CORP\mayuresh CORP\domain users 12288 Jan 10 13:30 node_modules
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 1058 Jan 10 13:27 package.json
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 78791 Jan 10 13:27 package-lock.json
drwxr-xr-x 2 CORP\mayuresh CORP\domain users 4096 Jan 10 13:27 routes
drwxr-xr-x 2 CORP\mayuresh CORP\domain users 4096 Jan 10 17:01 utils
drwxr-xr-x 2 CORP\mayuresh CORP\domain users 4096 Jan 10 13:27 VMCreationFiles```
Have you tried using the full path? Especially beneficial if you are using modules.
I.E:
private_key = file("${path.module}/id_rsa.pem")
Or I think even this will work
private_key = file("./id_rsa.pem")
I believe your existing code is looking for the file at the root of your filesystem.
Your path to the .pem is wrong. It looks like the file exists in your $HOME directory.
You can provide the absolute path of the id_rsa.pem file if that file is outside of path.module, path.root, path.cwd
To provide the absolute path
Fetch the full path of the file How to get full path of a file?
Paste the path in:
provisioner "remote-exec" {
connection {
type = "ssh"
host = aws_eip.nat-eip.public_ip
user = "ubuntu"
private_key = file("<Absolute path to .pem file e.g /home/ubuntu/id_rsa.pem>")
}

how to compile mariadb to get libmysqlclient.so? (missing libmysqlclient.so in /usr/local/mysql/lib)

I wanted to move our database from mysql (community version) to mariadb with the further use of php7.1/apache2.4.25... So I have to compile mariadb in our new production environment. I compiled it with these options:
cmake -DCMAKE_CXX_FLAGS:STRING="-std=c++11" -DCONC_WITH_CURL=ON -DCONC_WITH_EXTERNAL_ZLIB=ON -DDISABLE_SHARED=OFF -DCONC_WITH_MYSQLCOMPAT:BOOL=ON -DPLUGIN_CLIENT_ED25519:STRING=DYNAMIC .
make all && make install
The mysql community version has a libmysqlclient.so in /usr/local/mysql/lib located. If I compile it with the options given above I only found these files in /usr/local/mysql/lib (MariaDB 10.2.6):
# ls -l /usr/local/mysql/lib/
total 3572
-rw-r--r-- 1 root root 2305518 Jul 4 08:14 libmariadbclient.a
lrwxrwxrwx 1 root root 15 Jul 4 08:31 libmariadb.so -> libmariadb.so.3
-rwxr-xr-x 1 root root 1297664 Jul 4 08:14 libmariadb.so.3
-rw-r--r-- 1 root root 48406 Jul 4 08:14 libmysqlservices.a
drwxr-xr-x 2 root root 4096 Jul 4 08:31 plugin
How can I get libmysqlclient.so? There isn't also any libmariadbclient.so just libmariadbclient.a ...
Thank you for further hints!
OK, now I found a solution.
I've just did a symbolic link to libmariadb.so and it now looks like the following:
ls -l /usr/local/mysql/lib/
total 3572
-rw-r--r-- 1 root root 2305518 Jul 4 16:21 libmariadbclient.a
lrwxrwxrwx 1 root root 15 Jul 4 16:39 libmariadb.so -> libmariadb.so.3
-rwxr-xr-x 1 root root 1297664 Jul 4 16:21 libmariadb.so.3
lrwxrwxrwx 1 root root 15 Jul 4 16:40 libmysqlclient_r.so -> libmariadb.so.3
lrwxrwxrwx 1 root root 15 Jul 4 16:40 libmysqlclient.so -> libmariadb.so.3
-rw-r--r-- 1 root root 48406 Jul 4 16:21 libmysqlservices.a
drwxr-xr-x 2 root root 4096 Jul 4 16:39 plugin
In this case PHP 7 would finally find the mysql libraries...

python bindings for gstreamer: how to import typelib

I was building gstreamer latest version on my raspberry pi. I wanted to have python bindings, hence I installed gobject-introspection-1.0 and pygobject-3.18.2 before compiling the gstreamer and its plugins.
At the end of the build of gstreamer and all of its plugins, I see these files:
pi#raspberrypi:~/kurento $ ls -ltr /usr/local/lib/girepository-1.0
total 580
-rw-r--r-- 1 root staff 214076 Mar 28 19:28 Gst-1.5.typelib
-rw-r--r-- 1 root staff 43712 Mar 28 19:28 GstBase-1.5.typelib
-rw-r--r-- 1 root staff 6500 Mar 28 19:28 GstController-1.5.typelib
-rw-r--r-- 1 root staff 6272 Mar 28 19:28 GstNet-1.5.typelib
-rw-r--r-- 1 root staff 13116 Mar 28 19:29 GstCheck-1.5.typelib
-rw-r--r-- 1 root staff 14460 Mar 28 20:23 GstTag-1.5.typelib
-rw-r--r-- 1 root staff 2508 Mar 28 20:23 GstFft-1.5.typelib
-rw-r--r-- 1 root staff 27460 Mar 28 20:23 GstRtp-1.5.typelib
-rw-r--r-- 1 root staff 24160 Mar 28 20:23 GstSdp-1.5.typelib
-rw-r--r-- 1 root staff 32856 Mar 28 20:23 GstRtsp-1.5.typelib
-rw-r--r-- 1 root staff 75268 Mar 28 20:23 GstVideo-1.5.typelib
-rw-r--r-- 1 root staff 46800 Mar 28 20:24 GstAudio-1.5.typelib
-rw-r--r-- 1 root staff 25764 Mar 28 20:24 GstPbutils-1.5.typelib
-rw-r--r-- 1 root staff 5732 Mar 28 20:24 GstApp-1.5.typelib
-rw-r--r-- 1 root staff 1876 Mar 28 20:24 GstAllocators-1.5.typelib
-rw-r--r-- 1 root staff 17736 Mar 28 22:37 Nice-0.1.typelib
Then I compiled gst-python-1.7.1 and then I see the following at appropriate location:
pi#raspberrypi:~/kurento $ ls -l /usr/local/lib/python2.7/site-packages/gi/overrides/
total 640
-rw-r--r-- 1 root staff 15002 Mar 28 18:11 Gdk.py
-rw-r--r-- 1 root staff 14996 Mar 28 18:11 Gdk.pyc
-rw-r--r-- 1 root staff 14996 Mar 28 18:11 Gdk.pyo
-rwxr-xr-x 1 root staff 1141 Mar 29 22:19 _gi_gst.la
-rwxr-xr-x 1 root staff 56124 Mar 29 22:19 _gi_gst.so
-rw-r--r-- 1 root staff 2240 Mar 28 18:11 GIMarshallingTests.py
-rw-r--r-- 1 root staff 2428 Mar 28 18:11 GIMarshallingTests.pyc
-rw-r--r-- 1 root staff 2428 Mar 28 18:11 GIMarshallingTests.pyo
-rw-r--r-- 1 root staff 8147 Mar 28 18:11 Gio.py
-rw-r--r-- 1 root staff 8176 Mar 28 18:11 Gio.pyc
-rw-r--r-- 1 root staff 8075 Mar 28 18:11 Gio.pyo
-rw-r--r-- 1 root staff 33233 Mar 28 18:11 GLib.py
-rw-r--r-- 1 root staff 31701 Mar 28 18:11 GLib.pyc
-rw-r--r-- 1 root staff 31656 Mar 28 18:11 GLib.pyo
-rw-r--r-- 1 root staff 26255 Mar 28 18:11 GObject.py
-rw-r--r-- 1 root staff 23401 Mar 28 18:11 GObject.pyc
-rw-r--r-- 1 root staff 23401 Mar 28 18:11 GObject.pyo
-rw-r--r-- 1 root staff 2785 Mar 29 22:19 GstPbutils.py
-rw-r--r-- 1 root staff 2584 Mar 29 22:19 GstPbutils.pyc
-rw-r--r-- 1 root staff 2584 Mar 29 22:19 GstPbutils.pyo
-rw-r--r-- 1 root staff 11570 Mar 29 22:19 Gst.py
-rw-r--r-- 1 root staff 16602 Mar 29 22:19 Gst.pyc
-rw-r--r-- 1 root staff 16602 Mar 29 22:19 Gst.pyo
-rw-r--r-- 1 root staff 56202 Mar 28 18:11 Gtk.py
-rw-r--r-- 1 root staff 64602 Mar 28 18:11 Gtk.pyc
-rw-r--r-- 1 root staff 64602 Mar 28 18:11 Gtk.pyo
-rw-r--r-- 1 root staff 12820 Mar 28 18:11 __init__.py
-rw-r--r-- 1 root staff 13128 Mar 28 18:11 __init__.pyc
-rw-r--r-- 1 root staff 13070 Mar 28 18:11 __init__.pyo
-rw-r--r-- 1 root staff 1705 Mar 28 18:11 keysyms.py
-rw-r--r-- 1 root staff 1137 Mar 28 18:11 keysyms.pyc
-rw-r--r-- 1 root staff 1137 Mar 28 18:11 keysyms.pyo
-rw-r--r-- 1 root staff 1679 Mar 28 18:11 Pango.py
-rw-r--r-- 1 root staff 1727 Mar 28 18:11 Pango.pyc
-rw-r--r-- 1 root staff 1727 Mar 28 18:11 Pango.pyo
With this setup, I expect to see Gst module being loaded from gi repository.
>>> sys.path
['/usr/local/lib/python2.7/site-packages', '', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-arm-linux-gnueabihf', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7']
>>> import gi
>>> from gi.repository import Gst
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name Gst
>>> gi.require_version('Gst','1.5')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/gi/__init__.py", line 102, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gst not available
>>>
But this is not happening. Please, your help is needed to import the Gst modules into python. Has anyone come across similar situation?
Thanks!
GObject instrospection need type descriptions located at /usr/lib/girepository-1.0
In my case I have:
/usr/lib/girepository-1.0$ ls Gst*1.5*
Gst-1.5.typelib GstFft-1.5.typelib GstRtp-1.5.typelib
GstAllocators-1.5.typelib GstGL-1.5.typelib GstRtsp-1.5.typelib
GstApp-1.5.typelib GstInsertBin-1.5.typelib GstSdp-1.5.typelib
GstAudio-1.5.typelib GstMpegts-1.5.typelib GstTag-1.5.typelib
GstBase-1.5.typelib GstNet-1.5.typelib GstVideo-1.5.typelib
GstCheck-1.5.typelib GstPbutils-1.5.typelib
GstController-1.5.typelib GstPlayer-1.5.typelib
Try installing typelib files there.
I don't have any Gst*.py files installed, with the types description is enough.
Edit
Defining GI_TYPELIB_PATH pointing it to the directory containing the typelib files, in your case /usr/local/lib/girepository-1.5, also solves the problem.

How to solve the "Push rejected, no Cedar-supported app detected" on Heroku when pushing a Django project?

I followed all the steps indicated in the heroku site and each time I get the same error:
$ git push heroku master
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (11/11), 4.12 KiB, done.
Total 11 (delta 0), reused 0 (delta 0)
! Push rejected, no Cedar-supported app detected
To git#heroku.com:glacial-mountain-3911.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:glacial-mountain-3911.git'
I've looked for other solutions, some of them have a bit differences, but none of them have run :(
Here's the structure of my project:
drwxr-xr-x 9 marcpou staff 306 28 jul 22:07 .
drwxr-xr-x 17 marcpou staff 578 28 jul 00:52 ..
drwxr-xr-x 13 marcpou staff 442 28 jul 22:09 .git
-rw-r--r-- 1 marcpou staff 24 28 jul 01:05 .gitignore
-rw-r--r-- 1 marcpou staff 32 28 jul 00:57 Procfile
drwxr-xr-x 10 marcpou staff 340 28 jul 00:58 hellodjango
-rw-r--r-- 1 marcpou staff 254 28 jul 00:56 manage.py
-rw-r--r-- 1 marcpou staff 154 28 jul 22:08 requeriments.txt
drwxr-xr-x 6 marcpou staff 204 28 jul 00:56 venv
And the content of the requeriments.txt file
Django==1.5.1
distribute==0.6.34
dj-database-url==0.2.2
dj-static==0.0.5
django-toolbelt==0.0.1
gunicorn==17.5
psycopg2==2.5.1
static==0.4
wsgiref==0.1.2
And that's the content of the Procfile
web: gunicorn hellodjango.wsgi
I see that the file "hellodjango.wsgi" don't exist on my project. What should be the content? These are the files of my project.
-rw-r--r-- 1 marcpou staff 0 28 jul 00:56 __init__.py
-rw-r--r-- 1 marcpou staff 155 28 jul 00:57 __init__.pyc
-rw-r--r-- 1 marcpou staff 5869 28 jul 01:02 settings.py
-rw-r--r-- 1 marcpou staff 2876 28 jul 00:58 settings.pyc
-rw-r--r-- 1 marcpou staff 571 28 jul 00:56 urls.py
-rw-r--r-- 1 marcpou staff 293 28 jul 00:58 urls.pyc
-rw-r--r-- 1 marcpou staff 1557 28 jul 01:04 wsgi.py
-rw-r--r-- 1 marcpou staff 1059 28 jul 00:57 wsgi.pyc
The test the Push process on heroku, I've created an application, but I haven't edited anything, that means that I haven't set any database connection.
Does anybody have any idea? I suppose that the error is trivial, but I'm unable to see the error.
Thanks in advance!
I'm pretty sure that correct the spelling of requirements.txt will fix this. Then on to the next problem of adding the postgres db and PROMOTING it.
https://devcenter.heroku.com/articles/heroku-postgresql.

run demo django app on google app engine (DJANGO_SETTINGS_MODULE is undefined.)

I am trying to run the django 1.3 test app named Polls in googleappenginelauncher version 1.6.6 and am getting the following error. Can anyone tell me how to do this, please?
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
INFO 2012-06-05 19:08:30,766 dev_appserver.py:2904] "GET /polls/1/ HTTP/1.1" 500 -
I have placed my app.yaml in the app directory, not the project directory, and that may be a problem, but here is my current app.yaml. Also, I have declared my views.py as my main script, which was also a guess.
application: ctst
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /_ah/queue/deferred
script: djangoappengine.deferred.handler.application
login: admin
- url: /.*
script: views.app
libraries:
- name: django
version: "1.3"
My mysite and my polls directories are as follows.
server:mysite brian$ ls -l
total 352
-rw-r--r-- 1 brian staff 0 Jun 4 10:22 __init__.py
-rw-r--r-- 1 brian staff 155 Jun 4 13:56 __init__.pyc
-rw-r--r-- 1 brian staff 503 Jun 4 10:22 manage.py
drwxr-xr-x 20 brian staff 680 Jun 5 14:54 polls
-rw-r--r-- 1 brian staff 5273 Jun 5 15:00 settings.py
-rw-r--r-- 1 brian staff 2955 Jun 5 15:00 settings.pyc
drwxr-xr-x 2 brian staff 68 Jun 4 14:04 sqlite3.db
-rw-r--r-- 1 brian staff 147456 Jun 5 11:42 sqlite3.dp
-rw-r--r-- 1 brian staff 1048 Jun 5 10:16 urls.py
-rw-r--r-- 1 brian staff 464 Jun 5 10:18 urls.pyc
server:mysite brian$ ls -l polls/
total 104
-rw-r--r-- 1 brian staff 0 Jun 4 14:23 __init__.py
-rw-r--r-- 1 brian staff 151 Jun 4 14:33 __init__.pyc
-rw-r--r-- 1 brian staff 505 Jun 4 16:33 admin.py
-rw-r--r-- 1 brian staff 1123 Jun 4 16:33 admin.pyc
-rw-r--r-- 1 brian staff 263 Jun 5 14:54 app.yaml
-rw-r--r-- 1 brian staff 524 Jun 4 14:50 models.py
-rw-r--r-- 1 brian staff 1484 Jun 4 14:50 models.pyc
-rw-r--r-- 1 brian staff 383 Jun 4 14:23 tests.py
-rw-r--r-- 1 brian staff 708 Jun 5 11:26 urls.py
-rw-r--r-- 1 brian staff 902 Jun 5 11:42 urls.pyc
-rw-r--r-- 1 brian staff 1154 Jun 5 11:41 views.py
-rw-r--r-- 1 brian staff 1231 Jun 5 11:42 views.pyc
server:mysite brian$
Try adding
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
somewhere you know it's called for every request. Note that os.environ is threadlocal with python27, so setting on initial import is probably not enough.