Skip to content

Commit

Permalink
Merge pull request #672 from NebraLtd/backup_updates
Browse files Browse the repository at this point in the history
Add wingbits to backup
  • Loading branch information
shawaj authored Jul 8, 2024
2 parents 6f8780a + bedafe1 commit bac451c
Show file tree
Hide file tree
Showing 3 changed files with 27 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
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

0 comments on commit bac451c

Please sign in to comment.