       (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)

  (for [error errors]
    (let [prefix (ffirst (re-seq #"\n([1-9]|[0-9][1-9]|[0-9][0-9][1-9])>" error))
          pattern (re-pattern (str prefix "[^\\n]+"))]
      (println prefix)
      (println "pattern:" pattern)
      (when prefix
          (re-seq (re-pattern pattern) result-text)))))


(def micromanager (file* "../.."))

(def MS-PER-HOUR (* 60 60 1000))

(def today-token
  (let [format (SimpleDateFormat. "yyyyMMdd")
        one-hour-ago (doto (Calendar/getInstance)
                       (.add Calendar/HOUR -1))]
    (.format format (.getTime one-hour-ago))))
    
(def yyyymmdd (SimpleDateFormat. "yyyyMMdd"))

(doto (Calendar/getInstance) (.add Calendar/HOUR -1))

(defn result-file [bits mode]
  (File. micromanager (str "/result" bits (name mode) ".txt")))
