File tree 2 files changed +19
-4
lines changed 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 5
5
6
6
from assigner .config .versions import upgrade , validate , ValidationError
7
7
8
+
8
9
class DuplicateUserError (Exception ):
9
10
pass
10
11
12
+
11
13
def config_context (func ):
12
14
def wrapper (cmdargs , * args ):
13
15
with Config (cmdargs .config ) as conf :
Original file line number Diff line number Diff line change 1
1
import jsonschema
2
+ import logging
3
+
2
4
from assigner .config .schemas import SCHEMAS
3
5
from assigner .config .upgrades import UPGRADES
4
6
7
+ logger = logging .getLogger (__name__ )
8
+
9
+
5
10
class ValidationError (jsonschema .ValidationError ):
6
11
pass
7
12
@@ -29,9 +34,17 @@ def upgrade(config):
29
34
current = get_version (config )
30
35
latest = len (SCHEMAS ) - 1
31
36
32
- for i in range (current , latest ):
33
- config = UPGRADES [i ](config )
34
- #validate(config, i + 1)
35
- assert get_version (config ) == i + 1
37
+ if current > latest :
38
+ logger .warning ("Configuration version %d is newer than latest known configuration version %d" , current , latest )
39
+ logger .warning ("Is your installation of Assigner up to date?" )
40
+ logger .warning ("Attempting to continue anyway..." )
41
+ return config
42
+
43
+ if current != latest :
44
+ logger .info ("Migrating configuration from version %d to version %d." , current , latest )
45
+
46
+ for version in range (current , latest ):
47
+ config = UPGRADES [version ](config )
48
+ assert get_version (config ) == version + 1
36
49
37
50
return config
You can’t perform that action at this time.
0 commit comments