fix flow
This commit is contained in:
parent
b3285421d1
commit
7ddaecb9c7
|
@ -13,14 +13,9 @@ import gettext
|
||||||
import locale
|
import locale
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
from string import Template
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
BASE_DIR = Path(__file__).resolve().parent
|
|
||||||
|
|
||||||
|
|
||||||
SNAPSHOT_BASE = {
|
SNAPSHOT_BASE = {
|
||||||
'timestamp': str(datetime.now()),
|
'timestamp': str(datetime.now()),
|
||||||
'type': 'Snapshot',
|
'type': 'Snapshot',
|
||||||
|
@ -76,15 +71,6 @@ def exec_cmd_erase(cmd):
|
||||||
## End Utility functions ##
|
## End Utility functions ##
|
||||||
|
|
||||||
|
|
||||||
def convert_to_credential(snapshot):
|
|
||||||
snapshot["data"] = json.dumps(snapshot["data"])
|
|
||||||
file_path = os.path.join(BASE_DIR, "templates", "snapshot.json")
|
|
||||||
with open(file_path) as f:
|
|
||||||
ff = f.read()
|
|
||||||
template = Template(ff)
|
|
||||||
cred = template.substitute(**snapshot)
|
|
||||||
return cred
|
|
||||||
|
|
||||||
|
|
||||||
## Command Functions ##
|
## Command Functions ##
|
||||||
## Erase Functions ##
|
## Erase Functions ##
|
||||||
|
@ -470,17 +456,17 @@ def main():
|
||||||
snapshot['erase'] = gen_erase(all_disks, config['erase'])
|
snapshot['erase'] = gen_erase(all_disks, config['erase'])
|
||||||
|
|
||||||
|
|
||||||
if config.get("wb_sign_token"):
|
|
||||||
tk = config.get("wb_sign_token").encode("utf8")
|
|
||||||
snapshot["token_hash"] = hashlib.hash256(tk).hexdigest()
|
|
||||||
|
|
||||||
if config.get("legacy"):
|
if config.get("legacy"):
|
||||||
convert_to_legacy_snapshot(snapshot)
|
convert_to_legacy_snapshot(snapshot)
|
||||||
snapshot = json.dumps(snapshot)
|
snapshot = json.dumps(snapshot)
|
||||||
else:
|
else:
|
||||||
snapshot = convert_to_credential(snapshot)
|
|
||||||
url_wallet = config.get("url_wallet")
|
url_wallet = config.get("url_wallet")
|
||||||
wb_sign_token = config.get("wb_sign_token")
|
wb_sign_token = config.get("wb_sign_token")
|
||||||
|
|
||||||
|
if wb_sign_token:
|
||||||
|
tk = wb_sign_token.encode("utf8")
|
||||||
|
snapshot["token_hash"] = hashlib.hash256(tk).hexdigest()
|
||||||
|
|
||||||
if url_wallet and wb_sign_token:
|
if url_wallet and wb_sign_token:
|
||||||
snapshot = send_to_sign_credential(snapshot, wb_sign_token, url_wallet)
|
snapshot = send_to_sign_credential(snapshot, wb_sign_token, url_wallet)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue