Giter VIP home page Giter VIP logo

Comments (5)

lavigne958 avatar lavigne958 commented on June 2, 2024 4

I went through the list of missing actions it seems the new HTTP client is missing the bellow actions:

  • export
  • list_permissions
  • insert_permission/share
  • remove_permission

I will fix that soon (in a couple of days at most) and make the next fixup release 6.0.1

thank you everyone for helping.

from gspread.

lavigne958 avatar lavigne958 commented on June 2, 2024 1

I saw your first investigation I thought you wanted to continue when you have time.
I understand, I'll have a look then.

I think we can provide a fix for both issues that just raised and then release 6.0.1 with both fixes, you agree ?

from gspread.

teodororo avatar teodororo commented on June 2, 2024

@Joangaes, sorry for taking advantage of your issue, but I had a similar problem so I'll just add it here. It was with the export function.

Traceback (most recent call last):
  File "xxx.py", line xxx, in <module>
    export_file = workbook.export(format=ExportFormat.EXCEL)
  File "/home/xxx/oss/changehistory/venv/lib/python3.8/site-packages/gspread/spreadsheet.py", line 518, in export
    return self.client.export(self.id, format)
AttributeError: 'HTTPClient' object has no attribute 'export'

Here's what I've tried:

import gspread
gc = gspread.service_account()
sh = gc.open("XXX").export()

from gspread.

alifeee avatar alifeee commented on June 2, 2024

Hi, thanks for the issue :)

This seems to be a big problem with the new release. For now I would consider using the latest version v5.12.4 until this is fixed, with

pip install gspread==5.12.4

Information

I am not sure what the problem is, but I provide relevant parts of code for v5 and v6

v5 (old, working)

class Client:
    def __init__(self, auth, session=None):
        if auth is not None:
            self.auth = convert_credentials(auth)
            self.session = session or AuthorizedSession(self.auth)
        else:
            self.session = session
        self.timeout = None
    def open(self, title, folder_id=None):
        spreadsheet_files, response = self._list_spreadsheet_files(title, folder_id)
        try:
            properties = finditem(
                lambda x: x["name"] == title,
                spreadsheet_files,
            )
        except StopIteration as ex:
            raise SpreadsheetNotFound(response) from ex
        # Drive uses different terminology
        properties["title"] = properties["name"]
        return Spreadsheet(self, properties)
class Spreadsheet:
    def __init__(self, client, properties):
        self.client = client
    ...
    def export(self, format=ExportFormat.PDF):
        return self.client.export(self.id, format)

v6 (new, broken)

class Client:
    def __init__(
        self, auth: Credentials, http_client: HTTPClientType = HTTPClient
    ) -> None:
        self.http_client = http_client(auth)
    def open(self, title: str, folder_id: Optional[str] = None) -> Spreadsheet:
        spreadsheet_files, response = self._list_spreadsheet_files(title, folder_id)
        try:
            properties = finditem(
                lambda x: x["name"] == title,
                spreadsheet_files,
            )
        except StopIteration as ex:
            raise SpreadsheetNotFound(response) from ex
        # Drive uses different terminology
        properties["title"] = properties["name"]
        return Spreadsheet(self.http_client, properties)
class Spreadsheet:
    def __init__(self, http_client, properties):
        self.client = http_client
    ...
    def export(self, format=ExportFormat.PDF):
        return self.client.export(self.id, format)

I must go now but the investigation can be continued from here. Looks like a problem with what is passed to the Spreadsheet initialisation, as one passes an entire Client object, and the other just the http_client, which does not have the export method attached to it.

from gspread.

alifeee avatar alifeee commented on June 2, 2024

@lavigne958 you assign me but I do not know much about the Client object, perhaps it is better if you take a look as you know more about it and the changes that were made v5->v6?

from gspread.

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.