예제 #1
0
 def send_query(self, package):
     # TODO: Handle larger packages on client side (what is needed?!)
     self.logger.debug("Sending package:" + str(package))
     message = (json.write(package) + u"\u0000").encode('utf-8')
     self.logger.debug(repr(message))
     try:
         self.client_sock.sendall(message)
     except bluetooth.BluetoothError:
         self.logger.debug("Trying to send while remote side was disconnected")
예제 #2
0
 def send_query(self, package):
     """Send query to phone serialized as json data"""
     self.logger.debug("Sending package:" + str(package))
     message = (json.write(package) + u"\u0000").encode('utf-8')
     self.logger.debug(repr(message))
     try:
         self.client_sock.sendall(message)
     except bluetooth.BluetoothError:
         self.logger.debug(
                         "Trying to send while remote side was disconnected")
     self.logger.debug("Package send done")
예제 #3
0
 def _write_config(absfilename, config):
     """
     Serialize configuration stored in C{config} and write to file
     
     @param    absfilename:    Filename to store config in
     @type     absfilename:    String
     @param    config:         dictionary holding the config data
     @type     config:         dictionary
     """
     config_file = open(absfilename, 'w')
     config_data = json.write(config, pretty_print=True)
     config_file.write(config_data)
     config_file.close()
예제 #4
0
 def _write_config(absfilename, source_config_data):
     """
     Serialize configuration stored in C{config} and write to file
     
     @param    absfilename:    Filename to store config in
     @type     absfilename:    String
     @param    config:         dictionary holding the config data
     @type     config:         dictionary
     """
     try:
         config_file = open(absfilename, 'w')
         config_data = json.write(source_config_data, pretty_print=True)
         config_file.write(config_data)
         config_file.close()
     except IOError:
         logging.getLogger('LBRC.Config').exception(
                             _("Error while writing to: %s") % absfilename)
     except json.ReadException:
         logging.getLogger('LBRC.Config').exception(
                             _("Error while encoding config data to json"))