Skip to content
This repository was archived by the owner on Apr 27, 2021. It is now read-only.

Invalid format string #21

Open
ahallicks opened this issue Nov 23, 2015 · 12 comments
Open

Invalid format string #21

ahallicks opened this issue Nov 23, 2015 · 12 comments

Comments

@ahallicks
Copy link

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
Copy link
Contributor

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
Copy link

deanhume commented Feb 3, 2016

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
Copy link
Contributor

Thanks, I'll have a look.

@paullewis
Copy link
Contributor

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

@deanhume
Copy link

deanhume commented Feb 3, 2016

I am using 1.9.31 - just downloaded it this morning.

@paullewis
Copy link
Contributor

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

@deanhume
Copy link

deanhume commented Feb 3, 2016

Awesome - thanks Paul.

@paullewis
Copy link
Contributor

@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
Copy link

deanhume commented Feb 3, 2016

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

Please shout if you need any more info!

@paullewis
Copy link
Contributor

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
Copy link

deanhume commented Feb 4, 2016

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
Copy link

@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?

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

No branches or pull requests

4 participants