本文整理汇总了Python中static.BACKEND_SEP类的典型用法代码示例。如果您正苦于以下问题:Python BACKEND_SEP类的具体用法?Python BACKEND_SEP怎么用?Python BACKEND_SEP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BACKEND_SEP类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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:Openivo,项目名称:mythtv,代码行数:7,代码来源:mythproto.py
示例2: 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:camdbug,项目名称:mythtv,代码行数:28,代码来源:mythproto.py
示例3: 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:Openivo,项目名称:mythtv,代码行数:33,代码来源:mythproto.py
示例4: 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:camdbug,项目名称:mythtv,代码行数:59,代码来源:mythproto.py
示例5: 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:Openivo,项目名称:mythtv,代码行数:10,代码来源:mythproto.py
示例6: 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:Openivo,项目名称:mythtv,代码行数:13,代码来源: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:Openivo,项目名称:mythtv,代码行数:13,代码来源:mythproto.py
示例8: 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(i) for i in sp[2:]]
开发者ID:DocOnDev,项目名称:mythtv,代码行数:17,代码来源:mythproto.py
示例9: 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:camdbug,项目名称:mythtv,代码行数:18,代码来源:mythproto.py
示例10: 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
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(whence),
str(curhigh),str(curlow)])\
).split(BACKEND_SEP)
if res[0] == '-1':
raise MythFileError(MythError.FILE_FAILED_SEEK, \
str(self), offset, whence)
self._pos = self.joinInt(*res)
开发者ID:DocOnDev,项目名称:mythtv,代码行数:40,代码来源:mythproto.py
示例11: toString
def toString(self):
"""
Program.toString() -> string representation
for use with backend protocol commands
"""
return BACKEND_SEP.join(self._deprocess())
开发者ID:camdbug,项目名称:mythtv,代码行数:6,代码来源:mythproto.py
示例12: getHash
def getHash(self, file, sgroup, host=None):
"""FileOps.getHash(file, storagegroup, host) -> hash string"""
m = [file, sgroup]
if host:
m.append(host)
return self.backendCommand(BACKEND_SEP.join(m))
开发者ID:camdbug,项目名称:mythtv,代码行数:6,代码来源:mythproto.py
示例13: deleteFile
def deleteFile(self, file, sgroup):
"""FileOps.deleteFile(file, storagegroup) -> retcode"""
return self.backendCommand(BACKEND_SEP.join(\
['DELETE_FILE',file,sgroup]))
开发者ID:camdbug,项目名称:mythtv,代码行数:4,代码来源:mythproto.py
示例14: forgetRecording
def forgetRecording(self, program):
"""FileOps.forgetRecording(program) -> None"""
self.backendCommand(BACKEND_SEP.join(['FORGET_RECORDING',
program.toString()]))
开发者ID:camdbug,项目名称:mythtv,代码行数: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:camdbug,项目名称:mythtv,代码行数:5,代码来源:mythproto.py
示例16: getHash
def getHash(self, file, sgroup):
"""FileOps.getHash(file, storagegroup) -> hash string"""
return self.backendCommand(BACKEND_SEP.join((\
'QUERY_FILE_HASH',file, sgroup)))
开发者ID:DocOnDev,项目名称:mythtv,代码行数:4,代码来源:mythproto.py
注:本文中的static.BACKEND_SEP类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论