You can customize Pylint to just never tell you about whole vast swaths of best-practice things and…. It’s annoying that jumbled in next to pedantic little PEP 8 things I didn’t want to care about, Pylint would hide egregious python 3 syntax errors and runtime errors but I got over that and we got along fine. What I did is I fell all the way back to installing a separate instance of python 3 and just pointing pylint at all the source code and letting it yell at me – this actually went a long way. it’s quite possible that I’m just an idiot and there was a simple way around this, but for what it’s worth I tried some of these roads and I couldn’t make any of them work so… ![]() Or fine we can hack it locally but you can’t then have all the customers of your app do that – it would be a support nightmare. For instance you can’t “just use pip install”. We don’t really have control over that thing. None of these ideas seem to work in Splunk’s Python 2. In the normal python world everything says just import from future, or use a compatibility library like six – great ideas. Take a moment of silence for Splunk Engineering who had to port all the existing SplunkWeb code, in all its internationalized and localized glory. More painful than that, if you’re using any class or function with the word unicode in it, ok… you’re gonna have a bad day. In these areas you’ll hit some bumps for sure. It’s a bit anticlimactic really.Īnd conversely the painful parts you might hit, will be anything that actually deals with low level streams, or things like base 64 encoding, or StringIO. Likewise if you used the old syntax when raising exceptions you’ll have to change all that. ![]() The first line there only runs in python 2, the second works in both 2 and 3. The good news is that the python parts of an actual Splunk app, at least most Splunk apps, are usually not doing heavy lifting at low layers where all the nasty stuff is, so at least in terms of lines of diffs, almost all the changes are going to be exception syntax.įind all those, change them. If this is the first you’re reading about these differences, yes they are terrifying. I have heard very recently that Splunk engineering has written a porting guide but I have not seen it unfortunately so I can’t tell you how useful it is. So what are the differences? There are lots of resources out there but here’s a handy and pretty compact cheatsheet from the python-future project. 0 beta recently, and I thought I’d share some high level notes on what was involved in actually making the code in our apps run happily in both Python 2 and Python 3. We’ve been working on this for a while and I got a chance to play with the Splunk Enterprise 8. And on the other side, Splunk admins out in the real world can be forced for security reasons to just flip the entire thing to force Python 3 everywhere for all apps and all pieces everywhere (and then run and hide in the broom closet as appropriate).īut I digress. As they get to feel better about such things they can ship their app with python 3 on for those pieces, eventually for all pieces. (for more read Splunk’s official post, and main docs page about this.)Īpp developers can then test their apps by flipping python 3 on for individual pieces. And last but not least, at some point in the future, Splunk will change this and the app layers will also default to python 3. The core python pieces inside Splunk itself will pretty much all be running in Python 3 out of the box, however conversely all, or pretty much all things in the app layers are still python 2 by default in 8. Still there? OK the short version is that Splunk Enterprise 8 ships both Python 2 and Python 3. ![]() 0 is coming! And it has Python 3!ĭisclaimer: If you have never written any Python in Splunk and don’t plan on it, this is probably not the blog post for you.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |