TpddTool

Tpdd Tool
The comand line tool that use the Tpdd class

TpddTool.py Copyright 2016 - Gary Hammond email gfhammond@gmail.com

Python command line tool for the Tandy TPDD and TPDD2 external floppy disk drives.

The available commands are:

  • copy <source> <dest> - copy file from <source> to <dest>
  • copydir <source> <dest> - copy directory to/from disk
  • del <file> - delete file on disk
  • dir <bank|dirspec> - listing of disk bank (0:|1:) or local directory
  • format - format disk
  • help or ? - displays this help information
  • ren <from file> <to file> - renames file <from> to <to>
  • status - drive status
  • type <file> - prints the contents of a file
  • q or x - quit/exit

Notes:

  • Note 1: It is assumed that you know what you are doing. There are no warnings or prompts! Formatting a disk does precisely that without a prompt.
  • Note 2: Use the prefix 0: or 1: to specify a file on the TPDD disk for disk file commands. e.g. “0:hello.do”. Filenames without the prefix will be considered to be on the local file system.
  • Note 3: The linux equivalent cat, cp, rm, ls, mv can be used in the place of type, copy, del, dir and ren respectively. cpd can be used in place of copydir.
  • Note 4: There is no wildcard support.
param comport:The com port that the TPDD is connected to.
TpddTool.copy_command(dd, in_filename, out_filename)[source]

Copy the contents of the in file to out file or prints an error message.

Parameters:
  • dd – The TPDD object.
  • in_filename – The file to read from.
  • out_filename – The file to write to.
TpddTool.copydir_command(dd, source, destination)[source]

Copy the contents of the files in the directory/disk to the out directory/disk or prints an error message.

Parameters:
  • dd – The TPDD object.
  • source – The directory/disk to read from.
  • destination – The directory/disk to write to.
TpddTool.del_command(dd, filename)[source]

Deletes the file specified from the TPDD disk. This command does not work on the local filesystem.

Parameters:
  • dd – The TPDD object.
  • filename – The file to be deleted.
TpddTool.dir_command(dd, dirspec='.')[source]

Prints a listing of the host directory or the TPDD bank if specified.

Parameters:
  • dd – The TPDD object.
  • dirspec – (optional) The directory to list. The default is the local host directory.
TpddTool.format_command(dd)[source]

Formats the disk bank in the TPDD. Prints error message on failure.

Parameters:dd – The TPDD object.
TpddTool.get_dir(dd, dirspec, size=True)[source]

gets a list of the files of the host directory or the TPDD bank if specified.

Parameters:
  • dd – The TPDD object.
  • dirspec – The directory to list. The default is the local host directory.
  • size – (Optional) Used to include file sizes and bytes free in listing. Default is True.
Returns:

A list of directory entries. The TPDD list includes the bytes free entry as the last entry.

TpddTool.help_command()[source]

Prints the hlep information for TpddTool.

TpddTool.process_command(dd, cmd_param, token_count)[source]

Process commands typed in at the ‘Tpdd-Tool>’ prompt.

Parameters:
  • dd – The TPDD object.
  • cmd_param – List containing command and options (if any).
  • token_count – Number of items in the ‘cmd_param’ list.
TpddTool.read_file(filename)[source]

Reads the contents of a local file.

Parameters:filename – The name of the file to read from.
Returns:The data as read from the file if successful, otherwise an empty string.
TpddTool.ren_command(dd, old_filename, new_filename)[source]

Function not implemented. ToDo.

TpddTool.status_command(dd)[source]

Returns the status of the TPDD as a text message.

Parameters:dd – The TPDD object.
TpddTool.type_command(dd, filename)[source]

Prints the contents of the file specified to stdout or prints an error message.

Parameters:
  • dd – The TPDD object.
  • filename – The file on the disk to read.
TpddTool.write_file(filename, data)[source]

Writes data to a local file.

Parameters:
  • filename – The name of the file to write to.
  • data – The data to write to the file.
Returns:

True if successful, otherwise False.