Skip to content

Commit

Permalink
Add wingbits to backup
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Putt authored and Robert Putt committed Jul 8, 2024
1 parent 6f8780a commit 5c62aa7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
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
8 changes: 5 additions & 3 deletions hw_diag/views/backup_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,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 +65,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

0 comments on commit 5c62aa7

Please sign in to comment.