dajaxice collectstatic creating a temp file - boto

I'm having a problem with Dajaxice and how it appears to create a custom javascript file to be used for ajax. When one runs manage.py collectstatic with Dajaxice installed, it creates a custom javascript file. This post references this issue as well. In my case running:
python manage.py findstatic dajaxice/dajaxice.core.js
gives:
Found 'dajaxice/dajaxice.core.js' here:
/private/var/folders/dp/yw0xd2f52yg7qmt992s72_9r0000gn/T/tmpRWRAGT
when run locally. The problem I have is that when pairing this with django-storages and boot to serve static files from Amazon S3, it blows up because that file is created referencing an absolute path instead of a relative path (I think it's boto that doesn't implement something that django-storages doesn't like). The error looks like this:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 163, in handle_noargs
collected = self.collect()
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 113, in collect
handler(path, prefixed_path, storage)
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 290, in copy_file
source_path = source_storage.path(path)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/storage.py", line 82, in path
raise NotImplementedError("This backend doesn't support absolute paths.")
(in this case, I'm deploying on Heroku, which is why I can't just copy the created file manually to a static location and reference it). Is there a way around this? Can I make Dajaxice put the generated file in a relative path location? Or can I get around it by forcing django-storages/boto to accept an absolute path? Or if all else fails, is there an easy way to pre-generate the file short of uninstalling all my S3 dependencies when I collectstatic, copying the file over and forcing Dajax to stop looking for the generated file?
Any help appreciated.

I have meet this issue, please see https://github.com/jorgebastida/django-dajaxice/issues/66,
use
python manager.py collectstatic

Related

Unable to start rst2html5slides after installation

We are using Powerpoint and Restructured Text together with Python-Sphinx. I was asking myself, if it is possible to create slides using ReST.
I found the interesting Tool rst2html5slides on
https://rst2html5slides.readthedocs.io/en/latest/index.html.
I installed the tool with:
pip install rst2html5slides
This worked without problems.
Now, I was unable to use the tool. Typing rst2html5slides on my console gives:
Traceback (most recent call last):
File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\rst2html5slides.exe\__main__.py", line 5, in <module>
File "c:\python27\lib\site-packages\rst2html5slides.py", line 16, in <module>
from rst2html5 import HTML5Translator, HTML5Writer
ImportError: No module named rst2html5
Typing pip list issues:
rst2html5 1.9.4
rst2html5slides 1.0
After inspecting my c:\python27\lib\site-packages\ directory I found out, that there is an rst2html5slides_.py, but no rst2html5slides.py. So I tried to just rename this file.
No it was possible for me to start rst2html5slides --traceback presentation.txt simple_deck.html, but I just have another problem.
Traceback (most recent call last):
File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\rst2html5slides.exe\__main__.py", line 9, in <module>
File "c:\python27\lib\site-packages\rst2html5slides.py", line 484, in main
publish_cmdline(writer=SlideWriter(), description=description)
File "c:\python27\lib\site-packages\docutils\core.py", line 352, in publish_cmdline
config_section=config_section, enable_exit_status=enable_exit_status)
File "c:\python27\lib\site-packages\docutils\core.py", line 219, in publish
output = self.writer.write(self.document, self.destination)
File "c:\python27\lib\site-packages\docutils\writers\__init__.py", line 80, in write
self.translate()
File "c:\python27\lib\site-packages\rst2html5slides.py", line 200, in translate
HTML5Writer.translate(self)
File "c:\python27\lib\site-packages\rst2html5.py", line 227, in translate
self.document.walkabout(visitor)
File "c:\python27\lib\site-packages\docutils\nodes.py", line 187, in walkabout
visitor.dispatch_departure(self)
File "c:\python27\lib\site-packages\docutils\nodes.py", line 1895, in dispatch_departure
return method(node)
File "c:\python27\lib\site-packages\rst2html5slides.py", line 294, in depart_document
self._ordered_tag_attributes(deck,
AttributeError: SlideTranslator instance has no attribute '_ordered_tag_attributes'
AttributeError: SlideTranslator instance has no attribute '_ordered_tag_attributes'
Exiting due to error. Use "--traceback" to diagnose.
Please report errors to <docutils-users#lists.sf.net>.
Include "--traceback" output, Docutils version (0.12 [release]),
Python version (2.7.10), your OS type & version, and the
command line used.
What I'm doing wrong here?
rst2html5slides' author here. I've updated the package a while ago. Please, update it and it should run.

Python unable to detect file, throws an error

I run a cocos2dx to generate an APK file, but it throws out this error
BUILD SUCCESSFUL in 7m 49s
54 actionable tasks: 3 executed, 51 up-to-date
Traceback (most recent call last):
File "/cocos2dx/tools/cocos2d-console/bin/cocos.py", line 1072, in <module>
run_plugin(command, argv, plugins)
File "/cocos2dx/tools/cocos2d-console/bin/cocos.py", line 961, in run_plugin
plugin.run(argv, dependencies_objects)
File "/cocos2dx/tools/cocos2d-console/plugins/plugin_compile/project_compile.py", line 1646, in run
self.build_android()
File "/cocos2dx/tools/cocos2d-console/plugins/plugin_compile/project_compile.py", line 581, in build_android
self.apk_path = builder.do_build_apk(build_mode, self._no_apk, output_dir, self._custom_step_args, self._ap, self)
File "/cocos2dx/tools/cocos2d-console/plugins/plugin_compile/build_android.py", line 669, in do_build_apk
shutil.copy(gen_apk_path, output_dir)
File "/usr/lib/python2.7/shutil.py", line 119, in copy
copyfile(src, dst)
File "/usr/lib/python2.7/shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: '/project/Cocos2dx/proj.android-studio/app/build/outputs/apk/Cocos2dx-debug.apk
Any idea what could be the issue?
You should use Android Studio (instead of run the python function to call ANT) to build the project to apk. It's far easier use, trace error and debug.
about your question:
/project/Cocos2dx/proj.android-studio/app/build/outputs/apk/Cocos2dx-debug.apk
this path is belong to project Android Studio. In my experience, when using the cocos console command, it use proj.android instead of proj.android-studio

Get rid of pyximport

I'm trying to use Cython. I use setup.py and build as opposed to letting pyximport do this. However, every time I import my module it seems pyximport is called. Pyximport fails to build and everything crashes.
I use Spyder. I do not have a single reference to pyximport in my project, but Spyder does not seem to care and keeps calling pyximprot.
I called my program from the command window (outside Spyder) and it ran just fine.
How can i get rid of the call to pyximport? Or is something else going on?
import c_result
Traceback (most recent call last):
File "<ipython-input-2-3e92d1c50179>", line 1, in <module>
import c_result
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyximport\pyximport.py", line 458, in load_module
language_level=self.language_level)
File "C:\Users\xxxR\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyximport\pyximport.py", line 231, in load_module
raise exc.with_traceback(tb)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyximport\pyximport.py", line 215, in load_module
inplace=build_inplace, language_level=language_level)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyximport\pyximport.py", line 191, in build_module
reload_support=pyxargs.reload_support)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyximport\pyxbuild.py", line 102, in pyx_to_dll
dist.run_commands()
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\Cython\Distutils\old_build_ext.py", line 185, in run
_build_ext.build_ext.run(self)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\distutils\command\build_ext.py", line 339, in run
self.build_extensions()
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\Cython\Distutils\old_build_ext.py", line 192, in build_extensions
ext.sources = self.cython_sources(ext.sources, ext)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\site-packages\Cython\Distutils\old_build_ext.py", line 327, in cython_sources
self.mkpath(os.path.dirname(target))
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\distutils\cmd.py", line 338, in mkpath
dir_util.mkpath(name, mode, dry_run=self.dry_run)
File "C:\Users\xxx\AppData\Local\Continuum\Anaconda3\lib\distutils\dir_util.py", line 74, in mkpath
"could not create '%s': %s" % (head, exc.args[-1]))
ImportError: Building module c_result failed: ["distutils.errors.DistutilsFileError: could not create 'C:\\Windows\\system32\\config\\systemprofile': Kan ikke opprette en fil når filen allerede finnes\n"]
The problem appeared in Spyder because the package's initialization actually loads pyximport and calls pyximport.install(), in the file utils/site/sitecustomize.py.
Other have complained about it on GitHub:
spyder issue #5299
spyder issue #5087
A solution that is not elegant (will not survive updates of spyder, for instance) but that should work is to manually edit the sitecustomize.py file in your spyder installation and remove the section under if HAS_PYXIMPORT:
(Spyder maintainer here) This problem was fixed in our 3.2.8 version, released on March 2018.

Compress command fails on fresh installation of WireCloud

I cannot set up a basic wirecloud instance anymore. I tried to create a minimum Wirecloud instance like this:
virtualenv venv
source venv/bin/activate
pip install wirecloud
wirecloud-admin startproject prj
cd prj/
python manage.py collectstatic
python manage.py compress --force
Upon the call to compress the static files an error is thrown:
CommandError: An error occurred during rendering /opt/wc/venv/local/lib/python2.7/site-packages/wirecloud/defaulttheme/templates/wirecloud/views/base_plain.html: Error parsing expression at 30:
none if($important, !important)
^
on line 2 of theme/wirecloud.defaulttheme/css/base/z-depth.scss
Traceback:
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/calculator.py", line 167, in parse_expression
ast = getattr(parser, target)()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 110, in goal
expr_lst = self.expr_lst()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 199, in expr_lst
expr_slst = self.expr_slst()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 211, in expr_slst
or_expr = self.or_expr()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 216, in or_expr
and_expr = self.and_expr()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 225, in and_expr
not_expr = self.not_expr()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 236, in not_expr
comparison = self.comparison()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 244, in comparison
a_expr = self.a_expr()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 275, in a_expr
m_expr = self.m_expr()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 290, in m_expr
u_expr = self.u_expr()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 319, in u_expr
atom = self.atom()
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/grammar/expression.py", line 359, in atom
return TernaryOp(expr_lst)
File "/opt/wc/venv/local/lib/python2.7/site-packages/scss/ast.py", line 558, in __init__
raise SyntaxError("if() must have exactly 3 arguments")
SyntaxError: if() must have exactly 3 arguments
What is the problem here? I just set up the most basic Wirecloud instance possible. If I do not compress it the same error gets thrown in the browser. Is the latest release of wirecloud broken? Or is it something else?
What do I need to do to get a running version again? Help would be much appreciated since the docker image seems to not be able to get restarted and configurations like other databases and so on are thus not very easy to set up...
Use the just released version 0.9.2 of WireCloud :)
See this github ticket for more details.
We are also updated the docker images but if you continue have problems using it, please create a Github ticket or create a new question on StackOverflow with the details.
Wirecloud seems to not be ready for pyscss version 1.3.5.
A downgrade via ´pip install -I pyscss==1.3.4` will do the trick.

Pyramid, Python3, SQLAlchemy and MySQL

I want Pyramid, Python3, SQLAlchemy and MySQL to play nice on a single machine. This question has been asked before, but it was a long enough time ago that I'm hoping the answer has changed...
Questions:
What driver works for getting a Python 3 Pyramid app to talk nicely to MySQL via SQLAalchemy? Is this even possible?
I've gotten quite far in this project thinking it would be a simple thing to switch out databases, now I'm a bit stuck and downgrading to Python 2.7 is not something I want to have to go through. So my second question is:
If there is no way to talk to MySQL nicely without downgrading, is there a database that Python 3 is ready for (besides SQLite)?
Or lastly, how would I overcome any of the problems mentioned in the 'Stuff I've Tried' section below?
Stuff I've Tried:
PyMySQL
I have PyMySQL installed and I even got it to complain about incorrect passwords and a missing database so it's getting something right. But when I tried to initialize my database (using initialize_foo_db) everything went sour:
2013-02-06 17:18:31,282 INFO [sqlalchemy.engine.base.Engine][MainThread] b'SELECT DATABASE()'
2013-02-06 17:18:31,282 INFO [sqlalchemy.engine.base.Engine][MainThread] ()
Traceback (most recent call last):
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/pool.py", line 719, in _do_get
return self._pool.get(wait, self._timeout)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/util/queue.py", line 137, in get
raise Empty
sqlalchemy.util.queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "../bin/initialize_mega_db", line 9, in <module>
load_entry_point('mega==0.0', 'console_scripts', 'initialize_mega_db')()
File "/home/sheena/MegaCatalogue/env/mega/mega/scripts/initializedb.py", line 46, in main
Base.metadata.create_all(engine)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/schema.py", line 2567, in create_all
tables=tables)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/base.py", line 2301, in _run_visitor
conn = self.contextual_connect(close_with_result=False)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/base.py", line 2492, in contextual_connect
self.pool.connect(),
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/pool.py", line 224, in connect
return _ConnectionFairy(self).checkout()
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/pool.py", line 387, in __init__
rec = self._connection_record = pool._do_get()
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/pool.py", line 741, in _do_get
con = self._create_connection()
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/pool.py", line 188, in _create_connection
return _ConnectionRecord(self)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/pool.py", line 273, in __init__
pool.dispatch.first_connect.exec_once(self.connection, self)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/event.py", line 279, in exec_once
self(*args, **kw)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/event.py", line 288, in __call__
fn(*args, **kw)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/strategies.py", line 168, in first_connect
dialect.initialize(c)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/dialects/mysql/base.py", line 1999, in initialize
default.DefaultDialect.initialize(self, connection)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/default.py", line 177, in initialize
self._get_default_schema_name(connection)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/dialects/mysql/base.py", line 1964, in _get_default_schema_name
return connection.execute('SELECT DATABASE()').scalar()
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/base.py", line 1449, in execute
params)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/base.py", line 1628, in _execute_text
statement, parameters
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/base.py", line 1691, in _execute_context
context)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/SQLAlchemy-0.7.8-py3.2.egg/sqlalchemy/engine/default.py", line 333, in do_execute
cursor.execute(statement, parameters)
File "/home/sheena/MegaCatalogue/env/local/lib/python3.2/site-packages/PyMySQL3-0.5-py3.2.egg/pymysql/cursors.py", line 108, in execute
query = query % escaped_args
TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple'
oursql
I tried installing oursql using pip install -r file
where file contains:
#oursql==0.9.3 but need special Python 3 build https://bugs.launchpad.net/oursql/+bug/1051512
https://launchpad.net/oursql/py3k/py3k-0.9.3/+download/oursql-0.9.3.zip
pyramid==1.3.4
And I got:
oursqlx/compat.h:13:19: fatal error: mysql.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
myconnpy
This installs without error but I can't seem to find out what I should tell SQLAlchemy to look for. In the appropriate settings.ini file I have tried:
sqlalchemy.url = mysql+myconnpy://...
as well as a bunch of other things. Google is failing me on this one...
UPDATE - a semblance of progress
I've managed to install oursql build dependencies:
sudo aptitude install python-pip libmysqlclient-dev
I then downloaded oursql0.9.3 and ran:
setup.py install
The output was this:
cython not found, using previously-cython'd .c file.
running install
running build
running build_ext
running install_lib
copying build/lib.linux-x86_64-3.2/oursql.cpython-32mu.so -> /home/sheena/MegaCatalogue/env/lib/python3.2/site-packages
running install_egg_info
Writing /path/to/virtualenv/foo/lib/python3.2/site-packages/oursql-0.9.3.egg-info
I opened a shell and apparently the module doesn't exist - it can't be imported anyway. But for some reason it is listed if I say help() then modules