def triggerS3DatasetExport(self, valueAsString, bucketname, keyname, onCompletedCallback): if not isinstance(valueAsString, RemotePythonObject.ComputedRemotePythonObject): onCompletedCallback( Exceptions.PyforaError( "The argument to triggerS3DatasetExport should be a ComputedRemotePythonObject" ) ) return import pyfora.SubscribableWebObjects as SubscribableWebObjects if not isinstance(valueAsString.computedValue, SubscribableWebObjects.PyforaComputedValue): onCompletedCallback( Exceptions.PyforaError( "The object handle in the object passed to triggerS3DatasetExport should be a ComputedValue" ) ) return #first, ensure that the value itself resolves computedValue = valueAsString.computedValue computedValueToCalculate = self.webObjectFactory.ComputedValueForMember( { 'baseComputedValue': computedValue, 'memberName': '@pyfora_string_as_paged_vec_of_char' }) def onFailure(err): if not self.closed: onCompletedCallback(Exceptions.PyforaError(err['message'])) def isFinishedChanged(isFinished): if not self.closed and isFinished: self.triggerS3DatasetExportOnFinishedCalculation( computedValueToCalculate, bucketname, keyname, onCompletedCallback ) def subscribeToFinished(result): computedValueToCalculate.subscribe_isFinished({ 'onSuccess': isFinishedChanged, 'onFailure': onFailure, 'onChanged': isFinishedChanged }) computedValueToCalculate.increaseRequestCount( {}, {'onSuccess':subscribeToFinished, 'onFailure':onFailure} )
def onSuccess(result): if not self.closed and result is not None: if result['success']: onCompletedCallback(None) else: onCompletedCallback( Exceptions.PyforaError(result['message']))
def statusChanged(jsonStatus): if not self.closed: if jsonStatus is not None: if jsonStatus['status'] == 'failure': onFailedCallback(Exceptions.PyforaError(jsonStatus['message'])) else: onCompletedCallback(jsonStatus)
def _classObjectFromFilenameAndLine(self, filename, lineNumber, members): """Construct a class object given its textual definition.""" objectOrNone = self.moduleLevelObject(filename, lineNumber) if objectOrNone is not None: return objectOrNone sourceAst = PyAstUtil.getAstFromFilePath(filename) classAst = PyAstUtil.classDefAtLineNumber(sourceAst, lineNumber) outputLocals = {} globalScope = {} globalScope.update(members) self.importModuleMagicVariables(globalScope, filename) try: code = compile(ast.Module([classAst]), filename, 'exec') exec code in globalScope, outputLocals except: logging.error("Failed to instantiate class at %s:%s\n%s", filename, lineNumber, traceback.format_exc()) raise Exceptions.PyforaError("Failed to instantiate class at %s:%s" % (filename, lineNumber)) assert len(outputLocals) == 1 return list(outputLocals.values())[0]
def onFailure(result): if isinstance(result, Exception): onExpanded(result) else: onExpanded( Exceptions.PyforaError( "Unknown error translating to dictionary of proxies: %s" + str(result)))
def onFailure(err): if not self.closed: onResultCallback(Exceptions.PyforaError(err['message']))
def onFailure(err): if not self.closed: onFailedCallback(Exceptions.PyforaError(err))
def onFailure(err): onCompletedCallback(Exceptions.PyforaError(err['message']))
def _raiseIfClosed(self): if self.connection is None: raise Exceptions.PyforaError( 'Attempted operation on a closed executor')