bakfile/bak

A few starting issues

Closed this issue · 7 comments

I installed this in a virtualenv on my desktop and couldn't get the bak up <file> command to work.
I installed with this process:
git clone git clone https://github.com/bakfile/bak.git
'virtualenv bak/
source bak/bin/activate
python3 bak/setup.py install
When I just typed bak I would get a help menu so I assumed it was installed properly.

The problem occurs when I tried to use bak up test.cfg for the first time I got an error that looks like this:

> bak up test.cfg 
Traceback (most recent call last):
  File "/home/user/bak/bin/bak", line 33, in <module>
    sys.exit(load_entry_point('bak==0.0.1a1', 'console_scripts', 'bak')())
  File "/home/user/bak/lib/python3.6/site-packages/click-7.1.2-py3.6.egg/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/bak/lib/python3.6/site-packages/click-7.1.2-py3.6.egg/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/user/bak/lib/python3.6/site-packages/click-7.1.2-py3.6.egg/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/user/bak/lib/python3.6/site-packages/click-7.1.2-py3.6.egg/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/bak/lib/python3.6/site-packages/click-7.1.2-py3.6.egg/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/user/bak/lib/python3.6/site-packages/bak-0.0.1a1-py3.6.egg/bak/__main__.py", line 45, in bak_up
  File "/home/user/bak/lib/python3.6/site-packages/bak-0.0.1a1-py3.6.egg/bak/commands/__init__.py", line 227, in bak_up_cmd
  File "/home/user/bak/lib/python3.6/site-packages/bak-0.0.1a1-py3.6.egg/bak/commands/__init__.py", line 95, in _do_select_bakfile

I checked out the offending file and line number and it looks like this:

90    def _do_select_bakfile(bakfiles: List[bakfile.BakFile],
91                          select_prompt=default_select_prompt,
92                           err=True):
93        console = Console(file=stderr if err else stdout)
94        console.print(
95            f"Found {len(bakfiles)} bakfiles for file: {bakfiles[0].orig_abspath}")
96        console.print("Please select from the following: ")
97        console.print("Range %d", len(bakfiles))

On line 95 there is that bakfiles[0] reference, and since the error was a IndexError I figured it was the culprit. I commented those couple of print lines out and reinstalled it. After that I could run the bak up test.cfg command but I didn't really understand the menu that pops up after:

Enter a number to overwrite a .bakfile, or:
(V)iew (L)ist (C)ancel [C]:

This was sort of confusing and I didn't know what to do and after trying all the options I can say that the file seems to not have backed up anything.

I hope this can be a useful issue. I didn't dive into understanding the code much but am willing to help solve it with some direction.
Also, I think there is need for install guide in the README. I found a way to do it but I'm not sure if that is the best way.

This is very much appreciated! A couple clarifying questions, though I suspect this boils down to a missing error check:

  • Had you already done bak test.cfg? If not, you should have gotten No bakfile found for test.cfg, and I'll need to investigate why you didn't.
  • If you had, does bak list test.cfg work? bak up might be passing the wrong something.

Either way, that function definitely needs to check for a result before trying to access it. At minimum, this was revealing!

As for installation - and I'll definitely put a note in the README - I'm trying to keep the source accessible by your choice of setup.py or pip, because (even while I'm the only dev 👅) development is much easier when you can, in a venv, pip3 install --editable .

But, for those who just wanna use it, a setup.py install is indeed the way to go.

I re-cloned everything to start fresh and I think I realized the issue,
I first ran bak up test.cfg, but you're supposed to run bak test.cfg the first time. I guess this wasn't intuitive to me. And after I ran bak test.cfg the first time, the bak up command worked like it should have.
After playing with it a bit more I see why things are this way. The bak command creates a new backup, while the bak up command replaces an existing backup. This makes more sense now. So as far as things that could be fixed, I think the first time you run bak up on any give file, it should effectively run a bak command on that file. Maybe this is a good solution, maybe it isn't.

That's an excellent suggestion. I'll try it out.

Ended up going with los dos. Thanks both for the report, and the suggestion! It's a safe assumption that a person running bak up wants a .bak, whether or not the file already had one.

It might end up needing a confirmation prompt, just in case of typos, but we'll see if anyone complains.

Wow you're fast! Way to go!

Not so fast. bak is a "blow off steam" project =P