这是我为从我的 Django 支持的基于 Web 的代码编辑器更新 GitHub 存储库而编写的损坏代码,请参阅https://github.com/DjangoCoder/DjangoGUI/blob/master/projects/views.py第 763 行。我重写此代码以实际工作?
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('')