forked from openlp/openlp
Fix code standard issues. Remove redundant modules
This commit is contained in:
parent
fbb7c0349e
commit
d6fada90e2
61
cnvdb.py
61
cnvdb.py
@ -1,61 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# Copyright (c) 2008-2009 Raoul Snyman #
|
|
||||||
# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten #
|
|
||||||
# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
|
||||||
# Software Foundation; version 2 of the License. #
|
|
||||||
# #
|
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
||||||
# more details. #
|
|
||||||
# #
|
|
||||||
# You should have received a copy of the GNU General Public License along #
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
import codecs
|
|
||||||
import sys
|
|
||||||
|
|
||||||
def convert_file(inname, outname):
|
|
||||||
"""
|
|
||||||
Convert a file from another encoding into UTF-8.
|
|
||||||
|
|
||||||
``inname``
|
|
||||||
The name of the file to be opened and converted.
|
|
||||||
|
|
||||||
``outname``
|
|
||||||
The output file name.
|
|
||||||
"""
|
|
||||||
infile = codecs.open(inname, 'r', encoding='CP1252')
|
|
||||||
writefile = codecs.open(outname, 'w', encoding='utf-8')
|
|
||||||
for line in infile:
|
|
||||||
#replace the quotes with quotes
|
|
||||||
#TODO fix double quotes
|
|
||||||
#line = line.replace(u'\'\'', u'@')
|
|
||||||
writefile.write(line)
|
|
||||||
infile.close()
|
|
||||||
writefile.close()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
"""
|
|
||||||
Run the conversion script.
|
|
||||||
"""
|
|
||||||
if len(sys.argv) < 2:
|
|
||||||
print 'No action specified.'
|
|
||||||
sys.exit()
|
|
||||||
print 'Uncode conversion:'
|
|
||||||
print 'Input file = ', sys.argv[1]
|
|
||||||
print 'Output file = ', sys.argv[2]
|
|
||||||
print 'Converting...'
|
|
||||||
convert_file(sys.argv[1], sys.argv[2])
|
|
||||||
print 'Done.'
|
|
@ -47,10 +47,10 @@ from openlp.migration.migratesongs import *
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG,
|
logging.basicConfig(level=logging.DEBUG,
|
||||||
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
|
format=u'%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
|
||||||
datefmt='%m-%d %H:%M',
|
datefmt=u'%m-%d %H:%M',
|
||||||
filename='openlp-migration.log',
|
filename=u'openlp-migration.log',
|
||||||
filemode='w')
|
filemode=u'w')
|
||||||
|
|
||||||
class Migration(object):
|
class Migration(object):
|
||||||
"""
|
"""
|
||||||
@ -76,10 +76,10 @@ class Migration(object):
|
|||||||
"""
|
"""
|
||||||
Move the log file to a new location.
|
Move the log file to a new location.
|
||||||
"""
|
"""
|
||||||
fname = 'openlp-migration.log'
|
fname = u'openlp-migration.log'
|
||||||
c = os.path.splitext(fname)
|
c = os.path.splitext(fname)
|
||||||
b = (c[0]+'-'+ unicode(self.stime) + c[1])
|
b = (c[0]+'-'+ unicode(self.stime) + c[1])
|
||||||
self.display.output(u'Logfile " +b + " generated')
|
self.display.output(u'Logfile ' + b + u' generated')
|
||||||
self.display.output(u'Migration Utility Finished ')
|
self.display.output(u'Migration Utility Finished ')
|
||||||
os.rename(fname, b)
|
os.rename(fname, b)
|
||||||
|
|
||||||
@ -93,12 +93,9 @@ class Migration(object):
|
|||||||
``outname``
|
``outname``
|
||||||
The output file name.
|
The output file name.
|
||||||
"""
|
"""
|
||||||
infile = codecs.open(inname, 'r', encoding='CP1252')
|
infile = codecs.open(inname, u'r', encoding=u'CP1252')
|
||||||
writefile = codecs.open(outname, 'w', encoding='utf-8')
|
writefile = codecs.open(outname, u'w', encoding=u'utf-8')
|
||||||
for line in infile:
|
for line in infile:
|
||||||
#replace the quotes with quotes
|
|
||||||
#TODO fix double quotes
|
|
||||||
#line = line.replace(u'\'\'', u'@')
|
|
||||||
writefile.write(line)
|
writefile.write(line)
|
||||||
infile.close()
|
infile.close()
|
||||||
writefile.close()
|
writefile.close()
|
||||||
@ -106,16 +103,16 @@ class Migration(object):
|
|||||||
def convert_sqlite2_to_3(self, olddb, newdb):
|
def convert_sqlite2_to_3(self, olddb, newdb):
|
||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
hKey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, u'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\SQLite ODBC Driver')
|
hKey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, u'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\SQLite ODBC Driver')
|
||||||
value, type = win32api.RegQueryValueEx (hKey, "UninstallString")
|
value, type = win32api.RegQueryValueEx (hKey, u'UninstallString')
|
||||||
sqlitepath, temp = os.path.split(value)
|
sqlitepath, temp = os.path.split(value)
|
||||||
sqliteexe = os.path.join(sqlitepath, u'sqlite.exe')
|
sqliteexe = os.path.join(sqlitepath, u'sqlite.exe')
|
||||||
else:
|
else:
|
||||||
sqliteexe = u'sqlite'
|
sqliteexe = u'sqlite'
|
||||||
cmd = sqliteexe + u' "' + olddb + u'" .dump'
|
cmd = u'%s "%s" .dump' % (sqliteexe, olddb)
|
||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
subprocess.call(cmd, stdout=open(u'./sqlite.dmp', 'w'))
|
subprocess.call(cmd, stdout=open(u'./sqlite.dmp', u'w'))
|
||||||
else:
|
else:
|
||||||
subprocess.call(cmd, stdout=open(u'./sqlite.dmp', 'w'), shell=True)
|
subprocess.call(cmd, stdout=open(u'./sqlite.dmp', u'w'), shell=True)
|
||||||
self.convert_file(u'sqlite.dmp', u'sqlite3.dmp')
|
self.convert_file(u'sqlite.dmp', u'sqlite3.dmp')
|
||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
sqlite3exe = os.path.join(sqlitepath, u'sqlite3.exe')
|
sqlite3exe = os.path.join(sqlitepath, u'sqlite3.exe')
|
||||||
@ -124,16 +121,15 @@ class Migration(object):
|
|||||||
if os.path.isfile(newdb):
|
if os.path.isfile(newdb):
|
||||||
saveddb = newdb + self.stime
|
saveddb = newdb + self.stime
|
||||||
os.rename(newdb, saveddb)
|
os.rename(newdb, saveddb)
|
||||||
cmd = sqlite3exe + ' "' + newdb + '"'
|
cmd = '%s "%s"' % (sqlite3exe, newdb)
|
||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
subprocess.call(cmd, stdin=open('sqlite3.dmp', 'r'))
|
subprocess.call(cmd, stdin=open(u'sqlite3.dmp', u'r'))
|
||||||
else:
|
else:
|
||||||
subprocess.call(cmd, stdin=open('sqlite3.dmp', 'r'), shell=True)
|
subprocess.call(cmd, stdin=open(u'sqlite3.dmp', u'r'), shell=True)
|
||||||
os.remove(u'sqlite.dmp')
|
os.remove(u'sqlite.dmp')
|
||||||
os.remove(u'sqlite3.dmp')
|
os.remove(u'sqlite3.dmp')
|
||||||
|
|
||||||
|
if __name__ == u'__main__':
|
||||||
if __name__ == '__main__':
|
|
||||||
mig = Migration()
|
mig = Migration()
|
||||||
config = PluginConfig(u'Songs')
|
config = PluginConfig(u'Songs')
|
||||||
newpath = config.get_data_path()
|
newpath = config.get_data_path()
|
||||||
@ -141,7 +137,7 @@ if __name__ == '__main__':
|
|||||||
if not os.path.isdir(newpath):
|
if not os.path.isdir(newpath):
|
||||||
os.makedirs(newpath)
|
os.makedirs(newpath)
|
||||||
ALL_USERS_APPLICATION_DATA = 35
|
ALL_USERS_APPLICATION_DATA = 35
|
||||||
shell = Dispatch("Shell.Application")
|
shell = Dispatch(u'Shell.Application')
|
||||||
folder = shell.Namespace(ALL_USERS_APPLICATION_DATA)
|
folder = shell.Namespace(ALL_USERS_APPLICATION_DATA)
|
||||||
folderitem = folder.Self
|
folderitem = folder.Self
|
||||||
olddb = os.path.join(folderitem.path, u'openlp.org', u'Data', u'songs.olp')
|
olddb = os.path.join(folderitem.path, u'openlp.org', u'Data', u'songs.olp')
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
/usr/bin/sqlite ~/.local/share/openlp/songs/songs.olp .dump > ~/.local/share/openlp/songs/songs.dmp
|
|
||||||
./cnvdb.py ~/.local/share/openlp/songs/songs.dmp ~/.local/share/openlp/songs/songs.dmp2
|
|
||||||
rm ~/.local/share/openlp/songs/songs.sqlite
|
|
||||||
sqlite3 ~/.local/share/openlp/songs/songs.sqlite < ~/.local/share/openlp/songs/songs.dmp2
|
|
||||||
./openlpcnv.pyw
|
|
Loading…
Reference in New Issue
Block a user