1
這是我寫的從我的Django驅動的基於web的代碼編輯器更新GitHub repo的代碼,請參見https://github.com/DjangoCoder/DjangoGUI/blob/master/projects/views.py 763行。如何重寫此代碼以實際工作?使用Python/Django來更新GitHub
def update_github(request, project_slug):
print 'UPDATE GITHUB\n' * 100
project = Project.objects.get(created_by=request.user, slug=project_slug)
import pexpect
child = pexpect.spawn('/bin/bash',)
import sys
child.logfile = sys.stdout
print 'a'
child.sendline('cd %s' % (project.get_current_directory()))
print 'b'
child.sendline('git add *')
child.sendline('git commit -m "commit"')
print 'c'
child.sendline('git push -u origin master')
print 'd'
child.sendline('ssgmssgm2')
print 'e'
return HttpResponse('')
您可以使用[這個python git庫](http://gitorious.org/git-python#more)來代替它嗎?找到的文檔[here](http://packages.python.org/GitPython/0.3.2/tutorial.html) –