@@ -24,13 +24,19 @@ root.setLevel(logging.INFO)
2424
2525handler = logging .StreamHandler (sys .stdout )
2626handler .setLevel (logging .DEBUG )
27- formatter = logging .Formatter (' %(message)s' )
27+ formatter = logging .Formatter (" %(message)s" )
2828handler .setFormatter (formatter )
2929root .addHandler (handler )
3030
31+
3132@click .command ()
3233@click .argument ("backend-url" )
33- @click .option ('--lightning-dir' , type = click .Path (exists = True ), default = None , help = 'Use an existing lightning directory (default: initialize an empty backup).' )
34+ @click .option (
35+ "--lightning-dir" ,
36+ type = click .Path (exists = True ),
37+ default = None ,
38+ help = "Use an existing lightning directory (default: initialize an empty backup)." ,
39+ )
3440def init (lightning_dir , backend_url ):
3541 destination = backend_url
3642 backend = get_backend (destination , create = True )
@@ -40,13 +46,21 @@ def init(lightning_dir, backend_url):
4046 db_file = os .path .join (lightning_dir , "lightningd.sqlite3" )
4147
4248 with open (lock_file , "w" ) as f :
43- f .write (json .dumps ({
44- 'backend_url' : destination ,
45- }))
49+ f .write (
50+ json .dumps (
51+ {
52+ "backend_url" : destination ,
53+ }
54+ )
55+ )
4656
4757 data_version = 0
4858 if os .path .exists (db_file ):
49- print ("Found an existing database at {db_file}, initializing the backup with a snapshot" .format (db_file = db_file ))
59+ print (
60+ "Found an existing database at {db_file}, initializing the backup with a snapshot" .format (
61+ db_file = db_file
62+ )
63+ )
5064 # Peek into the DB to see if we have
5165 db = sqlite3 .connect (db_file )
5266 cur = db .cursor ()
@@ -55,20 +69,26 @@ def init(lightning_dir, backend_url):
5569
5670 snapshot = Change (
5771 version = data_version ,
58- snapshot = open (db_file , 'rb' ).read (),
59- transaction = None
72+ snapshot = open (db_file , "rb" ).read (),
73+ transaction = None ,
6074 )
6175 if not backend .add_change (snapshot ):
6276 print ("Could not write snapshot to backend" )
6377 sys .exit (1 )
6478 else :
65- print ("Successfully written initial snapshot to {destination}" .format (destination = destination ))
79+ print (
80+ "Successfully written initial snapshot to {destination}" .format (
81+ destination = destination
82+ )
83+ )
6684 else :
6785 print ("Database does not exist yet, created an empty backup file" )
6886
69- print ("Initialized backup backend {destination}, you can now start Core-Lightning" .format (
70- destination = destination ,
71- ))
87+ print (
88+ "Initialized backup backend {destination}, you can now start Core-Lightning" .format (
89+ destination = destination ,
90+ )
91+ )
7292
7393
7494@click .command ()
@@ -83,11 +103,24 @@ def restore(backend_url, restore_destination):
83103@click .command ()
84104@click .argument ("backend-url" )
85105@click .argument ("addr" )
86- @click .option ('--log-mode' , type = click .Choice (['plain' , 'systemd' ], case_sensitive = False ), default = 'plain' , help = 'Debug log mode, defaults to plain' )
87- @click .option ('--log-level' , type = click .Choice (['debug' , 'info' , 'notice' , 'warning' , 'error' , 'critical' ], case_sensitive = False ), default = 'info' , help = 'Debug log level, defaults to info' )
106+ @click .option (
107+ "--log-mode" ,
108+ type = click .Choice (["plain" , "systemd" ], case_sensitive = False ),
109+ default = "plain" ,
110+ help = "Debug log mode, defaults to plain" ,
111+ )
112+ @click .option (
113+ "--log-level" ,
114+ type = click .Choice (
115+ ["debug" , "info" , "notice" , "warning" , "error" , "critical" ],
116+ case_sensitive = False ,
117+ ),
118+ default = "info" ,
119+ help = "Debug log level, defaults to info" ,
120+ )
88121def server (backend_url , addr , log_mode , log_level ):
89122 backend = get_backend (backend_url )
90- addr , port = addr .split (':' )
123+ addr , port = addr .split (":" )
91124 port = int (port )
92125
93126 setup_server_logging (log_mode , log_level )
0 commit comments