How can I debug Openstack Dashboard? - python

I'm running the Openstack Cloud System. I installed and deployed the kilo version on the server successful, but this is only the default version of Openstack. So that, I want to have some modifies on this openstack source and add more features to it.
I started to change something with the Openstack Dashboard. However, there are some problems happened. Therefore, I have debugged this django web application. All everything I have configured is the same as the official tutorials on the openstack website (http://docs.openstack.org).
So, I have search on my server and find out 2 places that have the sources:
The first one is /usr/share/openstack-dashboard/
The second one is /usr/lib/python2.7/dist-packages/horizon/
And the config file is /etc/openstack-dashboard/local_settings.py
I set the option Debug = True in local_settings.py file.
On the server I typed these commands:
cd /usr/share/openstack-dashboard/
python manage.py runserver
Here is the output:
RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
WARNING:py.warnings:RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
WARNING:py.warnings:RemovedInDjango18Warning: XViewMiddleware has been moved to django.contrib.admindocs.middleware.
Performing system checks...
System check identified no issues (0 silenced).
August 05, 2015 - 09:28:50
Django version 1.7.6, using settings 'openstack_dashboard.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
But in the browser, it shows the error:
And then, on the console, it shows:
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[05/Aug/2015 10:21:29] "GET / HTTP/1.1" 302 0
Not Found: /horizon/auth/login/
[05/Aug/2015 10:21:29] "GET /horizon/auth/login/?next=/ HTTP/1.1" 404 4237
Not Found: /favicon.ico
[05/Aug/2015 10:21:29] "GET /favicon.ico HTTP/1.1" 404 4206
Please help me to get out of this problems. And how can to debug Openstack Django Website properly.Thank you very much !

As you run server by runserver command you should go to the root url like
127.0.0.1:8000/
not
127.0.0.1:8000/horizon
The difference is in running method.
When you installed openstack_dashboard there is apache config that listen to address http://host/horizon look in to /etc/apache2/conf/sites-available/
The directories
/usr/lib/python2.7/dist-packages/horizon/
Is like the framework for all dashboards
/usr/share/openstack-dashboard/
Is the default dashboard for openstack
/etc/openstack-dashboard/local_settings.py
The config file for dashboard. Here you can apply changes for default dash, for example attach your project that modifies or extends default dash
So, your problem will be solved if you follow that link http://127.0.0.1:8000/
For debugging use
pdb or ide with integrated debugger

Follow this link.
http://docs.openstack.org/developer/horizon/quickstart.html
Once this is done, add pdb statements to your code that you wish to debug.Go into the horizon folder and run the following command
./run_tests.sh --runserver 127.0.0.1:port_number
Instead of local host you can put in the IP address where horizon is running

I have written the OpenStack documentation for debugging dashboards using PyCharm.
(It is good for any Openstack Dashboard including Horizon)
http://docs.openstack.org/developer/mistral/developer/troubleshooting.html

Related

How to fix "Unable to fetch link_token" with Plaid API?

I followed the instructions here: https://dashboard.plaid.com/overview/sandbox.
I have everything setup the way it should, my .env looks like this:
PLAID_CLIENT_ID=myclientid
PLAID_SECRET=mysandboxsecret
PLAID_ENV=sandbox
PLAID_PRODUCTS=auth,transactions
PLAID_COUNTRY_CODES=US,CA
PLAID_REDIRECT_URI='http://localhost:3000/'
I did try leaving URI blank as well - made no difference.
For some reason, I continue to get this error when I visit http://localhost:3000 after running npm start
Unable to fetch link_token: please make sure your backend server is running and that your .env file has been configured correctly.
The error code, error type, and error message are all blank.
Here are the terminal outputs for ./start.sh & npm start
./start.sh
* Serving Flask app "server" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:8000/ (Press CTRL+C to quit)
127.0.0.1 - - [22/Feb/2022 20:05:45] "POST /api/info HTTP/1.1" 200 -
127.0.0.1 - - [22/Feb/2022 20:05:45] "POST /api/create_link_token HTTP/1.1" 200 -
npm start
> plaid_react_quickstart#0.1.0 start
> react-scripts start
[HPM] Proxy created: / -> http://localhost:8000
ℹ 「wds」: Project is running at http://192.168.1.45/
ℹ 「wds」: webpack output is served from
ℹ 「wds」: Content not from webpack is served from /Users/user/plaid/quickstart/frontend/public
ℹ 「wds」: 404s will fallback to /
Starting the development server...
Compiled with warnings.
src/dataUtilities.ts
Line 11:3: 'AssetReportGetResponse' is defined but never used #typescript-eslint/no-unused-vars
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
Does anyone familiar with Plaid API know how to fix this?
It feels like the API/quickstart process has changed a bit since those postings.
EDIT:
I re-cloned the repo and started from step 1 and re-did everything. It all works now. I traced the issue back to an extra digit at the end of my SECRET. Thank you Alex for the help, but it was all a silly mistake. Cheers!
You can always get more data about what went wrong by looking at the activity log at https://dashboard.plaid.com/activity/logs. That said, the most common causes of this issue are the following:
Specifying a REDIRECT_URI in the .env file but not adding it to "allowed redirect uris" at https://dashboard.plaid.com/team/api
Being on Windows and not cloning the repo in a manner that preserves symlinks, which you can do like this:
git clone -c core.symlinks=true https://github.com/plaid/quickstart
try this answer as well, seems like python3.9 certificates are missing for mac os
https://stackoverflow.com/a/68595419/6013354

How to run python scripts in one computer in LAN and send the output to other system in same LAN?

I am following this solution and tried there accepted answer but it not worked.
I have Django project in desktop destination and Apache24 installed in C drive. But I want to use this Django project on other system connected to Same LAN. I am using window 10.
I have tried all the solution i found in SO as follows but nothing worked
such as:
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['127.0.0.1', 'localhost','192.168.1.8']
Making debug = true/false
adding IP address in ALLOWED_HOSTS
But nothing worked.
Please help in making/give direction how i can make a connection to get access to Django project via access of LAN.
Let system A run the django application by the development server
(venv) C:\Users\Carthaginian\Desktop\rp-portfolio\personal_portfolio>python manage.py runserver 192.168.1.8:8080
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
September 10, 2019 - 12:00:18
Django version 2.2.4, using settings 'personal_portfolio.settings'
Starting development server at http://192.168.1.8:8080/
Quit the server with CTRL-BREAK.
Now How system B can connect to this URL http://192.168.1.8:8080/ via LAN?
Below is some structure.
This below is edit
My Django web application is working fine in my system as follows:
(venv) C:\Users\Carthaginian\Desktop\rp-portfolio\personal_portfolio>python manage.py runserver 0.0.0.0:8080
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
September 11, 2019 - 10:41:21
Django version 2.2.4, using settings 'personal_portfolio.settings'
Starting development server at http://0.0.0.0:8080/
Quit the server with CTRL-BREAK.
[11/Sep/2019 10:43:32] "GET /blog/ HTTP/1.1" 200 5196
[11/Sep/2019 10:43:33] "GET /blog/5/ HTTP/1.1" 200 4897
[11/Sep/2019 10:43:35] "GET /blog/Softwares/ HTTP/1.1" 200 2483
[11/Sep/2019 10:43:37] "GET /projects/ HTTP/1.1" 200 2774
[11/Sep/2019 10:43:37] "GET /blog/ HTTP/1.1" 200 5196
[11/Sep/2019 10:43:40] "GET /blog/Computer%20Networks/ HTTP/1.1" 200 2503
[11/Sep/2019 10:43:41] "GET /projects/ HTTP/1.1" 200 2774
you can use python manage.py runserver 0.0.0.0:Port_No on the host computer. It will bind your IP address to server address and make it accessible to all the other computers on the same network. On other computers now you can access this server by using your_ip:Port_NO.

Running python3 manage.py runserver but not seeing any requests

I activated my virtual environment with source env/bin/activate, and then started my server with python3 manage.py runserver 0.0.0.0:80.
I have made sure I have the following in my settings.py:
ALLOWED_HOSTS = ['xx.xx.xx.xxx', 'mywebsite.org']
I start the server and it outputs :
System check identified no issues (0 silenced).
January 28, 2019 - 21:40:33
Django version 2.0.7, using settings 'app.settings'
Starting development server at http://0.0.0.0:80/
Quit the server with CONTROL-C.
But, I visit "mywebsite.org" and it outputs
> Index of /
> Name Last modified Size Description cgi-bin
> 2018-08-23 07:26 -
The homepage of my website normally appears when I visit "http://127.0.0.1:8000/", so how can I get that to appear?
I'm using a Mac

Django admin CSS missing, after collecting static, with python manage.py runserver

I run django project on django 1.8.0, with "django manage.py runserver".
It is to be noted that the admin page worked perfectly with CSS a few months ago. However without any change in any file in the project directory (checked with git), the django admin page is missing now its CSS files.
I've noticed that many have had similar problems but I have been unable to solve the problem with their solution. e.g. running manage.py collectstatic.
[13/Dec/2015 00:35:00]"GET /admin/login/?next=/admin/ HTTP/1.1" 200 1931
[13/Dec/2015 00:35:00]"GET /static/admin/css/base.css HTTP/1.1" 200 1591
[13/Dec/2015 00:35:00]"GET /static/admin/css/login.css HTTP/1.1" 200 1591
As you can see the css file is accessed normally according to the log, but the css file received by the browser is empty.
Your help would be very appreciated. Thanks.
UDPATE:
All the files are given the read access as you can see below!
You need to enable DEBUG and enable staticfiles app. If you do not want to enable DEBUG, you may run runserver with --insecure commandline parameter.
https://docs.djangoproject.com/en/1.9/ref/contrib/staticfiles/
[I answer since I cannot comment]
You should check the permissions on these files. Make sure that read access is given to all users !
You can give read access to all with this command
chmod a+r static_file

Running Django with gunicorn: Bad Request (400)

I am following this tutorial to set up a Django application and serve it with Gunicorn on a Debian DigitalOcean server: http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
I have got as far as the section starting "Now that you have gunicorn, you can test whether it can serve your Django application by running the following command". Now I'm stuck.
In other words, I can successfully run the application using python manage.py runserver, but not by using gunicorn.
I've successfully accessed my app with:
$ python manage.py runserver xx.xx.xx.xx:8000
Now from the same directory, I'm trying to run:
$ gunicorn my_django.wsgi:application --bind xx.xx.xx.xx:8001
It appears to start OK, but when I go to http://xx.xx.xx.xx:8001, I see:
Bad Request (400)
I'm not sure how to debug this: there's nothing in /var/log/gunicorn/.
I have set ALLOWED_HOSTS=['xx.xx.xx.xx'] in my settings file.
UPDATE: Being an idiot: gunicorn was looking in production settings file, not local settings file. Setting the ALLOWED_HOSTS in production settings fixed it.
I'd still really like to know how to debug problems like this though.
The answer: gunicorn was looking in production settings file, not local settings file. Setting the ALLOWED_HOSTS in production settings fixed it.

Categories