Maria 项目相关工作总结

暑假过完了。项目也差不多要结题了。原始项目地址和我提交的pr在这里

关于 Maria 项目

A way to serve git repos through ssh and http protocol like Github.

Features

1. support git clone/push/pull with ssh and http protocol.
2. auth by pub key, you can write your own verify code to use mysql and others easily.
3. people always like coroutine, powered by gevent.
4. safely, only allow commands in white list.

关于 Maria 接口重构

主要实现目标

  1. 实现命令行参数如:
 * -b, --bind host:port
 * -k, --key key file path
 * -w, --worker async(gevent), sync(socketserver)
 * --git-path git command path
 * --repo-path git repository root path
 and so on ...
  1. 指定 app, 设置 Hook
maria -b host:port app.wsgi:application

构造程序入口类

在 method load_config 综合管理程序接口的各种参数,并加载实例化的 app。load_worker 加载选择的 worker。run作为服务器启动入口。

class Application(object):

    def __init__(self, usage=None, prog=None): 

    def init_log(self):

    def load_config(self):

    def load_worker(self):

    def run(self):

构造 worker

增加 maria/worker 目录,base.py 里构造 worker 的基类。在 socket.py 和 ggevent 分别构造两个 worker 子类socketservergeventserver,这两个类分别使用 TCPServerStreamServer 作为 server。

|---worker
|     |---__init__.py
|     |---base.py
|     |---socket.py
|     |---ggevent.py

关于测试

测试目标

验证 Maria 的 git push、clone 功能。

测试构造

使用nose和unittest作为测试框架。主要试类的构造如下:

class TestMaria(unittest.TestCase):

    def setUp(self):

    def tearDown(self):

    def test_clone(self):

    def test_push(self):

在方法 setUp 中建立临时空仓库作为远端仓库,然后用 subprocess 的一个 Popen 实例运行 maria 服务器。

test_clonetest_push 分别验证 git clone、git push 是否成功运行。test_clone 中直接 git clone 远端仓库,验证是否成功。test_push 方法中首先建立本地仓库,做一些 commit 后,push 到远端,验证是否成功。

最后 tearDown 中进行扫尾工作,关闭子进程,删除临时仓库。

总结

两个月里基本完成了 Maria 项目接口重构的各部分需求,学习收获良多。第一次亲身参与开源项目,培养了这方面的兴趣,同时也掌握了 git 和 github 等开源项目托管工具的基本操作。加深了使用 python 等编程工具的熟练成度以及对 ssh 等协议的理解。

(最后吐糟一下 csdn 的博客编辑系统。不支持 markdown 是比较遗憾,但不应该没有预览功能。编辑完提交,审核要半天返回来才能看出排版效果。看来目前方便些的办法,只能通过 markdown 输出 html 代码贴上去)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值