Git Product home page Git Product logo

Comments (10)

gpocentek avatar gpocentek commented on June 6, 2024

http://python-gitlab.readthedocs.org/en/latest/upgrade-from-0.10.html should help. Let me know if you need more information.

from python-gitlab.

sashkab avatar sashkab commented on June 6, 2024

I looked there, I looked into the code and it didn't help me.

Logic says that I need to pass to p.files.get(file_path, ref), but it doesn't work. What am I missing? Do I need to get branch first and then get files from the branch?

ie:

p  = self.projects.get(id=project_id)
b = p.branch.get(ref=ref)
f = b.files.get(file_path).content

from python-gitlab.

gpocentek avatar gpocentek commented on June 6, 2024

You actually had the correct syntax but there's in bug in the BaseManager class that made your code fail. I pushed commit 0e0c81d which should fix it.

The syntax is:

p = gl.projects.get(some_project_id)
f = p.files.get(file_path=file_path, ref=ref)
content = base64.b64decode(f.content)

Could you confirm that the patch works for you? If it's OK I'll push a new release. Thank you.

from python-gitlab.

sashkab avatar sashkab commented on June 6, 2024

Yes, this changes solved the problem with the downloading of the file, but introduces a debug output from somewhere...

The only remaining case I have now is creating a note for the project.

Old code was:

        p = self.projects.get(id=project_id).
        i = p.issues.get(project_id=project_id, id=issue_id)
        if i.canUpdate:
            n = i.Note({
                'project_id': project_id,
                'issue_id': issue_id,
                'body': body,
            })
            n.save()

Now replacing Note into notes.create:

>>> n = i.notes.create({'project_id': project_id, 'issue_id': issue_id, 'body': 'test'})
>>> n.save()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/b/.virtualenvs/bootstrap/lib/python2.7/site-packages/gitlab/objects.py", line 321, in save
    self._update(**kwargs)
  File "/home/b/.virtualenvs/bootstrap/lib/python2.7/site-packages/gitlab/objects.py", line 314, in _update
    raise NotImplementedError
NotImplementedError

from python-gitlab.

sashkab avatar sashkab commented on June 6, 2024

Do I understand correctly, that n.save() no longer required?

from python-gitlab.

gpocentek avatar gpocentek commented on June 6, 2024

n.save() is no longer needed. I'll check what's happening with the note creation.

from python-gitlab.

sashkab avatar sashkab commented on June 6, 2024

Then there is no issues with note creation.

Thank you.

from python-gitlab.

gpocentek avatar gpocentek commented on June 6, 2024

OK. Thank you for you report and tests!

from python-gitlab.

sashkab avatar sashkab commented on June 6, 2024

Please make sure to disable debug output you added recently :)

from python-gitlab.

gpocentek avatar gpocentek commented on June 6, 2024

It's done already :)

I'll push a new release after adding some unit and functional tests.

from python-gitlab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.