iterative / iterative/PyDrive2

fs.makedirs() fails unless you put a file in the folder (shared drive)

Offen
#349 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
670
Forks
75
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Example:

```python
# Setup
from pydrive2.fs import GDriveFileSystem
from pydrive2.auth import GoogleAuth

settings = {
"client_config_backend": "service",
'service_config': {
'client_json_dict': {
"type": "service_account",
"private_key_id": str(os.getenv('xxx')),
"private_key": str(os.getenv('xxx')).replace('\\n', '\n'),
"client_email": str(os.getenv('xxx')),
"client_id": str(os.getenv('xxx')),
},
'oauth_scope': [
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.metadata'
]
}
}

g = GoogleAuth(settings=settings)
g.ServiceAuth()
shared_d_name = "xxx"

fs = GDriveFileSystem(
shared_d_name,
google_auth=g
)

# Example that does not recursively create folders, and no exceptions raised
folder_path = f'{shared_d_name}/test_parent/test'
fs.makedirs(folder_path)

# Example that creates the folders
folder_path = f'{shared_d_name}/test_parent2/test2'
fs.makedirs(folder_path)
with fs.open(folder_path+'hi.txt', 'w') as f:
f.write('hi')
```

Easy to make and then delete the file as a workaround, but the lack of success in the first example was wierd.
Best,
T

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start by reproducing the shared-drive example with GDriveFileSystem.makedirs(), then inspect the makedirs entry point and its folder-creation logic. Done means recursively creating test_parent/test, or the equivalent nested path, without first creating a file; add or run a regression test if the repository provides one.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
api, cloud
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.