From 6f40ef601543e3284bfe344d8fa6c3c4ce1b529a Mon Sep 17 00:00:00 2001 From: Jimmy Kiselak Date: Mon, 7 Sep 2015 23:59:59 -0400 Subject: [PATCH] fix typo in migrator path, set up logging and running as a script for migrator, change args to windows migrator exe so they are all strings --- lbrynet/db_migrator/dbmigrator.py | 13 ++++++++++++- lbrynet/lbrynet_downloader_gui/LBRYDownloader.py | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lbrynet/db_migrator/dbmigrator.py b/lbrynet/db_migrator/dbmigrator.py index 8e61e1c93..d7644f6cd 100644 --- a/lbrynet/db_migrator/dbmigrator.py +++ b/lbrynet/db_migrator/dbmigrator.py @@ -1,3 +1,6 @@ +import logging + + def migrate_db(db_dir, start, end): current = start old_dirs = [] @@ -11,4 +14,12 @@ def migrate_db(db_dir, start, end): def run_migration_script(): import sys - migrate_db(sys.argv[1], sys.argv[2], sys.argv[3]) \ No newline at end of file + log_format = "(%(asctime)s)[%(filename)s:%(lineno)s] %(funcName)s(): %(message)s" + logging.basicConfig(level=logging.DEBUG, format=log_format, filename="migrator.log") + sys.stdout = open("migrator.out.log", 'w') + sys.stderr = open("migrator.err.log", 'w') + migrate_db(sys.argv[1], int(sys.argv[2]), int(sys.argv[3])) + + +if __name__ == "__main__": + run_migration_script() \ No newline at end of file diff --git a/lbrynet/lbrynet_downloader_gui/LBRYDownloader.py b/lbrynet/lbrynet_downloader_gui/LBRYDownloader.py index a81af8f8e..b55540dd1 100644 --- a/lbrynet/lbrynet_downloader_gui/LBRYDownloader.py +++ b/lbrynet/lbrynet_downloader_gui/LBRYDownloader.py @@ -86,14 +86,14 @@ class LBRYDownloader(object): def run_migrator(): migrator_exe = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), - "dmigrator", "migrator.exe") + "dbmigrator", "migrator.exe") print "trying to find the migrator at", migrator_exe si = subprocess.STARTUPINFO si.dwFlags = subprocess.STARTF_USESHOWWINDOW si.wShowWindow = subprocess.SW_HIDE print "trying to run the migrator" - migrator_proc = subprocess.Popen([migrator_exe, self.conf_dir, old_revision, - self.current_db_revision], startupinfo=si) + migrator_proc = subprocess.Popen([migrator_exe, self.conf_dir, str(old_revision), + str(self.current_db_revision)], startupinfo=si) print "started the migrator" migrator_proc.wait() print "migrator has returned"