googlearchive / big-rig

A proof-of-concept Performance Dashboard, CLI and Node module
Apache License 2.0
853 stars 42 forks source link

Invalid format string #21

Open ahallicks opened 8 years ago

ahallicks commented 8 years ago

Hi Paul,

When I upload a trace it doesn't show me any results, just the same 'Upload a trace for this action' message. If I then go back to the project I get the following:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "C:\Development\Tools\big-rig-master\app\dist\handlers\project.py", line 238, in get
    self.response.write(template.render(data))
  File "C:\Program Files (x86)\Google\google_appengine\lib\jinja2-2.6\jinja2\environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "C:\Development\Tools\big-rig-master\app\dist\handlers\..\templates\project\action.html", line 82, in top-level template code
    {{ log.date.strftime('%b %e, %r') }}
ValueError: Invalid format string

Ouch! I am currently running on Windows 10 Chrome 46.0.2490.86 m

Thanks!

paullewis commented 8 years ago

Any chance you can post the trace for me? First time I'm seeing this bug crop up. Also, while we're here, what version of the Launcher do you have? I'm on 1.9.25.

deanhume commented 8 years ago

Hey @paullewis / @ahallicks - I've just seen the same error happen for me. I've uploaded a copy of my trace file.

TimelineRawData-20160203T114228.zip

paullewis commented 8 years ago

Thanks, I'll have a look.

paullewis commented 8 years ago

Actually, @deanhume, what version of the Launcher are you using?

deanhume commented 8 years ago

I am using 1.9.31 - just downloaded it this morning.

paullewis commented 8 years ago

Ok, let me take an update and see what's what.

deanhume commented 8 years ago

Awesome - thanks Paul.

paullewis commented 8 years ago

@deanhume are you on Windows, too? And which version of python?

It seems like I might have favoured Unix-y style date formatting: http://stackoverflow.com/questions/10807164/python-time-formatting-different-in-windows

deanhume commented 8 years ago

Yep - on Windows and running Python 2.7.10. Ah! That's not good....

Please shout if you need any more info!

paullewis commented 8 years ago

Can you run this python for me?

from datetime import date
today = date.today()
print today.strftime('%b')
print today.strftime('%e')
print today.strftime('%r')

I need to know which (or all?) of those don't work on Windows. In any case I can wrap it in an exception, mind, but I'd like to figure it out all the same.

deanhume commented 8 years ago

Apologies for the slow response! Okay, here is the output of the file:

Feb
Traceback (most recent call last):
  File "c:\datetest.py", line 4, in <module>
    print today.strftime('%e')
ValueError: Invalid format string

Both these fail with an "Invalid format string":

print today.strftime('%e')
print today.strftime('%r')

However, this one passes: print today.strftime('%b')

DiscoStarslayer commented 8 years ago

@paullewis Here is the documentation from microsoft in regards to what string formaters it supports: https://msdn.microsoft.com/en-us/library/fe06s4ak(v=vs.140).aspx#Anchor_3

And of course python has a list of portable string directives here: https://docs.python.org/3/library/time.html#time.strftime

In this case, '%b %e, %r' could be ported to something like '%d $b, %I:%M:%S %p' which would give the result of 17 Jun, 12:00:00 AM

I wouldn't mind taking a crack at porting these over, but some things don't have an obvious portable replacement, for instance: "time": {{ action.date.strftime('%s000') }},

%s gives you the number of seconds since the Epoch, which doesn't seem to have an equivalent, and I'm not the most familiar with the code base so this may be a hard requirement. What does the extra 000 do here? Could it be replaced with something else?