Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wingbits to backup #672

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion hw_diag/utilities/backup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
from hw_diag.utilities.backup.myst import MystBackupRestore
from hw_diag.utilities.backup.thingsix import ThingsIXBackupRestore
from hw_diag.utilities.backup.nebra import NebraBackupRestore
from hw_diag.utilities.backup.wingbits import WingbitsBackupRestore
from hw_diag.utilities.db import get_value, set_value
from hw_diag.utilities.crypto import empty_hash


PLUGINS = [
MystBackupRestore,
ThingsIXBackupRestore,
NebraBackupRestore
NebraBackupRestore,
WingbitsBackupRestore
]


Expand Down
18 changes: 18 additions & 0 deletions hw_diag/utilities/backup/wingbits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os
import shutil

from hw_diag.utilities.backup.base import BaseBackupRestore


CONFIG_FILE = '/var/nebra/wingbits.json'


class WingbitsBackupRestore(BaseBackupRestore):
name = 'WINGBITS'

def backup(self):
os.mkdir(self.tmpdir)
shutil.copyfile(CONFIG_FILE, '%s/wingbits.json' % self.tmpdir)

def restore(self):
os.system('cp %s/wingbits.json %s' % (self.tmpdir, CONFIG_FILE)) # nosec
9 changes: 6 additions & 3 deletions hw_diag/views/backup_restore.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
import time

from flask import Blueprint
from flask import render_template
Expand Down Expand Up @@ -29,11 +30,12 @@
def get_backup_page():
diagnostics = read_diagnostics_file()
claim_deeplink = claim_miner_deeplink()

return render_template(
'backup_restore.html',
diagnostics=diagnostics,
claim_deeplink=claim_deeplink
claim_deeplink=claim_deeplink,
now=round(time.time())
)


Expand Down Expand Up @@ -64,7 +66,8 @@ def do_restore():
return render_template(
'reconfigure_countdown.html',
seconds=120,
next_url='/'
next_url='/',
now=round(time.time())
)
except Exception:
return 'Error during restoration', 500
Loading