Commit 1265f247 by Őry Máté

store: refactor file_dict creation to new function

parent 3cd9fb33
......@@ -305,18 +305,21 @@ def list_directory(home, path):
return json.dumps((os.path.basename(path), 'F', os.path.getsize(path), os.path.getmtime(path)))
# List directory and return list
else:
tuplelist = []
filelist = os.listdir(path)
# Add type support
for item in filelist:
static_route = path+"/"+item
if os.path.isdir(static_route):
dictlist = [file_dict(os.path.join(path, f), home) for f in filelist]
return json.dumps(dictlist)
def file_dict(path, home):
basename = os.path.basename(path.rstrip('/'))
if os.path.isdir(path):
is_dir = 'D'
else:
is_dir = 'F'
element = { 'NAME' : item, 'TYPE' : is_dir, 'SIZE' : os.path.getsize(static_route)/1024, 'MTIME' : os.path.getmtime(static_route) }
tuplelist.append(element)
return json.dumps(tuplelist)
return {'NAME': basename,
'TYPE': is_dir,
'SIZE': os.path.getsize(path)/1024,
'MTIME': os.path.getmtime(path),
'DIR': os.path.relpath(os.path.dirname(path), home)}
def getQuotaStatus(neptun):
output=subprocess.check_output([ROOT_BIN_FOLDER+'/'+USER_MANAGER, 'status', neptun], stderr=subprocess.STDOUT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment