Skip to content

Instantly share code, notes, and snippets.

@mitkot
Last active December 13, 2018 09:54
Show Gist options
  • Save mitkot/9e94edd245576113d3308f51e6be5695 to your computer and use it in GitHub Desktop.
Save mitkot/9e94edd245576113d3308f51e6be5695 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# _*_ coding: utf-8 _*_
#
# OBJECTIVES
# ============
# On Windows OS, the following command can export the hotfixes list.
#
# "wmic qfe list full /format:list > hotfixes.txt"
#
# But the thing is a weird INI file-like format. So, this script will
# convert it to tsv (tab-separated values) format so that the users can
# paste it to spread sheet application like MS Excel.
#
#
import sys
def main():
argv = sys.argv
argc = len(argv)
if (argc !=2):
print ('Usage: convert-hotfixes-info.py [file name]')
quit()
fileName = argv[1]
try:
f = open(fileName, 'r', encoding='utf-16')
data = f.read()
f.close()
except FileNotFoundError:
print('File not found.')
quit()
lines = data.split('\n')
for line in lines:
if not line.find('='):
print('')
continue
cols=line.split('=',1)
if(len(cols)>1):
print(cols[1]+'\t', end='')
if(cols[0]=='Status'):
print('')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment