ckan / ckanapi

A command line interface and Python module for accessing the CKAN Action API
Other
182 stars 75 forks source link

ckanapi dump dataset --all -D $PWD fails #188

Closed frafra closed 2 years ago

frafra commented 3 years ago
env=$(poetry env info | grep ^Path: | awk '{ print $2 }')
ckanapi dump datasets --all -r $url -a $key -D . |& sed "s;$env;;g"
0 [1] --- None datasetname
Traceback (most recent call last):
  File "/bin/ckanapi", line 8, in <module>
    sys.exit(main())
  File "/lib/python3.8/site-packages/ckanapi/cli/main.py", line 144, in main
    return dump_things(ckan, thing[0], arguments)
  File "/lib/python3.8/site-packages/ckanapi/cli/dump.py", line 109, in dump_things
    create_datapackage(record, datapackages_path, stderr)
  File "/lib/python3.8/site-packages/ckanapi/datapackage.py", line 50, in create_datapackage
    os.makedirs(os.path.join(datapackage_dir, 'data'))
  File "/usr/lib64/python3.8/os.py", line 223, in makedirs
    mkdir(name, mode)
FileExistsError: [Errno 17] File exists: './datasetname/data'
Traceback (most recent call last):
  File "/bin/ckanapi", line 8, in <module>
    sys.exit(main())
  File "/lib/python3.8/site-packages/ckanapi/cli/main.py", line 144, in main
    return dump_things(ckan, thing[0], arguments)
  File "/lib/python3.8/site-packages/ckanapi/cli/dump.py", line 37, in dump_things
    return dump_things_worker(ckan, thing, arguments)
  File "/lib/python3.8/site-packages/ckanapi/cli/dump.py", line 187, in dump_things_worker
    reply(None, obj)
  File "/lib/python3.8/site-packages/ckanapi/cli/dump.py", line 162, in reply
    stdout.flush()
BrokenPipeError: [Errno 32] Broken pipe
wardi commented 3 years ago

@frafra could you be running it in a directory where the datasets were already exported?

frafra commented 3 years ago

@wardi I executed the same commands in an empty folder. I tried again using mktemp -d and entering into the temporary directory just to be sure. ckanapi creates a $dataset/data folder structure with no files.

wardi commented 3 years ago

Sounds like a bug. I don't use this feature but if you have a chance to submit a fix I'd appreciate it.

frafra commented 2 years ago

It looks that the directory was not empty after all.