doit icon indicating copy to clipboard operation
doit copied to clipboard

doit dumpdb fails when non default db name is used

Open ebak opened this issue 8 years ago • 5 comments

dumpdb does not take dep_file configuration into account because it does not read (or require a dodo.py). It would be better to use dep_file information if available.

Original report:


.doit.delayed.db file exists.

$ ./delayed.py dumpdb
DBM type is 'None'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/doit-0.29.0-py2.7.egg/doit/doit_cmd.py", line 168, in run
    return command.parse_execute(args)
  File "/usr/lib/python2.7/site-packages/doit-0.29.0-py2.7.egg/doit/cmd_base.py", line 122, in parse_execute
    return self.execute(params, args)
  File "/usr/lib/python2.7/site-packages/doit-0.29.0-py2.7.egg/doit/cmd_dumpdb.py", line 51, in execute
    data = dbm.open(dep_file)
  File "/usr/lib64/python2.7/anydbm.py", line 79, in open
    raise error, "need 'c' or 'n' flag to open new db"
error: need 'c' or 'n' flag to open new db

[delayed.py.txt](https://github.com/pydoit/doit/files/159206/delayed.py.txt)


<!-- POLAR PLEDGE BADGE START -->
<a href="https://dashboard.polar.sh/pydoit/doit/issues/126">
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://dashboard.polar.sh/api/github/pydoit/doit/issues/126/pledge.svg?darkmode=1">
  <img alt="Fund with Polar" src="https://dashboard.polar.sh/api/github/pydoit/doit/issues/126/pledge.svg">
</picture>
</a>
<!-- POLAR PLEDGE BADGE END -->

ebak avatar Mar 04 '16 18:03 ebak

I see. the problem is that dumpdb doesnt read dodo.py at all.

I like the fact that you can see the dump even without a dodo.py. Do you know you can specify the name of the DB file from the command line?

schettino72 avatar Mar 05 '16 11:03 schettino72

Hi,

I don't know currently the command line argument for the DB file name. In my case I don't use dodo.py. I execute the engine directly with "doit.run(globals())" in this case the engine gets the DOIT_CONFIG dict, which contains the DB file name. I guess for my case I could make a work-around. In delayed.py I could add the DB file name command line argument to "sys.argv" than execute "doit.run(globals())".

ebak avatar Mar 05 '16 14:03 ebak

When running in an IPython (notebook) context as %doit dumpdb, a custom dep_file in a DOIT_CONFIG dictionary I might define does not seem to be taken into account. I find this highly confusing, especially because in the notebook context, it's not quite clear where the database is stored. The dumpdb commands seems to report on ~/.ipython/profile_default/db/.doit.db, but I'm not sure that's the file that is actually being used when running tasks. The dumpdb should print the name of the database file that it's reading from, not just the type of the database.

goerz avatar Jun 05 '17 18:06 goerz

The dumpdb should print the name of the database file that it's reading from, not just the type of the database.

So maybe you should create another ticket for this.

I would accept a patch where dumpdb reads a dodo.py and get the value of file_dep, but it must still be able to work without a dodo.py file.

schettino72 avatar Jun 05 '17 18:06 schettino72

Done (#183). If I have some time at some point in the near future, I might look into making such a pull request.

goerz avatar Jun 05 '17 19:06 goerz