Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'christopher'
- import glob
- import re
- from lxml import etree
- def main():
- files = glob.glob('*Disks*.xml')
- for file in files:
- handle = open( file, 'r' )
- tree = etree.parse( handle )
- m = re.search(r'STD-Disks-([^-]*)', file )
- computer = file
- if m:
- computer = m.group(0)
- disks = tree.xpath("/STD-Disks/Disks/Source/Disk[not(contains(./Format, 'N/A'))]")
- for disk in disks:
- output = [ computer ]
- for attribute in ['Drive', 'Size', 'Free', 'Used']:
- tmp = ''
- try:
- tmp = disk.xpath(attribute)[0].text
- except:
- print "Couldn't find element", attribute
- output.append( tmp )
- print "\t".join( output )
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment