Ejemplo n.º 1
0
    def _repairAction(self, database, partialReqBuf):
        # Begin constructing the request buffer (incorporate the one passed as
        # param $partialReqBuf).
        fullReqBuf = _ServiceActionRequestBuilder(_ksrv.isc_action_svc_repair)

        # The filename of the database must be specified regardless of the
        # action sub-action being perfomed.
        fullReqBuf.addDatabaseName(database)

        # Incorporate the caller's partial request buffer.
        fullReqBuf.extend(partialReqBuf)

        _ksrv.action_thin(self._C_conn, fullReqBuf.render())

        # Return the results to the caller synchronously (in this case, there
        # won't be any textual results, but issuing this call will helpfully
        # cause the program to block until the Services Manager is finished
        # with the action).
        return self._collectUnformattedResults()
Ejemplo n.º 2
0
    def _propertyAction(self, database, partialReqBuf):
        # Begin constructing the request buffer (incorporate the one passed as
        # param $partialReqBuf).
        fullReqBuf = _ServiceActionRequestBuilder(
            _ksrv.isc_action_svc_properties)

        # The filename of the database must be specified regardless of the
        # action sub-action being perfomed.
        fullReqBuf.addDatabaseName(database)

        # Incorporate the caller's partial request buffer.
        fullReqBuf.extend(partialReqBuf)

        _ksrv.action_thin(self._C_conn, fullReqBuf.render())

        # Return the results to the caller synchronously.
        # Since they don't produce output, is the following useful?
        # LATER: Yes, because it blocks until there's been some resolution of
        # the action.
        return self._collectUnformattedResults()
Ejemplo n.º 3
0
 def _act(self, requestBuffer):
     return _ksrv.action_thin(self._C_conn, requestBuffer.render())
Ejemplo n.º 4
0
    def restore(
        self,
        sourceFilenames,
        destFilenames,
        destFilePages=(),
        pageSize=None,
        cacheBuffers=None,
        accessModeReadOnly=0,
        replace=0,
        create=1,
        deactivateIndexes=0,
        doNotRestoreShadows=0,
        doNotEnforceConstraints=0,
        commitAfterEachTable=0,
        # If $useAllPageSpace is 1, entirely fill each page rather than
        # reserving 20% of each page for future use:
        useAllPageSpace=0):
        # Begin parameter validation section.
        sourceFilenames = _requireStrOrTupleOfStr(sourceFilenames)
        destFilenames = _requireStrOrTupleOfStr(destFilenames)

        _validateCompanionStringNumericSequences(
            destFilenames, destFilePages, 'destination filenames',
            'destination file page counts')
        # End parameter validation section.

        # Begin option bitmask setup section.
        optionMask = 0
        if replace:
            optionMask |= _ksrv.isc_spb_res_replace
        if create:
            optionMask |= _ksrv.isc_spb_res_create
        if deactivateIndexes:
            optionMask |= _ksrv.isc_spb_res_deactivate_idx
        if doNotRestoreShadows:
            optionMask |= _ksrv.isc_spb_res_no_shadow
        if doNotEnforceConstraints:
            optionMask |= _ksrv.isc_spb_res_no_validity
        if commitAfterEachTable:
            optionMask |= _ksrv.isc_spb_res_one_at_a_time
        if useAllPageSpace:
            optionMask |= _ksrv.isc_spb_res_use_all_space
        # End option bitmask setup section.

        # Construct the request buffer.
        request = _ServiceActionRequestBuilder(_ksrv.isc_action_svc_restore)

        # Backup filenames:
        request.addSequenceOfStrings(_ksrv.isc_spb_bkp_file, sourceFilenames)

        # Database filenames:
        request.addSequenceOfStringNumericPairs(_ksrv.isc_spb_dbname,
                                                destFilenames,
                                                _ksrv.isc_spb_res_length,
                                                destFilePages)

        # Page size of the restored database:
        if pageSize:
            request.addNumeric(_ksrv.isc_spb_res_page_size, pageSize)

        # cacheBuffers is the number of default cache buffers to configure for
        # attachments to the restored database:
        if cacheBuffers:
            request.addNumeric(_ksrv.isc_spb_res_buffers, cacheBuffers)

        # accessModeReadOnly controls whether the restored database is
        # "mounted" in read only or read-write mode:
        if accessModeReadOnly:
            accessMode = _ksrv.isc_spb_prp_am_readonly
        else:
            accessMode = _ksrv.isc_spb_prp_am_readwrite
        request.addNumeric(_ksrv.isc_spb_res_access_mode,
                           accessMode,
                           numCType='B')

        # Options bitmask:
        request.addNumeric(_ksrv.isc_spb_options, optionMask)

        # Tell the service to make its output available to us.
        request.addCode(_ksrv.isc_spb_verbose)

        # Done constructing the request buffer.

        _ksrv.action_thin(self._C_conn, request.render())

        # Return the results to the caller synchronously.
        return self._collectUnformattedResults()