Created
February 13, 2009 05:27
-
-
Save Circuitsoft/63061 to your computer and use it in GitHub Desktop.
Revisions
-
Circuitsoft revised this gist
Apr 21, 2011 . 2 changed files with 59 additions and 64 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ import os, time import subprocess class repo: def __init__(self, repodir="."): self.repodir=repodir def __callgit(self, cmd, *args): command = ['git', cmd] for a in args: command.append(a) env = {'GIT_DIR':self.repodir} p = subprocess.PIPE print 'Calling',command,'on',self.repodir return subprocess.Popen(command, env=env, stdin=p, stdout=p) callgit = __callgit # Make it temporarily available outside def snapshot(self, ref='HEAD', format='zip', filter=None): results = self.__callgit('archive', '--format=%s' % format, ref) if filter: output = subprocess.Popen(filter, stdin=results.stdout, stdout=subprocess.PIPE).stdout else: output = results.stdout while True: yield output.read(0x1000) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,64 +1,34 @@ #!/usr/bin/python import git import web from subprocess import * class hello: def GET(self): for a in ['callgit', 'snapshot']: yield '<A HREF="%s">%s</a>' % (a,a) class callgit: def GET(self): web.header('Content-Type', 'application/binary') web.header('Content-Disposition', 'attachment; filename=test.tar.gz') repoobj = git.repo('/var/spool/gitosis/repositories/sensorcentral.git') output = repoobj.callgit('archive', '--format=tar', '4cc3471f876f8a6814c567902a07b5f15083b9d4').stdout return Popen(('gzip', '-9c', '-'), stdout=PIPE, stdin=output).stdout class snapshot: def GET(self): web.header('Content-Type', 'application/binary') web.header('Content-Disposition', 'attachment; filename=test.tar.gz') repoobj = git.repo('/var/spool/gitosis/repositories/sensorcentral.git') return repoobj.snapshot('4cc3471f876f8a6814c567902a07b5f15083b9d4', 'tar', ('gzip', '-9c', '-')) if __name__ == "__main__": urls = ("/", "hello", "/callgit", "callgit", "/snapshot", "snapshot") web.application(urls, globals()).run() -
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,64 @@ # This is the important part of git.py import os, time import subprocess class repo: def __init__(self, repodir="."): self.repodir=repodir def __callgit(self, cmd, *args): command = ['git', cmd] for a in args: command.append(a) env = {'GIT_DIR':self.repodir} p = subprocess.PIPE print 'Calling',command,'on',self.repodir return subprocess.Popen(command, env=env, stdin=p, stdout=p) callgit = __callgit # Make it temporarily available outside def snapshot(self, ref='HEAD', format='zip', filter=None): results = self.__callgit('archive', '--format=%s' % format, ref) if filter: output = subprocess.Popen(filter, stdin=results.stdout, stdout=subprocess.PIPE).stdout else: output = results.stdout while True: yield output.read(0x1000) # This is test.py #!/usr/bin/python import git import web from subprocess import * class hello: def GET(self): for a in ['callgit', 'snapshot']: yield '<A HREF="%s">%s</a>' % (a,a) class callgit: def GET(self): web.header('Content-Type', 'application/binary') web.header('Content-Disposition', 'attachment; filename=test.tar.gz') repoobj = git.repo('/var/spool/gitosis/repositories/sensorcentral.git') output = repoobj.callgit('archive', '--format=tar', '4cc3471f876f8a6814c567902a07b5f15083b9d4').stdout return Popen(('gzip', '-9c', '-'), stdout=PIPE, stdin=output).stdout class snapshot: def GET(self): web.header('Content-Type', 'application/binary') web.header('Content-Disposition', 'attachment; filename=test.tar.gz') repoobj = git.repo('/var/spool/gitosis/repositories/sensorcentral.git') return repoobj.snapshot('4cc3471f876f8a6814c567902a07b5f15083b9d4', 'tar', ('gzip', '-9c', '-')) if __name__ == "__main__": urls = ("/", "hello", "/callgit", "callgit", "/snapshot", "snapshot") web.application(urls, globals()).run()