|
18 | 18 | # from .table import ServiceTable
|
19 | 19 | #
|
20 | 20 | #
|
21 |
| -# class CFHeaderState: |
22 |
| -# def __init__(self): |
23 |
| -# self.current = 0 |
24 |
| -# self.total = 0 |
25 |
| -# self.ready = False |
26 |
| -# |
27 |
| -# |
28 |
| -# class Action: |
29 |
| -# def __init__(self, node_manager: NodeManager): |
30 |
| -# self.logger = logging.getLogger("launcher.CheckWalletsAction") |
31 |
| -# self.node_manager = node_manager |
32 |
| -# self.lnd_cfheaders = {} |
33 |
| -# |
34 |
| -# @property |
35 |
| -# def shell(self): |
36 |
| -# return self.node_manager.shell |
37 |
| -# |
38 |
| -# @property |
39 |
| -# def config(self): |
40 |
| -# return self.node_manager.config |
41 |
| -# |
42 |
| -# @property |
43 |
| -# def network(self) -> XudNetwork: |
44 |
| -# return self.config.network |
45 | 21 | #
|
46 | 22 | # def lnd_has_unlock_log_line(self, c):
|
47 | 23 | # pass
|
|
142 | 118 | # except Exception as e:
|
143 | 119 | # raise RuntimeError("Failed to restart xud") from e
|
144 | 120 | #
|
145 |
| -# @staticmethod |
146 |
| -# def _get_percentage(current, total): |
147 |
| -# if total == 0: |
148 |
| -# return "0.00%% (%d/%d)" % (current, total) |
149 |
| -# if current >= total: |
150 |
| -# return "100.00%% (%d/%d)" % (current, total) |
151 |
| -# p = current / total * 100 |
152 |
| -# if p > 0.005: |
153 |
| -# p = p - 0.005 |
154 |
| -# else: |
155 |
| -# p = 0 |
156 |
| -# return "%.2f%% (%d/%d)" % (p, current, total) |
157 | 121 | #
|
158 | 122 | # def _print_lnd_cfheaders(self, erase_last_line=True):
|
159 | 123 | # services = {}
|
|
301 | 265 | # if self.node_manager.newly_installed:
|
302 | 266 | # print()
|
303 | 267 | #
|
304 |
| -# def xucli_create_wrapper(self, xud): |
305 |
| -# counter = 0 |
306 |
| -# ok = False |
307 |
| -# while counter < 3: |
308 |
| -# try: |
309 |
| -# xud.cli("create", self.shell) |
310 |
| -# while True: |
311 |
| -# confirmed = self.shell.confirm("YOU WILL NOT BE ABLE TO DISPLAY YOUR XUD SEED AGAIN. Press ENTER to continue...") |
312 |
| -# if confirmed: |
313 |
| -# break |
314 |
| -# ok = True |
315 |
| -# break |
316 |
| -# except (PasswordNotMatch, InvalidPassword): |
317 |
| -# counter += 1 |
318 |
| -# continue |
319 |
| -# if not ok: |
320 |
| -# raise Exception("Failed to create wallets") |
321 | 268 | #
|
322 | 269 | # def xucli_restore_wrapper(self, xud):
|
323 | 270 | # counter = 0
|
|
337 | 284 | # if not ok:
|
338 | 285 | # raise Exception("Failed to restore wallets")
|
339 | 286 | #
|
340 |
| -# def check_backup_dir(self, backup_dir): |
341 |
| -# assert not backup_dir.startswith("/mnt/hostfs") |
342 |
| -# |
343 |
| -# hostfs_dir = get_hostfs_file(backup_dir) |
344 |
| -# |
345 |
| -# if not os.path.exists(hostfs_dir): |
346 |
| -# return False, "not existed" |
347 |
| -# |
348 |
| -# if not os.path.isdir(hostfs_dir): |
349 |
| -# return False, "not a directory" |
350 |
| -# |
351 |
| -# if not os.access(hostfs_dir, os.R_OK): |
352 |
| -# return False, "not readable" |
353 |
| -# |
354 |
| -# if not os.access(hostfs_dir, os.W_OK): |
355 |
| -# return False, "not writable" |
356 |
| -# |
357 |
| -# return True, None |
358 |
| -# |
359 |
| -# def check_restore_dir(self, restore_dir): |
360 |
| -# return self.check_backup_dir(restore_dir) |
361 |
| -# |
362 |
| -# def check_restore_dir_files(self, restore_dir): |
363 |
| -# files = os.listdir(get_hostfs_file(restore_dir)) |
364 |
| -# contents = [] |
365 |
| -# if "xud" in files: |
366 |
| -# contents.append("xud") |
367 |
| -# if "lnd-BTC" in files: |
368 |
| -# contents.append("lndbtc") |
369 |
| -# if "lnd-LTC" in files: |
370 |
| -# contents.append("lndltc") |
371 |
| -# return contents |
372 |
| -# |
373 |
| -# def setup_backup_dir(self): |
374 |
| -# if self.config.backup_dir: |
375 |
| -# return |
376 |
| -# |
377 |
| -# backup_dir = None |
378 |
| -# |
379 |
| -# while True: |
380 |
| -# reply = self.shell.input("Enter path to backup location: ") |
381 |
| -# reply = reply.strip() |
382 |
| -# if len(reply) == 0: |
383 |
| -# continue |
384 |
| -# |
385 |
| -# backup_dir = normalize_path(reply) |
386 |
| -# |
387 |
| -# print("Checking backup location... ", end="") |
388 |
| -# sys.stdout.flush() |
389 |
| -# ok, reason = self.check_backup_dir(backup_dir) |
390 |
| -# if ok: |
391 |
| -# print("OK.") |
392 |
| -# break |
393 |
| -# else: |
394 |
| -# print(f"Failed. ", end="") |
395 |
| -# self.logger.debug(f"Failed to check backup dir {backup_dir}: {reason}") |
396 |
| -# sys.stdout.flush() |
397 |
| -# r = self.shell.no_or_yes("Retry?") |
398 |
| -# if r == "no": |
399 |
| -# self.node_manager.down() |
400 |
| -# raise FatalError("Backup directory not available") |
401 |
| -# |
402 |
| -# self.config.backup_dir = backup_dir |
403 |
| -# |
404 |
| -# def is_backup_available(self): |
405 |
| -# if self.config.backup_dir is None: |
406 |
| -# return False |
407 |
| -# |
408 |
| -# ok, reason = self.check_backup_dir(self.config.backup_dir) |
409 |
| -# |
410 |
| -# if not ok: |
411 |
| -# return False |
412 |
| -# |
413 |
| -# return True |
414 |
| -# |
415 | 287 | # def setup_restore_dir(self) -> None:
|
416 | 288 | # """This function will try to interactively setting up restore_dir. And
|
417 | 289 | # store it in self._config.restore_dir
|
|
463 | 335 | #
|
464 | 336 | # self.config.restore_dir = restore_dir
|
465 | 337 | #
|
466 |
| -# def _get_service(self, name: str) -> Node: |
467 |
| -# return self.node_manager.get_node(name) |
468 |
| -# |
469 |
| -# def _create_wallets(self): |
470 |
| -# try: |
471 |
| -# self.xucli_create_wrapper(xud) |
472 |
| -# break |
473 |
| -# except: |
474 |
| -# pass |
475 | 338 | #
|
476 | 339 | # def _restore_wallets(self):
|
477 | 340 | # self.setup_restore_dir()
|
|
493 | 356 | #
|
494 | 357 | # self.config.restore_dir = None
|
495 | 358 | #
|
496 |
| -# def _has_wallets(self) -> bool: |
497 |
| -# pass |
498 | 359 | #
|
499 | 360 | # def _setup_wallets(self) -> None:
|
500 | 361 | # xud = self._get_service("xud")
|
|
0 commit comments