1
0
mirror of https://gitlab.com/openlp/packaging.git synced 2024-12-22 13:02:50 +00:00

Fix python3 issues and include the default theme json file

This commit is contained in:
Jonathan Springer 2014-05-06 15:51:27 -04:00
parent b66db894fd
commit c0cbc8a014
2 changed files with 57 additions and 26 deletions

View File

@ -118,7 +118,7 @@ import subprocess
import sys
from shutil import copy, rmtree
from subprocess import Popen, PIPE
from configparser import SafeConfigParser as ConfigParser
from configparser import ConfigParser
from argparse import ArgumentParser
@ -193,7 +193,7 @@ class MacosxBuilder(object):
# Get the output in plist format.
paths = []
output = self._run_command([self.hdiutil, 'info', '-plist'], 'Detecting mount points failed.')
pl = plistlib.readPlistFromString(output)
pl = plistlib.readPlistFromBytes(output)
for image in pl['images']:
for se in image['system-entities']:
if se.get('mount-point'):
@ -322,8 +322,8 @@ class MacosxBuilder(object):
'--additional-hooks-dir', self.hooks_path,
'--runtime-hook', os.path.join(self.hooks_path, 'rthook_openlp_pyqt4.py'),
'--log-level=ERROR',
'-o', self.branch_path,
#u'-i', self.mac_icon,
# '--distpath', self.branch_path,
# '-i', self.mac_icon,
'-p', self.branch_path,
'-n', 'OpenLP',
self.openlp_script),
@ -350,24 +350,39 @@ class MacosxBuilder(object):
tag = '0.0.0'
revision = '0'
else:
tag, revision = lines[-1].split()
tag, revision = lines[-1].decode('utf-8').split()
bzr = Popen(('bzr', 'log', '--line', '-r', '-1'), stdout=PIPE)
output, error = bzr.communicate()
code = bzr.wait()
if code != 0:
raise Exception('Error running bzr log')
output_ascii = str(output, errors='ignore')
latest = output_ascii.split(':')[0]
latest = output.decode('utf-8').split(':')[0]
self.version_string = '%s-bzr%s' % (tag, latest)
self.version_tag = tag
version_file = open(os.path.join(self.dist_path, '.version'), 'w')
# Release version does not contain revision in .dmg name.
if self.args.devel:
version_file.write(self.version_string)
version_file.write(str(self.version_string))
else:
version_file.write(self.version_tag)
version_file.write(str(self.version_tag))
version_file.close()
def copy_default_theme(self):
"""
Copy the default theme to the correct directory for OpenLP.
"""
self._print('Copying default theme...')
source = os.path.join(self.source_path, 'core', 'lib', 'json')
dest = os.path.join(self.dist_path, 'core', 'lib', 'json')
for root, dirs, files in os.walk(source):
for filename in files:
if filename.endswith('.json'):
dest_path = os.path.join(dest, root[len(source) + 1:])
if not os.path.exists(dest_path):
os.makedirs(dest_path)
self._print_verbose('... %s', filename)
copy(os.path.join(root, filename), os.path.join(dest_path, filename))
def copy_plugins(self):
"""
Copy all the plugins to the correct directory so that OpenLP sees that
@ -498,15 +513,15 @@ class MacosxBuilder(object):
# Release version does not contain revision in .dmg name.
if self.args.devel:
dmg_name = 'OpenLP-' + self.version_string + '.dmg'
dmg_name = 'OpenLP-' + str(self.version_string) + '.dmg'
else:
dmg_name = 'OpenLP-' + self.version_tag + '.dmg'
dmg_name = 'OpenLP-' + str(self.version_tag) + '.dmg'
dmg_file = os.path.join(self.branch_path, 'build', dmg_name)
# Remove dmg if it exists.
if os.path.exists(dmg_file):
os.remove(dmg_file)
# Create empty dmg file.
# Create empty dmg file.
size = self._get_directory_size(self.dist_app_path) # in bytes.
size = size / (1024 * 1024) # Convert to megabytes.
size += 10 # Additional space in .dmg for other files.
@ -555,7 +570,7 @@ class MacosxBuilder(object):
self.adjust_dmg_view(os.path.basename(dmg_volume_path))
## Unmount dmg file.
# Unmount dmg file.
self._print('... unmounting the dmg.')
# Sometimes it could happen that OSX Finder is blocking umount.
# We need to find this process and kill it.
@ -580,7 +595,7 @@ class MacosxBuilder(object):
self._run_command([self.hdiutil, 'convert', dmg_file, '-format', 'UDZO', '-imagekey', 'zlib-level=9', '-o',
compressed_dmg], 'Could not compress the dmg file, dmg creation failed.')
# Jenkins integration.
# Jenkins integration.
# Continuous integration server needs to know the filename of dmg.
# Write java property file. For uploading dmg to openlp.
if self.args.devel:
@ -600,7 +615,7 @@ class MacosxBuilder(object):
# TODO: Use only one applescript file. Remove one for osx 10.5.
f = open(os.path.join(self.script_path, 'applescript-adjust-dmg-view.master'))
p = Popen([self.osascript], stdin=PIPE)
p.communicate(f.read() % (dmg_volume_name, 'OpenLP'))
p.communicate(bytes(f.read() % (dmg_volume_name, 'OpenLP'), 'utf-8'))
f.close()
result = p.returncode
if (result != 0):
@ -627,6 +642,7 @@ class MacosxBuilder(object):
self.run_pyinstaller()
self.write_version_file()
self.copy_mac_bundle_files()
self.copy_default_theme()
self.copy_plugins()
self.copy_media_player()
# TODO creating help on Mac

View File

@ -129,7 +129,7 @@ import sys
from shutil import copy, rmtree, move
from distutils import dir_util
from subprocess import Popen, PIPE
from configparser import SafeConfigParser as ConfigParser
from configparser import ConfigParser
from argparse import ArgumentParser
@ -253,11 +253,9 @@ class WindowsBuilder(object):
self.args.portable = self.portable_path
else:
self.portable_path = ''
self.openlp_script = os.path.abspath(
os.path.join(branch_path, 'openlp.py'))
self.openlp_script = os.path.abspath(os.path.join(branch_path, 'openlp.py'))
self.hooks_path = os.path.abspath(self.config.get('paths', 'hooks'))
self.win32_icon = os.path.abspath(
self.config.get('paths', 'win32icon'))
self.win32_icon = os.path.abspath(self.config.get('paths', 'win32icon'))
self.i18n_utils = os.path.join(self.branch_path, 'scripts', 'translation_utils.py')
self.source_path = os.path.join(self.branch_path, 'openlp')
self.manual_path = os.path.join(self.docs_path, 'manual')
@ -302,7 +300,7 @@ class WindowsBuilder(object):
'--additional-hooks-dir', self.hooks_path,
'--runtime-hook', os.path.join(self.hooks_path, 'rthook_openlp_pyqt4.py'),
'--log-level=ERROR',
'-o', self.branch_path,
'--distpath', self.branch_path,
'-i', self.win32_icon,
'-p', self.branch_path,
'-n', 'OpenLP',
@ -330,21 +328,36 @@ class WindowsBuilder(object):
tag = '0.0.0'
revision = '0'
else:
tag, revision = lines[-1].split()
tag, revision = lines[-1].decode('utf-8').split()
bzr = Popen(('bzr', 'log', '--line', '-r', '-1'), stdout=PIPE)
output, error = bzr.communicate()
code = bzr.wait()
if code != 0:
raise Exception('Error running bzr log')
output_ascii = str(output, errors='ignore')
latest = output_ascii.split(':')[0]
latest = output.decode('utf-8').split(':')[0]
version_string = latest == revision and tag or '%s-bzr%s' % (tag, latest)
# Save decimal version in case we need to do a portable build.
self.version = latest == revision and tag or '%s.%s' % (tag, latest)
version_file = open(os.path.join(self.dist_path, '.version'), 'w')
version_file.write(version_string)
version_file.write(str(version_string))
version_file.close()
def copy_default_theme(self):
"""
Copy the default theme to the correct directory for OpenLP.
"""
self._print('Copying default theme...')
source = os.path.join(self.source_path, 'core', 'lib', 'json')
dest = os.path.join(self.dist_path, 'core', 'lib', 'json')
for root, dirs, files in os.walk(source):
for filename in files:
if filename.endswith('.json'):
dest_path = os.path.join(dest, root[len(source) + 1:])
if not os.path.exists(dest_path):
os.makedirs(dest_path)
self._print_verbose('... %s', filename)
copy(os.path.join(root, filename), os.path.join(dest_path, filename))
def copy_plugins(self):
"""
Copy all the plugins to the correct directory so that OpenLP sees that
@ -555,7 +568,8 @@ class WindowsBuilder(object):
code = portableapps.wait()
if code != 0:
raise Exception('Error running PortableApps Installer')
portable_app = os.path.abspath(os.path.join(self.portable_path, '..', 'OpenLPPortable_%s.paf.exe' % self.version))
portable_app = os.path.abspath(os.path.join(self.portable_path, '..',
'OpenLPPortable_%s.paf.exe' % self.version))
if os.path.exists(portable_app):
move(portable_app, os.path.abspath(os.path.join(self.dist_path, '..')))
self._print(' PortableApp build complete')
@ -599,6 +613,7 @@ class WindowsBuilder(object):
self.build_pptviewlib()
self.run_pyinstaller()
self.write_version_file()
self.copy_default_theme()
self.copy_plugins()
self.copy_media_player()
if os.path.exists(self.manual_path):