Created
April 19, 2018 03:36
-
-
Save mdeguzis/241cfa26fbb89ff1ac68b8ba45cc35c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
json_text = r.json() | |
# get total length of dictionary keys for tracking | |
for key, value in json_text.iteritems(): | |
item_index = 0 | |
if key == 'FileStatuses': | |
total_items = len(json_text['FileStatuses']['FileStatus'][:]) | |
for listitems in json_text['FileStatuses']['FileStatus'][:]: | |
perm_set = [] | |
item_count = len(json_text['FileStatuses']['FileStatus'][:]) | |
octal_perms = json_text['FileStatuses']['FileStatus'][item_index]['permission'] | |
replcount = json_text['FileStatuses']['FileStatus'][item_index]['replication'] | |
fileuser = json_text['FileStatuses']['FileStatus'][item_index]['owner'] | |
filegroup = json_text['FileStatuses']['FileStatus'][item_index]['group'] | |
filename = json_text['FileStatuses']['FileStatus'][item_index]['pathSuffix'] | |
filetype = json_text['FileStatuses']['FileStatus'][item_index]['type'] | |
filelength = json_text['FileStatuses']['FileStatus'][item_index]['length'] | |
# modtime is epoch (UNIX time) with the last 3 digits as milliseconds | |
modtime_epoch = json_text['FileStatuses']['FileStatus'][item_index]['modificationTime'] | |
modtime = time.strftime('%Y-%m-%d %H:%M', time.gmtime(modtime_epoch/1000.0)) | |
# update counter | |
item_index += 1 | |
logging.debug("Analyzing " + str(item_index) + ' out of ' + str(total_items)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment