Django app in Eclipse won't run after upgrade to django 1.4 - windows

After upgrading to Django 1.4, I now get the following error message:
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'settings.py' (Is it on sys.path?): No module named py
I read that it might have something to do with pydev 2.4 eg: here, so I upgraded pydev to the latest version, 2.5. I am using eclipse indigo.
I started to have a look at the run cnofiguration, and noticed that the django 1.3 egg was still being referenced. So I went to windows/preferences/pydev/interpreter-python, and the 1.3 egg was being referenced in the system PYTHON path.
To try and correct this, I removed the existing python interpreter, and re-added a new one. My python is run from venv, so I added this. An error comes up:
I don't think this is related, but I can see that /venv/lib has appears in the System PYTHONPATH list, whereas in Windows the folder is called /venv/Lib, so I added this as well. Still the new django egg hasn't been include, so I manually added this under the 'Libraries' window.
However, I'm still receiving the error message.
The app runs fine from the command line.

Figured this out after a few hours of trying different things.
I created a new Django project using the pydev 2.5 just to see what would happen, and I noticed that the 'django settings module' entry (see below) was appname.settings. Previously I had put 'settings.py'. I removed the entry entirely, which cleared up the first problem.
After this I was getting a 'module appname not found' error, so I tried putting an empty __init__.py file in the root of my app, which seemed to work.

In a virtualenv, this is usually the case where you forgot to add the /Lib from the base python install during the install process (so, when searching in the PYTHONPATH it's not finding things such as 'threading.py' or 'traceback.py', etc.

I solved this by adding the following to manage.py:
import os
os.environ['DJANGO_SETTINGS_MODULE'] = '<django_app_folder>.settings'
os.environ['SERVER_NAME'] = '<name_of_server>'
<django_app_folder> is the name of the folder containing the settings.py file.
<name_of_server> needs to be there, but I didn't find that it matters what it's set to.

I had this problem. My project did not have a PyDev - Django property so the other solution here did not work. I think this is because I did not initially create it as a Django project. Instead, what worked was:
right click project > properties > PyDev PYTHONPATH > String substitution variables.
Add a variable named DJANGO_SETTINGS_MODULE Its value should be yourapp.settings (or edit it if it's already there)

Related

Joomla "Fatal error: Cannot redeclare jblogerror() in on line 0"

Here is a weird problem i'm facing; after updating Joomla to the latest version, website failed to up load but, as i've made a backup manually from these folders:
administrator
bin
cli
components
includes
layouts
libraries
modules
plugins
yt-assets
and all the root files, after restoring the backup still the website is not loading and just says
"Fatal error: Cannot redeclare jblogerror() in on line 0" !
Any suggestion? Thank you.
Apparently, the version of jBlog you are using is loading its attempting to load its own classes twice.
Let's assume the jBlog developers already fixed it and you carelessly ignored the warning to ensure all your extensions are compatible before updating.
Are you able to access administrator? Simply go there and upgrade jBlog including any modules.
Else, the issue lies within a plugin. In order to access the administrator and perform the update, you will need to manually disable the offending plugin.
A simple way is to rename its folder: start from plugins/system then plugins/content hopefully you'll have spotted it by then. Look into the subfolders of each and spot any that may be relevant to jBlog (or grep through the folder to locate the specific string)
If you have console access, simply run
# grep -rl jblogerror plugins/system
and you should see all the files that include such string, just rename their main plugin folder. But you could also do all this through ftp and guessing.

go-swagger restapi/configure_todo_list.go - api.TodoGetHandler undefined error

I am a newbie in go and go-swagger. I am following steps in Simple Server tutorial in goswagger.io.
I am using Ubuntu 18.04, swagger v0.25.0 and go 1.15.6.
Following the same steps, there are a few differences of the files generated. For instance, goswagger.io's has find_todos_okbody.go and get_okbody.go in models but mine does not. Why is that so?
Link to screenshot of my generated files vs
Link to screenshot of generated files by swagger.io
Starting the server as written in the tutorial go install ./cmd/todo-list-server/ gives me the following error. Can anyone please help with this?
# my_folder/swagger-todo-list/restapi
restapi/configure_todo_list.go:41:8: api.TodosGetHandler undefined (type *operations.TodoListAPI has no field or method TodosGetHandler)
restapi/configure_todo_list.go:42:6: api.TodosGetHandler undefined (type *operations.TodoListAPI has no field or method TodosGetHandler)
The first step in goswagger.io todo-list is swagger init spec .... Which directory should I run this command in? I ran it in a newly created folder in my home directory. However, from the page, it shows the path to be ~/go/src/github.com/go-swagger/go-swagger/examples/tutorials/todo-list. I am not sure whether I should use go get ..., git clone ... or create those folders. Can someone advise me?
Thanks.
This is likely the documentation lagging behind the version of the code that you are running. As long as it compiles, the specific files the tool generates isn't so crucial.
This is a compilation error. When you do go install foo it will try to build the foo package as an executable and then move that to your GOPATH/bin directory. It seems that the generated code in restapi/configure_todo_list.go isn't correct for the operations code generated.
All you need to run this tutorial yourself is an empty directory and the swagger tool (not its source code). You run the commands from the root of this empty project. In order not to run into GOPATH problems I would initialise a module with go mod init todo-list-example before doing anything else.
Note that while the todo-list example code exists inside the go-swagger source, it's there just for documenting example usage and output.
What I would advice for #2 is to make sure you're using a properly released version of go-swagger, rather than installing from the latest commit (which happens when you just do a go get), as I have found that to be occasionally unstable.
Next, re-generate the entire server, but make sure you also regenerate restapi/configure_todo_list.go by passing --regenerate-configureapi to your swagger generate call. This file isn't always refreshed because you're meant to modify it to configure your app, and if you changed versions of the tool it may be different and incompatible.
If after that you still get the compilation error, it may be worth submitting a bug report at https://github.com/go-swagger/go-swagger/issues.
Thanks #EzequielMuns. The errors in #2 went away after I ran go get - u -f ./... as stated in
...
For this generation to compile you need to have some packages in your GOPATH:
* github.com/go-openapi/runtime
* github.com/jessevdk/go-flags
You can get these now with: go get -u -f ./...
I think it's an error of swagger code generation. You can do as folloing to fix this:
delete file configure_todo_list.go;
regenerate code.
# swagger generate server -A todo-list -f ./swagger.yml
Then, you can run command go install ./cmd/todo-list-server/, it will succeed.

Yocto SYSTEMD_SERVICE to install a parameterized service ("#.service")

I need to configure WireGuard to bring up a VPN on boot on an Embedded Linux device.
My recipe installs a /etc/wireguard/wg0.conf pretty much like the examples found through the Internet.
Then I try to enable the service on SystemD like this on my wireguard.bb:
SYSTEMD_SERVICE = "wg-quick#wg0.service"
SYSTEMD_AUTO_ENABLE = "enable"
But bitbake throws me an error:
ERROR: Function failed: SYSTEMD_SERVICE_my-conf value wg-quick#wg0.service does not exist
I checked the temporary directory and file wg0.conf appears in the correct places but it seems that bitbake's SYSTEMD_SERVICE doesn't know how to expand the "wg0" after # sign.
If I try without the interface name (wg0):
SYSTEMD_SERVICE = "wg-quick#.service"
Bitbake is happy and finalizes my recipe, but it is not what systemd is expecting. Starting a service without an interface makes no sense...
Then I tried another approach and split the "wireguard" package itself from the configuration ("wireguard-conf" package) and added DEPENDS and RDEPENDS on "wireguard".
This got even worse since my wireguard-conf.bb recipe does not contain a "wg-quick#.service" file (it comes from the dependency "wireguard").
Well,
I don't know how to properly fix it and any suggestions will be highly appreciated.
Additional Info
I am using Yocto 2.0.3 in this project (with no hope of updating it).
Thanks to #TomasNovotny comments I managed to compare my "systemd.bbclas" against Github and noticed a change in systemd_populate_packages() that seems to solve the problem.
It works in newer OpenEmbedded (looks like in krogoth, version 2.1 released Apr 2016) and it is introduced by this commit. It works for me in rocko (version 2.4 released Oct 2017). According to j4x's comment, it doesn't work in jethro (version 2.0, Nov 2015).
For older (and currently unsupported OpenEmbeddeds) you can try to backport the patch or handle the symlinks for enabling the service in do_install().
Also please note that SYSTEMD_SERVICE_${PN} variable is package specific, so the _${PN} suffix has to be added (see manual).
I've also tried to enable OpenVPN with my profile (in Yocto rocko) without success.
Finally, I've made it working by providing OpenVPN recipe extension instead of custom one. So, the openvpn_%.bbappend file looks like:
inherit systemd
SYSTEMD_SERVICE_${PN} = "openvpn#clientprofile.service"
SYSTEMD_AUTO_ENABLE = "enable"
do_install_append() {
install -d ${D}${sysconfdir}/openvpn/
ln -sf /data/etc/openvpn/clientprofile.conf ${D}${sysconfdir}/openvpn/clientprofile.conf
}
As you can see, I'm using a symlink to my profile instead of the normal file. You can install a normal OpenVPN profile file instead of making symlink and it also works fine.

Update CodeIgniter from version 1.7.2 to 2.0.0 - class CI_Controller not found

I'm trying to update my project from CI version 1.7.2 to CI v. 2.0.0 (then I will update to next versions - but first I need to deal with that).
So:
Path to my CI is:
/home/user/www/mysite. That’s all right, it’s written here: http://codeigniter.com/user_guide/installation/upgrade_200.html That I should replace my system folder (except application folder) with this from v2.0.
I copied these directories from 2.0.0’s system folder (that’s core, database, fonts, helpers, language, libraries) and replaced older ones. I’ve done all other things - and after trying to launch my new version of CI - it shows
Fatal error: Class ‘CI_Controller’ not found in/home/user/sitesystem/application/controllers/test.php on line 3.
MY /system/core folder contains file Controller.php and it starts with
class CI_Controller
- so everything should work fine - what’s going on?
First, in CI 2, the application folder is in the root dir, not under the system directory. And second, if you watch closely your error say:
/home/user/sitesystem/application/
and you wrote previously, that the path is:
/home/user/www/mysite
so i would check this 2 things first.

Zend OSX, and a "." added to context path

I downloaded and unpacked the latest version of Zend Framework, onto OSX (10.6) (am also running webserver with XAMPP, but I added the include_path change to both XAMPP and OSX path, but this is all command line so I dont think the php compiler is using the XAMPP install)
I try to create a project and get the following: (note that i am replacing part of the path with "----" just for the purpose of privacy)
sh-3.2# zf create project
testProject
Fatal error: Uncaught exception
'Zend_Exception' with message 'File "Zend/Tool/Project/Context/Zf/./AbstractClassFile.php" does not exist or class "Zend_Tool_Project_Context_Zf_._AbstractClassFile" was not found in the file' in /Volumes/----/----/z/library/Zend/Loader.php:99 Stack trace:
0 /Volumes/----/----/z/library/Zend/Tool/Project/Context/Repository.php(88):
Zend_Loader::loadClass('Zend_Tool_Proje...')
1 /Volumes/----/----/z/library/Zend/Tool/Project/Context/Repository.php(79):
Zend_Tool_Project_Context_Repository->addContextClass('Zend_Tool_Proje...')
2 /Volumes/----/----/z/library/Zend/Tool/Project/Provider/Abstract.php(87):
Zend_Tool_Project_Context_Repository->addContextsFromDirectory('/Volumes/----/...',
'Zend_Tool_Proje...')
3 /Volumes/----/----/z/library/Zend/Tool/Framework/Provider/Repository.php(187):
Zend_Tool_Project_Provider_Abstract->initialize()
4 /Volumes/----/----/z/library/Zend/Tool/Framework/Client/Abstract.php(128):
Zend_Tool_F in
/Volumes/----/----/z/library/Zend/Loader.php
on line 99 sh-3.2#
Note the period after "Context_Zf_"
I've narrowed it down to this block of code:
File: /Volumes/----/----/z/library/Zend/Tool/Project/Provider/Abstract.php
public function initialize()
{
// initialize the ZF Contexts (only once per php request)
if (!self::$_isInitialized) {
// load all base contexts ONCE
$contextRegistry = Zend_Tool_Project_Context_Repository::getInstance();
$contextRegistry->addContextsFromDirectory(
dirname(dirname(__FILE__)) . '/Context/Zf/', 'Zend_Tool_Project_Context_Zf_'
);
$contextRegistry->addContextsFromDirectory(
dirname(dirname(__FILE__)) . '/Context/Filesystem/', 'Zend_Tool_Project_Context_Filesystem_'
);
// determine if there are project specfic providers ONCE
Specifically "dirname(dirname(FILE))" is echoing as "."
if I wrap the block with an 'if (dirname(dirname(__FILE))!=".") { … } ', then I don't get that error, but I get another:
sh-3.2# zf create project testProject
An Error Has Occurred
Context by name applicationDirectory does not exist in the registry.
Zend Framework Command Line Console
Tool v1.11.3 Details for action
"Create" and provider "Project"
Project
zf create project path name-of-profile file-of-profile
I tested on my Mac and it works fine. Have you tried to restart you xampp server, I don't really know how it works as I use Apache & PHP already installed versions not a "AMP pack". Maybe it's a problem with the php.ini include_path which has not been reloaded.
It's clearly a problem with the path as it don't succeed to build the class name :
"Zend/Tool/Project/Context/Zf/./AbstractClassFile.php"
the dot should not appear here.
Can you share you PATH variable from the terminal and your include_path from your php.ini.
Sadly the solution was to install zend server community edition, and have that take care of everything for me. For anyone else on OSX going this route, check out: http://cmorrell.com/webdev/installing-zend-server-zend-framework-on-os-x-291
includes the steps for enabling CLI support.

Resources