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

This commit is contained in:
Jimmy Kiselak 2015-09-07 23:59:59 -04:00
parent c7758506ac
commit 6f40ef6015
2 changed files with 15 additions and 4 deletions

View file

@ -1,3 +1,6 @@
import logging
def migrate_db(db_dir, start, end): def migrate_db(db_dir, start, end):
current = start current = start
old_dirs = [] old_dirs = []
@ -11,4 +14,12 @@ def migrate_db(db_dir, start, end):
def run_migration_script(): def run_migration_script():
import sys import sys
migrate_db(sys.argv[1], sys.argv[2], sys.argv[3]) 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()

View file

@ -86,14 +86,14 @@ class LBRYDownloader(object):
def run_migrator(): def run_migrator():
migrator_exe = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), 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 print "trying to find the migrator at", migrator_exe
si = subprocess.STARTUPINFO si = subprocess.STARTUPINFO
si.dwFlags = subprocess.STARTF_USESHOWWINDOW si.dwFlags = subprocess.STARTF_USESHOWWINDOW
si.wShowWindow = subprocess.SW_HIDE si.wShowWindow = subprocess.SW_HIDE
print "trying to run the migrator" print "trying to run the migrator"
migrator_proc = subprocess.Popen([migrator_exe, self.conf_dir, old_revision, migrator_proc = subprocess.Popen([migrator_exe, self.conf_dir, str(old_revision),
self.current_db_revision], startupinfo=si) str(self.current_db_revision)], startupinfo=si)
print "started the migrator" print "started the migrator"
migrator_proc.wait() migrator_proc.wait()
print "migrator has returned" print "migrator has returned"