       (file-seq dir))
     time-limit-hours))
 
+(defn exe-on-server? [bits date-token]
+  (let [txt (slurp "http://valelab.ucsf.edu/~MM/nightlyBuilds/1.4/Windows/")
+        pattern (re-pattern (str "MMSetup" bits "BIT_[^\\s]+?_" date-token ".exe"))]
+    (re-find pattern txt)))
+
+(defn str-lines [sequence]
+  (apply str (interpose "\n" sequence)))
+
 (defn report-build-errors [bits mode]
   (let [f (result-file bits mode)
         result-txt (slurp f)

                                         32 "bin_Win32"
                                         64 "bin_x64")) 24)
        javac-errs (javac-errors result-txt)
        outdated-jars (old-jars (File. micromanager "Install_AllPlatforms") 24)]
    (when-not (and (empty? vs-error-text) (empty? outdated-dlls)
                   (empty? javac-errs) (empty? outdated-jars))
      (println (str "\n\nMICROMANAGER " bits "-bit "
                    ({:inc "INCREMENTAL" :full "FULL"} mode)
                    " BUILD ERROR REPORT"))
      (println (str "For the full build output, see " (.getAbsolutePath f)))
      (println "\nVisual Studio reported errors:")
      (if-not (empty? vs-error-text) (println vs-error-text) (println "None."))
      (println "\nOutdated device adapter DLLs:")
      (if-not (empty? outdated-dlls) (dorun (map #(println (.getName %)) outdated-dlls)) (println "None."))
      (println "\nErrors reported by java compiler:")
      (if-not (empty? javac-errs) (dorun (map println javac-errs)) (println "None."))
      (println "\nOutdated jar files:")
      (if-not (empty? outdated-jars) (dorun (map #(println (.getName %)) outdated-jars)) (println "None."))
      )))

(defn make-full-report [mode send?]
  (let [report
        (with-out-str
          (report-build-errors 32 mode)
          (report-build-errors 64 mode))]
    (if-not (empty? report)

(ns buildcheck.core
  (:import (java.io File)
           (java.text SimpleDateFormat)
           (java.util Calendar Date))
  (:use [local-file :only (file*)]
        [clj-mail.core])
  (:gen-class))
