scrapy crawl <spider_name> works fine in my project.
In a smoke test I crawl a private page and assert the items are as expected.
Things were fine until I finished a serious project refactor, which for the smoke test ends up setting an env var in setUp(), which in effect sets os.environ['SCRAPY_SETTINGS_MODULE'] = '<project_name>.settings'
After setting this env var, scrapy crawl complains that 'ImportError: No module named <project_name>.settings'
scrapy.cfg settings are correct, every thing else except this smoke test works fine.
The problem goes away simply by os.environ.pop('SCRAPY_SETTINGS_MODULE') before os.sys('scrapy crawl <spider_name>'), but this doesn't feel right.
So, please someone let me know whtat caused the problem and what is the proper way to fix it, thanks!
I found out the reason:
Before scrapy crawl scrapy executes scrapy.utils.project.get_project_settings, where scrapy.utils.conf.init_env is called if os.environ['SCRAPY_SETTINGS_MODULE'] is not set, where project main dir is added to sys.path.
By setting this env var, the copy of sys.path scrapy gets does not have the path for project main dir, so the import fails.
Popping out os.environ['SCRAPY_SETTINGS_MODULE'] will cause init_env to be called, thus scrapy crawl works as supposed. Another way to get around would be to set os.environ['PYTHONPATH'] to project main dir path, which is where scrapy looks later for the path.
The approach I finally take is to modify scrapy, disable the check for os.environ['SCRAPY_SETTINGS_MODULE'], and always execute init_env. The worst cost for this is that every time scrapy crawl executes, scrapy will look for the project main dir path once, which does not seem like much work to me. And the path will not be added multiple times to sys.path because it is checked before appending.
That's about it, please let me know if I am mistaken somewhere, thanks!
Related
Reading the CLI Docs, there doesn't appear to be a way to set the default browser window size. Is there a way to do this so that each test or each test fixture doesn't have to?
I should point out that adding a resizeWindow call in each test, or even once per test fixture is not a scalable solution across many fixtures so the "proper" solution should/would involve some sort of config so it only needs to be set once.
TestCafe does not have such an option out of the box. However, you can put the t.resizeWindow action into the beforeEach test hook.
Another way is to run a browser with the special command line argument.
For example, the command line for Chrome:
testcafe "chrome '--window-size=800,600'" test.js
I have direnv installed, and I was wondering if there was a way of stopping it from showing all of the environment variables it loads? The output lines it currently shows are:
direnv: loading .envrc
direnv: export +FOO +BAR +FOO2 +BAR2 +FOO3 +BAR3 +FOO4 +BAR4
I'm fine with having the first line show, but since my second line has something like 50 variables in it, it's slightly annoying to have the lot of them shown every time I go into the directory.
It's possible to remove the logs entirely by setting export DIRENV_LOG_FORMAT= but then the rest of the logs are also missing
As far as I know, you cannot change that behavior through configuration.
If that behavior was part of the stdlib, you could override it. In fact, the first ouput, direnv: loading .envrc comes from source_env which uses log_status to output to stderr, so you could override either of source_env or log_status in ~/.config/direnv/.direnvrc or ~/.direnvrc.
However, the second output is coming from diffString in cmd_export.go (via log_status in log.go). Short of compiling your own, modified version of direnv, I don't see how you can change that behavior as of the current release (v2.17.0).
I just started testing with Karma. When i specify a browser in the config-file it basically just opens a window that tells me that the test is idle or running, nothing more and nothing less. That doesn't make sense to me, why would i need a browser for that? Okay i get it you need to debug but thats another page where you can debug isn't it?
Although this site is reloading when Karma is doing something, the other , way more usefull, karma-html-reporter output stays like it is until i reload it manually.
Is there any way to either
(A) Show the test ouput in a html-reporter like fashion on the connected-page?
or
(B) Connect the html-reporter-page to the socket and live-reload it?
I know i can just use the console, but isn't it nice to have some order and styling in all the chaos?
I am building a simple Safari extension and sometimes the start script start.js specified is never included ans sometimes it is included many times like so :
Has it ever happened to you ?
This is probably due to iframes. The injected script is loaded in every iframe in the current tab. I don't think you can stop the script itself loading, but you can use if (window == window.top) within the script to ensure that code is only executed in the main page, not the contained iframes.
mod_ajax_dock cart Not working in which come following error.
this.load undefined or can not Cannot read property 'style'.
so plz help me solve this question
That's generally a Javascript conflict caused by the various scripts that your site is loading. The first place to start is to install jQuery Easy to strip out multiple instances of jQuery as well as the usually loaded Mootools. You will have to mess around with the settings, I usually have it strip everything out and see what breaks, then start adding scripts back in until everything works.
http://extensions.joomla.org/extensions/core-enhancements/performance/jquery-scripts/18327