import openlayers3 in ember.js - ember.js

I am starting up an ember.js app aimed at drawing and displaying maps.
I am using ember.js v1.11.0 and ol3 v3.4.0
I managed to install ol3 via bower and import it using Brocfile.js:
app.import('bower_components/ol3/build/ol.js');
app.import('bower_components/ol3/css/ol.css');
I can use it as well without problem in my views, etc. What I would like if possible is to get rid of the server errors:
views/map.js: line 6, col 22, 'ol' is not defined.
views/map.js: line 7, col 19, 'ol' is not defined.
views/map.js: line 10, col 21, 'ol' is not defined.
views/map.js: line 11, col 19, 'ol' is not defined.
views/map.js: line 14, col 19, 'ol' is not defined.
views/map.js: line 17, col 17, 'ol' is not defined.
And if possible get autocompletion in my Intellij IDEA (make it recognise the ol library)
If somebody could give me a hand, that owuld be much apreciated.

add ol to your .jshintrc file. in the predef array:
"predef": [
"document",
"window",
"-Promise",
"ol"
]
....
And for the intellij-idea you should be able to get your answer from the docs here:
https://www.jetbrains.com/idea/help/configuring-javascript-libraries.html

Related

ember build error: the code generator has deoptimised the styling of as it exceeds the max of 100KB

Problem:
1. the ember build process completes with warnings and culminates with a corrupt output file that throws a Uncaught SyntaxError: Invalid or unexpected token on the chromium client, which prevents the app to load.
Symptoms:
1. "After bower install bootstrap --save and necessary app.import(...) commands, the ember build process threw a couple of warnings [BABEL]: the code generator has deoptimised the styling of bower_components/bootsrap/....../jquery.js as it exceeds the max of 100KB, followed with a 129 JSHint errors.
first few lines of JSHint Errors:
bower_components/bootstrap/Gruntfile.js: line 8, col 1, 'module' is not defined.
bower_components/bootstrap/Gruntfile.js: line 18, col 12, 'require' is not defined.
bower_components/bootstrap/Gruntfile.js: line 19, col 14, 'require' is not defined.
bower_components/bootstrap/Gruntfile.js: line 20, col 32, 'require' is not defined.
bower_components/bootstrap/Gruntfile.js: line 21, col 25, 'require' is not defined.
bower_components/bootstrap/Gruntfile.js: line 28, col 26, 'require' is not defined.
bower_components/bootstrap/Gruntfile.js: line 29, col 32, 'require' is not defined.
bower_components/bootstrap/Gruntfile.js: line 434, col 3, 'require' is not defined.
bower_components/bootstrap/Gruntfile.js: line 435, col 3, 'require' is not defined.
bower_components/bootstrap/Gruntfile.js: line 23, col 30, '__dirname' is not defined.
bower_components/bootstrap/Gruntfile.js: line 395, col 18, 'process' is not defined.
bower_components/bootstrap/Gruntfile.js: line 441, col 13, 'process' is not defined.
bower_components/bootstrap/Gruntfile.js: line 441, col 38, 'process' is not defined.
bower_components/bootstrap/Gruntfile.js: line 452, col 7, 'process' is not defined.
bower_components/bootstrap/Gruntfile.js: line 458, col 24, 'process' is not defined.
bower_components/bootstrap/Gruntfile.js: line 462, col 14, 'process' is not defined.
bower_components/bootstrap/Gruntfile.js: line 466, col 24, 'process' is not defined
17 errors
bower_components/bootstrap/dist/js/bootstrap.js: line 8, col 61, Missing semicolon.
bower_components/bootstrap/dist/js/bootstrap.js: line 13, col 53, Missing semicolon.
bower_components/bootstrap/dist/js/bootstrap.js: line 14, col 59, Expected '===' and instead saw '=='.
bower_components/bootstrap/dist/js/bootstrap.js: line 14, col 78, Expected '===' and instead saw '=='.
bower_components/bootstrap/dist/js/bootstrap.js: line 15, col 113, Missing semicolon.
bower_components/bootstrap/dist/js/bootstrap.js: line 17, col 9, Expected an assignment or function call and instead saw an expression.
bower_components/bootstrap/dist/js/bootstrap.js: line 35, col 49, Missing semicolon.
bower_components/bootstrap/dist/js/bootstrap.js: line 42, col 6, Missing semicolon.
and similar errors pointing to files in the 'bootstrap' folder (which does not exist) and the 'jquery' folder in bower_components
reverting back to configuration without bootstrap did not resolve the issue, the build process throws the same errors even though no 'bootstrap' folder exists in the "bower_components" folder
ember-cli-build.js
``
/*jshint node:true*/
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
// Add options here
});
// Use app.import to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.
// app.import('bower_components/bootstrap/dist/css/bootstrap.css');
// app.import('bower_components/bootstrap/dist/css/bootstrap-theme.css');
// app.import('bower_components/bootstrap/dist/js/bootstrap.js');
return app.toTree();
};
``
bower.json
{
"name": "ember-client",
"dependencies": {
"ember": "~2.10.0",
"ember-cli-shims": "0.1.3",
"jquery": "^3.2.1"
}
}
package.json
{
"name": "ember-client",
"version": "0.0.0",
"description": "Small description for ember-client goes here",
"license": "MIT",
"author": "",
"directories": {
"doc": "doc",
"test": "tests"
},
"repository": "",
"scripts": {
"build": "ember build",
"start": "ember server",
"test": "ember test"
},
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^2.4.1",
"ember-cli": "2.10.0",
"ember-cli-app-version": "^2.0.0",
"ember-cli-babel": "^5.1.7",
"ember-cli-dependency-checker": "^1.3.0",
"ember-cli-htmlbars": "^1.0.10",
"ember-cli-htmlbars-inline-precompile": "^0.3.3",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-jshint": "^2.0.1",
"ember-cli-qunit": "^3.0.1",
"ember-cli-release": "^0.2.9",
"ember-cli-sri": "^2.1.0",
"ember-cli-test-loader": "^1.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-data": "^2.10.0",
"ember-export-application-global": "^1.0.5",
"ember-load-initializers": "^0.5.1",
"ember-resolver": "^2.0.3",
"ember-simple-auth": "1.2.0",
"ember-welcome-page": "^1.0.3",
"loader.js": "^4.0.10"
},
"engines": {
"node": ">= 0.12.0"
},
"private": true,
"dependencies": {
"ember-ajax": "2.5.6"
}
}
Resultant Error in file ember-client.js (compiled output of ember build in dist folder)
Deep within the file is buried one line #!/usr/bin/env node that causes the issue on the client
grunt.log.writeln('File ' + rawFilesJs.cyan + ' created.');
};
});
#!/usr/bin/env node
define('ember-client/bower_components/bootstrap/grunt/change-version', ['exports'], function (exports) {
'use strict';
/* globals Set */
/*!
Quick Fix:
1. the uncaught syntax error exists in the compiled js file (ember-client.js) in the dist folder, removing the syntax error (highlighted in the code below) fixes the 'uncaught syntax error' issue so the app can load successfully in the browser.
Question:
a) why is this happening?
b) how do I permanently fix this issue without having to edit the compiled file manually every time I build the app?
I have looked over other stackoverflow discussions, but still haven't resolved the issue relevant to my specific case.
Other discussions with similar problem:
Discussion # 1
Discussion # 2
Discussion # 3
You are running into the issue because you are doing an import from Bower. If you use this Ember addon it should handle some of the complexities of importing for you: https://github.com/ef4/ember-sass-bootstrap
ef4 is on the Ember core team, so you can generally trust his addons.

Wagtail sitemap produces VariableDoesNotExist error in console

We've noticed this error (below ) cropping up when running the Wagtail sitemap.xml, we haven't modified it, and it does work. These errors are just in the console/logs locally. Our server person wants to know if we should worry about these or not?
Exception while resolving variable 'priority' in template 'wagtailsitemaps/sitemap.xml'.
VariableDoesNotExist: Failed lookup for key [priority] in u"{u'lastmod': datetime.datetime(2015, 7, 22, 10, 57, 43, 759421, tzinfo=<UTC>), u'location': u'http://localhost/streamfield-page/news-index/news-1/'}"

Bokeh Line chart not plotting complete pandas dataframe

I'm not sure if this is an issue because charts are currently being updated in Bokeh but I can no longer plot a complete dataframe using Line charts from Bokeh in my Jupyter notebook. Using this example from the docs:
from collections import OrderedDict
import numpy as np
import pandas as pd
from bokeh.charts import Line
from bokeh.plotting import show, output_file
from bokeh.charts import Chart, Line
xyvalues = OrderedDict(
python=[2, 3, 7, 5, 26, 221, 44, 233, 254, 265, 266, 267, 120, 111],
pypy=[12, 33, 47, 15, 126, 121, 144, 233, 254, 225, 226, 267, 110, 130],
jython=[22, 43, 10, 25, 26, 101, 114, 203, 194, 215, 201, 227, 139, 160],
)
# any of the following commented are valid Line inputs
xyvalues = pd.DataFrame(xyvalues)
#xyvalues = xyvalues.values()
#xyvalues = np.array(xyvalues.values())
output_file("lines.html", title="line.py example")
chart = Line(xyvalues, title="Lines", ylabel='measures', legend=True)
show(chart)
I get: Incorrect dataframe plot which is clearly different to the example shown in the docs.
If I explicitly give the dataframe an index and pass all the columns like below then it gives the expected plot:
xyvalues = pd.DataFrame(xyvalues, index=range(14))
output_file("lines.html", title="line.py example")
chart = Line(xyvalues, y=['python', 'pypy', 'jython'],
title="Lines", ylabel='measures', legend=True)
show(chart)
My notebook specs:
You are using Jupyter notebook.
The version of the notebook server is 4.0.6 and is running on:
Python 2.7.11 |Anaconda 2.4.1 (64-bit)| (default, Dec 6 2015, 18:08:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
IPython 4.0.1 -- An enhanced Interactive Python.
Updating to 0.11.0dev4 through conda fixed the issue.
conda install -c bokeh/channel/dev bokeh

How do i get request and response count in scrapyd?

I am trying to get request and response count in scrapyd,while running multiple spider means 8 spider dynamically.I am try to get those count using python.
following counts:
enter code here{'downloader/request_bytes': 130427,
'downloader/request_count': 273,
'downloader/request_method_count/GET': 273,
'downloader/response_bytes': 2169984,
'downloader/response_count': 273,
'downloader/response_status_count/200': 271,
'downloader/response_status_count/404': 2,
'dupefilter/filtered': 416,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2015, 7, 21, 14, 21, 38, 13000),
'item_scraped_count': 119,
'log_count/DEBUG': 406,
'log_count/INFO': 44,
'offsite/domains': 9,
'offsite/filtered': 5865,
'request_depth_max': 14,
'response_received_count': 273,
'scheduler/dequeued': 273,
'scheduler/dequeued/memory': 273,
'scheduler/enqueued': 273,
'scheduler/enqueued/memory': 273,
'start_time': datetime.datetime(2015, 7, 21, 14, 16, 41, 144000)}
enter code here
Thanks,
Use the Stats Collection from Scrapy.
With this you can access the statistics dumped at the end to the console and if you write your own middleware you can combine the results of your 8 spiders together -- like in the example of the documentation.

Why my scrapy does not used all urls in start_urls list?

I have almost 300 urls in my start_urls list, but the scrapy only scrawl about 200 urls. But not all of these listed urls. I do not know why? How I can deal with that. I have to scrawl more items from the website.
Another question I do not understand is: how I can see the log error when the scrapy finishes? From the terminal or I have to write code to see the log error. I think the log is enabled by default.
Thanks for your answers.
updates:
The output is in the following. I do not know why there are only 2829 items scraped. There are 600 urls in my start_urls actually.
But when I only give 400 urls in start_urls, it can scrape 6000 items. I expect to scrape almost the whole website of www.yhd.com. Could anyone give any more suggestions?
2014-12-08 12:11:03-0600 [yhd2] INFO: Closing spider (finished)
2014-12-08 12:11:03-0600 [yhd2] INFO: Stored csv feed (2829 items) in myinfoDec.csv
2014-12-08 12:11:03-0600 [yhd2] INFO: Dumping Scrapy stats:
{'downloader/exception_count': 1,
'downloader/exception_type_count/twisted.web._newclient.ResponseNeverReceived': 1,
'downloader/request_bytes': 142586,
'downloader/request_count': 476,
'downloader/request_method_count/GET': 476,
'downloader/response_bytes': 2043856,
'downloader/response_count': 475,
'downloader/response_status_count/200': 474,
'downloader/response_status_count/504': 1,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2014, 12, 8, 18, 11, 3, 607101),
'item_scraped_count': 2829,
'log_count/DEBUG': 3371,
'log_count/ERROR': 1,
'log_count/INFO': 14,
'response_received_count': 474,
'scheduler/dequeued': 476,
'scheduler/dequeued/memory': 476,
'scheduler/enqueued': 476,
'scheduler/enqueued/memory': 476,
'start_time': datetime.datetime(2014, 12, 8, 18, 4, 19, 698727)}
2014-12-08 12:11:03-0600 [yhd2] INFO: Spider closed (finished)
Finally I solved the problem....
First,it does not crawl all url listed in start_urls is because I have a typo in url in start_urls. One of the "http://..." is mistakenly written as "ttp://...", the first 'h' is missing. Then it seems the spider stopped to looked at the rest urls listed after it. Horrifed.
Second, I solved the log file problem by click the configuiration panel of Pycharm, which provides showing log file panel. By the way, my scrapy framework is put into the Pycharm IDE. It works great for me. Not advertisement.
Thanks for all the comments and suggestions.