当前位置: 首页>>代码示例>>Python>>正文


Python static.BACKEND_SEP类代码示例

本文整理汇总了Python中MythTV.static.BACKEND_SEP的典型用法代码示例。如果您正苦于以下问题:Python BACKEND_SEP类的具体用法?Python BACKEND_SEP怎么用?Python BACKEND_SEP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BACKEND_SEP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write

 def write(self, data):
     """
     FileTransfer.write(data) -> None
         Requests over 128KB will be buffered internally
     """
     if self.mode != 'w':
         raise MythFileError('attempting to write to a read-only socket')
     while len(data) > 0:
         size = len(data)
         # check size for buffering
         if size > self._tsize:
             size = self._tsize
             buff = data[:size]
             data = data[size:]
         else:
             buff = data
             data = ''
         # push data to server
         self._pos += int(self.ftsock.send(buff))
         if self._pos > self._size:
             self._size = self._pos
         # inform server of new data
         self.backendCommand('QUERY_FILETRANSFER '\
                 +BACKEND_SEP.join(\
                         [str(self._sockno),
                          'WRITE_BLOCK',
                          str(size)]))
     return
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:28,代码来源:mythproto.py

示例2: read

    def read(self, size):
        """
        FileTransfer.read(size) -> string of <size> characters
            Requests over 128KB will be buffered internally.
        """

        # some sanity checking
        if self.mode != 'r':
            raise MythFileError('attempting to read from a write-only socket')
        if size == 0:
            return ''
        if self._pos + size > self._size:
            size = self._size - self._pos

        buff = ''
        while len(buff) < size:
            ct = size - len(buff)
            if ct > self._tsize:
                # drop size and bump counter if over limit
                self._count += 1
                ct = self._tsize

            # request transfer
            res = self.backendCommand('QUERY_FILETRANSFER '\
                        +BACKEND_SEP.join(
                                [str(self._sockno),
                                 'REQUEST_BLOCK',
                                 str(ct)]))

            if res == '':
                # complete failure, hard reset position and retry
                self._count = 0
                self.seek(self._pos)
                continue

            if int(res) == ct:
                if (self._count >= 5) and (self._tsize < self._tmax):
                    # multiple successful transfers, bump transfer limit
                    self._count = 0
                    self._tsize += self._step

            else:
                if int(res) == -1:
                    # complete failure, hard reset position and retry
                    self._count = 0
                    self.seek(self._pos)
                    continue

                # partial failure, reset counter and drop transfer limit
                ct = int(res)
                self._count = 0
                self._tsize -= 2*self._step
                if self._tsize < self._step:
                    self._tsize = self._step

            # append data and move position
            buff += self.ftsock.recv(ct)
            self._pos += ct
        return buff
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:59,代码来源:mythproto.py

示例3: fileExists

 def fileExists(self, file, sgroup='Default'):
     """FileOps.fileExists() -> file path"""
     res = self.backendCommand(BACKEND_SEP.join((\
                 'QUERY_FILE_EXISTS',file,sgroup))).split(BACKEND_SEP)
     if int(res[0]) == 0:
         return None
     else:
         return res[1]
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:8,代码来源:mythproto.py

示例4: deleteRecording

 def deleteRecording(self, program, force=False):
     """
     FileOps.deleteRecording(program, force=False) -> retcode
         'force' will force a delete even if the file cannot be found
         retcode will be -1 on success, -2 on failure
     """
     command = 'DELETE_RECORDING'
     if force:
         command = 'FORCE_DELETE_RECORDING'
     return self.backendCommand(BACKEND_SEP.join(\
                 [command,program.toString()]))
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:11,代码来源:mythproto.py

示例5: undelete_all

def undelete_all(backend, recs):
    """Undeletes all recordings from the dict recs.

    Send an UNDELETE_RECORDING protocol message to the backend and test for
    failure.
    """
    for rec in recs.values():
        print('undelete ' + rec_to_string(rec))
        cmd = BACKEND_SEP.join(['UNDELETE_RECORDING', rec.to_string()])
        res = backend.backendCommand(cmd)
        if int(res) != 0:
            raise MythBEError("undelete failed")
开发者ID:cmcginty,项目名称:mythtv-tools,代码行数:12,代码来源:undelete_recordings.py

示例6: reschedule

 def reschedule(self, recordid=-1, wait=False):
     """FileOps.reschedule() -> None"""
     if wait:
         eventlock = self.allocateEventLock(\
                         re.escape(BACKEND_SEP).join(\
                                 ['BACKEND_MESSAGE',
                                  'SCHEDULE_CHANGE',
                                  'empty']))
     if recordid == 0:
         self.backendCommand(BACKEND_SEP.join(\
             ['RESCHEDULE_RECORDINGS',
              'CHECK 0 0 0 Python',
              '', '', '', '**any**']))
     else:
         if recordid == -1:
             recordid = 0
         self.backendCommand(BACKEND_SEP.join(\
             ['RESCHEDULE_RECORDINGS',
              'MATCH ' + str(recordid) + ' 0 0 - Python']))
     if wait:
         eventlock.wait()
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:21,代码来源:mythproto.py

示例7: announce

        def announce(self):
            if self.mode == 'r':
                cmd = 'ANN FileTransfer %s 0 0 2000'
            elif self.mode == 'w':
                cmd = 'ANN FileTransfer %s 1'

            res = self.backendCommand(
                    BACKEND_SEP.join([cmd % self.localname,
                                      self.filename,
                                      self.sgroup]))
            if res.split(BACKEND_SEP)[0] != 'OK':
                raise MythBEError(MythError.PROTO_ANNOUNCE,
                                  self.host, self.port, res)
            else:
                sp = res.split(BACKEND_SEP)
                self._sockno = int(sp[1])
                self._size = int(sp[2])
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:17,代码来源:mythproto.py

示例8: downloadTo

 def downloadTo(self, url, storagegroup, filename, \
                      forceremote=False, openfile=False):
     if openfile:
         eventlock = self.allocateEventLock(\
                 re.escape(BACKEND_SEP).\
                         join(['BACKEND_MESSAGE',
                               'DOWNLOAD_FILE UPDATE',
                               re.escape(url)]))
     if filename[0] != '/':
         filename = '/'+filename
     res = self.backendCommand(BACKEND_SEP.join((\
                 'DOWNLOAD_FILE', url, storagegroup, filename))).\
                 split(BACKEND_SEP)
     if res[0] != 'OK':
         raise MythBEError('Download failed')
     if openfile:
         eventlock.wait()
         return ftopen(res[1], 'r', forceremote, db=self.db, download=True)
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:18,代码来源:mythproto.py

示例9: seek

    def seek(self, offset, whence=0):
        """
        FileTransfer.seek(offset, whence=0) -> None
            Seek 'offset' number of bytes
            whence == 0 - from start of file
                      1 - from current position
                      2 - from end of file
        """
        if whence == 0:
            if offset < 0:
                offset = 0
            elif offset > self._size:
                offset = self._size
        elif whence == 1:
            if offset + self._pos < 0:
                offset = -self._pos
            elif offset + self._pos > self._size:
                offset = self._size - self._pos
        elif whence == 2:
            if offset > 0:
                offset = 0
            elif offset < -self._size:
                offset = -self._size
            whence = 0
            offset = self._size+offset

        res = self.backendCommand('QUERY_FILETRANSFER '\
                +BACKEND_SEP.join(
                        [str(self._sockno),'SEEK',
                         str(offset),
                         str(whence),
                         str(self._pos)])\
                 ).split(BACKEND_SEP)
        if res[0] == '-1':
            raise MythFileError(MythError.FILE_FAILED_SEEK, \
                                    str(self), offset, whence)
        self._pos = int(res[0])
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:37,代码来源:mythproto.py

示例10: toString

 def toString(self):
     """
     Program.toString() -> string representation
                 for use with backend protocol commands
     """
     return BACKEND_SEP.join(self._deprocess())
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:6,代码来源:mythproto.py

示例11: getHash

 def getHash(self, file, sgroup, host=None):
     """FileOps.getHash(file, storagegroup, host) -> hash string"""
     m = ['QUERY_FILE_HASH', file, sgroup]
     if host:
         m.append(host)
     return self.backendCommand(BACKEND_SEP.join(m))
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:6,代码来源:mythproto.py

示例12: deleteFile

 def deleteFile(self, file, sgroup):
     """FileOps.deleteFile(file, storagegroup) -> retcode"""
     return self.backendCommand(BACKEND_SEP.join(\
                 ['DELETE_FILE',file,sgroup]))
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:4,代码来源:mythproto.py

示例13: stopRecording

 def stopRecording(self, program):
     """FileOps.stopRecording(program) -> None"""
     self.backendCommand(BACKEND_SEP.join(['STOP_RECORDING',
                 program.toString()]))
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:4,代码来源:mythproto.py

示例14: forgetRecording

 def forgetRecording(self, program):
     """FileOps.forgetRecording(program) -> None"""
     self.backendCommand(BACKEND_SEP.join(['FORGET_RECORDING',
                 program.toString()]))
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:4,代码来源:mythproto.py

示例15: __del__

 def __del__(self):
     self.backendCommand('QUERY_FILETRANSFER '+BACKEND_SEP.join(
                                     [str(self._sockno), 'DONE']))
     del self.ftsock
     self.open = False
开发者ID:Beirdo,项目名称:mythtv-stabilize,代码行数:5,代码来源:mythproto.py


注:本文中的MythTV.static.BACKEND_SEP类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。