本文整理汇总了Python中interpreter.Interpreter.buildGetFile方法的典型用法代码示例。如果您正苦于以下问题:Python Interpreter.buildGetFile方法的具体用法?Python Interpreter.buildGetFile怎么用?Python Interpreter.buildGetFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interpreter.Interpreter
的用法示例。
在下文中一共展示了Interpreter.buildGetFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Modem
# 需要导入模块: from interpreter import Interpreter [as 别名]
# 或者: from interpreter.Interpreter import buildGetFile [as 别名]
#.........这里部分代码省略.........
self.status = Modem.Status.BUSY2REQ
name = os.path.basename(file_path)
size = os.path.getsize(file_path)
self.send(self.interpreter.buildSendFile(name,size))
#sleep(self.m_to/2) #to give the rx the time to parse the command
while self.status != Modem.Status.IDLE and self.status != Modem.Status.KILL:
sleep(self.m_to)
# self.recvCommand()
if self.status == Modem.Status.KILL:
return self.close()
self.status = Modem.Status.BUSY2DATA
f = open (file_path, "rb")
l = f.read(self.conn.data_buf_size)
while (l):
self.conn.send(l)
l = f.read(self.conn.data_buf_size)
f.close()
self.status = Modem.Status.IDLE
def reqDataFile(self, file_name, delete_flag = 1):
"""
Require a file from the submerged node
@param self pointer to the class object
@param file_name name of the required file
@param delete_flag, if 1 erase it after sending, if 0 not
"""
while self.status != Modem.Status.IDLE :
sleep(0.1)
if self.status != Modem.Status.IDLE:
raise ValueError("Modem reqDataFile unexpected status: \
" + str(self.status))
self.status = Modem.Status.BUSY2REQ
self.send(self.interpreter.buildGetFile(file_name, delete_flag))
while self.status != Modem.Status.IDLE and self.status != Modem.Status.KILL:
sleep(self.m_to)
# self.recvCommand()
if self.status == Modem.Status.KILL:
return self.close()
return self.errorCheck()
def reqAllData(self, delete_flag = 1):
"""
Require all the data from the submerged node
@param self pointer to the class object
@param delete_flag, if 1 erase it after sending, if 0 not
"""
while self.status != Modem.Status.IDLE :
sleep(0.1)
if self.status != Modem.Status.IDLE:
raise ValueError("Modem reqAllData unexpected status: \
" + str(self.status))
self.status = Modem.Status.BUSY2REQ
self.send(self.interpreter.buildGetData(delete_flag))
while self.status != Modem.Status.IDLE and self.status != Modem.Status.KILL:
sleep(self.m_to)
# self.recvCommand()
if self.status == Modem.Status.KILL:
return self.close()
return self.errorCheck()
def reqRTData(self, ID_list, starting_time, duration, \
chunck_duration = 1, delete = 1, force_flag = 0):
"""
Require the data real time from the submerged node.
@param self pointer to the class object