def update_favourite_zone_indicator(self): #icon if self.app.favZone is not None: self.favAreaIndicator.setIcon(self.app.favZone.icon) #tooltip messageArguments = array([self.app.favZone.name], String) formatter = MessageFormat("") formatter.applyPattern(self.app.strings.getString("favAreaIndicator_tooltip")) msg = formatter.format(messageArguments) self.favAreaIndicator.setToolTipText(msg) #status self.favAreaIndicator.setVisible(self.app.favouriteZoneStatus)
def update_favourite_zone_indicator(self): #icon if self.app.favZone is not None: self.favAreaIndicator.setIcon(self.app.favZone.icon) #tooltip messageArguments = array([self.app.favZone.name], String) formatter = MessageFormat("") formatter.applyPattern( self.app.strings.getString("favAreaIndicator_tooltip")) msg = formatter.format(messageArguments) self.favAreaIndicator.setToolTipText(msg) #status self.favAreaIndicator.setVisible(self.app.favouriteZoneStatus)
def on_falsePositiveBtn_clicked(self, event): """Tell the tool server that selected error is a false positive """ check = self.selectedError.check tool = check.tool if tool.falseFeedbackMode == "url": #the tool supports automatic reporting if self.properties.getProperty("false_positive_warning.%s" % tool.name) == "on": messageArguments = array([tool.title], String) formatter = MessageFormat("") formatter.applyPattern(self.strings.getString("false_positive_confirmation")) msg = formatter.format(messageArguments) options = [self.strings.getString("yes_do_not_ask_the_next_time"), self.strings.getString("Yes"), self.strings.getString("No")] answer = JOptionPane.showOptionDialog(Main.parent, msg, self.strings.getString("flagging_a_false_positive"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, None, options, options[2]) if answer == 0: #don't ask again self.properties.setProperty("false_positive_warning.%s" % tool.name, "off") self.save_config(self) elif answer == 2: #don't flag as false positive return tool.sayFalseBug(self.selectedError, check) elif tool.falseFeedbackMode == "msg": #the tool supports manual reporting of false positives if self.properties.getProperty("false_positive_warning.%s" % tool.name) == "on": messageArguments = array([tool.title], String) formatter = MessageFormat("") formatter.applyPattern(self.strings.getString("manual_false_positive_confirmation")) msg = formatter.format(messageArguments) options = [self.strings.getString("yes_do_not_ask_the_next_time"), self.strings.getString("Yes"), self.strings.getString("No")] answer = JOptionPane.showOptionDialog(Main.parent, msg, self.strings.getString("flagging_a_false_positive"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, None, options, options[2]) errorInfo = [tool.title, check.name, self.selectedError.errorId, self.selectedError.osmId] self.falsePositiveDlg.tableModel.addRow(errorInfo) else: #the tool does not support feedback return self.editDone()
def __init__(self): dataDir = Settings.dataDir + 'loading_saving/' # The path to the document which is to be processed. filePath = dataDir + "document.doc" info = FileFormatUtil.detectFileFormat(filePath) if info.hasDigitalSignature(): print MessageFormat.format( "Document {0} has digital signatures, they will be lost if you open/save this document with Aspose.Words.", File(doc).getName()) else: print "Document has no digital signature." print "Process Completed Successfully"
def format_message(key, *args): bundle = ResourceBundle.getBundle(TestingConstants.RESOURCE_BUNDLE_NAME) message = bundle.getString(key) if len(args) > 0: message = MessageFormat.format(message, list(args)) #message = MessageFormat.format(message, args) return message
def get_message(key, *args): """ Get the formatted message from the resource bundle. :param key: the message key :param args: the token values :return: the formatted message string """ bundle = ResourceBundle.getBundle(TestingConstants.RESOURCE_BUNDLE_NAME) message = bundle.getString(key) if len(args) > 0: message = MessageFormat.format(message, list(args)) return message
def doInBackground(self): #print "\n- Checking for the latest version..." try: url = URL(self.app.scriptVersionUrl) uc = url.openConnection() ins = uc.getInputStream() p = Properties() p.load(ins) latestScriptVersion = p.getProperty("script") self.app.latestToolsVersion = p.getProperty("tools") except (UnknownHostException, SocketException): print "I can't connect to:\n%s" % url ins.close() return if latestScriptVersion == self.app.SCRIPTVERSION: #using latest script print " already using the latest script version:", self.app.SCRIPTVERSION if self.app.latestToolsVersion == self.app.TOOLSVERSION: #using latest tools print " already using the latest tools version:", self.app.TOOLSVERSION if self.mode != "auto": JOptionPane.showMessageDialog( self.app.preferencesFrame, self.app.strings.getString("using_latest")) return else: #not using latest tools print " tools can be updated: %s -> %s" % ( self.app.TOOLSVERSION, self.app.latestToolsVersion) if self.app.mode == "stable": infoString = self.app.strings.getString( "update_tools_question") else: infoString = self.app.strings.getString( "dev_update_tools_question") answer = JOptionPane.showConfirmDialog( Main.parent, infoString, self.app.strings.getString("updates_available"), JOptionPane.YES_NO_OPTION) if answer == 0: #Download the updated tools data print "\n- Update tools data" try: self.app.toolsProgressDialog except AttributeError: from java.awt import Dialog self.app.toolsProgressDialog = ToolsProgressDialog( Main.parent, self.app.strings.getString( "download_tools_updates"), Dialog.ModalityType.APPLICATION_MODAL, self.app) self.app.toolsProgressDialog.show() else: #not using latest script print "a new script version is available:\n%s -> %s" % ( self.app.SCRIPTVERSION, latestScriptVersion) messageArguments = array( [self.app.SCRIPTVERSION, latestScriptVersion], String) formatter = MessageFormat("") if self.app.mode == "stable": formatter.applyPattern( self.app.strings.getString("updates_warning")) infoBtnString = self.app.strings.getString("Visit_Wiki") else: formatter.applyPattern( self.app.strings.getString("dev_updates_warning")) infoBtnString = self.app.strings.getString("Visit_git") msg = formatter.format(messageArguments) options = [ self.app.strings.getString("Do_not_check_for_updates"), infoBtnString, self.app.strings.getString("cancel") ] answer = JOptionPane.showOptionDialog( Main.parent, msg, self.app.strings.getString("updates_available"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, None, options, options[1]) if answer == 0: self.app.properties.setProperty("check_for_update", "off") self.app.save_config(self) elif answer == 1: if self.app.mode == "stable": url = self.app.SCRIPTWEBSITE else: url = self.app.GITWEBSITE OpenBrowser.displayUrl(url)
def doInBackground(self): #print "\n- Checking for the latest version..." try: url = URL(self.app.scriptVersionUrl) uc = url.openConnection() ins = uc.getInputStream() p = Properties() p.load(ins) latestScriptVersion = p.getProperty("script") self.app.latestToolsVersion = p.getProperty("tools") except (UnknownHostException, SocketException): print "I can't connect to:\n%s" % url ins.close() return if latestScriptVersion == self.app.SCRIPTVERSION: #using latest script print " already using the latest script version:", self.app.SCRIPTVERSION if self.app.latestToolsVersion == self.app.TOOLSVERSION: #using latest tools print " already using the latest tools version:", self.app.TOOLSVERSION if self.mode != "auto": JOptionPane.showMessageDialog(self.app.preferencesFrame, self.app.strings.getString("using_latest")) return else: #not using latest tools print " tools can be updated: %s -> %s" % (self.app.TOOLSVERSION, self.app.latestToolsVersion) answer = JOptionPane.showConfirmDialog(Main.parent, self.app.strings.getString("update_tools_question"), self.app.strings.getString("updates_available"), JOptionPane.YES_NO_OPTION) if answer == 0: #Download the updated tools data print "\n- Update tools data" try: self.app.toolsProgressDialog except AttributeError: from java.awt import Dialog self.app.toolsProgressDialog = ToolsProgressDialog(Main.parent, self.app.strings.getString("download_tools_updates"), Dialog.ModalityType.APPLICATION_MODAL, self.app) self.app.toolsProgressDialog.show() else: #not using latest script print "a new script version is available:\n%s -> %s" % (self.app.SCRIPTVERSION, latestScriptVersion) messageArguments = array([self.app.SCRIPTVERSION, latestScriptVersion], String) formatter = MessageFormat("") formatter.applyPattern(self.app.strings.getString("updates_warning")) msg = formatter.format(messageArguments) options = [ self.app.strings.getString("Do_not_check_for_updates"), self.app.strings.getString("Visit_Wiki"), self.app.strings.getString("cancel")] answer = JOptionPane.showOptionDialog(Main.parent, msg, self.app.strings.getString("updates_available"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, None, options, options[1]) if answer == 0: self.app.properties.setProperty("check_for_update", "off") self.app.save_config(self) elif answer == 1: OpenBrowser.displayUrl(self.app.SCRIPTWEBSITE)
def on_falsePositiveBtn_clicked(self, event): """Tell the tool server that selected error is a false positive """ check = self.selectedError.check tool = check.tool if tool.falseFeedbackMode == "url": #the tool supports automatic reporting if self.properties.getProperty("false_positive_warning.%s" % tool.name) == "on": messageArguments = array([tool.title], String) formatter = MessageFormat("") formatter.applyPattern( self.strings.getString("false_positive_confirmation")) msg = formatter.format(messageArguments) options = [ self.strings.getString("yes_do_not_ask_the_next_time"), self.strings.getString("Yes"), self.strings.getString("No") ] answer = JOptionPane.showOptionDialog( Main.parent, msg, self.strings.getString("flagging_a_false_positive"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, None, options, options[2]) if answer == 0: #don't ask again self.properties.setProperty( "false_positive_warning.%s" % tool.name, "off") self.save_config(self) elif answer == 2: #don't flag as false positive return tool.sayFalseBug(self.selectedError, check) elif tool.falseFeedbackMode == "msg": #the tool supports manual reporting of false positives if self.properties.getProperty("false_positive_warning.%s" % tool.name) == "on": messageArguments = array([tool.title], String) formatter = MessageFormat("") formatter.applyPattern( self.strings.getString( "manual_false_positive_confirmation")) msg = formatter.format(messageArguments) options = [ self.strings.getString("yes_do_not_ask_the_next_time"), self.strings.getString("Yes"), self.strings.getString("No") ] answer = JOptionPane.showOptionDialog( Main.parent, msg, self.strings.getString("flagging_a_false_positive"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, None, options, options[2]) errorInfo = [ tool.title, check.name, self.selectedError.errorId, self.selectedError.osmId ] self.falsePositiveDlg.tableModel.addRow(errorInfo) else: #the tool does not support feedback return self.editDone()
def test(numMessages, islandId, domain, cloudDomainFormat, cloudDomainSize, stage1Mta, storageImporter): users = ["testuser1", "testuser2", "testuser3", "testuser4"] sftpUserMsgs = [4, 3, 3, 3] userMsgs = [0] * len(users) result = False mc = ManagementContainer.getInstance() cm = mc.getCustomerManager() cust = cloud.setupCustomer(mc, str(islandId), domain, False, True, users) try: cloud.propagateMtaConfig() onPremisesGuid = cust.getGuids(CloudService.ONPREMISES)[0].getGuid() format = MessageFormat(cloudDomainFormat) # stage SMTP messages for i in range(numMessages): replZone = i % (cloudDomainSize + 1) if replZone == 0: cloudDomain = String(cloudDomainFormat).replaceFirst("(\\{.*\\})", "") # non replicated else: cloudDomain = format.format(array(Object, [replZone])) # replicated if (i % 5) == 0: cloud.sendJournalMessage(onPremisesGuid, users[0], ["invaliduser"], None, None, domain, cloudDomain, stage1Mta) userMsgs[0] += 1 elif (i % 4) == 0: cloud.sendJournalMessage(onPremisesGuid, "invaliduser", [users[1]], None, None, domain, cloudDomain, stage1Mta) userMsgs[1] += 1 elif (i % 3) == 0: cloud.sendJournalMessage(onPremisesGuid, "invaliduser", None, [users[2]], None, domain, cloudDomain, stage1Mta) userMsgs[2] += 1 elif (i % 2) == 0: cloud.sendJournalMessage(onPremisesGuid, "invaliduser", None, None, [users[3]], domain, cloudDomain, stage1Mta) userMsgs[3] += 1 else : cloud.sendJournalMessage(onPremisesGuid, users[0], [users[1]], [users[2]], [users[3]], domain, cloudDomain, stage1Mta) for j in range(len(users)): userMsgs[j] += 1 sleep(1) # stage SFTP messages if os.system("cd /tmp;rm -rf sftp_journal;tar -xf endtoend-sftp-journaled-mail.tar;cd -") != 0: print 'failed to overwrite SFTP journal bundle to /tmp/sftp_journal/' numSftpMsgs = len(os.listdir('/tmp/sftp_journal/')) / 2 numMessages += 4 print "uploading " + str(numSftpMsgs) + " SFTP messages to " + storageImporter print 'uploading 1 - 4 new messages...' if os.system("sed -i 's/${guid}/" + onPremisesGuid + "/g' /tmp/sftp_journal/*.journal.m1.index.done.ftp") != 0: print 'failed to replace the GUID variable' if os.system("lftp -u root,!mailst0rm -e 'mput -O /ems/bigdisk/sftp.drop/" + str(cust.getCustID()) + " /tmp/sftp_journal/2000[1-4].journal.m1.gzip.enc.done.ftp; quit' sftp://" + storageImporter) != 0: print 'failed to upload the journal content files' if os.system("lftp -u root,!mailst0rm -e 'mput -O /ems/bigdisk/sftp.drop/" + str(cust.getCustID()) + " /tmp/sftp_journal/2000[1-4].journal.m1.index.done.ftp; quit' sftp://" + storageImporter) != 0: print 'failed to upload the journal index files, is the storage importer running?' # Do not shorten this because the test will intermittently fail. These messages are expected to match # previously imported messages (see above) so the sleep must be long enough to allow the original copy of # of the message to be imported first. sleep(60) print 'uploading 5 - ' + str(numSftpMsgs) + ' message updates...' if os.system("lftp -u root,!mailst0rm -e 'mput -O /ems/bigdisk/sftp.drop/" + str(cust.getCustID()) + " /tmp/sftp_journal/2000[5-6].journal.m1.gzip.enc.done.ftp; quit' sftp://" + storageImporter) != 0: print 'failed to upload the journal content files' if os.system("lftp -u root,!mailst0rm -e 'mput -O /ems/bigdisk/sftp.drop/" + str(cust.getCustID()) + " /tmp/sftp_journal/2000[5-6].journal.m1.index.done.ftp; quit' sftp://" + storageImporter) != 0: print 'failed to upload the journal index files, is the storage importer running?' # add static SFTP message counts for j in range(len(userMsgs)): userMsgs[j] += sftpUserMsgs[j] # wait for cloud messages to import msgs = cloud.findMessages(mc, cust.getCustID(), numMessages) if msgs.size() < numMessages: print 'Did not find all on-premises messages in mailstore, only found', msgs.size() else: result = True # verify individual users were categorized correctly as sender/recipients if result is True: print 'verifying categorized recipients...' for i in range(len(users)): userAddress = users[i] + '@' + domain userCount = 0; for msg in msgs: json = msg.getCategorizedRecipients() if json is None: print 'categorized recipients not set for: ' + msg.toString() result = False # count recipient fields for key in json.keys(): recipients = json.optJSONArray(key); for j in range(recipients.length()): if userAddress == recipients.getString(j): userCount += 1 # count sender field if userAddress == msg.getSender(): userCount += 1 if userMsgs[i] != userCount or result is False: print 'categorized recipients count for ' + userAddress + ' was ' + str(userCount) + ', but expected ' + str(userMsgs[i]) result = False break # verify archive search if result is True and not cloud.checkCustomerSearchStatus(mc, msgs, cust.getCustID()): print 'Did not find all on-premises messages in index' result = False # verify individual users were resolved correctly if result is True: for i in range(len(users)): userAccount = mc.getUserManager().findUserForEmail(users[i] + '@' + domain) print 'searching for ' + str(userMsgs[i]) + ' indexed messages resolved to: ' + users[i] + '@' + domain + ', ' + str(userAccount.getUserID()) if not cloud.checkUserSearchStatus(mc, userMsgs[i], cust.getCustID(), userAccount.getUserID()): print 'Did not find messages in index for user: '******'@' + domain + ', ' + str(userAccount.getUserID()) result = False if result is True: print 'on-premises message import successful' else: print 'on-premises message import failed' finally: print "Deleting customer " + str(cust.getCustID()) + "..." cm.deleteCustomers([cust.getCustID()]) if result is True: sys.exit(0) else: sys.exit(1)