talpor / django-dashing

django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing
BSD 3-Clause "New" or "Revised" License
730 stars 107 forks source link

Repository Custom Widgets #72

Open bash-j opened 7 years ago

bash-j commented 7 years ago

Hi,

I am having trouble adding a custom widget to my dashboard because my webserver does not have access to the internet. I have downloaded the django dashing weather widget, placed the files in the static/widgets/weather folder, added the 'weather' widget to the 'INSTALLED_WIDGETS' config. Then I added the widget to my dashing-config.js file.

When I load the page in my browser I get an internal server error and error in the log file (shown below). How can I configure django-dashing to either not try to connect to an external webpage or use a local repository instead?

[2016-Nov-28 21:50:28] ERROR [django.request:124] Internal Server Error: /dashboard/
Traceback (most recent call last):
  File "d:\localapp\anaconda3\lib\urllib\request.py", line 1254, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "d:\localapp\anaconda3\lib\http\client.py", line 1106, in request
    self._send_request(method, url, body, headers)
  File "d:\localapp\anaconda3\lib\http\client.py", line 1151, in _send_request
    self.endheaders(body)
  File "d:\localapp\anaconda3\lib\http\client.py", line 1102, in endheaders
    self._send_output(message_body)
  File "d:\localapp\anaconda3\lib\http\client.py", line 934, in _send_output
    self.send(msg)
  File "d:\localapp\anaconda3\lib\http\client.py", line 877, in send
    self.connect()
  File "d:\localapp\anaconda3\lib\http\client.py", line 1252, in connect
    super().connect()
  File "d:\localapp\anaconda3\lib\http\client.py", line 849, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "d:\localapp\anaconda3\lib\socket.py", line 693, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "d:\localapp\anaconda3\lib\socket.py", line 732, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\localapp\anaconda3\lib\site-packages\django\core\handlers\exception.py", line 39, in inner
    response = get_response(request)
  File "d:\localapp\anaconda3\lib\site-packages\django\core\handlers\base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "d:\localapp\anaconda3\lib\site-packages\django\core\handlers\base.py", line 217, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "d:\localapp\anaconda3\lib\site-packages\django\core\handlers\base.py", line 215, in _get_response
    response = response.render()
  File "d:\localapp\anaconda3\lib\site-packages\django\template\response.py", line 109, in render
    self.content = self.rendered_content
  File "d:\localapp\anaconda3\lib\site-packages\django\template\response.py", line 86, in rendered_content
    content = template.render(context, self._request)
  File "d:\localapp\anaconda3\lib\site-packages\django\template\backends\django.py", line 66, in render
    return self.template.render(context)
  File "d:\localapp\anaconda3\lib\site-packages\django\template\base.py", line 208, in render
    return self._render(context)
  File "d:\localapp\anaconda3\lib\site-packages\django\template\base.py", line 199, in _render
    return self.nodelist.render(context)
  File "d:\localapp\anaconda3\lib\site-packages\django\template\base.py", line 994, in render
    bit = node.render_annotated(context)
  File "d:\localapp\anaconda3\lib\site-packages\django\template\base.py", line 961, in render_annotated
    return self.render(context)
  File "d:\localapp\anaconda3\lib\site-packages\django\template\loader_tags.py", line 174, in render
    return compiled_parent._render(context)
  File "d:\localapp\anaconda3\lib\site-packages\django\template\base.py", line 199, in _render
    return self.nodelist.render(context)
  File "d:\localapp\anaconda3\lib\site-packages\django\template\base.py", line 994, in render
    bit = node.render_annotated(context)
  File "d:\localapp\anaconda3\lib\site-packages\django\template\base.py", line 961, in render_annotated
    return self.render(context)
  File "d:\localapp\anaconda3\lib\site-packages\django\template\library.py", line 203, in render
    output = self.func(*resolved_args, **resolved_kwargs)
  File "d:\localapp\anaconda3\lib\site-packages\dashing\templatetags\dashing_tags.py", line 66, in widget_styles
    return load('<link rel="stylesheet" href="{}">\n', 'css')
  File "d:\localapp\anaconda3\lib\site-packages\dashing\templatetags\dashing_tags.py", line 57, in load
    path = remote_path(name)
  File "d:\localapp\anaconda3\lib\site-packages\dashing\templatetags\dashing_tags.py", line 31, in remote_path
    resource = json.load(reader(urllib2.urlopen(dashing_settings.REPOSITORY)))
  File "d:\localapp\anaconda3\lib\urllib\request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "d:\localapp\anaconda3\lib\urllib\request.py", line 466, in open
    response = self._open(req, data)
  File "d:\localapp\anaconda3\lib\urllib\request.py", line 484, in _open
    '_open', req)
  File "d:\localapp\anaconda3\lib\urllib\request.py", line 444, in _call_chain
    result = func(*args)
  File "d:\localapp\anaconda3\lib\urllib\request.py", line 1297, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "d:\localapp\anaconda3\lib\urllib\request.py", line 1256, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 11001] getaddrinfo failed>
wickeym commented 7 years ago

Good Morning bash-j,

The weather widget is trying to get the weather from the yahoo weather api. line 85: weather widget

If you want it to use a local resource, you will have to change that js code.

Or am I not understanding your question?

Sincerely, Michael

bash-j commented 7 years ago

Hi Michael,

With the weather widget, I thought the client would be accessing the yahoo api using javascript.

Does the django-dashing library try to access the repository json file on github, if it can't find the files in the static directory matching the name of the widget in the config?

I have the weather files in my static directory, so I was thinking it for some reason could not find the weather files, then was attempting to load the repository json file on github and it was failing at that point.

Regards, Jonathon

wickeym commented 7 years ago

Hi Jonathon,

Sorry, I don't know what it does, I have always placed the files locally. Can you use a browser debugger (right click->inspect in Chrome) to see where it is trying to reach these files when you load the site?

Sincerely, Michael