Looks like logs are crashing my Django app - python

I have a Django app running on heroku.
The app keeps crashing with the following stacktrace:
Traceback (most recent call last):
File "/app/.heroku/python/bin/honcho", line 9, in <module>
load_entry_point('honcho==0.4.2', 'console_scripts', 'honcho')()
File "/app/.heroku/python/lib/python2.7/site-packages/honcho/command.py", line 292, in main
app.parse()
File "/app/.heroku/python/lib/python2.7/site-packages/honcho/command.py", line 129, in parse
options.func(self, options)
File "/app/.heroku/python/lib/python2.7/site-packages/honcho/command.py", line 190, in start
sys.exit(process_manager.loop())
File "/app/.heroku/python/lib/python2.7/site-packages/honcho/process.py", line 114, in loop
File "/app/.heroku/python/lib/python2.7/site-packages/honcho/printer.py", line 22, in write
Process exited with status 1
From Honcho's printer.py source code it looks like someting is going wrong while honcho is trying to write to the console.
My app is pulling data from web pages so I may print some text with accented characters. Is that related ?
Currently i'm printing things like this:
logger.info('Saved article' + str(title) + '.')
I may also dump some json from time to time:
logger.debug('Article: %s' % json.dumps(article_datas, indent=4))
It is working fine on my development machine but not on Heroku.
Do I need to log things differently ? Why is this not working on Heroku ?

I finally found that my Heroku app needed the PYTHONIOENCODING evironment variable to be set to utf-8.
heroku config:set PYTHONIOENCODING=utf-8
See this question for details about stdout encoding.

Related

Logging into GCP SQL: How to Ensure PromptSession Is Imported or Otherwise Resolve

I am trying to use the Cloud Shell to update some user permissions. I am logging in using gcloud sql connect my-instance --user=root
gcloud sql connect my-instance
Whitelisting your IP for incoming connection for 5 minutes...done.
Connecting to database with SQL user [sqlserver].********************************************************************************
Python command will soon point to Python v3.7.3.
Python 2 will be sunsetting on January 1, 2020.
See http://https://www.python.org/doc/sunset-python-2/
Until then, you can continue using Python 2 at /usr/bin/python2, but soon
/usr/bin/python symlink will point to /usr/local/bin/python3.
To suppress this warning, create an empty ~/.cloudshell/no-python-warning file.
The command will automatically proceed in seconds or on any key.
********************************************************************************
> Password:
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/mssqlcli/main.py", line 117, in <module>
main()
File "/usr/local/lib/python2.7/dist-packages/mssqlcli/main.py", line 110, in main
run_cli_with(mssqlcli_options)
File "/usr/local/lib/python2.7/dist-packages/mssqlcli/main.py", line 43, in run_cli_with
from mssqlcli.mssql_cli import MssqlCli
File "/usr/local/lib/python2.7/dist-packages/mssqlcli/mssql_cli.py", line 18, in <module>
from prompt_toolkit.shortcuts import PromptSession, CompleteStyle
ImportError: cannot import name PromptSession
A) I have made the root user's password so insecure and easy there is no way I am mistyping it.
B) It is the third of January, so I really don't know what this Python version error is on about. I made the file but FYI ~/.cloudshell did not exist so I had to make it first. Even so, it just suppresses the version warning, the main error persists when I try to log in.
The documentation acknowledges there are a couple other login methods using glcoud beta sql connect, but that gets me another error
2020/01/04 18:38:41 Rlimits for file descriptors set to {&{8500 1048576}}
2020/01/04 18:38:41 invalid json file "/tmp/tmp.s38C662KKr/legacy_credentials/me#gmail.com/adc.json": open /tmp/tmp.s38C662KKr/legacy_credentials/me#gmail.com/adc.json: no such file or directory
ERROR: (gcloud.beta.sql.connect) Failed to start the Cloud SQL Proxy.
Same for alpha.
This is the first thing I have typed into Cloud Shell, so I can't imagine what could have broken PromptSession.
How can I resolve this error and log into SQL Server using Cloud Shell?
There most likely is an issue while attempting to connect from the Cloud Shell (I managed to connect from a Compute Engine instance with this command); possibly related to the Python run-time / environment variable. It has been reported here. Engineering is aware and are looking into it.

Python:Pycall Validation Error while Calling

I have Asterisk 13.20 set up and running fine on Ubuntu 16.04,calls are going well through a Softphone(Zoiper), I came across a Library in Python "Pycall" which lets you make calls through a Python Script.So I tried testing a snippet from the site Pycall
The code that I used:
from pycall import CallFile, Call, Application
call = Call('SIP/flowroute/18882223333')
action = Application('Playback', 'hello-world')
c = CallFile(call, action)
c.spool()
Just made changes in the extension,wherein I used one from my server
However I am getting the following error:
Traceback (most recent call last):
File "test.py", line 10, in <module>
c.spool()
File "/usr/local/lib/python2.7/dist-packages/pycall/callfile.py", line 131, in spool
self.writefile()
File "/usr/local/lib/python2.7/dist-packages/pycall/callfile.py", line 119, in writefile
f.write(self.contents)
File "/usr/local/lib/python2.7/dist-packages/pycall/callfile.py", line 114, in contents
return '\n'.join(self.buildfile())
File "/usr/local/lib/python2.7/dist-packages/pycall/callfile.py", line 96, in buildfile
raise ValidationError
pycall.errors.ValidationError
Tried searching online for the solution but coudnt find one,What am I doing wrong?
This question not related to PBX, it is just incorrect use of LIB.
General instruction how to solve ANY issue with availible source code.
You have error
File "/usr/local/lib/python2.7/dist-packages/pycall/callfile.py", line 96, in buildfile
Go that file and line, check code, add more debug if needed, fix your app.
Run as asterisk user.
sudo su asterisk -s /bin/bash
python
from pycall import CallFile, Call, Application
call = Call('SIP/flowroute/18882223333')
action = Application('Playback', 'hello-world')
c = CallFile(call, action)
c.spool()

Google App Engine Launcher not running application

I started using Google App Engine Launcher in Python. I have also installed Python 2.7 on my PC and confirmed the interpreter works.
When I click run on an application a yellow triangle with an exclamation mark appears next to the name. I have tried accessing the application on localhost:8080, but as expected nothing shows up.
This is my error code:
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\appinfo.py", line 1873, in LoadSingleAppInfo
listener.Parse(app_info)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\yaml_listener.py", line 226, in Parse
self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\yaml_listener.py", line 177, in _HandleEvents
raise yaml_errors.EventError(e, event_object)
google.appengine.api.yaml_errors.EventError: Unable to assign value 'Hello-Udacity' to attribute 'application':
Value 'Hello-Udacity' for application does not match expression '^(?:(?:[a-z\d\-]{1,100}\~)?(?:(?!\-)[a-z\d\-\.]{1,100}:)?(?!-)[a-z\d\-]{0,99}[a-z\d])$'
in "C:\Users\username\Hello-Udacity\app.yaml", line 1, column 14
2014-04-22 00:07:52 (Process exited with code 1)
Any ideas on what is causing this? Why is the application not running?
Your error code indicates that your app id does not follow the allowed format. Looks like you are not allowed to use uppercase letters.

Flask Config Sytax Error - Independent of File Contents

I'm creating a Flask application, and attempting to load configuration from a file. Not too hard right? I'm loading it like this:
from flask import Flask
app = Flask(__name__)
app.config.from_pyfile('../config.py')
The config file looks something like this:
# App settings
DEBUG = True
TESTING = True
The issue is, it returns an error...
[root#helios gdn]# env/bin/python run.py
Traceback (most recent call last):
File "run.py", line 3, in <module>
from gdn import app
File "/var/www/gdn/gdn/__init__.py", line 5, in <module>
app.config.from_pyfile('../config.py')
File "/var/www/gdn/env/lib/python2.6/site-packages/flask/config.py", line 129, in from_pyfile
exec(compile(config_file.read(), filename, 'exec'), d.__dict__)
File "/var/www/gdn/gdn/../config.py", line 1
DEBUG = True
^
That is strange... So I tried replacing the contents, even with the lines print 'foo' / print 'bar' and it returns the same error, referencing the end of the line. Empty files work, and single lines work, but multiple lines? Nope. Each line is ended with a single \n, just like the rest of my Python files. I cannot find what is causing the issue.
I'm running Python 2.6.6 on a CentOS VM.
Make sure your config.py file is present just inside the project root and you can call that config file like this
app.config.from_object('config')
Hope it helps !

Cloud code from parse.com

I'm trying to use cloud code from parse.com but when I type "parse new" in the Terminal the following error occurs
parse new
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/bin/parse/__main__.py", line 5, in <module>
File "/usr/local/bin/parse/main.py", line 550, in main
File "/usr/local/bin/parse/main.py", line 281, in handle_new
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 71, in join
path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcc in position 48: ordinal not in range(128)
I'd used cloud code for a test app earlier today and everything went smoothly, but when trying to set up cloud code for the new app the above happened.
Can anyone tell me what Im doing wrong?
It seems its a problem is that the name of the directory I was in had an accent which caused problems. It works now!
You can't write cloud code directly in parse cloud,
For that You have to install parse console
and Create Parse App in local/cloud directory.
parse new "Your_app_name"
enter your credentials
and it will generate app
in app there is CLOUD Folder -> Traverse Their ->in main.js Edit your code
and Finaly push by parse deploy command.
Here is my answer:
Use this command to generate a new app:
parse new "yourappnamehere"
It will create your parse app. If you want to use express use:
parse generate express

Categories