generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from amosproj/Dev
Dev
- Loading branch information
Showing
11 changed files
with
493 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
__pycache__ | ||
__pycache__ | ||
/venv/ |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: "3.7" | ||
|
||
services: | ||
|
||
metadata-hub: | ||
container_name: metadata-hub | ||
image: amosproject2/metadatahub:latest | ||
ports: | ||
- 8080:8080 | ||
volumes: | ||
- /home/data:/filesystem | ||
|
||
synthetic-file-system: | ||
build: | ||
context: . | ||
dockerfile: docker/Dockerfile | ||
container_name: synthetic-file-system | ||
image: fuse_skeleton | ||
stdin_open: true | ||
tty: true | ||
network_mode: "host" | ||
depends_on: | ||
- metadata-hub |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cd src | ||
python3 main.py /test_root /fuse_mount | ||
cd /fuse_mount |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
fusepy | ||
requests | ||
anytree |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from anytree import * | ||
from send_mdh_request import * | ||
|
||
|
||
def build_tree_from_files(files: [File]): | ||
""" | ||
build_tree_from_files Turns a list of FilePaths into a directory tree. The tree is built upon a "Root" node | ||
:param files: a list of file paths e.g ["/metadatahub/crawler/test", "/metadatahub/docs/test", ...] | ||
:return: The root Node (anytree.Node) of the resulting tree | ||
""" | ||
|
||
root_node = Node("Root") | ||
|
||
# prepare directory names for easier processing | ||
file_paths = [] | ||
for file in files: | ||
full_file_name = file.dir_path + "/" + file.name | ||
file_paths.append(full_file_name.split("/")) | ||
|
||
i = 1 | ||
num_files_to_parse = len(file_paths) | ||
while True: | ||
for file_path in file_paths: | ||
if i >= len(file_path): | ||
num_files_to_parse -= 1 | ||
continue | ||
path_part = file_path[i] | ||
prev_path = "" | ||
for j in range(1, i): | ||
prev_path += file_path[j] + "/" | ||
|
||
prev_path = prev_path[:len(prev_path) - 1] # remove trailing "/" | ||
|
||
has_child = False | ||
parent_finder = Resolver("name") | ||
parent_node: Node | ||
parent_node = parent_finder.get(root_node, prev_path) | ||
for child in parent_node.children: | ||
if child.name == path_part: | ||
has_child = True | ||
if not has_child: | ||
Node(path_part, parent_node) | ||
if num_files_to_parse <= 0: | ||
break | ||
i += 1 | ||
|
||
return root_node |
Oops, something went wrong.