Beispiel #1
0
def user_friendly_open_local_repository(path):
    # This won't catch invalid/nonexisting repos. Let the repo constructor do that
    path = os.path.abspath(path)
    if repository.looks_like_repo(path) and repository.has_pending_operations(path):
        notice("The repository at %s has pending operations. Resuming..." % os.path.basename(path))
        repo = repository.Repo(path)
        notice("Pending operations completed.")
    else:
        repo = repository.Repo(path)
    return repo
Beispiel #2
0
 def __init__(self, repopath, port=50000):
     self.server = jsonrpc.Server(
         jsonrpc.JsonRpc20(),
         jsonrpc.TransportTcpIp(timeout=60.0, addr=("0.0.0.0", port)))
     repo = repository.Repo(repopath)
     fr = front.Front(repo)
     self.server.register_instance(fr, "front")
Beispiel #3
0
 def setUp(self):
     self.repopath = tempfile.mktemp(dir=TMPDIR)
     repository.create_repository(self.repopath)
     self.repo = repository.Repo(self.repopath)
     self.sessioninfo1 = {"foo": "bar", "name": SESSION_NAME}
     self.fileinfo1 = {"filename": "testfilename.txt", "md5sum": DATA1_MD5}
     self.fileinfo2 = {"filename": "testfilename2.txt", "md5sum": DATA2_MD5}
     self.fileinfo3 = {"filename": "testfilename3.txt", "md5sum": DATA3_MD5}
Beispiel #4
0
def run_socketserver(repopath, address, port):
    repository.Repo(repopath)  # Just check if the repo path is valid

    class BoarTCPHandler(SocketServer.BaseRequestHandler):
        def handle(self):
            to_client = self.request.makefile(mode="wb")
            from_client = self.request.makefile(mode="rb")
            PipedBoarServer(repopath, from_client, to_client).serve()

    if "fork" not in dir(os):
        warn(
            "Your operating system does not support the 'fork()' system call. This server will only be able to handle one client at a time. Please see the manual on how to set up a server on your operating system to handle multiple clients."
        )
        server = SocketServer.TCPServer((address, port), BoarTCPHandler)
    else:
        server = ForkingTCPServer((address, port), BoarTCPHandler)

    ip = server.socket.getsockname()[0]
    if ip == "0.0.0.0":
        ip = socket.gethostname()
    print "Serving repository %s as boar://%s:%s/" % (repopath, ip, port)
    server.serve_forever()
Beispiel #5
0
 def initialize(self):
     self.repo = repository.Repo(self.repopath)
     fr = front.Front(self.repo)
     self.handler.register_instance(fr, "front")