Пример #1
0
 def _StoreDataFileOnNetwork(self, data):
     if not self.data_uid:
         mist_network_client = network.MistNetworkClient(
             self.mist_network_address)
         (self.mist_network_member_uid,
          self.data_uid) = mist_network_client.StoreDataOnNetwork(data)
         self._data = None
Пример #2
0
 def SendRetrieveRequest(self, data_uid):
     self._history.append("retrieve: %s" % data_uid)
     mist_member_client = network.MistNetworkClient(self.mist_address)
     response = mist_member_client.retrieve(str(data_uid))
     if "error_message" in response:
         logger.error("Unable to retrieve data. data_uid: %s, Error: %s",
                      data_uid, response["error_message"])
         return None
     else:
         return response["data"].decode(response["encoding"])
Пример #3
0
 def Delete(self):
     if self._creation_thread:
         self._creation_thread.join(MistDataFile.DEFAULT_READ_TIMEOUT)
         if self._creation_thread.isAlive():
             logger.warning(
                 "Network File deleting has timed out as file is still being saved. Please try again later."
             )
             return False
     mist_network_client = network.MistNetworkClient(
         self.mist_network_address)
     return mist_network_client.DeleteDataOnNetwork(
         self.mist_network_member_uid, str(self.data_uid))
Пример #4
0
Файл: mist.py Проект: potay/mist
 def JoinNetwork(self, mist_network_address):
     self.mist_network_address = mist_network_address
     self.mist_network_client = network.MistNetworkClient(
         self.mist_network_address)
     self.mist_local_server = network_member.MistNetworkMemberServer(
         self, "localhost")
     self.mist_local_server.Start()
     self.mist_local_address = "http://%s:%d" % self.mist_local_server.server_address
     uid = self.mist_network_client.JoinNetwork(
         self.mist_local_address, self.mist_network_member_uid)
     if uid:
         self.mist_network_member_uid = uid
         self._RewriteMistIndexFile()
     else:
         self.mist_local_server.Stop()
Пример #5
0
 def SendDisconnectRequest(self):
     self._history.append("disconnect request")
     mist_member_client = network.MistNetworkClient(self.mist_address)
     mist_member_client.disconnect()
Пример #6
0
 def SendDeleteRequest(self, data_uid):
     self._history.append("delete: %s" % data_uid)
     mist_member_client = network.MistNetworkClient(self.mist_address)
     return mist_member_client.delete(str(data_uid))
Пример #7
0
 def SendStoreRequest(self, data):
     self._history.append("store: size: %s" % len(data))
     mist_member_client = network.MistNetworkClient(self.mist_address)
     response = mist_member_client.store(data.encode("base64"),
                                         encoding="base64")
     return uuid.UUID(response["data_uid"])