Skip to content

Commit

Permalink
add get dbs
Browse files Browse the repository at this point in the history
  • Loading branch information
Cifko committed Feb 19, 2024
1 parent b6d85c1 commit 73aaa79
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 127 deletions.
8 changes: 8 additions & 0 deletions Processes/common_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,13 @@ def get_stdout(self):
logs.append((os.path.join(path, file), "stdout"))
return logs

def get_dbs(self):
dbs: list[tuple[str, str]] = []
for path, _dirs, files in os.walk(os.path.join(DATA_FOLDER, self.name)):
for file in files:
if file.endswith(".sqlite") or file.endswith(".db"):
dbs.append((os.path.join(path, file), self.name))
return dbs


all_processes: dict[str, CommonExec] = {}
8 changes: 8 additions & 0 deletions Processes/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,13 @@ def get_stdout(self):
logs.append((os.path.join(path, file), "stdout"))
return logs

def get_dbs(self):
dbs: list[tuple[str, str]] = []
for path, _dirs, files in os.walk(os.path.join(DATA_FOLDER, self.name)):
for file in files:
if file.endswith(".sqlite") or file.endswith(".db"):
dbs.append((os.path.join(path, file), self.name))
return dbs


miner = Miner()
82 changes: 0 additions & 82 deletions Stats/scan.py

This file was deleted.

42 changes: 0 additions & 42 deletions temp.py

This file was deleted.

45 changes: 42 additions & 3 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ def grpc(what: str) -> Result: # type:ignore

@method
def http(what: str) -> Result: # type:ignore
print(what)
http_address = self.commands.http(what)
print(http_address)
if http_address:
return Success(http_address)
return InvalidParams()
Expand All @@ -189,6 +187,47 @@ def burn(public_key: str, outfile: str, amount: int) -> Result: # type:ignore
self.commands.burn(public_key, outfile, amount)
return Success()

@method
def get_dbs(what: Optional[str]) -> Result: # type:ignore
try:
if what is None:
dbs: list[tuple[str, str]] = []
for path, _dirs, files in os.walk(DATA_FOLDER):
for file in files:
if file.endswith(".sqlite") or file.endswith(".db"):
dbs.append((os.path.join(path, file), os.path.split(path)[1])) # type:ignore
return Success(dbs)
if process_type.is_miner(what):
return Success(self.commands.miner.get_dbs())
if process_type.is_connector(what):
if self.commands.tari_connector_sample:
return Success(self.commands.tari_connector_sample.get_dbs())
return Success("Not running")
if process_type.is_signaling_server(what):
return Success(self.commands.signaling_server.get_dbs())
id = process_type.get_index(what)
if id is None:
return InvalidParams()
if process_type.is_validator_node(what):
if id in self.commands.validator_nodes:
return Success(self.commands.validator_nodes[id].get_dbs())
if process_type.is_asset_wallet(what):
if id in self.commands.dan_wallets:
return Success(self.commands.dan_wallets[id].get_dbs())
if process_type.is_indexer(what):
if id in self.commands.indexers:
return Success(self.commands.indexers[id].get_dbs())
if process_type.is_base_node(what):
if self.commands.base_nodes.has(id):
return Success(self.commands.base_nodes[id].get_dbs())
if process_type.is_base_wallet(what):
if self.commands.base_wallets.has(id):
return Success(self.commands.base_wallets[id].get_dbs())
return InvalidParams()
except Exception as error:
Error(error)
return Error("Unknown")

@method
def get_logs(what: Optional[str]) -> Result: # type:ignore
try:
Expand Down Expand Up @@ -287,7 +326,7 @@ def get_file_binary(filename: str) -> Result: # type:ignore
file = open(filename, "rb")
data = file.read()
file.close()
return Success(base64.b64encode(data).decode('utf-8'))
return Success(base64.b64encode(data).decode("utf-8"))
return InvalidParams("File not found")


Expand Down

0 comments on commit 73aaa79

Please sign in to comment.