Ticket #7687: 7687.patch

File 7687.patch, 3.2 KB (added by Raymond Wagner <raymond@…>, 14 years ago)
  • setup.py

     
    44
    55setup(
    66                name='MythTV',
    7                 version='0.21',
     7                version='0.22',
    88                description='MythTV Python bindings.',
    99                packages=['MythTV'],
    1010                )
  • MythTV/MythTV.py

     
    285285                """
    286286                Returns a Program object for the current recorders recording.
    287287                """
    288                 res = self.backendCommand('QUERY_RECORDER '+BACKEND_SEP.join([recorder,'GET_CURRENT_RECORDING']))
     288                res = self.backendCommand('QUERY_RECORDER '+BACKEND_SEP.join([str(recorder),'GET_CURRENT_RECORDING']))
    289289                return Program(res.split(BACKEND_SEP))
    290290
    291291        def isRecording(self, recorder):
    292292                """
    293293                Returns a boolean as to whether the given recorder is recording.
    294294                """
    295                 res = self.backendCommand('QUERY_RECORDER '+BACKEND_SEP.join([recorder,'IS_RECORDING']))
     295                res = self.backendCommand('QUERY_RECORDER '+BACKEND_SEP.join([str(recorder),'IS_RECORDING']))
    296296                if res == '1':
    297297                        return True
    298298                else:
     
    526526        write = False
    527527
    528528        def __init__(self, file, mode):
    529                 regex = re.compile('myth://((?P<group>.*)@)?(?P<host>[0-9\.]*)(:(?P<port>[0-9]*))?/(?P<file>.*)')
     529                regex = re.compile('myth://((?P<group>.*)@)?(?P<host>[a-zA-Z-_0-9\.]*)(:(?P<port>[0-9]*))?/(?P<file>.*)')
     530                reip = re.compile('(?:\d{1,3}\.){3}\d{1,3}')
    530531                self.db = MythDB(sys.argv[1:])
    531532                self.comsock = MythTV()
    532533                self.mode = mode
     
    540541                if isinstance(file, Program):
    541542                        match = regex.match(file.filename)
    542543                        self.host = match.group('host')
    543                         self.port = int(match.group('port'))
    544544                        self.filename = match.group('file')
    545545                        self.sgroup = file.storagegroup
    546546                        if self.port is None:
     
    551551                                sys.exit(1)
    552552                        else:
    553553                                self.host = file[0]
    554                                 self.port = int(self.db.getSetting('BackendServerPort',self.host))
    555554                                self.filename = file[1]
    556555                                self.sgroup = file[2]
    557556                elif isinstance(file, str):
     
    561560                                sys.exit(1)
    562561                        self.sgroup = match.group('group')
    563562                        self.host = match.group('host')
    564                         self.port = int(match.group('port'))
    565563                        self.filename = match.group('file')
    566564                        if self.sgroup is None:
    567                                 self.sgroup = ''
    568                         if self.port is None:
    569                                 self.port = 6543
     565                                self.sgroup = 'Default'
    570566                else:
    571567                        log.Msg(CRITICAL, 'Improper input to FileTransfer()')
    572568                        sys.exit(1)
    573569
     570                if reip.match(self.host):
     571                        self.host = socket.gethostbyaddr(self.host)
     572                self.port = int(self.db.getSetting('BackendServerPort',self.host))
     573
    574574                try:
    575575                        self.datsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    576576                        self.datsock.settimeout(10)
     
    579579                        if res[0] == 'REJECT':
    580580                                log.Msg(CRITICAL, 'Backend has version %s and we speak version %s', res[1], PROTO_VERSION)
    581581                                sys.exit(1)
    582                         res = self.send('ANN FileTransfer %s %d %d %s' % (socket.gethostbyname(),write, False, BACKEND_SEP.join(['-1',self.filename,self.sgroup])))
     582                        res = self.send('ANN FileTransfer %s %d %d %s' % (socket.gethostname(),write, False, BACKEND_SEP.join(['-1',self.filename,self.sgroup])))
    583583                        if res.split(BACKEND_SEP)[0] != 'OK':
    584584                                log.Msg(CRITICAL, 'Unexpected answer to ANN command: %s', res)
    585585                        else: