コード例 #1
0
ファイル: dbtools.py プロジェクト: prrvchr/HsqlDBembeddedOOo
def getDataBaseConnection(ctx, url, dbname, name='', password='', shutdown=False):
    info = getDataSourceJavaInfo(url)
    if name != '':
        info += getPropertyValueSet({'user': name})
        if password != '':
            info += getPropertyValueSet({'password': password})
    path = getDataSourceLocation(url, dbname, shutdown)
    manager = ctx.ServiceManager.createInstance('com.sun.star.sdbc.DriverManager')
    connection, error = None, None
    try:
        connection = manager.getConnectionWithInfo(path, info)
    except SQLException as e:
        error = e
    return connection, error
コード例 #2
0
ファイル: contentcore.py プロジェクト: Vman45/DropboxOOo
def _setTitle(source, context, title):
    identifier = source.Identifier
    parent = identifier.getParent()
    count = parent.countChildTitle(title)
    if u'~' in title:
        msg = "Can't set property: Title value: %s contains invalid character: '~'." % title
        level = uno.getConstantByName('com.sun.star.logging.LogLevel.SEVERE')
        data = getPropertyValueSet({
            'Uri': identifier.getContentIdentifier(),
            'ResourceName': title
        })
        error = getInteractiveAugmentedIOException(msg, context, 'ERROR',
                                                   'INVALID_CHARACTER', data)
        result = uno.Any('com.sun.star.ucb.InteractiveAugmentedIOException',
                         error)
    elif (identifier.IsNew and count == 1) or (not identifier.IsNew
                                               and count != 0):
        msg = "Can't set property: %s value: %s - Name Clash Error" % ('Title',
                                                                       title)
        level = uno.getConstantByName('com.sun.star.logging.LogLevel.SEVERE')
        data = getPropertyValueSet({
            'TargetFolderURL':
            parent.getContentIdentifier(),
            'ClashingName':
            title,
            'ProposedNewName':
            '%s(1)' % title
        })
        #data = getPropertyValueSet({'Uri': identifier.getContentIdentifier(),'ResourceName': title})
        error = getInteractiveAugmentedIOException(msg, context, 'ERROR',
                                                   'ALREADY_EXISTING', data)
        result = uno.Any('com.sun.star.ucb.InteractiveAugmentedIOException',
                         error)
    else:
        if identifier.IsNew:
            source.MetaData.insertValue(
                'Title', identifier.setTitle(title, source.IsFolder))
        else:
            default = source.MetaData.getValue('Title')
            source.MetaData.insertValue('Title',
                                        identifier.updateTitle(title, default))
        msg = "Set property: %s value: %s" % ('Title', title)
        level = uno.getConstantByName('com.sun.star.logging.LogLevel.INFO')
        result = None
    return result, level, msg
コード例 #3
0
ファイル: wizardhandler.py プロジェクト: Vman45/smtpMailerOOo
 def _createForm(self, forms, name):
     service = 'com.sun.star.sdb.DocumentDefinition'
     args = getPropertyValueSet({
         'Name': name,
         'ActiveConnection': self.Connection
     })
     form = forms.createInstanceWithArguments(service, args)
     forms.insertByName(name, form)
     form = forms.getByName(name)
     return form
コード例 #4
0
ファイル: contentcore.py プロジェクト: prrvchr/DropboxOOo
def _setTitle(source, context, title):
    identifier = source.Identifier
    user = identifier.User
    if u'~' in title:
        msg = "Can't set property: Title value: %s contains invalid character: '~'." % title
        level = SEVERE
        data = getPropertyValueSet({
            'Uri': identifier.getContentIdentifier(),
            'ResourceName': title
        })
        error = getInteractiveAugmentedIOException(msg, context, 'ERROR',
                                                   'INVALID_CHARACTER', data)
        result = uno.Any('com.sun.star.ucb.InteractiveAugmentedIOException',
                         error)
    elif user.DataBase.countChildTitle(user.Id, identifier.ParentId,
                                       title) > 0:
        msg = "Can't set property: %s value: %s - Name Clash Error" % ('Title',
                                                                       title)
        level = SEVERE
        data = getPropertyValueSet({
            'TargetFolderURL':
            identifier.getContentIdentifier(),
            'ClashingName':
            title,
            'ProposedNewName':
            '%s(1)' % title
        })
        #data = getPropertyValueSet({'Uri': identifier.getContentIdentifier(),'ResourceName': title})
        error = getInteractiveAugmentedIOException(msg, context, 'ERROR',
                                                   'ALREADY_EXISTING', data)
        result = uno.Any('com.sun.star.ucb.InteractiveAugmentedIOException',
                         error)
    else:
        # When you change Title you must change also the Identifier.getContentIdentifier()
        # It's done by Identifier.setTitle()
        identifier.setTitle(title)
        msg = "Set property: %s value: %s" % ('Title', title)
        level = INFO
        result = None
    return result, level, msg
コード例 #5
0
ファイル: OAuth2Service.py プロジェクト: prrvchr/OAuth2OOo
 def getAuthorization(self, url, username, close=True, parent=None):
     print("OAuth2Service.getAuthorization() 1")
     authorized = False
     self._result = None
     listener = DispatchListener(self)
     arguments = getPropertyValueSet({'Url': url,
                                      'UserName': username,
                                      'Close': close})
     executeDispatch(self._ctx, 'oauth2:wizard', arguments, listener)
     print("OAuth2Service.getAuthorization() 2")
     if self._result is not None:
         authorized = self.initializeSession(*self._result)
     print("OAuth2Service.getAuthorization() 3")
     return authorized
コード例 #6
0
ファイル: wizardhandler.py プロジェクト: Vman45/smtpMailerOOo
 def _getForm(self, create, name='smtpMailerOOo'):
     forms = self._database.DatabaseDocument.getFormDocuments()
     if forms.hasByName(name):
         form = forms.getByName(name)
     elif create:
         form = self._createForm(forms, name)
     else:
         return None, None
     args = getPropertyValueSet({
         'ActiveConnection': self.Connection,
         'OpenMode': 'openDesign',
         'Hidden': True
     })
     doc = forms.loadComponentFromURL(name, '', 0, args)
     return doc, form
コード例 #7
0
 def _getDriverVersion(self):
     try:
         service = '%s.Driver' % g_identifier
         driver = createService(self.ctx, service)
         url = 'sdbc:embedded:hsqldb'
         infos = getPropertyValueSet({'URL': self._getUrl()})
         connection = driver.connect(url, infos)
         version = connection.getMetaData().getDriverVersion()
         connection.close()
         return version
     except UnoException as e:
         msg = getMessage(self.ctx, g_message, 141, e.Message)
         logMessage(self.ctx, SEVERE, msg, 'OptionsDialog',
                    '_getDriverVersion()')
     except Exception as e:
         msg = getMessage(self.ctx, g_message, 142,
                          (e, traceback.print_exc()))
         logMessage(self.ctx, SEVERE, msg, 'OptionsDialog',
                    '_getDriverVersion()')
コード例 #8
0
def getDataSourceInfo():
    info = getDataBaseInfo()
    return getPropertyValueSet(info)
コード例 #9
0
def getDataSourceJavaInfo(location):
    info = {}
    info['JavaDriverClass'] = g_class
    info['JavaDriverClassPath'] = '%s/%s' % (location, g_jar)
    return getPropertyValueSet(info)