def connect(self, context, authenticator): if isDebugMode(): msg = getMessage(self._ctx, g_message, 131) logMessage(self._ctx, INFO, msg, 'SmtpService', 'connect()') if self.isConnected(): raise AlreadyConnectedException() if not hasInterface(context, 'com.sun.star.uno.XCurrentContext'): raise IllegalArgumentException() if not hasInterface(authenticator, 'com.sun.star.mail.XAuthenticator'): raise IllegalArgumentException() server = context.getValueByName('ServerName') error = self._setServer(context, server) if error is not None: if isDebugMode(): msg = getMessage(self._ctx, g_message, 132, error.Message) logMessage(self._ctx, SEVERE, msg, 'SmtpService', 'connect()') raise error authentication = context.getValueByName('AuthenticationType').title() if authentication != 'None': error = self._doLogin(authentication, authenticator, server) if error is not None: if isDebugMode(): msg = getMessage(self._ctx, g_message, 133, error.Message) logMessage(self._ctx, SEVERE, msg, 'SmtpService', 'connect()') raise error self._context = context for listener in self._listeners: listener.connected(self._notify) if isDebugMode(): msg = getMessage(self._ctx, g_message, 134) logMessage(self._ctx, INFO, msg, 'SmtpService', 'connect()')
def appendChild(self, node): if not node.getParent(): node.set_parent(node) self.children.append(node) try: self.data_model.changed(ChangeType.NodeInserted, self, (node,)) except Exception as e: print(e) else: e = IllegalArgumentException() e.ArgumentPosition = 0 raise e
def appendChild(self, node): if not node.getParent(): node.set_parent(node) self.children.append(node) try: self.data_model.changed(ChangeType.NodeInserted, self, (node, )) except Exception as e: print(e) else: e = IllegalArgumentException() e.ArgumentPosition = 0 raise e
def addRows(self, headings, data): if len(headings) != len(data): raise IllegalArgumentException() row_count = len(self.rows) self.headings += list(headings) self.rows += list(data) self.broadcast_inserted(0, self.column_count - 1, row_count, len(self.headings))
def checkPublish2(self, s, text, _property): p = self.getPublisher(s) if p.cp_Publish: url = getattr(text.Model, _property) if url is None or url == "": raise IllegalArgumentException() else: return True else: return False
def insertByName( self, name, value ): log.debug( "insertByName called " + str( name ) + " " + str( value )) uri = expandUri( name ) if isPyFileInPath( self.provCtx.sfa, uri ): self.provCtx.addPackageByUrl( uri ) else: # package is no python package ... log.debug( "insertByName: no python files in " + str( uri ) + ", ignoring" ) raise IllegalArgumentException( uri + " does not contain .py files", self, 1 ) log.debug( "insertByName called " + str( uri ) + " successful" )
def execute(self, args): try: args = unprops(args) except Exception: debugexception() if 'Action' not in args: super().execute(args) return # Enable API Mode (no msg boxes) self.isAPIMode = True if args['Action'] == "InsertBarcode": if 'BarcodeType' not in args: raise IllegalArgumentException('"BarcodeType" missing!', self, 0) barcodeType = args['BarcodeType'] if barcodeType not in self.CODETYPES: raise IllegalArgumentException( "Invalid BarcodeType '{}' Valid types: {}".format( barcodeType, ', '.join(self.CODETYPES)), self, 0) if 'BarcodeValue' not in args: raise IllegalArgumentException('"BarcodeValue" missing!', self, 0) barcodeValue = str(args['BarcodeValue']) if not barcodeValue: raise IllegalArgumentException( 'Empty or invalid "BarcodeValue" given.', self, 0) if 'WidthScale' in args: self.barwidthmodify = int(args['WidthScale']) if self.barwidthmodify < 1: raise IllegalArgumentException('"WidthScale" must be > 0!', self, 0) if 'HeightScale' in args: self.barlengthmodify = int(args['HeightScale']) if self.barlengthmodify < 1: raise IllegalArgumentException( '"HeightScale" must be > 0!', self, 0) positionX = 5000 if 'PositionX' in args: positionX = args['PositionX'] positionY = 5000 if 'PositionY' in args: positionY = args['PositionY'] addChecksum = True if 'BarcodeAddChecksum' in args: addChecksum = args['BarcodeAddChecksum'] if 'TargetComponent' in args: self.targetComponent = args['TargetComponent'] self.insertBarcodeAPI(barcodeType, barcodeValue, addChecksum, positionX, positionY) else: raise IllegalArgumentException('No valid "Action" provided.', self, 0)
def connect(self, context, authenticator): if isDebugMode(): msg = getMessage(self._ctx, g_message, 321) logMessage(self._ctx, INFO, msg, 'ImapService', 'connect()') if self.isConnected(): raise AlreadyConnectedException() if not hasInterface(context, 'com.sun.star.uno.XCurrentContext'): raise IllegalArgumentException() if not hasInterface(authenticator, 'com.sun.star.mail.XAuthenticator'): raise IllegalArgumentException() self._context = context server = context.getValueByName('ServerName') port = context.getValueByName('Port') timeout = context.getValueByName('Timeout') connection = context.getValueByName('ConnectionType').title() authentication = context.getValueByName('AuthenticationType').title() if connection == 'Ssl': self._server = imapclient.IMAPClient(server, port=port, ssl=True, timeout=timeout) else: self._server = imapclient.IMAPClient(server, port=port, ssl=False, timeout=timeout) if connection == 'Tls': self._server.starttls() if authentication == 'Login': user = authenticator.getUserName() password = authenticator.getPassword() code = self._server.login(user, password) print("ImapService.connect() 1: %s" % code) elif authentication == 'Oauth2': user = authenticator.getUserName() token = getOAuth2Token(self._ctx, self, server, user) code = self._server.oauth2_login(user, token) print("ImapService.connect() 2: %s" % code) for listener in self._listeners: listener.connected(self._notify) if isDebugMode(): msg = getMessage(self._ctx, g_message, 324) logMessage(self._ctx, INFO, msg, 'ImapService', 'connect()')
def updateRowData(self, columns, row, values): if len(columns) != len(values): raise IllegalArgumentException( "length of column index and values are different", self, 0) if 0 <= row < len(self.rows): data = list(self.rows[row]) column_count = len(data) for column, value in zip(columns, values): if 0 <= column < column_count: data[column] = value else: raise IndexOutOfBoundsException("", self) self.rows[row] = data self.broadcast_changed(min(columns), max(columns), row, row)
def getFunctionArguments(self, func_signature): nOpenParenthesis = func_signature.find( "(" ) if -1 == nOpenParenthesis: function_name = func_signature arguments = None else: function_name = func_signature[0:nOpenParenthesis] arg_part = func_signature[nOpenParenthesis+1:len(func_signature)] nCloseParenthesis = arg_part.find( ")" ) if -1 == nCloseParenthesis: raise IllegalArgumentException( "PythonLoader: mismatch parenthesis " + func_signature, self, 0 ) arguments = arg_part[0:nCloseParenthesis].strip() if arguments == "": arguments = None else: arguments = tuple([x.strip().strip('"') for x in arguments.split(",")]) return function_name, arguments
def save_document(self, doc_name="", filter_name=""): """ Save document. @type doc_name: string @param doc_name: Document name. If no document name defined the current name is used. @type filter_name: string @param filter_name: file type: # ods="" # pdf="calc_pdf_Export" # csv="Text - txt - csv (StarCalc)" # xls="calc_MS_Excel_40" # xlsx="Calc Office Open XML" @rtype: bool @return: Operation result """ result = False if self._oDoc: if 0 == len(doc_name): self._oDoc.store() else: full_file_name = unohelper.systemPathToFileUrl(doc_name) try: self._oDoc.storeToURL( full_file_name, self._to_properties(FilterName=filter_name)) result = True except IllegalArgumentException as e: raise IllegalArgumentException(e) except ErrorCodeIOException as e: raise ErrorCodeIOException(e) except IOException as e: raise IOException(e) return result
def raiseException(self, ArgumentPosition, Message, Context): raise IllegalArgumentException(Message, Context, ArgumentPosition)
def _getIllegalArgumentException(self, position, code): e = IllegalArgumentException() e.ArgumentPosition = position e.Message = getMessage(self.ctx, code) e.Context = self return e
def getScript(self, uri): log.debug("DirBrowseNode getScript " + uri + " invoked") raise IllegalArgumentException( "PackageBrowseNode couldn't instantiate script " + uri, self, 0)