Skip to content
This repository was archived by the owner on May 6, 2024. It is now read-only.

Commit 16b2906

Browse files
Merge remote-tracking branch 'origin/master'
2 parents 1c2b4e2 + 96ce45e commit 16b2906

File tree

2 files changed

+26
-33
lines changed

2 files changed

+26
-33
lines changed

vantage6/cli/configuration_manager.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
import os
2-
import collections
3-
import yaml
4-
import logging
5-
6-
from pathlib import Path
7-
from schema import Schema, And, Or, Use, Optional
1+
from schema import And, Or, Use, Optional
82

93
from vantage6.common.configuration_manager import (
104
Configuration,
115
ConfigurationManager
126
)
137

8+
149
class ServerConfiguration(Configuration):
1510

1611
VALIDATORS = {
@@ -21,7 +16,8 @@ class ServerConfiguration(Configuration):
2116
"uri": Use(str),
2217
"allow_drop_all": Use(bool),
2318
"logging": {
24-
"level": And(Use(str), lambda l: l in ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL")),
19+
"level": And(Use(str), lambda l: l in ("DEBUG", "INFO", "WARNING",
20+
"ERROR", "CRITICAL")),
2521
"file": Use(str),
2622
"use_console": Use(bool),
2723
"backup_count": And(Use(int), lambda n: n > 0),
@@ -31,6 +27,7 @@ class ServerConfiguration(Configuration):
3127
}
3228
}
3329

30+
3431
class NodeConfiguration(Configuration):
3532

3633
VALIDATORS = {
@@ -41,7 +38,8 @@ class NodeConfiguration(Configuration):
4138
"databases": {Use(str): Use(str)},
4239
"api_path": Use(str),
4340
"logging": {
44-
"level": And(Use(str), lambda l: l in ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL")),
41+
"level": And(Use(str), lambda l: l in ("DEBUG", "INFO", "WARNING",
42+
"ERROR", "CRITICAL")),
4543
"file": Use(str),
4644
"use_console": Use(bool),
4745
"backup_count": And(Use(int), lambda n: n > 0),
@@ -55,12 +53,15 @@ class NodeConfiguration(Configuration):
5553
}
5654
}
5755

56+
5857
class TestConfiguration(Configuration):
5958

6059
VALIDATORS = {
6160
# "api_key": And(Use(str), len),
6261
# "logging": {
63-
# "level": And(Use(str), lambda l: l in ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", "NONE")),
62+
# "level": And(Use(str), lambda l: l in ("DEBUG", "INFO",
63+
# "WARNING", "ERROR",
64+
# "CRITICAL", "NONE")),
6465
# "file": Use(str),
6566
# "use_console": Use(bool),
6667
# "backup_count": And(Use(int), lambda n: n > 0),
@@ -71,7 +72,6 @@ class TestConfiguration(Configuration):
7172
}
7273

7374

74-
7575
class NodeConfigurationManager(ConfigurationManager):
7676

7777
def __init__(self, name, *args, **kwargs):
@@ -81,6 +81,7 @@ def __init__(self, name, *args, **kwargs):
8181
def from_file(cls, path):
8282
return super().from_file(path, conf_class=NodeConfiguration)
8383

84+
8485
class ServerConfigurationManager(ConfigurationManager):
8586

8687
def __init__(self, name, *args, **kwargs):

vantage6/cli/configuration_wizard.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
import click
2-
import sys
3-
import os
4-
import shutil
5-
import yaml
61
import questionary as q
72

83
from pathlib import Path
9-
from schema import Schema, And, Or, Use, Optional
10-
11-
from vantage6.node import util
124

135
from vantage6.cli.context import NodeContext
146
from vantage6.cli.configuration_manager import NodeConfigurationManager
@@ -59,19 +51,19 @@ def node_configuration_questionaire(dirs, instance_name):
5951
i = 1
6052
while q.confirm("Do you want to add another database?").ask():
6153
q2 = q.prompt([
62-
{
63-
"type": "text",
64-
"name": "label",
65-
"message": "Enter the label for the database:",
66-
"default": f"database_{i}"
67-
},
68-
{
69-
"type": "text",
70-
"name": "path",
71-
"message": "The path of the database file:",
72-
"default": str(
73-
Path(config.get("databases").get("default")).parent)
74-
}])
54+
{
55+
"type": "text",
56+
"name": "label",
57+
"message": "Enter the label for the database:",
58+
"default": f"database_{i}"
59+
},
60+
{
61+
"type": "text",
62+
"name": "path",
63+
"message": "The path of the database file:",
64+
"default": str(
65+
Path(config.get("databases").get("default")).parent)
66+
}])
7567
config["databases"][q2.get("label")] = q2.get("path")
7668
i += 1
7769

@@ -152,4 +144,4 @@ def select_configuration_questionaire(system_folders):
152144
name, env = q.select("Select the configuration you want to use:",
153145
choices=choices).ask()
154146

155-
return name, env
147+
return name, env

0 commit comments

Comments
 (0)