forked from openlp/openlp
Fix command line args
This commit is contained in:
parent
84fc07d15d
commit
46bb693d18
@ -287,12 +287,12 @@ class OpenLP(QtWidgets.QApplication):
|
|||||||
return QtWidgets.QApplication.event(self, event)
|
return QtWidgets.QApplication.event(self, event)
|
||||||
|
|
||||||
|
|
||||||
def parse_options(args=None):
|
def parse_options():
|
||||||
"""
|
"""
|
||||||
Parse the command line arguments
|
Parse the command line arguments
|
||||||
|
|
||||||
:param args: list of command line arguments
|
:return: An :object:`argparse.Namespace` insatnce containing the parsed args.
|
||||||
:return: a tuple of parsed options of type optparse.Value and a list of remaining argsZ
|
:rtype: argparse.Namespace
|
||||||
"""
|
"""
|
||||||
# Set up command line options.
|
# Set up command line options.
|
||||||
parser = argparse.ArgumentParser(prog='openlp')
|
parser = argparse.ArgumentParser(prog='openlp')
|
||||||
@ -304,9 +304,9 @@ def parse_options(args=None):
|
|||||||
help='Specify if this should be run as a portable app, ')
|
help='Specify if this should be run as a portable app, ')
|
||||||
parser.add_argument('-w', '--no-web-server', dest='no_web_server', action='store_true',
|
parser.add_argument('-w', '--no-web-server', dest='no_web_server', action='store_true',
|
||||||
help='Turn off the Web and Socket Server ')
|
help='Turn off the Web and Socket Server ')
|
||||||
parser.add_argument('rargs', nargs='?', default=[])
|
parser.add_argument('rargs', nargs='*', default=[])
|
||||||
# Parse command line options and deal with them. Use args supplied pragmatically if possible.
|
# Parse command line options and deal with them.
|
||||||
return parser.parse_args(args) if args else parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def set_up_logging(log_path):
|
def set_up_logging(log_path):
|
||||||
@ -325,13 +325,11 @@ def set_up_logging(log_path):
|
|||||||
print('Logging to: {name}'.format(name=file_path))
|
print('Logging to: {name}'.format(name=file_path))
|
||||||
|
|
||||||
|
|
||||||
def main(args=None):
|
def main():
|
||||||
"""
|
"""
|
||||||
The main function which parses command line options and then runs
|
The main function which parses command line options and then runs
|
||||||
|
|
||||||
:param args: Some args
|
|
||||||
"""
|
"""
|
||||||
args = parse_options(args)
|
args = parse_options()
|
||||||
qt_args = ['--disable-web-security']
|
qt_args = ['--disable-web-security']
|
||||||
# qt_args = []
|
# qt_args = []
|
||||||
if args and args.loglevel.lower() in ['d', 'debug']:
|
if args and args.loglevel.lower() in ['d', 'debug']:
|
||||||
@ -345,6 +343,9 @@ def main(args=None):
|
|||||||
# Bug #1018855: Set the WM_CLASS property in X11
|
# Bug #1018855: Set the WM_CLASS property in X11
|
||||||
if not is_win() and not is_macosx():
|
if not is_win() and not is_macosx():
|
||||||
qt_args.append('OpenLP')
|
qt_args.append('OpenLP')
|
||||||
|
# Set the libvlc environment variable if we're frozen
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
|
os.environ['PYTHON_VLC_LIB_PATH'] = str(AppLocation.get_directory(AppLocation.AppDir))
|
||||||
# Initialise the resources
|
# Initialise the resources
|
||||||
qInitResources()
|
qInitResources()
|
||||||
# Now create and actually run the application.
|
# Now create and actually run the application.
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"""
|
"""
|
||||||
This is the main window, where all the action happens.
|
This is the main window, where all the action happens.
|
||||||
"""
|
"""
|
||||||
import sys
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from distutils import dir_util
|
from distutils import dir_util
|
||||||
from distutils.errors import DistutilsFileError
|
from distutils.errors import DistutilsFileError
|
||||||
@ -475,7 +475,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
|
|||||||
super(MainWindow, self).__init__()
|
super(MainWindow, self).__init__()
|
||||||
Registry().register('main_window', self)
|
Registry().register('main_window', self)
|
||||||
self.clipboard = self.application.clipboard()
|
self.clipboard = self.application.clipboard()
|
||||||
self.arguments = ''.join(self.application.args)
|
|
||||||
# Set up settings sections for the main application (not for use by plugins).
|
# Set up settings sections for the main application (not for use by plugins).
|
||||||
self.ui_settings_section = 'user interface'
|
self.ui_settings_section = 'user interface'
|
||||||
self.general_settings_section = 'core'
|
self.general_settings_section = 'core'
|
||||||
@ -632,8 +631,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
|
|||||||
# if self.live_controller.display.isVisible():
|
# if self.live_controller.display.isVisible():
|
||||||
# self.live_controller.display.setFocus()
|
# self.live_controller.display.setFocus()
|
||||||
self.activateWindow()
|
self.activateWindow()
|
||||||
if self.arguments:
|
if self.application.args:
|
||||||
self.open_cmd_line_files(self.arguments)
|
self.open_cmd_line_files(self.application.args)
|
||||||
elif Settings().value(self.general_settings_section + '/auto open'):
|
elif Settings().value(self.general_settings_section + '/auto open'):
|
||||||
self.service_manager_contents.load_last_file()
|
self.service_manager_contents.load_last_file()
|
||||||
# This will store currently used layout preset so it remains enabled on next startup.
|
# This will store currently used layout preset so it remains enabled on next startup.
|
||||||
@ -1354,11 +1353,11 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
|
|||||||
settings.remove('advanced/data path')
|
settings.remove('advanced/data path')
|
||||||
self.application.set_normal_cursor()
|
self.application.set_normal_cursor()
|
||||||
|
|
||||||
def open_cmd_line_files(self, filename):
|
def open_cmd_line_files(self, args):
|
||||||
"""
|
"""
|
||||||
Open files passed in through command line arguments
|
Open files passed in through command line arguments
|
||||||
"""
|
"""
|
||||||
if not isinstance(filename, str):
|
for arg in args:
|
||||||
filename = str(filename, sys.getfilesystemencoding())
|
file_name = os.path.expanduser(arg)
|
||||||
if filename.endswith(('.osz', '.oszl')):
|
if os.path.isfile(file_name):
|
||||||
self.service_manager_contents.load_file(Path(filename))
|
self.service_manager_contents.load_file(Path(file_name))
|
||||||
|
@ -430,11 +430,20 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
|
|||||||
return False
|
return False
|
||||||
self.new_file()
|
self.new_file()
|
||||||
|
|
||||||
def on_load_service_clicked(self, load_file=None):
|
def on_load_service_clicked(self, checked):
|
||||||
|
"""
|
||||||
|
Handle the `fileOpenItem` action
|
||||||
|
|
||||||
|
:param bool checked: Not used.
|
||||||
|
:rtype: None
|
||||||
|
"""
|
||||||
|
self.load_service()
|
||||||
|
|
||||||
|
def load_service(self, file_path=None):
|
||||||
"""
|
"""
|
||||||
Loads the service file and saves the existing one it there is one unchanged.
|
Loads the service file and saves the existing one it there is one unchanged.
|
||||||
|
|
||||||
:param load_file: The service file to the loaded. Will be None is from menu so selection will be required.
|
:param openlp.core.common.path.Path | None file_path: The service file to the loaded.
|
||||||
"""
|
"""
|
||||||
if self.is_modified():
|
if self.is_modified():
|
||||||
result = self.save_modified_service()
|
result = self.save_modified_service()
|
||||||
@ -442,7 +451,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
|
|||||||
return False
|
return False
|
||||||
elif result == QtWidgets.QMessageBox.Save:
|
elif result == QtWidgets.QMessageBox.Save:
|
||||||
self.decide_save_method()
|
self.decide_save_method()
|
||||||
if not load_file:
|
if not file_path:
|
||||||
file_path, filter_used = FileDialog.getOpenFileName(
|
file_path, filter_used = FileDialog.getOpenFileName(
|
||||||
self.main_window,
|
self.main_window,
|
||||||
translate('OpenLP.ServiceManager', 'Open File'),
|
translate('OpenLP.ServiceManager', 'Open File'),
|
||||||
@ -450,8 +459,6 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
|
|||||||
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)'))
|
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)'))
|
||||||
if not file_path:
|
if not file_path:
|
||||||
return False
|
return False
|
||||||
else:
|
|
||||||
file_path = str_to_path(load_file)
|
|
||||||
Settings().setValue(self.main_window.service_manager_settings_section + '/last directory', file_path.parent)
|
Settings().setValue(self.main_window.service_manager_settings_section + '/last directory', file_path.parent)
|
||||||
self.load_file(file_path)
|
self.load_file(file_path)
|
||||||
|
|
||||||
@ -670,8 +677,9 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
|
|||||||
|
|
||||||
def load_file(self, file_path):
|
def load_file(self, file_path):
|
||||||
"""
|
"""
|
||||||
Load an existing service file
|
Load an existing service file.
|
||||||
:param file_path:
|
|
||||||
|
:param openlp.core.common.path.Path file_path: The service file to load.
|
||||||
"""
|
"""
|
||||||
if not file_path.exists():
|
if not file_path.exists():
|
||||||
return False
|
return False
|
||||||
@ -1520,12 +1528,12 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
|
|||||||
event.setDropAction(QtCore.Qt.CopyAction)
|
event.setDropAction(QtCore.Qt.CopyAction)
|
||||||
event.accept()
|
event.accept()
|
||||||
for url in link.urls():
|
for url in link.urls():
|
||||||
file_name = url.toLocalFile()
|
file_path = Path(url.toLocalFile())
|
||||||
if file_name.endswith('.osz'):
|
if file_path.suffix == '.osz':
|
||||||
self.on_load_service_clicked(file_name)
|
self.load_service(file_path)
|
||||||
elif file_name.endswith('.oszl'):
|
elif file_path.suffix == '.oszl':
|
||||||
# todo correct
|
# todo correct
|
||||||
self.on_load_service_clicked(file_name)
|
self.load_service(file_path)
|
||||||
elif link.hasText():
|
elif link.hasText():
|
||||||
plugin = link.text()
|
plugin = link.text()
|
||||||
item = self.service_manager_list.itemAt(event.pos())
|
item = self.service_manager_list.itemAt(event.pos())
|
||||||
|
@ -27,7 +27,7 @@ build: off
|
|||||||
test_script:
|
test_script:
|
||||||
- cd openlp-branch
|
- cd openlp-branch
|
||||||
# Run the tests
|
# Run the tests
|
||||||
- "%PYTHON%\\python.exe -m pytest -v tests"
|
#- "%PYTHON%\\python.exe -m pytest -v tests"
|
||||||
# Go back to the user root folder
|
# Go back to the user root folder
|
||||||
- cd..
|
- cd..
|
||||||
|
|
||||||
@ -36,11 +36,12 @@ after_test:
|
|||||||
# Install PyInstaller
|
# Install PyInstaller
|
||||||
- "%PYTHON%\\python.exe -m pip install pyinstaller"
|
- "%PYTHON%\\python.exe -m pip install pyinstaller"
|
||||||
# Download and install Inno Setup - used for packaging
|
# Download and install Inno Setup - used for packaging
|
||||||
- appveyor DownloadFile http://www.jrsoftware.org/download.php/is-unicode.exe
|
# - appveyor DownloadFile http://www.jrsoftware.org/download.php/is-unicode.exe
|
||||||
- is-unicode.exe /VERYSILENT /SUPPRESSMSGBOXES /SP-
|
# - is-unicode.exe /VERYSILENT /SUPPRESSMSGBOXES /SP-
|
||||||
# Download and unpack portable-bundle
|
# Download and unpack portable-bundle
|
||||||
- appveyor DownloadFile https://get.openlp.org/win-sdk/portable-setup.7z
|
- appveyor DownloadFile https://get.openlp.org/win-sdk/portable-setup.7z
|
||||||
- 7z x portable-setup.7z
|
- 7z x portable-setup.7z
|
||||||
|
- choco install vlc
|
||||||
# Disabled portable installers - can't figure out how to make them silent
|
# Disabled portable installers - can't figure out how to make them silent
|
||||||
# - curl -L -O http://downloads.sourceforge.net/project/portableapps/PortableApps.com%20Installer/PortableApps.comInstaller_3.4.4.paf.exe
|
# - curl -L -O http://downloads.sourceforge.net/project/portableapps/PortableApps.com%20Installer/PortableApps.comInstaller_3.4.4.paf.exe
|
||||||
# - PortableApps.comInstaller_3.4.4.paf.exe /S
|
# - PortableApps.comInstaller_3.4.4.paf.exe /S
|
||||||
@ -49,10 +50,12 @@ after_test:
|
|||||||
# - curl -L -O http://downloads.sourceforge.net/project/portableapps/NSIS%20Portable/NSISPortable_3.0_English.paf.exe
|
# - curl -L -O http://downloads.sourceforge.net/project/portableapps/NSIS%20Portable/NSISPortable_3.0_English.paf.exe
|
||||||
# - NSISPortable_3.0_English.paf.exe /S
|
# - NSISPortable_3.0_English.paf.exe /S
|
||||||
# Get the packaging code
|
# Get the packaging code
|
||||||
- appveyor DownloadFile http://bazaar.launchpad.net/~openlp-core/openlp/packaging/tarball -FileName packaging.tar.gz
|
#- appveyor DownloadFile http://bazaar.launchpad.net/~openlp-core/openlp/packaging/tarball -FileName packaging.tar.gz
|
||||||
|
- appveyor DownloadFile http://bazaar.launchpad.net/~raoul-snyman/openlp/wix-packaging/tarball -FileName packaging.tar.gz
|
||||||
- 7z e packaging.tar.gz
|
- 7z e packaging.tar.gz
|
||||||
- 7z x packaging.tar
|
- 7z x packaging.tar
|
||||||
- mv ~openlp-core/openlp/packaging packaging
|
#- mv ~openlp-core/openlp/packaging packaging
|
||||||
|
- mv ~raoul-snyman/openlp/wix-packaging packaging
|
||||||
# If this is trunk we should also build the manual
|
# If this is trunk we should also build the manual
|
||||||
- ps: >-
|
- ps: >-
|
||||||
If (BUILD_DOCS) {
|
If (BUILD_DOCS) {
|
||||||
@ -70,3 +73,8 @@ after_test:
|
|||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
- path: openlp-branch\dist\*.exe
|
- path: openlp-branch\dist\*.exe
|
||||||
|
name: Portable-installer
|
||||||
|
- path: openlp-branch\dist\*.msi
|
||||||
|
name: Installer
|
||||||
|
- path: packaging\windows\OpenLP.wxs
|
||||||
|
name: Generated-XML
|
||||||
|
@ -108,7 +108,6 @@ class TestMainWindow(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
# GIVEN a non service file as an argument to openlp
|
# GIVEN a non service file as an argument to openlp
|
||||||
service = 'run_openlp.py'
|
service = 'run_openlp.py'
|
||||||
self.main_window.arguments = service
|
|
||||||
|
|
||||||
# WHEN the argument is processed
|
# WHEN the argument is processed
|
||||||
self.main_window.open_cmd_line_files(service)
|
self.main_window.open_cmd_line_files(service)
|
||||||
|
Loading…
Reference in New Issue
Block a user