Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'LocalTimezone' object has no attribute 'localize' #1019

Closed
bobemoe opened this issue Nov 5, 2014 · 17 comments
Closed

'LocalTimezone' object has no attribute 'localize' #1019

bobemoe opened this issue Nov 5, 2014 · 17 comments
Assignees
Milestone

Comments

@bobemoe
Copy link
Contributor

bobemoe commented Nov 5, 2014

I am getting this error when trying to render a date range defined by absolute date/times. If I use relative (from=-24h and until=now or similar) then the graph renders fine.

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 111, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/graphite/webapp/graphite/render/views.py", line 54, in renderView
    (graphOptions, requestOptions) = parseOptions(request)
  File "/opt/graphite/webapp/graphite/render/views.py", line 301, in parseOptions
    untilTime = parseATTime(queryParams['until'], tzinfo, now)
  File "/opt/graphite/webapp/graphite/render/attime.py", line 41, in parseATTime
    return tzinfo.localize(datetime.strptime(s,'%H:%M%Y%m%d'), daylight)
AttributeError: 'LocalTimezone' object has no attribute 'localize'

Graphite version 0.9.x installed from git today.
Django version 1.7.1.

Timezone in local_settings.py is set to
TIME_ZONE = 'Europe/London'

The only thing I am doing slightly different than normal is using Waitress rather than Apache. I am using the /opt/graphite/conf/graphite.wsgi.example with the following lines added at the bottom:

from waitress import serve
serve(application, host='0.0.0.0', port=8080)
@brutasse
Copy link
Member

brutasse commented Nov 5, 2014

Do you have pytz installed? It's a requirement for proper timezone handling. We should probably add it / document this if that's not already the case.

@obfuscurity obfuscurity added this to the 0.9.13 milestone Nov 5, 2014
@bobemoe
Copy link
Contributor Author

bobemoe commented Nov 5, 2014

Bingo! Working fine now I've installed pytz. Thanks :)

@obfuscurity
Copy link
Member

@gwaldo Do you have a few mins to tackle this doc bug?

@gwaldo
Copy link
Member

gwaldo commented Nov 5, 2014

@obfuscurity Which would you say is the doc bug?

  1. pytz isn't installed, and should be a prereq
  2. Timezone should be set to zulu or local
  3. something about the relative times (I'd need help with an explanation on that)

@gwaldo gwaldo self-assigned this Nov 5, 2014
@obfuscurity
Copy link
Member

Number 1.

@gwaldo
Copy link
Member

gwaldo commented Nov 5, 2014

@obfuscurity I'll add to the docs.

Can / Should I add it to the code so that it's done automagically (w/ Twisted, et al.)?

@obfuscurity
Copy link
Member

It's already in requirements.txt so it shouldn't be an issue unless you try to install manually.

@obfuscurity
Copy link
Member

@gwaldo Do you have time to finish this up anytime soon?

@deniszh deniszh mentioned this issue Dec 21, 2014
@gwaldo
Copy link
Member

gwaldo commented Dec 21, 2014

Yes, I can do that tonight.

Apologies for my inattention. End-of-year madness at both home & work.

@deniszh
Copy link
Member

deniszh commented Dec 21, 2014

@gwaldo, just created #1061 - is that enough? If not - yw to create another one. 😸

@gwaldo
Copy link
Member

gwaldo commented Dec 21, 2014

That looks fabulous, @deniszh

Are you doing the same for Master, or shall I?

@deniszh
Copy link
Member

deniszh commented Dec 21, 2014

Simple cherry-pick - #1062

@obfuscurity
Copy link
Member

Thanks!

danosipov added a commit to danosipov/setup-graphite that referenced this issue Mar 12, 2015
pytz is required for handling timezones. See graphite-project/graphite-web#1019
arnaudlamy pushed a commit to arnaudlamy/docker-grafana-graphite that referenced this issue Oct 6, 2015
The bug is fixed in the graphite project, maybe it will be better to just
update it.

Source: graphite-project/graphite-web#1019
@billowqiu
Copy link

I have the same problem when use uwsgi with graphite.wsgi.example.
But start the app with run-graphite-devel-server.py is ok, even don't install pytz.

@deniszh
Copy link
Member

deniszh commented Sep 1, 2016

@billowqiu - yes, that will also work, but please note that development server is for development only, and not for production load.

@stttt2003pk
Copy link

stttt2003pk commented Jan 17, 2017

@deniszh @billowqiu but anybody know how to fix this on Centos7
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 113, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/opt/graphite/webapp/graphite/render/views.py", line 56, in renderView
(graphOptions, requestOptions) = parseOptions(request)
File "/opt/graphite/webapp/graphite/render/views.py", line 318, in parseOptions
fromTime = parseATTime('-1d', tzinfo, now)
File "/opt/graphite/webapp/graphite/render/attime.py", line 48, in parseATTime
return tzinfo.normalize(parseTimeReference(ref).astimezone(tzinfo) + parseTimeOffset(offset))
AttributeError: 'LocalTimezone' object has no attribute 'normalize'

if i try to get the render

i wanna update this process i ve fix this problem
i ctrl + shift +i to see which is wrong and i found the Traceback excception;
and i grep -rwn 'normailize' * in the dir which contains the dependency,it all ok

so i think its about the permission problem,i think the wsgi file cannot access out depandency lib,so i try
<Directory /usr/lib/python2.7/site-packages/>
#Order deny,allow
#Allow from all
Require all granted

apactl -v 2.4.*

so it can rend the data out.

so it s because the mod wsgi file cannot access our depandency,problem solved

@billowqiu
Copy link

@stttt2003pk install pytz?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants