# Path: common/httpd.py
# class ThreadedHTTPServer(SocketServer.ThreadingMixIn,
#                          BaseHTTPServer.HTTPServer):
# class BaseRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
#   def url_to_fs_path(self, url):
#   def send_head(self):
# 
# Path: common/util.py
# ANSI_BLUE = '\033[36m'
# ANSI_GREEN = '\033[32m'
# ANSI_RESET = '\033[0;0m'
# class Logger(object):
#   def __init__(self, color):
#   def __call__(self, msg, *args):
# def GetPackageDir():
# def GetUserDir():
# 
# Path: common/spy.py
# class Error(Exception):
# class UsageReporter(object):
# class NullUsageReporter(object):
#   def __init__(self, host_port):
#   def Send(self, msg):
#   def SendDict(self, d):
#   def SendRecord(self, event, d):
#   def Send(self, msg):
#   def SendDict(self, d):
#   def SendRecord(self, event, d):
# def _GetUsageConfig():
# def _ReadAddressFile(address_file=None):
# def GetClientFromConfig(address_file=None):


import optparse
import re
import os
import sys
import threading
import jsontemplate
import templates
from common import httpd
from common import util
from common import spy
      help='Directory to serve out of.')

  return parser


HOME_PAGE = jsontemplate.Template("""\
<h3>latch</h3>

{.repeated section pages}
  <a href="{@|htmltag}">{@}</a> <br/>
{.end}
""", default_formatter='html')


LATCH_PATH_RE = re.compile(r'/-/latch/(\S+)$')

# TODO: Rewrite latch.js using raw XHR, and get rid of jQuery.  This could
# interfere with pages that have jQuery already.
LATCH_HEAD = """\
<script type='text/javascript'
  src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>

<script src="/-/latch.js"></script>
"""

LATCH_BODY = """\
<p id="latch-status">Waiting for latch...</p>
"""


# Path: common/httpd.py
# class ThreadedHTTPServer(SocketServer.ThreadingMixIn,
#                          BaseHTTPServer.HTTPServer):
# class BaseRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
#   def url_to_fs_path(self, url):
#   def send_head(self):
# 
# Path: common/util.py
# ANSI_BLUE = '\033[36m'
# ANSI_GREEN = '\033[32m'
# ANSI_RESET = '\033[0;0m'
# class Logger(object):
#   def __init__(self, color):
#   def __call__(self, msg, *args):
# def GetPackageDir():
# def GetUserDir():
# 
# Path: common/spy.py
# class Error(Exception):
# class UsageReporter(object):
# class NullUsageReporter(object):
#   def __init__(self, host_port):
#   def Send(self, msg):
#   def SendDict(self, d):
#   def SendRecord(self, event, d):
#   def Send(self, msg):
#   def SendDict(self, d):
#   def SendRecord(self, event, d):
# def _GetUsageConfig():
# def _ReadAddressFile(address_file=None):
# def GetClientFromConfig(address_file=None):


# Path: latch/latch.py
import optparse
import re
import os
import sys
import threading
import jsontemplate
import templates
from common import httpd
from common import util
from common import spy

      help='Directory to serve out of.')

  return parser


HOME_PAGE = jsontemplate.Template("""\
<h3>latch</h3>

{.repeated section pages}
  <a href="{@|htmltag}">{@}</a> <br/>
{.end}
""", default_formatter='html')


LATCH_PATH_RE = re.compile(r'/-/latch/(\S+)$')

# TODO: Rewrite latch.js using raw XHR, and get rid of jQuery.  This could
# interfere with pages that have jQuery already.
LATCH_HEAD = """\
<script type='text/javascript'
  src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>

<script src="/-/latch.js"></script>
"""

LATCH_BODY = """\
<p id="latch-status">Waiting for latch...</p>
"""


class LatchRequestHandler(httpd.BaseRequestHandler):