Exemplo n.º 1
0
def cmd_daemon(args):
    """Entry point for starting a TCP git server."""
    import optparse
    parser = optparse.OptionParser()
    parser.add_option("-l", "--listen_address", dest="listen_address",
                      default="127.0.0.1",
                      help="Binding IP address.")
    parser.add_option("-p", "--port", dest="port", type=int,
                      default=TCP_GIT_PORT,
                      help="Binding TCP port.")
    parser.add_option("-c", "--swift_config", dest="swift_config",
                      default="",
                      help="Path to the configuration file for Swift backend.")
    options, args = parser.parse_args(args)

    try:
        import gevent
        import geventhttpclient
    except ImportError:
        print("gevent and geventhttpclient libraries are mandatory "
              " for use the Swift backend.")
        sys.exit(1)
    import gevent.monkey
    gevent.monkey.patch_socket()
    from dulwich.contrib.swift import load_conf
    from dulwich import log_utils
    logger = log_utils.getLogger(__name__)
    conf = load_conf(options.swift_config)
    backend = SwiftSystemBackend(logger, conf)

    log_utils.default_logging_config()
    server = TCPGitServer(backend, options.listen_address,
                          port=options.port)
    server.serve_forever()
Exemplo n.º 2
0
 def tearDown(self):
     super(PasterFactoryTests, self).tearDown()
     for rdir in self.repo_dirs:
         shutil.rmtree(rdir)
     root = getLogger()
     if root.handlers:
         root.removeHandler(root.handlers[0])
Exemplo n.º 3
0
from dulwich import log_utils
from dulwich.protocol import (
    ReceivableProtocol,
    )
from dulwich.repo import (
    Repo,
    )
from dulwich.server import (
    DictBackend,
    DEFAULT_HANDLERS,
    generate_info_refs,
    generate_objects_info_packs,
    )


logger = log_utils.getLogger(__name__)


# HTTP error strings
HTTP_OK = '200 OK'
HTTP_NOT_FOUND = '404 Not Found'
HTTP_FORBIDDEN = '403 Forbidden'
HTTP_ERROR = '500 Internal Server Error'


def date_time_string(timestamp=None):
    # From BaseHTTPRequestHandler.date_time_string in BaseHTTPServer.py in the
    # Python 2.6.5 standard library, following modifications:
    #  - Made a global rather than an instance method.
    #  - weekdayname and monthname are renamed and locals rather than class
    #    variables.
Exemplo n.º 4
0
    SINGLE_ACK,
    TCP_GIT_PORT,
    ZERO_SHA,
    ack_type,
    extract_capabilities,
    extract_want_line_capabilities,
    )
from dulwich.refs import (
    write_info_refs,
    )
from dulwich.repo import (
    Repo,
    )


logger = log_utils.getLogger(__name__)


class Backend(object):
    """A backend for the Git smart server implementation."""

    def open_repository(self, path):
        """Open the repository at a path.

        :param path: Path to the repository
        :raise NotGitRepository: no git repository was found at path
        :return: Instance of BackendRepo
        """
        raise NotImplementedError(self.open_repository)