Skip to content

Commit

Permalink
Print diagnostic messages to stderr; removed unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jschultz committed Jun 1, 2017
1 parent ef7b380 commit 766d555
Show file tree
Hide file tree
Showing 19 changed files with 183 additions and 175 deletions.
5 changes: 3 additions & 2 deletions AdjustDate.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function
from sqlalchemy import *
from sqlalchemy import exc
import warnings
Expand Down Expand Up @@ -68,10 +69,10 @@
if modifiedDate <= before:
modifiedDate += adjust
if createdDate > datetimeNow or modifiedDate > datetimeNow:
print("WARNING: future date")
print("WARNING: future date", file=sys.stderr)

if createdDate > modifiedDate:
print("WARNING: created date later than modified date")
print("WARNING: created date later than modified date", file=sys.stderr)
#row['_ModifiedDate'] = row['_CreatedDate']

row['_CreatedDate'] = createdDate
Expand Down
14 changes: 8 additions & 6 deletions DenormaliseNVP.py
Expand Up @@ -16,9 +16,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from __future__ import print_function
import argparse
import NVivo
import os
import sys
import shutil
import subprocess
import tempfile
Expand Down Expand Up @@ -115,29 +117,29 @@ def executescript(script, arglist=None):
instancename = regquerydata[0]
instanceversion = regquerydata[2].split('.')[0]
if args.verbosity >= 2:
print("Found SQL server instance " + instancename + " version " + instanceversion)
print("Found SQL server instance " + instancename + " version " + instanceversion, file=sys.stderr)
if (args.nvivoversion == '10' and instanceversion == 'MSSQL10_50') or (args.nvivoversion == '11' and instanceversion == 'MSSQL12'):
args.instance = instancename
break
else:
raise RuntimeError('No suitable SQL server instance found')

if args.verbosity > 0:
print("Using MSSQL instance: " + args.instance)
print("Using MSSQL instance: " + args.instance, file=sys.stderr)

if args.port is None:
regquery = executecommand(['reg', 'query', 'HKLM\\SOFTWARE\\Microsoft\\Microsoft SQL Server\\' + args.instance + '\\MSSQLServer\\SuperSocketNetLib\\Tcp']).splitlines()
args.port = int(regquery[1].split()[2])

if args.verbosity > 0:
print("Using port: " + str(args.port))
print("Using port: " + str(args.port), file=sys.stderr)

# Get reasonably distinct yet recognisable DB name
dbname = 'nvivo' + str(os.getpid())

executescript('mssqlAttach.bat', [tmpoutfilename, dbname, args.instance])
if args.verbosity > 0:
print("Attached database " + dbname)
print("Attached database " + dbname, file=sys.stderr)

try:
args.indb = 'sqlite:///' + args.infile
Expand All @@ -147,7 +149,7 @@ def executescript(script, arglist=None):

executescript('mssqlSave.bat', [tmpoutfilename, dbname, args.instance])
if args.verbosity > 0:
print("Saved database " + dbname)
print("Saved database " + dbname, file=sys.stderr)

if args.server is None:
shutil.move(tmpoutfilename, args.outfilename)
Expand All @@ -160,7 +162,7 @@ def executescript(script, arglist=None):
finally:
executescript('mssqlDrop.bat', [dbname, args.instance])
if args.verbosity > 0:
print("Dropped database " + dbname)
print("Dropped database " + dbname, file=sys.stderr)

if __name__ == '__main__':
DenormaliseNVP(None)
17 changes: 8 additions & 9 deletions DenormaliseNVPX.py
Expand Up @@ -16,7 +16,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from __future__ import print_function
import argparse
import NVivo
import os
import sys
import shutil
from subprocess import Popen, PIPE
import tempfile

parser = argparse.ArgumentParser(description='Create an NVivo for Mac file from a normalised SQLite file.')

Expand Down Expand Up @@ -66,14 +73,6 @@
args.mac = True
args.windows = False

import NVivo
import os
import shutil
import signal
from subprocess import Popen, PIPE
import tempfile
import time

tmpinfilename = tempfile.mktemp()
tmpinfileptr = file(tmpinfilename, 'wb')
tmpinfileptr.write(args.infile.read())
Expand Down Expand Up @@ -111,7 +110,7 @@
break

if args.verbosity > 0:
print("Started database server on port " + freeport)
print("Started database server on port " + freeport, file=sys.stderr)

args.indb = 'sqlite:///' + tmpinfilename
args.outdb = 'sqlalchemy_sqlany://wiwalisataob2aaf:iatvmoammgiivaam@localhost:' + freeport + '/NVivo' + freeport
Expand Down
23 changes: 11 additions & 12 deletions NVP2RQDA.py
Expand Up @@ -16,7 +16,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from __future__ import print_function
import argparse
import NVivo
import RQDA
import os
import sys
import shutil
import tempfile
from subprocess import Popen, PIPE

parser = argparse.ArgumentParser(description='Convert an NVivo for Windows (.nvp) file into an RQDA project.')

Expand Down Expand Up @@ -62,15 +70,6 @@
args.mac = False
args.windows = True

import NVivo
import RQDA
import os
import shutil
import signal
import tempfile
import time
from subprocess import Popen, PIPE

tmpinfilename = tempfile.mktemp()
tmpinfileptr = file(tmpinfilename, 'wb')
tmpinfileptr.write(args.infile.read())
Expand All @@ -88,15 +87,15 @@
proc = Popen([helperpath + 'mssqlInstance.bat'], stdout=PIPE)
args.instance = proc.stdout.readline()[0:-len(os.linesep)]
if args.verbosity > 0:
print("Using MSSQL instance: " + args.instance)
print("Using MSSQL instance: " + args.instance, file=sys.stderr)

# Get reasonably distinct yet recognisable DB name
dbname = 'nt' + str(os.getpid())

proc = Popen([helperpath + 'mssqlAttach.bat', tmpinfilename, dbname, args.instance])
proc.wait()
if args.verbosity > 0:
print("Attached database " + dbname)
print("Attached database " + dbname, file=sys.stderr)

args.indb = 'mssql+pymssql://nvivotools:nvivotools@localhost/' + dbname
args.outdb = 'sqlite:///' + tmpnormfilename
Expand All @@ -106,7 +105,7 @@
proc = Popen([helperpath + 'mssqlDrop.bat', dbname, args.instance])
proc.wait()
if args.verbosity > 0:
print("Dropped database " + dbname)
print("Dropped database " + dbname, file=sys.stderr)
os.remove(tmpinfilename)

tmpoutfilename = tempfile.mktemp()
Expand Down
19 changes: 9 additions & 10 deletions NVPX2RQDA.py
Expand Up @@ -16,7 +16,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from __future__ import print_function
import argparse
import NVivo
import RQDA
import os
import sys
import shutil
import tempfile
from subprocess import Popen, PIPE

parser = argparse.ArgumentParser(description='Convert an NVivo for Mac (.nvpx) file into an RQDA project.')

Expand Down Expand Up @@ -64,15 +72,6 @@
args.mac = True
args.windows = False

import NVivo
import RQDA
import os
import shutil
import signal
import tempfile
import time
from subprocess import Popen, PIPE

tmpinfilename = tempfile.mktemp()
tmpinfileptr = file(tmpinfilename, 'wb')
tmpinfileptr.write(args.infile.read())
Expand Down Expand Up @@ -101,7 +100,7 @@
break

if args.verbosity > 0:
print("Started database server on port " + freeport)
print("Started database server on port " + freeport, file=sys.stderr)

args.indb = 'sqlalchemy_sqlany://wiwalisataob2aaf:iatvmoammgiivaam@localhost:' + freeport + '/NVivo' + freeport
args.outdb = 'sqlite:///' + tmpnormfilename
Expand Down

0 comments on commit 766d555

Please sign in to comment.