Skip to content

Commit 08b43bf

Browse files
authored
Merge pull request Pennyw0rth#1070 from Signum21/main
2 parents 8aa9d6f + 6c063ce commit 08b43bf

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

nxc/database.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import configparser
22
import ipaddress
3+
import platform
34
import shutil
45
import sys
56
from os import mkdir
@@ -170,11 +171,23 @@ def reflect_table(self, table):
170171

171172
return reflected_table
172173
except (NoInspectionAvailable, NoSuchTableError, ValueError) as e:
174+
commands_platform = {
175+
"Windows": [
176+
f"cmd /c copy {self.db_path} %USERPROFILE%\\nxc_{self.protocol.lower()}.bak",
177+
f"del {self.db_path}"
178+
],
179+
"Linux": [
180+
f"cp {self.db_path} ~/nxc_{self.protocol.lower()}.bak",
181+
f"rm -f {self.db_path}"
182+
]
183+
}
184+
copy_command = commands_platform["Windows"][0] if platform.system() == "Windows" else commands_platform["Linux"][0]
185+
delete_command = commands_platform["Windows"][1] if platform.system() == "Windows" else commands_platform["Linux"][1]
173186
nxc_logger.fail(f"Schema mismatch detected for table '{table.__tablename__}' in protocol '{self.protocol}'")
174187
nxc_logger.debug(e)
175188
nxc_logger.fail("This is probably because a newer version of nxc is being run on an old DB schema.")
176-
nxc_logger.fail(f"Optionally save the old DB data (`cp {self.db_path} ~/nxc_{self.protocol.lower()}.bak`)")
177-
nxc_logger.fail(f"Then remove the {self.protocol} DB (`rm -f {self.db_path}`) and run nxc to initialize the new DB")
189+
nxc_logger.fail(f"Optionally save the old DB data (`{copy_command}`)")
190+
nxc_logger.fail(f"Then remove the {self.protocol} DB (`{delete_command}`) and run nxc to initialize the new DB")
178191
sys.exit()
179192

180193
def shutdown_db(self):

0 commit comments

Comments
 (0)