Page 3 of 4

Re: Preview: cbmshell, an interactive file processor

Posted: Sat Aug 14, 2021 12:31 am
by srowe
chysn wrote: Fri Aug 13, 2021 7:08 pm Is there a limitation of the TAP format that prevents it from having multiple files with the same filename?
Nope, you can write two files with the same name. When you want to read them the first is named FILE, the second one FILE~1 etc.
I get this error when using a filename that's already in the TAP file:

Code: Select all

EXCEPTION of type 'TypeError' occurred with message: open() got an unexpected keyword argument 'record_len'
So the question is, is this a bug in cbm-shell, or is that something the TAP format disallows?
That's a plain bug, which should be fixed in version 1.5, can you do

Code: Select all

pip install --upgrade cbmshell
(or pull the latest code) and try again?

Re: Preview: cbmshell, an interactive file processor

Posted: Sat Aug 14, 2021 7:08 am
by chysn
Thanks for being so responsive with this!

Is there a way to tell which version of cbmshell I'm on? pip3 indicated this:

Code: Select all

Requirement already up-to-date: cbmshell in /Library/Python/3.8/site-packages (1.5)
But still

Code: Select all

JEJ:vic jasonjustian$ cbm-shell
(cbm) attach test.tap
Attached test.tap to 0
(cbm) copy --type PRG easy.mod 0:EASY.MOD
Copying easy.mod to ImagePath(0:b'EASY.MOD')
(cbm) copy --type PRG easy.mod 0:EASY.MOD
Copying easy.mod to ImagePath(0:b'EASY.MOD')
EXCEPTION of type 'TypeError' occurred with message: open() got an unexpected keyword argument 'record_len'
To enable full traceback, run the following command: 'set debug true'
I'm not sure I entirely trust that pip3 is looking in /usr/bin/cbmshell. I've previously used the makefile.

Re: Preview: cbmshell, an interactive file processor

Posted: Sat Aug 14, 2021 8:29 am
by srowe
chysn wrote: Sat Aug 14, 2021 7:08 am Is there a way to tell which version of cbmshell I'm on? pip3 indicated this:

Code: Select all

Requirement already up-to-date: cbmshell in /Library/Python/3.8/site-packages (1.5)
You can use pip show cbmshell to tell you what's installed.

I'm seeing the same error, I'll investigate.

Re: Preview: cbmshell, an interactive file processor

Posted: Sat Aug 14, 2021 11:35 am
by chysn
OK, thanks. Yes, I am on 1.5.

At the moment, I'm unable to copy from a TAP file to the local file system. I think I had that working before. I'm trying to build a process for moving from VICE to real tape, which is turning out to be a fun project. I've already got the process for going the other way.

Note that the tap file here was originally created and populated by cbmshell.

Code: Select all

(cbm) $
0 <TAP image>
1    "DISASTER.MOD"     PRG
(cbm) copy 0:DISASTER.MOD disaster.mod
Copying ImagePath(0:b'DISASTER.MOD') to disaster.mod
Traceback (most recent call last):
  File "/Library/Python/3.8/site-packages/cmd2/cmd2.py", line 2330, in onecmd_plus_hooks
    stop = self.onecmd(statement, add_to_history=add_to_history)
  File "/Library/Python/3.8/site-packages/cmd2/cmd2.py", line 2781, in onecmd
    stop = func(statement)
  File "/Library/Python/3.8/site-packages/cmd2/decorators.py", line 379, in cmd_wrapper
    return func(*args_list, **kwargs)  # type: ignore[call-arg]
  File "/Library/Python/3.8/site-packages/cbm_shell/scripts/cbm_shell.py", line 314, in do_copy
    with dest.open('wb', ftype=ftype, record_len=src.record_len) as out_file:
AttributeError: 'TapImagePathRead' object has no attribute 'record_len'
EXCEPTION of type 'AttributeError' occurred with message: 'TapImagePathRead' object has no attribute 'record_len'

Re: Preview: cbmshell, an interactive file processor

Posted: Sat Aug 14, 2021 12:53 pm
by srowe
OK, this should be fixed in 1.6 which I've just released. It required a re-design of how TAP files are handled so there still might be some sharp edges.

Re: Preview: cbmshell, an interactive file processor

Posted: Sun Aug 15, 2021 8:31 am
by chysn
Hmm, under 1.6 it's about the same.

Code: Select all

JEJ:modpack jasonjustian$ cbm-shell
(cbm) attach disaster.tap
Attached disaster.tap to 0
(cbm) $
0 <TAP image>
1    "DISASTER.MOD"     PRG
(cbm) copy 0:DISASTER.MOD disaster.mod
Copying ImagePath(0:b'DISASTER.MOD') to disaster.mod
EXCEPTION of type 'AttributeError' occurred with message: 'TapImagePath' object has no attribute 'record_len'
To enable full traceback, run the following command: 'set debug true'
(cbm) set debug true
debug - was: False
now: True
(cbm) copy 0:DISASTER.MOD disaster.mod
Copying ImagePath(0:b'DISASTER.MOD') to disaster.mod
Traceback (most recent call last):
  File "/Library/Python/3.8/site-packages/cmd2/cmd2.py", line 2330, in onecmd_plus_hooks
    stop = self.onecmd(statement, add_to_history=add_to_history)
  File "/Library/Python/3.8/site-packages/cmd2/cmd2.py", line 2781, in onecmd
    stop = func(statement)
  File "/Library/Python/3.8/site-packages/cmd2/decorators.py", line 379, in cmd_wrapper
    return func(*args_list, **kwargs)  # type: ignore[call-arg]
  File "/Library/Python/3.8/site-packages/cbm_shell/scripts/cbm_shell.py", line 314, in do_copy
    with dest.open('wb', ftype=ftype, record_len=src.record_len) as out_file:
AttributeError: 'TapImagePath' object has no attribute 'record_len'
EXCEPTION of type 'AttributeError' occurred with message: 'TapImagePath' object has no attribute 'record_len'
(cbm) quit
JEJ:vic jasonjustian$ pip3 show cbmshell
Name: cbmshell
Version: 1.6
Summary: Interactive shell to manipulate Commodore files
Home-page: https://eden.mose.org.uk/gitweb/?p=python-cbmshell.git
Author: Simon Rowe
Author-email: srowe@mose.org.uk
License: UNKNOWN
Location: /Library/Python/3.8/site-packages
Requires: cmd2, cbmcodecs2, tapfile, cbmfiles, d64, t64
Required-by: 

Re: Preview: cbmshell, an interactive file processor

Posted: Sun Aug 15, 2021 9:12 am
by srowe
Doh, you're copying out of an image, I was doing the other way around.

[Edit] Try 1.7 which I've just released.

Re: Preview: cbmshell, an interactive file processor

Posted: Sun Aug 15, 2021 3:15 pm
by chysn
srowe wrote: Sun Aug 15, 2021 9:12 am Doh, you're copying out of an image, I was doing the other way around.

[Edit] Try 1.7 which I've just released.
Yep, it's copying in both directions now.

The FILENAME~2, etc., doesn't work if there are more than one file with the same name. But I can make sure that won't come up too often. It looks like the really important stuff is good. Thanks!

Re: Preview: cbmshell, an interactive file processor

Posted: Mon Aug 16, 2021 12:20 am
by srowe
chysn wrote: Sun Aug 15, 2021 3:15 pm The FILENAME~2, etc., doesn't work if there are more than one file with the same name.
Can you give an example?

Code: Select all

(venv) [srowe@gilraen python-cbmshell (master)]$ rm -f new.tap ; cbm-shell 'attach new.tap' 
Attached new.tap to 0
(cbm) copy short.prg 0:FILE
Copying short.prg to ImagePath(0:b'FILE')
(cbm) copy short.prg 0:FILE
Copying short.prg to ImagePath(0:b'FILE')
(cbm) copy short.prg 0:FILE~2
Copying short.prg to ImagePath(0:b'FILE')
(cbm) copy long.prg 0:FILE
Copying long.prg to ImagePath(0:b'FILE')
(cbm) $
0 <TAP image>
1    "FILE"             PRG
1    "FILE"             PRG
1    "FILE"             PRG
19   "FILE"             PRG

Code: Select all

(cbm) $
0 <TAP image>
1    "FILE"             PRG
1    "FILE"             PRG
1    "FILE"             PRG
19   "FILE"             PRG
(cbm) list 0:FILE~2 | wc -l
1
(cbm) list 0:FILE~3 | wc -l
100

Re: Preview: cbmshell, an interactive file processor

Posted: Mon Aug 16, 2021 5:51 am
by chysn
UPDATE: I had an aha moment, please see the post after the next

Huh. Here's what I'm trying to do:

Code: Select all

(cbm) attach zeptopolis.tap
Attached zeptopolis.tap to 0
(cbm) $
0 <TAP image>
3    "2068"             PRG_RELOC
3    "2068"             PRG_RELOC
3    "2069"             PRG_RELOC
3    "2070"             PRG_RELOC
3    "2070"             PRG
(cbm) copy 0:2069 2069
Copying ImagePath(0:b'2069') to 2069
(cbm) copy 0:2070~1 2070.1
Copying ImagePath(0:b'2070') to 2070.1
(cbm) copy 0:2070~2 2070.2
EXCEPTION of type 'FileNotFoundError' occurred with message: File not found: b'2070~2'
To enable full traceback, run the following command: 'set debug true'
(cbm) list 0:2070~2
File not found, ImagePath(0:b'2070')
(cbm) list 0:2068~2
File not found, ImagePath(0:b'2068')
(cbm) list 0:2068~1
$1e00:  10 11 12 13 14 15 21 21 21 21 21 21 21 21 16 17
$1e10:  18 19 1a 1b 1c 1d 3a 36 34 21 21 21 3b 32 33 39
    * * * etc. * * *
$1fe0:  20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
$1ff0:  20 20 20 20 20 20 20 06 ff 00 14 08 ef 00 0b 09
(cbm) quit
JEJ:tap jasonjustian$ pip3 show cbmshell
Name: cbmshell
Version: 1.7
Summary: Interactive shell to manipulate Commodore files
Home-page: https://eden.mose.org.uk/gitweb/?p=python-cbmshell.git
Author: Simon Rowe
Author-email: srowe@mose.org.uk
License: UNKNOWN
Location: /Library/Python/3.8/site-packages
Requires: cbmfiles, d64, cbmcodecs2, cmd2, t64, tapfile
Required-by: 

Re: Preview: cbmshell, an interactive file processor

Posted: Mon Aug 16, 2021 5:57 am
by chysn
I think I misunderstood how it works.

FILE is the first, FILE~1 is the second, FILE~2 is the third, etc. I thought FILE~1 was the first. I think it's good!

Re: Preview: cbmshell, an interactive file processor

Posted: Mon Aug 16, 2021 6:23 am
by srowe
Correct, it sort of makes sense I think. It's slightly different with the empty filename handling where the first instance is ~, the second ~1 etc.

https://cbmshell.readthedocs.io/en/late ... fname.html

Re: Preview: cbmshell, an interactive file processor

Posted: Mon Aug 16, 2021 8:25 am
by chysn
srowe wrote: Mon Aug 16, 2021 6:23 am Correct, it sort of makes sense I think. It's slightly different with the empty filename handling where the first instance is ~, the second ~1 etc.
Again, I appreciate your responsiveness on this. cbmshell is an excellent resource, and it's become an important part of my scripted build process.

Re: Preview: cbmshell, an interactive file processor

Posted: Mon Aug 16, 2021 10:57 am
by srowe
chysn wrote: Mon Aug 16, 2021 8:25 am Again, I appreciate your responsiveness on this. cbmshell is an excellent resource, and it's become an important part of my scripted build process.
Glad it's proving useful, the whole purpose of it was to remove the need for messy scripts joining together the existing tools.

Re: Preview: cbmshell, an interactive file processor

Posted: Fri Aug 27, 2021 9:16 pm
by mathom
I am probably missing something obvious here, but is there a way to create a new disk image with this?