wizards: completely work python wizard packaging and registration

Also improve exception handling and error printing in pythonloader
Allow registration of explicit .py components - the only method that works
This commit is contained in:
Michael Meeks
2011-12-05 13:04:05 +00:00
parent fb7f82382b
commit 41b8bad143
19 changed files with 80 additions and 225 deletions

View File

@@ -74,51 +74,6 @@ LOCALPYFILES= \
$(BIN)$/pythonloader.py \
$(BIN)$/officehelper.py \
$(BIN)$/mailmerge.py \
$(BIN)$/CallWizard.py \
$(BIN)$/__init__.py \
$(BIN)$/FaxDocument.py \
$(BIN)$/FaxWizardDialogResources.py \
$(BIN)$/CGFax.py \
$(BIN)$/FaxWizardDialogConst.py \
$(BIN)$/CGFaxWizard.py \
$(BIN)$/FaxWizardDialogImpl.py \
$(BIN)$/FaxWizardDialog.py \
$(BIN)$/Configuration.py \
$(BIN)$/ConfigGroup.py \
$(BIN)$/FileAccess.py \
$(BIN)$/Properties.py \
$(BIN)$/Resource.py \
$(BIN)$/ConfigNode.py \
$(BIN)$/DebugHelper.py \
$(BIN)$/Helper.py \
$(BIN)$/NoValidPathException.py \
$(BIN)$/PropertyNames.py \
$(BIN)$/SystemDialog.py \
$(BIN)$/ConfigSet.py \
$(BIN)$/Desktop.py \
$(BIN)$/HelpIds.py \
$(BIN)$/NumberFormatter.py \
$(BIN)$/PropertySetHelper.py \
$(BIN)$/OfficeDocument.py \
$(BIN)$/TextDocument.py \
$(BIN)$/TextFieldHandler.py \
$(BIN)$/TextSectionHandler.py \
$(BIN)$/ViewHandler.py \
$(BIN)$/ControlScroller.py \
$(BIN)$/ImageList.py \
$(BIN)$/PathSelection.py \
$(BIN)$/UIConsts.py \
$(BIN)$/UnoDialog.py \
$(BIN)$/XPathSelectionListener.py \
$(BIN)$/DocumentPreview.py \
$(BIN)$/PeerConfig.py \
$(BIN)$/UnoDialog2.py \
$(BIN)$/WizardDialog.py \
$(BIN)$/CommonListener.py \
$(BIN)$/DataAware.py \
$(BIN)$/ListModelBinder.py \
$(BIN)$/RadioDataAware.py \
$(BIN)$/UnoDataAware.py \
$(BIN)$/msgbox.py
.ENDIF

View File

@@ -93,13 +93,14 @@ my_components = \
component/scaddins/source/analysis/analysis \
component/scaddins/source/datefunc/date \
component/sccomp/source/solver/solver \
component/scripting/source/basprov/basprov \
component/scripting/source/dlgprov/dlgprov \
component/scripting/source/protocolhandler/protocolhandler \
component/scripting/source/basprov/basprov \
component/scripting/source/dlgprov/dlgprov \
component/scripting/source/protocolhandler/protocolhandler \
component/scripting/source/pyprov/mailmerge \
component/scripting/source/stringresource/stringresource \
component/scripting/source/vbaevents/vbaevents \
component/scripting/util/scriptframe \
component/wizards/com/sun/star/wizards/fax/fax \
component/scripting/source/stringresource/stringresource \
component/scripting/source/vbaevents/vbaevents \
component/scripting/util/scriptframe \
component/sd/util/sd \
component/sd/util/sdd \
component/sd/util/sdfilt \
@@ -196,7 +197,7 @@ my_components += pythonloader
.IF "$(OS)" != "WNT" && "$(OS)" != "MACOSX" && "$(OS)" != "IOS" && "$(OS)" != "ANDROID"
my_components += component/desktop/unx/splash/splash
.ENDIF
.IF "$(DISABLE_ATL)" == ""
my_components += emboleobj
.END
@@ -357,8 +358,6 @@ my_components += evoab
my_components += component/avmedia/source/gstreamer/avmediagstreamer
.END
my_ooo_components = mailmerge component/wizards/com/sun/star/wizards/fax/fax
.INCLUDE: target.mk
ALLTAR : $(MISC)/services.rdb

View File

@@ -35,7 +35,7 @@ from com.sun.star.loader import XImplementationLoader
from com.sun.star.lang import XServiceInfo
MODULE_PROTOCOL = "vnd.openoffice.pymodule:"
DEBUG = 0
DEBUG = 1
g_supportedServices = "com.sun.star.loader.Python", # referenced by the native C++ loader !
g_implementationName = "org.openoffice.comp.pyuno.Loader" # referenced by the native C++ loader !
@@ -98,6 +98,7 @@ class Loader( XImplementationLoader, XServiceInfo, unohelper.Base ):
# read the file
filename = unohelper.fileUrlToSystemPath( url )
fileHandle = file( filename )
src = fileHandle.read().replace("\r","")
if not src.endswith( "\n" ):
@@ -110,11 +111,23 @@ class Loader( XImplementationLoader, XServiceInfo, unohelper.Base ):
g_loadedComponents[url] = mod
return mod
elif "vnd.openoffice.pymodule" == protocol:
return __import__( dependent )
print ("here")
nSlash = dependent.rfind('/')
if -1 != nSlash:
path = unohelper.fileUrlToSystemPath( dependent[0:nSlash] )
dependent = dependent[nSlash+1:len(dependent)]
if not path in sys.path:
sys.path.append( path )
var = __import__( dependent )
return var
else:
if DEBUG:
print("Unknown protocol '" + protocol + "'");
raise RuntimeException( "PythonLoader: Unknown protocol " +
protocol + " in url " +url, self )
except ImportError as e:
except Exception as e:
if DEBUG:
print ("Python import error " + str(e) + " args " + str(e.args));
raise RuntimeException( "Couldn't load " + url + " for reason " + str(e), None )
return None
@@ -124,6 +137,9 @@ class Loader( XImplementationLoader, XServiceInfo, unohelper.Base ):
mod = self.getModuleFromUrl( locationUrl )
implHelper = mod.__dict__.get( "g_ImplementationHelper" , None )
print ("dump stuff")
if DEBUG:
print ("Fetched ImplHelper as " + str(implHelper))
if implHelper == None:
return mod.getComponentFactory( implementationName, self.ctx.ServiceManager, regKey )
else:

View File

@@ -92,7 +92,7 @@ End
Directory gid_Dir_Wizards
Styles = (CREATE);
ParentID = gid_Dir_Program;
ParentID = gid_Brand_Dir_Program;
DosName = "wizards";
End

View File

@@ -469,63 +469,17 @@ STD_JAR_FILE( gid_File_Jar_Saxon, saxon9 )
#ifndef AIX
#ifndef DISABLE_PYUNO
STD_PY_FILE( gid_File_PyInitWizards, __init__, gid_Dir_Wizards )
File gid_File_Wizards_Common
Dir = gid_Dir_Wizards;
ARCHIVE_TXT_FILE_BODY;
Name = "wizards.zip";
End
STD_PY_FILE( gid_File_PyCallFaxWizard, CallWizard, gid_Dir_Program )
STD_PY_FILE( gid_File_PyInitFax, __init__, gid_Dir_Wizards_Fax )
STD_PY_FILE( gid_File_PyFaxDocument, FaxDocument, gid_Dir_Wizards_Fax )
STD_PY_FILE( gid_File_PyCGFax, CGFax, gid_Dir_Wizards_Fax )
STD_PY_FILE( gid_File_PyFaxWizardDialogResources, FaxWizardDialogResources, gid_Dir_Wizards_Fax )
STD_PY_FILE( gid_File_PyFaxWizardDialogConst, FaxWizardDialogConst, gid_Dir_Wizards_Fax )
STD_PY_FILE( gid_File_PyCGFaxWizard, CGFaxWizard, gid_Dir_Wizards_Fax )
STD_PY_FILE( gid_File_PyFaxWizardDialogImpl, FaxWizardDialogImpl, gid_Dir_Wizards_Fax )
STD_PY_FILE( gid_File_PyFaxWizardDialog, FaxWizardDialog, gid_Dir_Wizards_Fax )
STD_PY_FILE( gid_File_PyInitCommon, __init__, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyConfigGroup, ConfigGroup, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyConfiguration, Configuration, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyFileAccess, FileAccess, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyProperties, Properties, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyResource, Resource, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyConfigNode, ConfigNode, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyDebugHelper, DebugHelper, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PySystemDialog, SystemDialog, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyHelper, Helper, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyNoValidPathException, NoValidPathException, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyPropertyNames, PropertyNames, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyConfigSet, ConfigSet, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyDesktop, Desktop, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyHelpIds, HelpIds, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyNumberFormatter, NumberFormatter, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyPropertySetHelper, PropertySetHelper, gid_Dir_Wizards_Common )
STD_PY_FILE( gid_File_PyInitDocument, __init__, gid_Dir_Wizards_Document )
STD_PY_FILE( gid_File_PyOfficeDocument, OfficeDocument, gid_Dir_Wizards_Document )
STD_PY_FILE( gid_File_PyInitText, __init__, gid_Dir_Wizards_Text )
STD_PY_FILE( gid_File_PyTextDocument, TextDocument, gid_Dir_Wizards_Text )
STD_PY_FILE( gid_File_PyTextFieldHandler, TextFieldHandler, gid_Dir_Wizards_Text )
STD_PY_FILE( gid_File_PyTextSectionHandler, TextSectionHandler, gid_Dir_Wizards_Text )
STD_PY_FILE( gid_File_PyViewHandler, ViewHandler, gid_Dir_Wizards_Text )
STD_PY_FILE( gid_File_PyInitUI, __init__, gid_Dir_Wizards_Ui )
STD_PY_FILE( gid_File_PyControlScroller, ControlScroller, gid_Dir_Wizards_Ui )
STD_PY_FILE( gid_File_PyImageList, ImageList, gid_Dir_Wizards_Ui )
STD_PY_FILE( gid_File_PyPathSelection, PathSelection, gid_Dir_Wizards_Ui )
STD_PY_FILE( gid_File_PyUIConsts, UIConsts, gid_Dir_Wizards_Ui )
STD_PY_FILE( gid_File_PyUnoDialog, UnoDialog, gid_Dir_Wizards_Ui )
STD_PY_FILE( gid_File_PyXPathSelectionListener, XPathSelectionListener, gid_Dir_Wizards_Ui )
STD_PY_FILE( gid_File_PyDocumentPreview, DocumentPreview, gid_Dir_Wizards_Ui )
STD_PY_FILE( gid_File_PyPeerConfig, PeerConfig, gid_Dir_Wizards_Ui )
STD_PY_FILE( gid_File_PyUnoDialog2, UnoDialog2, gid_Dir_Wizards_Ui )
STD_PY_FILE( gid_File_PyWizardDialog, WizardDialog, gid_Dir_Wizards_Ui )
STD_PY_FILE( gid_File_PyInitEvent, __init__, gid_Dir_Wizards_Ui_Event )
STD_PY_FILE( gid_File_PyCommonListener, CommonListener, gid_Dir_Wizards_Ui_Event )
STD_PY_FILE( gid_File_PyDataAware, DataAware, gid_Dir_Wizards_Ui_Event )
STD_PY_FILE( gid_File_PyListModelBinder, ListModelBinder, gid_Dir_Wizards_Ui_Event )
STD_PY_FILE( gid_File_PyRadioDataAware, RadioDataAware, gid_Dir_Wizards_Ui_Event )
STD_PY_FILE( gid_File_PyUnoDataAware, UnoDataAware, gid_Dir_Wizards_Ui_Event )
File gid_File_Wizards_Fax
Dir = gid_Dir_Wizards_Fax;
ARCHIVE_TXT_FILE_BODY;
Name = "fax.zip";
End
#endif
#endif

View File

@@ -140,6 +140,9 @@ Module gid_Module_Root_Files_3
gid_File_Jar_Letter,
gid_File_Jar_Form,
gid_File_Jar_Fax,
gid_File_Wizards_Common,
gid_File_Wizards_Event,
gid_File_Wizards_Fax,
gid_File_Jar_Agenda,
gid_File_Jar_Web,
gid_File_Jar_Query,

View File

@@ -23,26 +23,39 @@
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
gb_Pyuno_ZIPCOMMAND := zip $(if $(findstring s,$(MAKEFLAGS)),-q)
gb_Pyuno__get_outdir_path = $(patsubst $(OUTDIR)/%,%,$(gb_Helper_OUTDIRLIBDIR))/pyuno/$(1)
$(call gb_Pyuno_get_target,%) :
$(call gb_Output_announce,$*,$(true),PYU,3)
mkdir -p $(dir $@) && touch $@
$(call gb_Pyuno_get_target_zip,%) : $(call gb_Package_get_target,%_pyuno)
$(call gb_Output_announce,$*,$(true),PYZIP,3)
cd $(gb_Helper_OUTDIRLIBDIR)/pyuno && \
$(gb_Pyuno_ZIPCOMMAND) -rX --filesync \
$(call gb_Pyuno_get_target_zip,$*) \
$(PYZFILES)
.PHONY : $(call gb_Pyuno_get_clean_target,%)
$(call gb_Pyuno_get_clean_target,%) :
$(call gb_Output_announce,$*,$(false),PYU,3)
rm -f $@
rm -f $@ $(gb_Pyuno_get_target_zip,$*)
define gb_Pyuno_Pyuno
$(call gb_Pyuno_get_target_zip,$(1)) : PYZFILES :=
$(call gb_Package_Package,$(1)_pyuno,$(2))
$$(eval $$(call gb_Module_register_target,$(call gb_Pyuno_get_target,$(1)),$(call gb_Pyuno_get_clean_target,$(1))))
$(call gb_Pyuno_get_target,$(1)) : $(call gb_Package_get_target,$(1)_pyuno)
$(call gb_Pyuno_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(1)_pyuno)
$(call gb_Pyuno_get_target,$(1)) : \
$(call gb_Package_get_target,$(1)_pyuno) \
$(call gb_Pyuno_get_target_zip,$(1))
$(call gb_Pyuno_get_clean_target,$(1)) : \
$(call gb_Package_get_clean_target,$(1)_pyuno)
endef
define gb_Pyuno_add_file
$(call gb_Pyuno_get_target_zip,$(1)) : PYZFILES += $(2)
$(call gb_Package_add_file,$(1)_pyuno,$(call gb_Pyuno__get_outdir_path,$(2)),$(2))
endef
@@ -54,11 +67,16 @@ endef
gb_Pyuno__COMPONENTPREFIX := vnd.openoffice.pymodule:
define gb_Pyuno_set_componentfile
$(call gb_ComponentTarget_ComponentTarget,$(2),$(gb_Pyuno__COMPONENTPREFIX),$(1))
define gb_Pyuno_set_componentfile_full
$(call gb_ComponentTarget_ComponentTarget,$(2),$(3),$(4))
$(call gb_Pyuno_get_target,$(1)) : $(call gb_ComponentTarget_get_outdir_target,$(2))
$(call gb_Pyuno_get_clean_target,$(1)) : $(call gb_ComponentTarget_get_clean_target,$(2))
endef
define gb_Pyuno_set_componentfile
$(call gb_Pyuno_set_componentfile_full,$(1),$(2),$(gb_Pyuno__COMPONENTPREFIX),$(1))
endef
# vim:set shiftwidth=4 tabstop=4 noexpandtab:

View File

@@ -104,6 +104,7 @@ gb_ObjCObject_get_target = $(WORKDIR)/ObjCObject/$(1).o
gb_Package_get_preparation_target = $(WORKDIR)/Package/prepared/$(1)
gb_Package_get_target = $(WORKDIR)/Package/$(1)
gb_Pyuno_get_target = $(WORKDIR)/Pyuno/$(1)
gb_Pyuno_get_target_zip = $(OUTDIR)/bin/$(1).zip
gb_RdbTarget_get_target = $(WORKDIR)/RdbTarget/$(1).rdb
gb_ResTarget_get_imagelist_target = $(WORKDIR)/ResTarget/$(1).ilst
gb_ResTarget_get_target = $(WORKDIR)/ResTarget/$(1).res

View File

@@ -38,7 +38,6 @@ $(eval $(call gb_Module_add_targets,wizards,\
AllLangResTarget_wzi \
Pyuno_fax \
Pyuno_commonwizards \
Pyuno_event \
Zip_depot \
Zip_euro \
Zip_form \

View File

@@ -1,62 +0,0 @@
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# Major Contributor(s):
# Copyright (C) 2011 David Tardon, Red Hat Inc. <dtardon@redhat.com> (initial developer)
#
# All Rights Reserved.
#
# For minor contributions see the git repository.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
$(eval $(call gb_Pyuno_Pyuno,common,$(SRCDIR)/wizards/com/sun/star/wizards))
$(eval $(call gb_Pyuno_add_files,common,\
common/ConfigGroup.py \
common/Configuration.py \
common/FileAccess.py \
common/Properties.py \
common/Resource.py \
common/ConfigNode.py \
common/DebugHelper.py \
common/Helper.py \
common/NoValidPathException.py \
common/PropertyNames.py \
common/SystemDialog.py \
common/ConfigSet.py \
common/Desktop.py \
common/HelpIds.py \
common/NumberFormatter.py \
common/PropertySetHelper.py \
document/OfficeDocument.py \
text/TextDocument.py \
text/TextFieldHandler.py \
text/TextSectionHandler.py \
text/ViewHandler.py \
ui/ControlScroller.py \
ui/ImageList.py \
ui/PathSelection.py \
ui/UIConsts.py \
ui/UnoDialog.py \
ui/XPathSelectionListener.py \
ui/DocumentPreview.py \
ui/PeerConfig.py \
ui/UnoDialog2.py \
ui/WizardDialog.py \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab:

View File

@@ -1,36 +0,0 @@
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# Major Contributor(s):
# Copyright (C) 2011 David Tardon, Red Hat Inc. <dtardon@redhat.com> (initial developer)
#
# All Rights Reserved.
#
# For minor contributions see the git repository.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
$(eval $(call gb_Pyuno_Pyuno,event,$(SRCDIR)/wizards/com/sun/star/wizards/ui/event))
$(eval $(call gb_Pyuno_add_files,event,\
CommonListener.py \
DataAware.py \
ListModelBinder.py \
RadioDataAware.py \
UnoDataAware.py \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab:

View File

@@ -26,6 +26,7 @@
$(eval $(call gb_Pyuno_Pyuno,fax,$(SRCDIR)/wizards/com/sun/star/wizards/fax))
$(eval $(call gb_Pyuno_add_files,fax,\
__init__.py \
CallWizard.py \
CGFax.py \
CGFaxWizard.py \
@@ -34,9 +35,7 @@ $(eval $(call gb_Pyuno_add_files,fax,\
FaxWizardDialogImpl.py \
FaxWizardDialog.py \
FaxWizardDialogResources.py \
__init__.py \
))
$(eval $(call gb_Pyuno_set_componentfile,fax,wizards/com/sun/star/wizards/fax/fax))
$(eval $(call gb_Pyuno_set_componentfile_full,fax,wizards/com/sun/star/wizards/fax/fax,vnd.sun.star.expand:\dLO_LIB_DIR/wizards/fax/CallWizard,.py))
# vim:set shiftwidth=4 softtabstop=4 expandtab:

View File

@@ -14,8 +14,13 @@ class CallWizard(unohelper.Base, XJobExecutor):
self.ctx = ctx
def trigger(self, args):
fw = FaxWizardDialogImpl(self.ctx.ServiceManager)
fx.startWizard()
try:
fw = FaxWizardDialogImpl(self.ctx.ServiceManager)
fw.startWizard(self.ctx.ServiceManager)
except Exception as e:
print ("Wizard failure exception " + str(type(e)) +
" message " + str(e) + " args " + str(e.args) +
traceback.format_exc());
# pythonloader looks for a static g_ImplementationHelper variable
g_ImplementationHelper = unohelper.ImplementationHelper()

View File

@@ -1,3 +1,4 @@
import wizards.ui.UIConsts
from wizards.ui.WizardDialog import *
from wizards.fax.FaxWizardDialogResources import FaxWizardDialogResources
from wizards.fax.FaxWizardDialogConst import *

View File

@@ -0,0 +1,2 @@
__all__ = ['CallWizard', 'CGFax', 'GCFaxWizard', 'FaxDocument', 'FaxWizardDialogConst',
'FaxWizardDialogImpl', 'FaxWizardDialog', 'FaxWizardDialogResources']

View File

@@ -28,8 +28,7 @@
<component loader="com.sun.star.loader.Python"
xmlns="http://openoffice.org/2010/uno-components">
<implementation
name="com.sun.star.wizards.fax.CallWizard">
<implementation name="com.sun.star.wizards.fax.CallWizard">
<service name="com.sun.star.task.Job"/>
</implementation>
</component>

View File

@@ -1,3 +1,4 @@
from wizards.ui.UIConsts import *
from wizards.ui.UnoDialog import *
from wizards.ui.event.CommonListener import *
from wizards.common.Desktop import Desktop

View File

@@ -1,3 +1,4 @@
import wizards.ui.UIConsts
from wizards.ui.UnoDialog2 import *
from abc import ABCMeta, abstractmethod
from wizards.common.Resource import Resource