mirror of
https://github.com/45Drives/cockpit-navigator.git
synced 2025-07-29 16:45:13 +02:00
rename script to ls.py
This commit is contained in:
parent
8c24123161
commit
a9e5dccc08
@ -58,7 +58,7 @@ class NavDir extends NavEntry {
|
|||||||
}
|
}
|
||||||
async get_children(nav_window_ref) {
|
async get_children(nav_window_ref) {
|
||||||
var children = [];
|
var children = [];
|
||||||
var data = await cockpit.spawn(["/usr/share/cockpit/navigator/scripts/ls-no-fail.py", this.path_str()], {err:"ignore"});
|
var data = await cockpit.spawn(["/usr/share/cockpit/navigator/scripts/ls.py", this.path_str()], {err:"ignore"});
|
||||||
var entries = JSON.parse(data);
|
var entries = JSON.parse(data);
|
||||||
entries.forEach(entry => {
|
entries.forEach(entry => {
|
||||||
var filename = entry["filename"];
|
var filename = entry["filename"];
|
||||||
@ -108,7 +108,6 @@ class NavWindow {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
up() {
|
up() {
|
||||||
console.log("up");
|
|
||||||
if(this.path_stack.length > 1)
|
if(this.path_stack.length > 1)
|
||||||
this.path_stack.pop();
|
this.path_stack.pop();
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
22
navigator/scripts/ls.py
Executable file
22
navigator/scripts/ls.py
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if(len(sys.argv) < 2):
|
||||||
|
sys.exit(1)
|
||||||
|
try:
|
||||||
|
nodes = os.listdir(sys.argv[1])
|
||||||
|
except:
|
||||||
|
print("No such file or directory")
|
||||||
|
sys.exit(1)
|
||||||
|
response = []
|
||||||
|
for node in nodes:
|
||||||
|
response.append({"filename": node, "isdir": os.path.isdir(sys.argv[1] + "/" + node)})
|
||||||
|
print(json.dumps(response, indent=4))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
x
Reference in New Issue
Block a user