← Back to team overview

dulwich-users team mailing list archive

Re: Dulwich Pull/Push command?

 

Thank you for the ideas and I'm trying to implement them in a small test
script but I am having some issues. I can't get client.GitClient.fetch() to
run. It seems the first parameter needs to be a GitClient instance but I
can't figure out how to start an instance. I've tried calling
client.GitClient.__init__ , or using self, or cl =
client.GitClient.fetch(cl, "https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r) . Also tried many others (All my
errors are at the end of the email). Here is my code to test fetching. I
have the two if not's because I was didn't want to keep deleting the folder
just to reinit it for testing.

I really appreciate all the help

import os
from dulwich import *

path = "myrepo"
if not os.path.exists(path):
        os.makedirs(path)
if not os.path.exists(os.path.join(path, ".git")):
     r = repo.Repo.init(path)
else:
    r = os.path.join(path, ".git")
cl = client.GitClient.__init__
client.get_transport_and_path("https://Shelnutt2@
github.com/Shelnutt2/apptester.git")
client.GitClient.fetch(cl, "https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)


My errors:

s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
Traceback (most recent call last):
  File "git-test.py", line 14, in <module>
    client.GitClient.fetch("https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
TypeError: unbound method fetch() must be called with GitClient instance as
first argument (got str instance instead)
s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
Traceback (most recent call last):
  File "git-test.py", line 15, in <module>
    client.GitClient.fetch("https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
TypeError: unbound method fetch() must be called with GitClient instance as
first argument (got str instance instead)
s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
Traceback (most recent call last):
  File "git-test.py", line 15, in <module>
    cl1 = client.GitClient.fetch("https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
TypeError: unbound method fetch() must be called with GitClient instance as
first argument (got str instance instead)
s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
Traceback (most recent call last):
  File "git-test.py", line 15, in <module>
    cl1 = client.GitClient.fetch(cl1, "https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
NameError: name 'cl1' is not defined
s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
Traceback (most recent call last):
  File "git-test.py", line 15, in <module>
    cl1 = client.GitClient.fetch(self, "https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
NameError: name 'self' is not defined
s.shelnutt@funtoo-64 ~/wine-dev/git-test $
s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
Traceback (most recent call last):
  File "git-test.py", line 15, in <module>
    client.GitClient.fetch(self, "https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
NameError: name 'self' is not defined
s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
Traceback (most recent call last):
  File "git-test.py", line 15, in <module>
    client.GitClient.fetch(GitClient, "https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
NameError: name 'GitClient' is not defined
s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
Traceback (most recent call last):
  File "git-test.py", line 15, in <module>
    client.GitClient.fetch(client.GitClient, "https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
TypeError: unbound method fetch() must be called with GitClient instance as
first argument (got type instance instead)
s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
  File "git-test.py", line 15
    client.GitClient.fetch(, "https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
                           ^
SyntaxError: invalid syntax
s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
Traceback (most recent call last):
  File "git-test.py", line 15, in <module>
    client.GitClient.fetch(cl, "https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
TypeError: unbound method fetch() must be called with GitClient instance as
first argument (got type instance instead)
s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
Traceback (most recent call last):
  File "git-test.py", line 15, in <module>
    client.GitClient.fetch(cl, "https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
TypeError: unbound method fetch() must be called with GitClient instance as
first argument (got instancemethod instance instead)
s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
Traceback (most recent call last):
  File "git-test.py", line 15, in <module>
    client.GitClient.fetch(client.GitClient.__init__, "https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
TypeError: unbound method fetch() must be called with GitClient instance as
first argument (got instancemethod instance instead)
s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
Traceback (most recent call last):
  File "git-test.py", line 15, in <module>
    clitest = client.GitClient.fetch(self,"https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
NameError: name 'self' is not defined
s.shelnutt@funtoo-64 ~/wine-dev/git-test $ python git-test.py
Traceback (most recent call last):
  File "git-test.py", line 15, in <module>
    clitest = client.GitClient.fetch("https://Shelnutt2@
github.com/Shelnutt2/apptester.git", r)
TypeError: unbound method fetch() must be called with GitClient instance as
first argument (got str instance instead)


On Wed, Jun 30, 2010 at 12:31 AM, Jelmer Vernooij <jelmer@xxxxxxxxx> wrote:

> On Tue, 2010-06-29 at 10:59 -0700, David Borowitz wrote:
> > On Mon, Jun 28, 2010 at 18:31, Seth Shelnutt <shelnutt2@xxxxxxxxx>
> > wrote:
> >         I'm actually just looking to use the modules. I want to
> >         integrate git support into my python script. I would be happy
> >         to help and add more functionality but first I'd like to
> >         finish my current project and second I'm familiar enough with
> >         Git. I'm in the process of learning how it works. It seems
> >         pretty straight forward, clone, pull, push, commit, all the
> >         basics don't seem to bad.
> >
> >         What I am doing is moving wine's appinstall to python and
> >         expanding it. Appinstall was first developed by Austin English
> >         for the purpose of automating testing of software packages.
> >         What I need git support for is when a person runs
> >         apptester.py, the first thing it does is do a git status (or I
> >         might have it simply look for .git folder), and determine if
> >         the git repository has already been established.
>
> >
> > The easiest way to do this in dulwich would be:
> > try:
> >   r = repo.Repo(dirname)
> > except errors.NotGitRepository:
> >   r = clone_repo()  # You'll have to define this function yourself;
> > see below.
> >
> >         If it has, it'll do a git pull to make sure it's up to date.
>
> > Fetching is unfortunately a bit circuitous. I'll let Augie or Jelmer
> > respond as they're much more familiar with the use of GitClient.
> > However, once you've seen the difficult way, feel free to offer any
> > interface suggestions that would make it easier.
> When you have a client object (e.g. by calling
> dulwich.client.get_transport_and_path), you should be able to call
> client.fetch("/path/to/remote/repo", r) where r is an instance of
> dulwich.repo.BaseRepo. This will call fetch_pack under the hood for you.
>
> [...]
>
> >
> >         and then push everything back to the main repo. I'm thinking
> >         that this needs to be done with the TCP or SSHGitClient and
> >         using fetch_pack and send_pack?
>
> > send_pack is what you want, but again I'll defer to people who know
> > this piece better.
> We need a wrapper for send_pack that can do The Right Thing, but for now
> you should be able to call it like this:
>
> client.send_pack("/path/to/remote/repo",
> r.object_store.determine_wants_all,
> r.object_store.generate_pack_contents)
>
> (also untested).
>
> Cheers,
>
> Jelmer
>
>

Follow ups

References