FriendCode / gittle

Pythonic Git for Humans
Other
732 stars 90 forks source link

dulwich throwing an error on cloning #94

Closed Rima closed 7 years ago

Rima commented 7 years ago

Exception Value: a bytes-like object is required, not 'str'

my code looks like this

    #res = create_new_project(repo_name)
    repo_path = "%s%s21"%(settings.REQUIREMENTS_REPOS['local_path'], repo_name)
    #remote_url = "%s/experiments/%s" % ( settings.GIT_SETTINGS['base_url'], repo_name )
    remote_url = 'ssh://git@git.mokus.io:31613/experiments/req_21.git'
    key_path = '/home/rima/.ssh/id_rsa'
    key_file = open(key_path)
    auth = GittleAuth(pkey=key_file)

    repo = git.clone(remote_url, repo_path, auth=auth)

my dulwich version is pip install dulwich==0.9.7 I cloned gittle from github to ensure I have the latest version and installed the required libraries as per setup.py

The error it throws at me is:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/integrations/first_issues_import/

Django Version: 1.10.6
Python Version: 3.6.0
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'rest_framework',
 'rest_framework.authtoken',
 'djoser',
 'rodster',
 'product',
 'release',
 'activity']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback:

File "/home/rima/anaconda3/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  42.             response = get_response(request)

File "/home/rima/anaconda3/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/home/rima/anaconda3/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/rima/Codes/gitrod/backend/app/integrations/views.py" in first_issues_import
  9.     store_all_issues_in_git(21)

File "/home/rima/Codes/gitrod/backend/app/integrations/gitlab/handle_issues.py" in store_all_issues_in_git
  21.     repo = git.clone(remote_url, repo_path, auth=auth)

File "/home/rima/Codes/gitrod/backend/app/gittle/gittle.py" in clone
  457.             local_repo = cls.init(local_path)

File "/home/rima/Codes/gitrod/backend/app/gittle/gittle.py" in init
  312.         repo = constructor(path)

File "/home/rima/anaconda3/lib/python3.6/site-packages/dulwich/repo.py" in init
  885.         cls._init_maybe_bare(controldir, False)

File "/home/rima/anaconda3/lib/python3.6/site-packages/dulwich/repo.py" in _init_maybe_bare
  869.         ret.refs.set_symbolic_ref("HEAD", "refs/heads/master")

File "/home/rima/anaconda3/lib/python3.6/site-packages/dulwich/refs.py" in set_symbolic_ref
  545.                 f.write(SYMREF + other + '\n')

Exception Type: TypeError at /integrations/first_issues_import/
Exception Value: a bytes-like object is required, not 'str'
jelmer commented 7 years ago

The version of Dulwich you're using is not Python3 compatible - only 0.15.0 and up support Python 3.

However, gittle itself doesn't have Python3 support at all - see https://github.com/FriendCode/gittle/issues/63