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): ...@@ -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))) return json.dumps((os.path.basename(path), 'F', os.path.getsize(path), os.path.getmtime(path)))
# List directory and return list # List directory and return list
else: else:
tuplelist = []
filelist = os.listdir(path) filelist = os.listdir(path)
# Add type support dictlist = [file_dict(os.path.join(path, f), home) for f in filelist]
for item in filelist: return json.dumps(dictlist)
static_route = path+"/"+item
if os.path.isdir(static_route): def file_dict(path, home):
is_dir = 'D' basename = os.path.basename(path.rstrip('/'))
else: if os.path.isdir(path):
is_dir = 'F' is_dir = 'D'
element = { 'NAME' : item, 'TYPE' : is_dir, 'SIZE' : os.path.getsize(static_route)/1024, 'MTIME' : os.path.getmtime(static_route) } else:
tuplelist.append(element) is_dir = 'F'
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): def getQuotaStatus(neptun):
output=subprocess.check_output([ROOT_BIN_FOLDER+'/'+USER_MANAGER, 'status', neptun], stderr=subprocess.STDOUT) 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