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

Preview: cbmshell, an interactive file processor

Post by srowe »

I've been developing a general-purpose utility called cbmshell that allows you to manipulate files within disk images. Think of it as a combination of c1541 and petcat but much more open-ended.

It's written in Python so should run on any platform, available from PyPI

https://pypi.org/project/cbmshell/

Documentation available here:

https://cbmshell.readthedocs.io/en/latest/

It's currently alpha quality, please back up any valuable image before trying it out. I plan to keep extending it, next feature will be to also support tape images.

Feedback welcome.

[edit: readthedocs link now live]
Last edited by srowe on Mon Mar 22, 2021 8:50 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 might not have a sufficient Python version, but I'll check it out if I can.

macOS Big Sur has 2.7.16, which seems new enough as far as 2.7 goes, but maybe not new enough for pip. But I'm no Python expert, so I'm not sure.
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: Sun Mar 21, 2021 4:45 pm I might not have a sufficient Python version, but I'll check it out if I can.

macOS Big Sur has 2.7.16, which seems new enough as far as 2.7 goes, but maybe not new enough for pip. But I'm no Python expert, so I'm not sure.
I should have said it requires Python3, Looks like Big Sur includes both Python 2&3.

https://apple.stackexchange.com/questio ... n-for-good

I'd appreciate the feedback if it does work on MacOS.
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 »

Latest version now has support for .tap images in read-only mode. You can copy from tape images to disk images and/or the local filesystem.
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 »

I've been steadily adding features and fixing bugs to the point I'm going to declare it "Done" (i.e. it satisfies all my needs). It now supports read/write to all disk formats that I'm aware of (except GEOS), read/write to .tap files and read only of T64 and PC64 files.

I'm still open to suggestions for improvements.
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 »

make ran successfully under Big Sur. I had to do

Code: Select all

sudo -H make
to avoid macOS complaining about directory privileges.

On the first invocation of cbm-shell, it advised that I needed to install gnureadline, which I was able to do with

Code: Select all

sudo pip3 install gnureadline
And now, when I invoke cbm-shell:

Code: Select all

$ cbm-shell
Traceback (most recent call last):
  File "/usr/local/bin/cbm-shell", line 6, in <module>
    from cbm_shell.scripts.cbm_shell import main
  File "/Library/Python/3.8/site-packages/cbm_shell/scripts/cbm_shell.py", line 10, in <module>
    from cmd2.utils import basic_complete
ImportError: cannot import name 'basic_complete' from 'cmd2.utils' (/Library/Python/3.8/site-packages/cmd2/utils.py)
My Python 3 version is 3.8.2. Am I missing another dependency?
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 Jul 03, 2021 6:59 pm My Python 3 version is 3.8.2. Am I missing another dependency?
No, I think it's a compatibility issue with the latest version of the cmd2 module (not one of mine). As a work around for now try

Code: Select all

pip3 install --upgrade 'cmd2<2'
I'll look to fix this properly.

[Edit] Rather than installing this as root (and potentially messing something up) try using a virtualenv. They isolate package installation away from the system.
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 »

I've fixed the compatibility issues and released a new version (1.3) that should work with either versions of cmd2.
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 »

Yes! I've got a prompt! I'll be playing around with this tomorrow. I've got a stupid Independence Day party to go to today.

Okay, it's not stupid, it's with my wife's friends. But it would be rude to bring my Mac along.

Thank you!
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 »

Is there a way to take a standalone PRG file and put it into a newly-created TAP image?
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 Jul 04, 2021 10:06 am Is there a way to take a standalone PRG file and put it into a newly-created TAP image?
Hum, I thought I'd tested just that but there's a glitch working with an empty TAP file. Just repeat the copy command for now

Code: Select all

(venv) [srowe@gilraen Downloads]$ cbm-shell 
(cbm) attach new.tap
Attached new.tap to 0
(cbm) copy dungeon.prg 0:DUNGEON
EXCEPTION of type 'FileNotFoundError' occurred with message: [Errno 2] No such file or directory: 'new.tap'
To enable full traceback, run the following command: 'set debug true'
(cbm) copy dungeon.prg 0:DUNGEON
Copying dungeon.prg to ImagePath(0:b'DUNGEON')
(cbm) $
0 <TAP image>
15   "DUNGEON"          PRG
(cbm) quit
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 Jul 04, 2021 12:56 pm Hum, I thought I'd tested just that but there's a glitch working with an empty TAP file. Just repeat the copy command for now
Yep, that's the exception I was getting, and the second copy works as expected. Thanks again, this is awesome!

Enormous-ass feature request: A built-in disassembler to complement list!
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 Jul 04, 2021 10:15 pm Enormous-ass feature request: A built-in disassembler to complement list!
I hadn't thought of that but it would be straightforward enough to do. The main limitation would be handling blocks of embedded data, but that's the same as any simple disassembler.
Vic20-Ian
Vic 20 Scientist
Posts: 1214
Joined: Sun Aug 24, 2008 1:58 pm

Re: Preview: cbmshell, an interactive file processor

Post by Vic20-Ian »

Great idea. Will you enter it into the Vic20 things we want to see / hear competition too? Closes November 30th.
Vic20-Ian

The best things in life are Vic-20

Upgrade all new gadgets and mobiles to 3583 Bytes Free today! Ready
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 Jul 05, 2021 1:20 am
chysn wrote: Sun Jul 04, 2021 10:15 pm Enormous-ass feature request: A built-in disassembler to complement list!
I hadn't thought of that but it would be straightforward enough to do. The main limitation would be handling blocks of embedded data, but that's the same as any simple disassembler.
I was going to amend my request to "If I were to write a 6502 disassembler in Python 3, could you integrate it?'

And, yeah, data's always going to be an issue. That's the way it goes.
Post Reply