Ticket #7687: 7687.patch
File 7687.patch, 3.2 KB (added by , 14 years ago) |
---|
-
setup.py
4 4 5 5 setup( 6 6 name='MythTV', 7 version='0.2 1',7 version='0.22', 8 8 description='MythTV Python bindings.', 9 9 packages=['MythTV'], 10 10 ) -
MythTV/MythTV.py
285 285 """ 286 286 Returns a Program object for the current recorders recording. 287 287 """ 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'])) 289 289 return Program(res.split(BACKEND_SEP)) 290 290 291 291 def isRecording(self, recorder): 292 292 """ 293 293 Returns a boolean as to whether the given recorder is recording. 294 294 """ 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'])) 296 296 if res == '1': 297 297 return True 298 298 else: … … 526 526 write = False 527 527 528 528 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}') 530 531 self.db = MythDB(sys.argv[1:]) 531 532 self.comsock = MythTV() 532 533 self.mode = mode … … 540 541 if isinstance(file, Program): 541 542 match = regex.match(file.filename) 542 543 self.host = match.group('host') 543 self.port = int(match.group('port'))544 544 self.filename = match.group('file') 545 545 self.sgroup = file.storagegroup 546 546 if self.port is None: … … 551 551 sys.exit(1) 552 552 else: 553 553 self.host = file[0] 554 self.port = int(self.db.getSetting('BackendServerPort',self.host))555 554 self.filename = file[1] 556 555 self.sgroup = file[2] 557 556 elif isinstance(file, str): … … 561 560 sys.exit(1) 562 561 self.sgroup = match.group('group') 563 562 self.host = match.group('host') 564 self.port = int(match.group('port'))565 563 self.filename = match.group('file') 566 564 if self.sgroup is None: 567 self.sgroup = '' 568 if self.port is None: 569 self.port = 6543 565 self.sgroup = 'Default' 570 566 else: 571 567 log.Msg(CRITICAL, 'Improper input to FileTransfer()') 572 568 sys.exit(1) 573 569 570 if reip.match(self.host): 571 self.host = socket.gethostbyaddr(self.host) 572 self.port = int(self.db.getSetting('BackendServerPort',self.host)) 573 574 574 try: 575 575 self.datsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 576 576 self.datsock.settimeout(10) … … 579 579 if res[0] == 'REJECT': 580 580 log.Msg(CRITICAL, 'Backend has version %s and we speak version %s', res[1], PROTO_VERSION) 581 581 sys.exit(1) 582 res = self.send('ANN FileTransfer %s %d %d %s' % (socket.gethost byname(),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]))) 583 583 if res.split(BACKEND_SEP)[0] != 'OK': 584 584 log.Msg(CRITICAL, 'Unexpected answer to ANN command: %s', res) 585 585 else: