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.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()
def cmd_init(args): import optparse parser = optparse.OptionParser() 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) conf = load_conf(options.swift_config) if args == []: parser.error("missing repository name") repo = args[0] scon = SwiftConnector(repo, conf) SwiftRepo.init_bare(scon, conf)
# modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; version 2 # or (at your option) a later version of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. import sys from dulwich.swift import ( SwiftConnector, SwiftRepo, load_conf, ) if __name__ == "__main__": if len(sys.argv) < 2: sys.exit(1) conf = load_conf() root = sys.argv[1] scon = SwiftConnector(root, conf) SwiftRepo.init_bare(scon, conf)