From: <ni...@us...> - 2008-10-31 22:51:16
|
Revision: 10191 http://jmol.svn.sourceforge.net/jmol/?rev=10191&view=rev Author: nicove Date: 2008-10-31 22:51:13 +0000 (Fri, 31 Oct 2008) Log Message: ----------- Folding@Home Modified Paths: -------------- trunk/Jmol-FAH/src/org/jmol/fah/Jmol-FAH.properties trunk/Jmol-FAH/src/org/jmol/fah/checkxyz/Check.java trunk/Jmol-FAH/src/org/jmol/fah/checkxyz/ConfigurationWindow.java trunk/Jmol-FAH/src/org/jmol/fah/checkxyz/MailSender.java Modified: trunk/Jmol-FAH/src/org/jmol/fah/Jmol-FAH.properties =================================================================== --- trunk/Jmol-FAH/src/org/jmol/fah/Jmol-FAH.properties 2008-10-31 21:24:51 UTC (rev 10190) +++ trunk/Jmol-FAH/src/org/jmol/fah/Jmol-FAH.properties 2008-10-31 22:51:13 UTC (rev 10191) @@ -3,4 +3,4 @@ # # Version # -Version=0.3 +Version=0.4 Modified: trunk/Jmol-FAH/src/org/jmol/fah/checkxyz/Check.java =================================================================== --- trunk/Jmol-FAH/src/org/jmol/fah/checkxyz/Check.java 2008-10-31 21:24:51 UTC (rev 10190) +++ trunk/Jmol-FAH/src/org/jmol/fah/checkxyz/Check.java 2008-10-31 22:51:13 UTC (rev 10191) @@ -148,6 +148,7 @@ } message.append(sentProjects.get(i).toString()); } + message.append(")"); } else { message.append("No new .xyz files found"); } @@ -161,6 +162,7 @@ } message.append(sentAmbers.get(i).toString()); } + message.append(")"); } else { message.append("No new .top/.trj files found"); } @@ -219,7 +221,7 @@ if (project == null) { System.out.print("Unable to find project number"); } else { - System.out.print("Project n\xB0" + project + " -> "); + System.out.print("Project n" + project + " -> "); processProjectNumber(file, project); } System.out.println(); @@ -349,31 +351,112 @@ * @param project Project identifier. */ private void processProjectNumber(File file, String project) { - if (configuration.hasBeenSent(project)) { + if ((file == null) || (project == null)) { + return; + } + + // Checking for Amber files + File topologyFile = null; + File trajectoryFile = null; + File logFile = null; + boolean pourcentEnough = false; + if (file.isFile() && "current.xyz".equalsIgnoreCase(file.getName())) { + for (int i = 0; (i < 10) && !pourcentEnough; i++) { + Object[] objects = new Object[] { Integer.valueOf(i) }; + File infoFile = new File(file.getParentFile(), String.format("wuinfo_%1$02d.dat", objects)); + if (infoFile.exists()) { + topologyFile = new File(file.getParentFile(), String.format("wudata_%1$02d.top", objects)); + trajectoryFile = new File(file.getParentFile(), String.format("wudata_%1$02d.trj", objects)); + logFile = new File(file.getParentFile(), String.format("logfile_%1$02d.txt", objects)); + if (topologyFile.exists() && trajectoryFile.exists() && logFile.exists()) { + try { + BufferedReader reader = new BufferedReader(new FileReader(logFile)); + try { + String line = null; + while (!pourcentEnough && (line = reader.readLine()) != null) { + if (line != null) { + if (line.contains("90%") || + line.contains("91%") || + line.contains("92%") || + line.contains("93%") || + line.contains("94%") || + line.contains("95%") || + line.contains("96%") || + line.contains("97%") || + line.contains("98%") || + line.contains("99%")) { + pourcentEnough = true; + } + } + } + } catch (IOException e) { + // + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + // + } + } + } + } catch (FileNotFoundException e) { + // + } + } else { + topologyFile = null; + trajectoryFile = null; + logFile = null; + } + } + } + } + + // Checking if something needs to be sent + if (configuration.hasBeenSent(project) && + ((topologyFile == null) || (trajectoryFile == null) || configuration.hasBeenSent("A_" + project))) { System.out.print("Already sent by you"); return; } - if ((!availableProjects.exists()) || (!availableAmbersDownloaded)) { + if ((!availableProjects.exists()) || (!availableAmbers.exists())) { downloadAvailableFiles(); } updateExistingProjects(); - if (existingProjects.contains(project)) { + if (existingProjects.contains(project) && + (existingAmbers.contains(project) || (topologyFile == null) || (trajectoryFile == null))) { System.out.print("Project available on Jmol website"); return; } if ((!availableProjectsDownloaded) || (!availableAmbersDownloaded)) { downloadAvailableFiles(); updateExistingProjects(); - if (existingProjects.contains(project)) { + if (existingProjects.contains(project) && + (existingAmbers.contains(project) || (topologyFile == null) || (trajectoryFile == null))) { System.out.print("Project available on Jmol website"); return; } } try { System.out.print("Found new project :)"); - MailSender sender = new MailSender(configuration, project, file, false); + File[] files = new File[4]; + files[0] = file; + if ((topologyFile != null) && (trajectoryFile != null)) { + files[1] = topologyFile; + files[2] = trajectoryFile; + if (logFile != null) { + files[3] = logFile; + } + } + MailSender sender = new MailSender(configuration, project, files, false); sender.sendMail(); - configuration.addSentFile(project); + if (!existingProjects.contains(project)) { + configuration.addSentFile(project); + sentProjects.add(project); + } + if (!existingAmbers.contains(project) && (topologyFile != null) && (trajectoryFile != null)) { + configuration.addSentFile("A_" + project); + sentAmbers.add(project); + } } catch (Throwable e) { outputError("Sending new file", e); } Modified: trunk/Jmol-FAH/src/org/jmol/fah/checkxyz/ConfigurationWindow.java =================================================================== --- trunk/Jmol-FAH/src/org/jmol/fah/checkxyz/ConfigurationWindow.java 2008-10-31 21:24:51 UTC (rev 10190) +++ trunk/Jmol-FAH/src/org/jmol/fah/checkxyz/ConfigurationWindow.java 2008-10-31 22:51:13 UTC (rev 10191) @@ -459,7 +459,9 @@ config.setPassword(textUserPassword.getText()); config.setUserMail(textUserMail.getText()); config.setUserName(textUser.getText()); - MailSender sender = new MailSender(config, "XXXX", testFile, true); + File[] files = new File[1]; + files[0] = testFile; + MailSender sender = new MailSender(config, "XXXX", files, true); try { sender.sendMail(); JOptionPane.showMessageDialog( Modified: trunk/Jmol-FAH/src/org/jmol/fah/checkxyz/MailSender.java =================================================================== --- trunk/Jmol-FAH/src/org/jmol/fah/checkxyz/MailSender.java 2008-10-31 21:24:51 UTC (rev 10190) +++ trunk/Jmol-FAH/src/org/jmol/fah/checkxyz/MailSender.java 2008-10-31 22:51:13 UTC (rev 10191) @@ -38,17 +38,17 @@ private Configuration config; private String projectNum; - private File projectFile; + private File[] projectFiles; private boolean testing; public MailSender( Configuration configuration, String project, - File file, + File[] files, boolean test) { config = configuration; projectNum = project; - projectFile = file; + projectFiles = files; testing = test; } @@ -76,13 +76,13 @@ if (testing) { email.addTo(config.getUserMail(), config.getUserName()); } else { - email.addTo("ni...@jm...", "FoldingAtHome XYZ Files"); + email.addTo("ni...@jm...", "FoldingAtHome Files"); email.addCc(config.getUserMail(), config.getUserName()); } email.setFrom(config.getUserMail(), config.getUserName()); - email.setSubject("FoldingAtHome XYZ file for project " + projectNum); + email.setSubject("FoldingAtHome file(s) for project " + projectNum); email.setMsg( - "This mail contains the XYZ file for project " + projectNum + ".\n" + + "This mail contains file(s) for project " + projectNum + ".\n" + "It has been submitted by " + config.getUserName()); if ((config.getLogin() != null) && (!config.getLogin().equals("")) && (config.getPassword() != null) && (!config.getPassword().equals(""))) { @@ -92,12 +92,18 @@ } // Create the attachments - EmailAttachment attachment = new EmailAttachment(); - attachment.setPath(projectFile.getAbsolutePath()); - attachment.setDisposition(EmailAttachment.ATTACHMENT); - attachment.setDescription("FoldingAtHome XYZ file for project " + projectNum); - attachment.setName(projectFile.getName()); - email.attach(attachment); + if (projectFiles != null) { + for (int i = 0; i < projectFiles.length; i++) { + if (projectFiles[i] != null) { + EmailAttachment attachment = new EmailAttachment(); + attachment.setPath(projectFiles[i].getAbsolutePath()); + attachment.setDisposition(EmailAttachment.ATTACHMENT); + attachment.setDescription("FoldingAtHome file for project " + projectNum); + attachment.setName(projectFiles[i].getName()); + email.attach(attachment); + } + } + } // Send email.send(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |