Preview: cbmshell, an interactive file processor

You need an actual VIC.

Moderator: Moderators

User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Preview: cbmshell, an interactive file processor

Post 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?
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Preview: cbmshell, an interactive file processor

Post 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.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5

WIP: MIDIcast BASIC extension

he/him/his
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Preview: cbmshell, an interactive file processor

Post 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.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Preview: cbmshell, an interactive file processor

Post 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'
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Preview: cbmshell, an interactive file processor

Post 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.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Preview: cbmshell, an interactive file processor

Post 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: 
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Preview: cbmshell, an interactive file processor

Post 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.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Preview: cbmshell, an interactive file processor

Post 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!
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Preview: cbmshell, an interactive file processor

Post 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
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Preview: cbmshell, an interactive file processor

Post 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: 
Last edited by chysn on Mon Aug 16, 2021 6:21 am, edited 1 time in total.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Preview: cbmshell, an interactive file processor

Post 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!
Last edited by chysn on Mon Aug 16, 2021 6:23 am, edited 3 times in total.
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Preview: cbmshell, an interactive file processor

Post 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
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Preview: cbmshell, an interactive file processor

Post 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.
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Preview: cbmshell, an interactive file processor

Post 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.
User avatar
mathom
Vic 20 Dabbler
Posts: 80
Joined: Wed Aug 07, 2019 11:37 am
Location: Centennial, Colorado
Occupation: Software Engineer

Re: Preview: cbmshell, an interactive file processor

Post by mathom »

I am probably missing something obvious here, but is there a way to create a new disk image with this?
...mathom...
Post Reply