示例#1
0
 def handle_fix_request1(self, arg1):
     #
     # Add your processing here.
     #
     arg1 = String(arg1)
     dbg_write('handling arg1: %s' % arg1)
     result = [arg1.upper(), ]
     return Atom('fix_request1'), result
 def handle_search(self, count, file_name, search_str):
     #
     # Add your processing here.
     #
     file_name = String(file_name)
     search_str = String(search_str)
     dbg_write('handling count: %s  file_name: %s  search_str: "%s"' % (
         count,
         file_name,
         search_str,
     ))
     doc = etree.parse(file_name)
     root = doc.getroot()
     result = root.xpath(search_str)
     return Atom('search'), count, result
示例#3
0
 def handle_fix_request1(self, process_count, task_count, file_name,
                         search_str):
     #
     # Add your processing here.
     #
     file_name = String(file_name)
     search_str = String(search_str)
     ##         dbg_write('1. process: %d  task: %s  file: %s  search: "%s"' % (
     ##             process_count, task_count, file_name, search_str, ))
     doc = etree.parse(file_name)
     root = doc.getroot()
     result = root.xpath(search_str)
     ##         dbg_write('2. process: %d  task: %s  file: %s  result len: %s' % (
     ##             process_count, task_count, file_name, len(result), ))
     return (Atom('task_response'), Atom('fix_request1'), process_count,
             task_count, result)
示例#4
0
 def handle_names(self, filename):
     filename = String(filename)
     dbg_write('handling filename: %s' % filename)
     doc = etree.parse(filename)
     root = doc.getroot()
     names = root.xpath('.//client/name/text()')
     dbg_write('returning names: %s' % (names, ))
     return names
示例#5
0
 def handle_decrypt(self, pem, message):
     try:
         Key = M2Crypto.RSA.load_key_string(pem)
     except:
         return "key read error"
     clear = Key.private_decrypt(
         String(message).decode('base64'), M2Crypto.RSA.pkcs1_oaep_padding)
     return clear
示例#6
0
 def handle_interestdescriptions(self, filename):
     filename = String(filename)
     dbg_write('handling filename: %s' % filename)
     doc = etree.parse(filename)
     root = doc.getroot()
     names = root.xpath('.//client/interest/description/text()')
     size = 0
     for name in names:
         size += len(name)
     dbg_write('returning size: %d' % (size, ))
     return size, names
示例#7
0
 def handle_name_interest(self, filename):
     filename = String(filename)
     dbg_write('handling filename: %s' % filename)
     doc = etree.parse(filename)
     root = doc.getroot()
     clients = root.xpath('./client')
     result = []
     for client in clients:
         name = client.xpath('./name/text()')
         if name:
             name = name[0]
             interests = client.xpath('./interest/name/text()')
             if interests:
                 result.append((name, interests))
     return Atom('name_interest'), result
示例#8
0
 def handle_name_address(self, filename):
     filename = String(filename)
     dbg_write('handling filename: %s' % filename)
     doc = etree.parse(filename)
     root = doc.getroot()
     clients = root.xpath('./client')
     result = []
     for client in clients:
         name = client.xpath('./name/text()')
         if name:
             name = name[0]
         address = client.xpath('./address/text()')
         if address:
             address = address[0]
         result.append((name, address))
     return Atom('name_address'), result
示例#9
0
 def handle_fix_request1(self, count, arg1, arg2, arg3):
     #
     # Add your processing here.
     #
     arg1_str = String(arg1)
     arg2_atom = Atom(arg2)
     dbg_write("handling request1 -- count: $s  arg1: %s arg2: %s\n" % (
         count,
         arg1_str,
         arg2_atom,
     ))
     #
     # Add your processing here.
     #
     result = None
     return Atom('fix_request1'), count, result
 def handle_hello(self, name):
     # String wrapper forces name to be a string instead of a list
     return "Hello, %s" % String(name)
示例#11
0
 def handle_encrypt(self, e, n, message):
     pubkey = M2Crypto.RSA.new_pub_key((str(e), str(n)))
     ciphertext = pubkey.public_encrypt(String(message),
                                        M2Crypto.RSA.pkcs1_oaep_padding)
     return ciphertext.encode('base64')
示例#12
0
 def handle_split_key(self, filename):
     try:
         pubkey = M2Crypto.RSA.load_pub_key(String(filename))
         return (pubkey.e, pubkey.n)
     except:
         return False
示例#13
0
 def handle_sign(self, pem, message):
     try:
         Key = M2Crypto.RSA.load_key_string(pem)
     except:
         return "key read error"
     return Key.sign_rsassa_pss(String(message)).encode('base64')
 def handle_create(self, db_name, id, rev):
     doc_changed.delay(String(db_name), String(id), String(rev))
示例#15
0
	def handle_guess(self, filename):
		print filename
		return guessit.guess_video_info(String(filename), info = ['filename'])
 def handle_hello(self, name):
     return "Hello, %s" % String(name)