Cloud code from parse.com - python

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

Related

PyCharm error: RuntimeError, Click will abort further execution because Python 3

I am learning Flask and first to use PyCharm.
Here is the template code:
from flask import Flask
app = Flask(__name__)
#app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
When i click to run, Here is the Error Info:
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/jzd/Movies/flask/Three_pyCharm/venv/lib/python3.6/site-packages/flask/__main__.py", line 14, in <module>
main(as_module=True)
File "/Users/jzd/Movies/flask/Three_pyCharm/venv/lib/python3.6/site-packages/flask/cli.py", line 894, in main
cli.main(args=args, prog_name=name)
File "/Users/jzd/Movies/flask/Three_pyCharm/venv/lib/python3.6/site-packages/flask/cli.py", line 557, in main
return super(FlaskGroup, self).main(*args, **kwargs)
File "/Users/jzd/Movies/flask/Three_pyCharm/venv/lib/python3.6/site-packages/click/core.py", line 676, in main
_verify_python3_env()
File "/Users/jzd/Movies/flask/Three_pyCharm/venv/lib/python3.6/site-packages/click/_unicodefun.py", line 118, in _verify_python3_env
'for mitigation steps.' + extra)
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult http://click.pocoo.org/python3/for mitigation steps.
This system lists a couple of UTF-8 supporting locales that
you can pick from. The following suitable locales where
discovered: af_ZA.UTF-8, am_ET.UTF-8, be_BY.UTF-8, bg_BG.UTF-8, ca_ES.UTF-8, cs_CZ.UTF-8, da_DK.UTF-8, de_AT.UTF-8, de_CH.UTF-8, de_DE.UTF-8, el_GR.UTF-8, en_AU.UTF-8, en_CA.UTF-8, en_GB.UTF-8, en_IE.UTF-8, en_NZ.UTF-8, en_US.UTF-8, es_ES.UTF-8, et_EE.UTF-8, eu_ES.UTF-8, fi_FI.UTF-8, fr_BE.UTF-8, fr_CA.UTF-8, fr_CH.UTF-8, fr_FR.UTF-8, he_IL.UTF-8, hr_HR.UTF-8, hu_HU.UTF-8, hy_AM.UTF-8, is_IS.UTF-8, it_CH.UTF-8, it_IT.UTF-8, ja_JP.UTF-8, kk_KZ.UTF-8, ko_KR.UTF-8, lt_LT.UTF-8, nl_BE.UTF-8, nl_NL.UTF-8, no_NO.UTF-8, pl_PL.UTF-8, pt_BR.UTF-8, pt_PT.UTF-8, ro_RO.UTF-8, ru_RU.UTF-8, sk_SK.UTF-8, sl_SI.UTF-8, sr_YU.UTF-8, sv_SE.UTF-8, tr_TR.UTF-8, uk_UA.UTF-8, zh_CN.UTF-8, zh_HK.UTF-8, zh_TW.UTF-8
I think the line is important.
RuntimeError: Click will abort further execution because Python 3 was
configured to use ASCII as encoding for the environment.
I find the answer Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment .
While still not to know how to fix it.
Instructions is very needed, which is easy to follow .
The Run/debug configurations can be opened from here.
There you can add the environment variable using this.(click the 3 dot icon next to the environment variables)

Google App Engine dev_appserver.py: watcher_ignore_re flag "is not JSON serializable"

Why I run the dev_appserver.py with the option watcher_ignore_re, I get an error message that the regex is not JSON serializable.
Is this a bug with the development server? Am I using this command improperly? The command and callstack is printed below.
C:\Users\mes65\Documents\MyProject>"C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin\dev_appserver.py" ^
--watcher_ignore_re="(.*\.git|.*\.idea|tmp\.py)" ^
"C:\Users\mes65\Documents\MyProject"
WARNING 2018-06-06 09:28:59,161 appinfo.py:1622] lxml version "2.3" is deprecated, use one of: "3.7.3"
INFO 2018-06-06 09:28:59,187 devappserver2.py:120] Skipping SDK update check.
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 96, in <module>
_run_file(__file__, globals())
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 90, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 454, in <module>
main()
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 442, in main
dev_server.start(options)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 163, in start
bool(ssl_certificate_paths), options)
File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\metrics.py", line 166, in Start
self._cmd_args = json.dumps(vars(cmd_args)) if cmd_args else None
File "C:\Python27\lib\json\__init__.py", line 244, in dumps
return _default_encoder.encode(obj)
File "C:\Python27\lib\json\encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\Python27\lib\json\encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "C:\Python27\lib\json\encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <_sre.SRE_Pattern object at 0x00000000063C2188> is not JSON serializable
It looks like it is an issue with the google analytics code built into dev_appserver2 (google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py on or around line 316). It wants to send all of your command line options to google analytics. If you remove the analytics client id by adding the command line option --google_analytics_client_id= (note: '=' without any following value) the appserver won't call the google analytics code where it is trying to JSON serialize an SRE object and failing. However, since you are on Windows I find that the --watcher_ignore_re does not work anyway even when you get past this issue.
There is a comment in file_watcher.py
TODO: b/33178251 - Add watcher_ignore_re support for windows.
I also faced with this usability problem on Windows and was really disappointed. I tried to find some workarounds but I hadn't found any appropriate way.
In the end, I decided to make my own implementation of support watcher_ignore_re for Windows. I put required changes in my Github repo
If describe them in several words:
Add _watcher_ignore_re, _skip_files_re properties and its setters
Add import statement from google.appengine.tools.devappserver2 import watcher_common and use it in newly created def _path_ginored
Filter additional_changes before adding them to watcher changed files
For resolving mentioned problem with not serializable regex attribute we should drop them from the serialized dictionary. Fix for this is added as consequent commit and can be checked at metrics.py:185-193.
I hope it helps other guys enjoy developing on GAE on Windows :)

tf.gfile.Glob gives me UnicodeDecodeError error anyway to fix this?

I was trying to get the list of name of txt file that was written in Korean in the specified directory with the code below
dir_list = tf.gfile.Glob(engine.TXT_DIR+"/*.txt")
However, This one gives me the following error:
Traceback (most recent call last):
File "D:/Prj_mayDay/Prj_FrankenShtine/shakespear_reborn/main.py", line 108, in <module>
dir_list = tf.gfile.Glob(engine.TXT_DIR+"/*.txt")
File "D:\KimKanna's Class\python35\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 326, in get_matching_files
compat.as_bytes(filename), status)
File "D:\KimKanna's Class\python35\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 325, in <listcomp>
for matching_filename in pywrap_tensorflow.GetMatchingFiles(
File "D:\KimKanna's Class\python35\lib\site-packages\tensorflow\python\util\compat.py", line 106, in as_str_any
return as_str(value)
File "D:\KimKanna's Class\python35\lib\site-packages\tensorflow\python\util\compat.py", line 84, in as_text
return bytes_or_text.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 19: invalid start byte
Now, throughout some research, I found out the reason
The error is because there is some non-ascii character in the dictionary and it can't be encoded/decoded
However, I do not see any way to apply the solution into my code. or is there?
**if there is alternative code for this. It should be applicable for both cloud stroage bucket / my personal hard drive as the code above did.
I'm using python3, Tensorflow version of 1.2.0-rc2
so after few hours of fiddling around with my code I finally found the solution.
Afterall one of the file inside of the directory I specified had a name in Korean. After I took that out of the directory. problem was gone.

django UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 87: invalid continuation byte

I'm trying to use aptana studio 3 for a django project, but got a unicodedecodeerror no matter what i did.
After a lot of unsuccessful google searches, tried a barebones django project. Not a line of code from me, just the start code from aptana.
I expected the usual blank page from django (project working, nothing done yet), but STILL got the encode error. I didn't write a single line of code, so there's no template with latin characters or any other encoding/decoding.
Tried:
Windows->Preferences->General->Workspace->Text file encoding to UTF-8
Right click on project ->Resource->Text file encoding to UTF-8
# -- coding: utf-8 -- on first line of every file
Nothing Worked.
I'm kind of stuck here. Can anyone help?
Win7 64bit
Error message from console:
Validating models...
0 errors found
April 02, 2014 - 17:55:34
Django version 1.6, using settings 'hello.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Traceback (most recent call last):
File "C:\Users\bruna\Documents\Aptana Studio 3 Workspace\hello\src\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 399, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 285, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 76, in handle
self.run(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 87, in run
self.inner_run(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 132, in inner_run
self.stderr.write("Error: %s" % error_text)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 65, in write
if ending and not msg.endswith(ending):
File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 87: invalid continuation byte
Judging by the stacktrace (the actual place where you should look for the root cause), there's something about msg (most likely, since ending is hardly 87 chars long) in if ending and not msg.endswith(ending): that isn't valid utf-8. This is probably an encoding issue in a settings file or input parameter.
I suggest to:
run the whole thing under PDB to see the value of msg or add a debug printing of repr(msg) before the offending line
track the origin of the incorrect data. It can very well be a developers' oversight (failure to check input data).
You try:
manage.py dbshell
ALTER TABLE database.table MODIFY COLUMN col VARCHAR(255) CHARACTER SET utf8 COLLATE
utf8_general_ci NOT NULL;
Change database.table and col.
Enjoy !
One reason is ,you used sed with grep in the past time like this:
sed -i "s#views_gaoji#fenye#g" grep -rl views_gaoji ./`
The above command will modify .pyc file without notification for you.
Then when you start your Django,
Django will start from .pyc,NOT from your engineering file.
Then you will get error without knowing where the error is
OR
you will get error in your manage.py file but you never modify it,
so why did it say,your manage.py has error?
---------------------------------------------------------------------
That's because you *.pyc file are changed by sed command
Solution:
find . -name "*.pyc" | xargs rm -f
and then type:
python manage.py runserver port

Looks like logs are crashing my Django app

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.

Categories