Keybase, PowerShell, Python statement order

  • Keybase's encrypted git is awesome. Encrypted git for everyone and the all new Keybase Teams feature. Download KeyBase. If I would have a project which would require such platforms and technology. Keybase would be very high on my list of providers to choose from. I mean project which would require high privacy. I'll also recheck if Keybase now supports ECC keys. - Yes they do. - My OpenPGP ECC key is now available on keybase/sl.
  • Got mixed feelings about PowerShell @ Wikipedia, it's totally awesome, but I haven't just internalized the syntax. Maybe I should spend a few weekends playing with it. So I could familiarize my self with basics like getting data, passing parameters, reading results, for, if and other statements. I've done some scripts, but getting those to work took ridiculous amounts of time. Because the method was googling and trial and error. Instead of studying the conceptual basics and then just doing it. Anyway when browsing what PowerShell @ Microsoft and PowerShell @ Wikipedia can do I found out tnc (Test-NetConnection) that's totally awesome tool for servers. No need for legacy tricks. And this is already included in Windows 2012 R2 so, it's good on all of the Windows platforms I'm currently using. For the scripts run rarely, I've often used Python for logic and control, and making calls and then processed the ConvertTo-Json data in Python. I do know how moronic that is, but it works, and has been easy for me. But I could drop that Python, if I would be able to implement same logic in PS directly and efficiently. Yet as said, this is deep swamp, and there's so much to learn in general, if you wan't to be awesome Windows guru in depth. Added basic-cookbooks, fundamental-concepts and more-powershell-learning and understanding-concepts-reference to my read list. Because without understanding that, it's just extremely painful to work with PowerShell.
  • Python stuff - This is something which might not be obvious, without little testing. So here's test code which makes it obvious. Which is the order of these statements are processed, if the statements are processed at all. Just leaving it here, and you can check the source and output. This should make it obvious how try, catch, enter, exit and with statement(s) interact together. Actually when I checked the code I've written. 95% of the cases were written correctly. So I knew this kind of in trial and error way, this is the way it works best. But I haven't ever checked in detail how it actually works. - Bit same as with the PowerShell stuff above. - Related source below.
class with_test():
  def __enter__(self):
    print('With Enter')
    return 'Enter Reference'
    
  def __exit__(self, *args):
    print('With Exit:', args)
    if args[0]:
      raise

print('* Try and catch statement outside with *')

try:
  with with_test() as f:
    print('Inside with code:', f)
    raise Exception('Testing Exception')
  print('After with code:', f)
except Exception as e:
  print('Exception handling with exception:', e, f)

print('\n* Try and catch statement inside with *')

with with_test() as f:
  try:
    print('Inside with code:', f)
    raise Exception('Testing Exception')
  except Exception as e:
    print('Exception handling:', e, f)

"""
* Try and catch statement outside with *
With Enter
Inside with code: Enter Reference
With Exit: (<class 'Exception'>, Exception('Testing Exception',), <traceback object at 0x000002CE6B64F908>)
Exception handling with exception: Testing Exception Enter Reference

* Try and catch statement inside with *
With Enter
Inside with code: Enter Reference
Exception handling: Testing Exception Enter Reference
With Exit: (None, None, None)
"""

2019-02-14