Opened 15 years ago

Closed 15 years ago

#6678 closed enhancement (fixed)

Additional functions for Python bindings

Reported by: Raymond Wagner <raymond@…> Owned by: Anduin Withers
Priority: minor Milestone: 0.22
Component: Bindings - Python Version: head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

MythDB.setSetting(value, data, hostname=None):

Counter function to the existing MythDB.getSetting(). Will create new entry if setting does not already exist.

MythDB.getCast(chanid, starttime, roles=None):

Takes channel id and start time as integers, with an optional 'roles' to search for. With no 'roles', will return a dictionary of tuples indexed by role. When given a single string or tuple of strings, will return a tuple of all cast members matching those roles.

MythTV.getRecording(chanid, starttime):

Takes channel id and start time as integers, and implements 'QUERY_RECORDING TIMESLOT'. Will return a Program object.

MythTV.getRecordings():

Implements 'QUERY_RECORDINGS' and returns a list of Program objects.

MythTV.getCheckfile(program):

Takes a Program object and implements 'QUERY_CHECKFILE', returning the location of a recording in the file system. This currently includes a bugfix where the command requires an additional two separators.

Program.toString():

Implements a 'toString' function to revert a Program object back to a string format usable by MythProto? command calls.

Attachments (12)

pyth.update.patch (6.6 KB) - added by Raymond Wagner <raymond@…> 15 years ago.
pyth.update2.patch (8.9 KB) - added by Raymond Wagner <raymond@…> 15 years ago.
pyth.update3.patch (8.7 KB) - added by Raymond Wagner <raymond@…> 15 years ago.
pyth.update4.patch (8.7 KB) - added by Raymond Wagner <raymond@…> 15 years ago.
pyth.update5.patch (13.3 KB) - added by Raymond Wagner <raymond@…> 15 years ago.
pyth.update6.patch (13.7 KB) - added by Raymond Wagner <raymond@…> 15 years ago.
pyth.update7.patch (18.9 KB) - added by Raymond Wagner <raymond@…> 15 years ago.
pyth.update8.patch (21.9 KB) - added by Raymond Wagner <raymond@…> 15 years ago.
pyth.update9.patch (23.6 KB) - added by Raymond Wagner <raymond@…> 15 years ago.
pyth.update10.patch (26.0 KB) - added by Raymond Wagner <raymond@…> 15 years ago.
pyth.update11.patch (26.1 KB) - added by Raymond Wagner <raymond@…> 15 years ago.
pyth.update12.patch (26.0 KB) - added by Raymond Wagner <raymond@…> 15 years ago.

Download all attachments as: .zip

Change History (23)

Changed 15 years ago by Raymond Wagner <raymond@…>

Attachment: pyth.update.patch added

comment:1 Changed 15 years ago by Raymond Wagner <raymond@…>

Added Job class to MythTV.MythDB for dealing with user jobs written in python

Job() takes two input options Job(jobid) or Job(chanid,starttime)

Job.setComment(comment) Job.setStatus(status)

Changed 15 years ago by Raymond Wagner <raymond@…>

Attachment: pyth.update2.patch added

comment:2 Changed 15 years ago by Raymond Wagner <raymond@…>

Ignore pyth.update2.patch

Also adds MythTV.Program.filesize as a processed long of fs_low and fs_high Properly fixes issue with getCheckfile and Program string

Changed 15 years ago by Raymond Wagner <raymond@…>

Attachment: pyth.update3.patch added

comment:3 Changed 15 years ago by Raymond Wagner <raymond@…>

pyth.update4.patch is a small fix for an improper call of QUERY_RECORDINGS

Changed 15 years ago by Raymond Wagner <raymond@…>

Attachment: pyth.update4.patch added

comment:4 Changed 15 years ago by Raymond Wagner <raymond@…>

MythTV.getRecordings() is now properly fixed, rather than functioning through chance.

Frontend socket access is now part of MythTV

MythTV.getFrontends():

Returns a list of Frontend objects for accessible frontends

MythTV.getFrontend(hostname):

Returns a Frontend object for the specified host

Frontend(hostname, port):

Returns a Frontend object, throws an exception if cannot connect to frontend

Frontend.getJump():

Returns a tuple containing available jumppoints

Frontend.sendJump(jumppoint):

Sends jumppoint to frontend

Frontend.getKey():

Returns a tuple containing available special keys

Frontend.sendKey():

Sends keycode to connected frontend

Frontend.getQuery():

Returns a tuple containing available queries

Frontend.sendQuery():

Returns query from connected frontend

Frontend.getPlay():

Returns a tuple containing available playback commands

Frontend.sendPlay():

Send playback command to connected frontend

Changed 15 years ago by Raymond Wagner <raymond@…>

Attachment: pyth.update5.patch added

comment:5 Changed 15 years ago by Raymond Wagner <raymond@…>

Patch 6 may return proper UTF-8 text from mythproto calls, or it may just return unicode strings full of garbled ASCII.

Changed 15 years ago by Raymond Wagner <raymond@…>

Attachment: pyth.update6.patch added

comment:6 Changed 15 years ago by Raymond Wagner <raymond@…>

Patch 7 adds a minor tweek to the UTF-8 support from R.D.Vaughan. It also adds the FileTransfer? class.

MythTV.FileTransfer?(file[,parent]):

'file' can take the form of a Program object, or a tuple containing (backend, filename, storagegroup)

filename is a relative path from the storagegroup base, starting with a '/'

'parent' is an optional command object (MythTV.MythTV()). If none is given, it will open a new one internally to use

The class uses the standard file i/o functions:

FileTransfer?.close()
FileTransfer?.tell()
FileTransfer?.read(byte count)

This currently pulls up to 64KB at a time, but will buffer an unlimited amount of bytes before returning the data. Don't go overboard here, because python will be buffering this in memory.

FileTransfer?.rewind()
FileTransfer?.seek(byte offset[,whence])

'whence' is an optional integer where 0 seeks absolute from file start, and 1 seeks relative from the current position. Default behavior is 0 (absolute).

Changed 15 years ago by Raymond Wagner <raymond@…>

Attachment: pyth.update7.patch added

comment:7 Changed 15 years ago by Raymond Wagner <raymond@…>

Patch 8 updates MythDB to pull database information from config.xml instead of the old mysql.txt. The correct way to do this would be to include failover to UPnP auto-detection of the backend, however there are no bare UPnP libraries available for python. I'll probably end up porting auto-discovery code from the Perl Net::UPNP::ControlPoint? module.

Changed 15 years ago by Raymond Wagner <raymond@…>

Attachment: pyth.update8.patch added

Changed 15 years ago by Raymond Wagner <raymond@…>

Attachment: pyth.update9.patch added

comment:8 Changed 15 years ago by Raymond Wagner <raymond@…>

Patch 9 updates the MythDB.py changes to changeset [21052].

Also adds the following functions to MythTV.py MythTV.deleteRecording(program,force=False)

deletes recording defined by program instance force will force mythtv to delete metadata even if recording file is not found

MythTV.forgetRecording(program)

allows recording defined by program instance to be re-recorded

MythTV.getFreeSpace(all=False)

returns a tuple of information about storage devices on the local system all returns information about all systems, and a summary line

MythTV.getFreeSpaceSummary()

returns summary information of all available storage devices

MythTV.getLoad()

returns standard 1/5/15 load averages

comment:9 Changed 15 years ago by Raymond Wagner <raymond@…>

That would be changeset [21051].

Changed 15 years ago by Raymond Wagner <raymond@…>

Attachment: pyth.update10.patch added

Changed 15 years ago by Raymond Wagner <raymond@…>

Attachment: pyth.update11.patch added

Changed 15 years ago by Raymond Wagner <raymond@…>

Attachment: pyth.update12.patch added

comment:10 Changed 15 years ago by Raymond Wagner <raymond@…>

Patches 10 and 11 illustrate that I need to start reviewing code before uploading it.

Patch 12 updates the FileTransfer? class. The class now requires two inputs, file and mode. The 'file' input still takes the existing Program or Tuple inputs, however can now understand the standard 'myth://group@host:port/path/to/file.ext' format, with group and port optional. The 'mode' input takes 'r' or 'w'.

Also added is the MythTV.deleteFile(file,group) routine.

comment:11 Changed 15 years ago by Rob Smith

Resolution: fixed
Status: newclosed

(In [21191]) Fixes #6678, this adds in python binding improvements from wagnerp

Note: See TracTickets for help on using tickets.