Exemplo n.º 1
0
 def __init__(self,
              drive_name = None,
              timeout = None,
              **kw):
     # Call ancestor init with the remaining keywords
     Message.__init__(self, **kw)
     self.drive_name = drive_name
     self.timeout = timeout
Exemplo n.º 2
0
 def __init__(self,
              origin_node,
              destination_key,
              Response_service=SERVICE_SHELVER,
              file_type="GET"):
     Message.__init__(self, SERVICE_SHELVER, file_type)
     self.origin_node = origin_node
     self.destination_key = destination_key
     self.add_content("service", Response_service)
     self.reply_to = origin_node
Exemplo n.º 3
0
 def __init__(self, action, arg, kw={}):
     """ Action message constructor.
     @param action: Type of the action to perform. The name of the handler will depend on the action name.
     @type action: C{str}
     @param arg: Arguments attached to the action (Empty tuple (C{()}) for none).
     @type arg: C{tuple or list}
     @param kw: Keywords (optional arguments) attached to the action (Empty dictionnary (C{E{lb}E{rb}}) for none).
     @type kw: C{dict}
     """
     Message.__init__(self, (action, arg, kw))
Exemplo n.º 4
0
 def __init__(self, db, fields):
     """
         Initializes a new IM conversation using a dictionary
         of database fields.
     """
     
     Message.__init__(self, db, fields)
     
     self.remoteId = fields['strIMRemoteId']
     
     self.entries = []
Exemplo n.º 5
0
 def __init__(self, db, fields):
     """
         Initializes a new Sms using a dictionary
         of database fields.
     """
     
     Message.__init__(self, db, fields)
     
     self.remoteId = fields['intSmsRemoteId']
     
     self.text = fields['strSmsText']
Exemplo n.º 6
0
 def __init__(self, db, fields):
     """
         Initializes a new Email using a dictionary
         of database fields.
     """
     fields['strMessageType'] = 'imap'
     
     Message.__init__(self, db, fields)
     
     encryptionKey = settings.settings['userDataEncryptionSalt'] + message._password
     
     self.remoteId = fields['intEmailRemoteId']
     
     self.subject = fields['strEmailSubject']
     
     self.bodyPlain = fields['strEmailBodyPlainText']
     self.bodyPlain = encryption.decrypt(encryptionKey, self.bodyPlain)
     
     self.bodyHtml = fields['strEmailBodyHtml']
     self.bodyHtml = encryption.decrypt(encryptionKey, self.bodyHtml)
     
     if 'strRaw' in fields:
         self.raw = fields['strRaw']
         self.raw = encryption.decrypt(encryptionKey, self.raw)
Exemplo n.º 7
0
 def __init__(self, sender, recipient):
     """initializes an ACK message. """
     # create an empty message
     Message.__init__(self, sender, recipient, [])
     # set the signal
     self.signal = 'ACK'
Exemplo n.º 8
0
 def __init__(self, origin_node, destination_key):
     Message.__init__(self, "SEC", "MSG")
     self.origin_node = origin_node  # node that just sent this message
     self.destination_key = destination_key  # the key we're trying to find the node responsible for
Exemplo n.º 9
0
 def __init__(self,
              timestamp = -1,
              **kw):
     # Call ancestor init with the remaining keywords
     Message.__init__(self, **kw)
     self.timestamp = timestamp
Exemplo n.º 10
0
	def __init__(self, msgfile, userdir=None, images=None, **keywords):

		Message.__init__(self)
		msgheaders = []

		if userdir is None:
			userdir = cfgdata.USERDIR

		try:
			f = open(os.path.join(userdir, msgfile), 'r')

			# File can start with comments, denoted by a starting # sign;
			curline = f.readline()
			while curline and curline[0].strip() == '#':
				curline = f.readline()

			# Then comes the header fields, concluded with a '--' line;
			while curline and curline.strip() != '--':
				curline = curline.strip()

				headerpair = curline.split(':',1)

				if len(headerpair) == 2:
					hdrname, hdrval = headerpair

					hdrname = hdrname.strip()

					hdrval  = hdrval.strip()
					hdrval  = Template(hdrval).safe_substitute(**keywords)

					msgheaders.append( (hdrname, hdrval) )

					curline = f.readline()
				else:
					logging.warning('User message "%s" contains improperly formatted '
							'header: "%s"', msgfile, curline)
					raise

			# The rest will be the message body;
			if curline:
				msgdata = f.read().strip()
				msgdata = Template(msgdata).safe_substitute(**keywords)

			else:
				msgdata = ""

		except:
			logging.info('Could not open user message file')
			raise

		# Compose user response message;
		if images == None:
			rawmsg = MIMEText(msgdata)
		else:
			txtmsg = MIMEText(msgdata)
			rawmsg = MIMEMultipart()
			rawmsg.attach(txtmsg)
			# Attach images
			for imgfile in images:
				# image paths should probably be taken relative to userdir;
				# imgfile = os.path.join(userdir, imgfile)
				fp = open(imgfile, 'rb')
				img = MIMEImage(fp.read())
				fp.close()
				rawmsg.attach(img)

		self.set_payload(rawmsg.get_payload())
		for hdr in rawmsg.keys():
			self.add_header(hdr, rawmsg[hdr])

		for hdr in msgheaders:
			self.add_header(*hdr)
Exemplo n.º 11
0
 def __init__(self, coord, node_name, slack):
     """ initializes an ADJ_SLK message. """
     # create the message
     Message.__init__(self, coord, node_name, slack)
     # set the signal
     self.signal = 'ADJ_SLK'
Exemplo n.º 12
0
 def __init__(self, coord, nodeList, estimate):
     """ initializes the new special message."""
     # create the message
     Message.__init__(self, coord, nodeList, estimate)
     # then, set the signal
     self.signal = 'NEW_EST'
Exemplo n.º 13
0
 def __init__(self, origin_node, backup_pile):
     Message.__init__(self, SERVICE_SHELVER, "BACKUP")
     self.origin_node = origin_node
     self.add_content("backup", backup_pile)
     self.reply_to = origin_node
Exemplo n.º 14
0
 def __init__(self, drive_name=None, timeout=None, **kw):
     # Call ancestor init with the remaining keywords
     Message.__init__(self, **kw)
     self.drive_name = drive_name
     self.timeout = timeout
Exemplo n.º 15
0
 def __init__(self, src, dests):
     Message.__init__(self, src, dests)
Exemplo n.º 16
0
	def __init__(self, cmd, content="", *params):
		Message.__init__(self, cmd, content, *params)
		self.content = content
Exemplo n.º 17
0
    def __init__(self, src, req_id):
        Message.__init__(self, src, None)

        # The id that identifies the request itself
        self.req_id = req_id
Exemplo n.º 18
0
 def __init__(self, node_name, coord, init_stats, weight):
     Message.__init__(self, node_name, coord, init_stats)
     self.signal = 'INIT'
     self.weight = weight
Exemplo n.º 19
0
 def __init__(self, type):
     Message.__init__(self, "MINER", type)
Exemplo n.º 20
0
 def __init__(self, coord, node_name):
     """ initializes the REQ message. """
     Message.__init__(self, coord, node_name)
     self.signal = 'REQ'
Exemplo n.º 21
0
 def __init__(self, node_name, coord, init_stats, weight):
     Message.__init__(self, node_name, coord, init_stats)
     self.signal = 'INIT'
     self.weight = weight
Exemplo n.º 22
0
 def __init__(self, node_name, coord, local_stats, drift):
     """ initializes a REP message. """
     # create the message. Content contains two vectors here
     Message.__init__(self, node_name, coord, (local_stats, drift))
     # and set the signal to REP (so as coord treat it properly)
     self.signal = 'REP'
Exemplo n.º 23
0
 def __init__(self, origin_node, destination_key, Response_service=SERVICE_CFS, action="GET"):
     Message.__init__(self, SERVICE_CFS, action)
     self.origin_node = origin_node
     self.destination_key = destination_key
     self.add_content("service",Response_service)
     self.reply_to = origin_node
Exemplo n.º 24
0
 def __init__(self, sender, recipient):
     """initializes an ACK message. """
     # create an empty message
     Message.__init__(self, sender, recipient, [])
     # set the signal
     self.signal = 'ACK'
Exemplo n.º 25
0
 def __init__(self, origin_node, destination_key):
     Message.__init__(self, "SEC", "MSG")
     self.origin_node = origin_node  # node that just sent this message
     self.destination_key = destination_key  # the key we're trying to find the node responsible for
 def __init__(self, text, shift):
     Message.__init__(self, text)
     self.shift = shift
     self.encrypting_dict = self.build_shift_dict(shift)
     self.message_text_encrypted = self.apply_shift(shift)
Exemplo n.º 27
0
 def __init__(self, origin_node, backup_pile):
     Message.__init__(self, SERVICE_SHELVER, "BACKUP")
     self.origin_node = origin_node
     self.add_content("backup",backup_pile)
     self.reply_to = origin_node
Exemplo n.º 28
0
 def __init__(self, coord, node_name):
     """ initializes the REQ message. """
     Message.__init__(self, coord, node_name)
     self.signal = 'REQ'
Exemplo n.º 29
0
 def __init__(self, timestamp=-1, **kw):
     # Call ancestor init with the remaining keywords
     Message.__init__(self, **kw)
     self.timestamp = timestamp
Exemplo n.º 30
0
 def __init__(self, cmd, content="", *params):
     Message.__init__(self, cmd, content, *params)
     self.content = content
Exemplo n.º 31
0
 def __init__(self, coord, nodeList, estimate):
     """ initializes the new special message."""
     # create the message
     Message.__init__(self, coord, nodeList, estimate)
     # then, set the signal
     self.signal = 'NEW_EST'
Exemplo n.º 32
0
 def __init__(self, node_name, coord, local_stats, drift):
     """ initializes a REP message. """
     # create the message. Content contains two vectors here
     Message.__init__(self, node_name, coord, (local_stats, drift))
     # and set the signal to REP (so as coord treat it properly)
     self.signal = 'REP'
Exemplo n.º 33
0
 def __init__(self, coord, node_name, slack):
     """ initializes an ADJ_SLK message. """
     # create the message
     Message.__init__(self, coord, node_name, slack)
     # set the signal
     self.signal = 'ADJ_SLK'
Exemplo n.º 34
0
 def __init__(self, origin_node, destination_key, Response_service="WEBSERVICE", file_type="GET"):
     Message.__init__(self, SERVICE_SHELVER, file_type)
     self.origin_node = origin_node
     self.destination_key = destination_key
     self.add_content("service",Response_service)
     self.reply_to = origin_node
 def __init__(self, text):
     Message.__init__(self, text)