Skip to content

Commit

Permalink
Change the 3*32 -> 64bit in Python bindings
Browse files Browse the repository at this point in the history
This gets rid of splitInt(), joinInt() and the SplitInt class

Refs #6256
  • Loading branch information
Beirdo committed May 27, 2011
1 parent 1508085 commit c7de5d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 33 deletions.
3 changes: 1 addition & 2 deletions mythtv/bindings/python/MythTV/methodheap.py
Expand Up @@ -256,8 +256,7 @@ def getFreeSpaceSummary(self):
"""
res = [int(r) for r in self.backendCommand('QUERY_FREE_SPACE_SUMMARY')\
.split(BACKEND_SEP)]
return (self.joinInt(res[0],res[1]),
self.joinInt(res[2],res[3]))
return (res[0], res[1])

def getLoad(self):
"""
Expand Down
28 changes: 9 additions & 19 deletions mythtv/bindings/python/MythTV/mythproto.py
Expand Up @@ -11,7 +11,7 @@
from altdict import DictData
from connections import BEConnection, BEEventConnection
from database import DBCache
from utility import SplitInt, CMPRecord, datetime, \
from utility import CMPRecord, datetime, \
ParseEnum, CopyData, CopyData2, check_ipv6

from datetime import date
Expand All @@ -24,7 +24,7 @@
import re
import os

class BECache( SplitInt ):
class BECache( object ):
"""
BECache(backend=None, noshutdown=False, db=None)
-> MythBackend connection object
Expand All @@ -40,10 +40,6 @@ class BECache( SplitInt ):
automatic shutdown while the connection is alive.
Available methods:
joinInt() - convert two signed ints to one 64-bit
signed int
splitInt() - convert one 64-bit signed int to two
signed ints
backendCommand() - Sends a formatted command to the backend
and returns the response.
"""
Expand Down Expand Up @@ -337,7 +333,7 @@ def announce(self):
else:
sp = res.split(BACKEND_SEP)
self._sockno = int(sp[1])
self._size = [int(i) for i in sp[2:]]
self._size = int(sp[2])

def __del__(self):
self.socket.shutdown(1)
Expand Down Expand Up @@ -370,7 +366,7 @@ def __init__(self, host, filename, sgroup, mode, db=None):
self.open = True

self._sockno = self.ftsock._sockno
self._size = self.joinInt(*self.ftsock._size)
self._size = self.ftsock._size
self._pos = 0
self._tsize = 2**15
self._tmax = 2**17
Expand Down Expand Up @@ -508,20 +504,17 @@ def seek(self, offset, whence=0):
whence = 0
offset = self._size+offset

curhigh,curlow = self.splitInt(self._pos)
offhigh,offlow = self.splitInt(offset)

res = self.backendCommand('QUERY_FILETRANSFER '\
+BACKEND_SEP.join(
[str(self._sockno),'SEEK',
str(offhigh),str(offlow),
str(offset),
str(whence),
str(curhigh),str(curlow)])\
str(self._pos)])\
).split(BACKEND_SEP)
if res[0] == '-1':
raise MythFileError(MythError.FILE_FAILED_SEEK, \
str(self), offset, whence)
self._pos = self.joinInt(*res)
self._pos = res[0]

def flush(self):
pass
Expand Down Expand Up @@ -742,12 +735,11 @@ def _getSortedPrograms(self, query, recstatus=None, \
return sorted(self._getPrograms(query, recstatus, recordid, header),\
key=lambda p: p.starttime)

class FreeSpace( DictData, SplitInt ):
class FreeSpace( DictData ):
"""Represents a FreeSpace entry."""
_field_order = [ 'host', 'path', 'islocal',
'disknumber', 'sgroupid', 'blocksize',
'ts_high', 'ts_low', 'us_high',
'us_low']
'totalspace', 'usedspace']
_field_type = [3, 3, 2, 0, 0, 0, 0, 0, 0, 0]
def __str__(self):
return "<FreeSpace '%s@%s' at %s>"\
Expand All @@ -758,8 +750,6 @@ def __repr__(self):

def __init__(self, raw):
DictData.__init__(self, raw)
self.totalspace = self.joinInt(self.ts_high, self.ts_low)
self.usedspace = self.joinInt(self.us_high, self.us_low)
self.freespace = self.totalspace - self.usedspace

class Program( DictData, RECSTATUS, AUDIO_PROPS, VIDEO_PROPS, \
Expand Down
12 changes: 0 additions & 12 deletions mythtv/bindings/python/MythTV/utility.py
Expand Up @@ -288,18 +288,6 @@ def buildQuery(self, where, select=None, tfrom=None, joinbit=0):

return sql

class SplitInt( object ):
"""Utility class for handling split integers sent over myth protocol."""
@staticmethod
def joinInt(high,low):
"""obj.joinInt(high, low) -> 64-bit int, from two signed ints"""
return (int(high) + (int(low)<0))*2**32 + int(low)

@staticmethod
def splitInt(dint):
"""obj.joinInt(64-bit int) -> (high, low)"""
return dint/(2**32),dint%2**32 - (dint%2**32 > 2**31)*2**32

class CMPVideo( object ):
"""
Utility class providing comparison operators between data objects
Expand Down

0 comments on commit c7de5d7

Please sign in to comment.