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
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)
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
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
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
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
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
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)
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')
def handle_split_key(self, filename): try: pubkey = M2Crypto.RSA.load_pub_key(String(filename)) return (pubkey.e, pubkey.n) except: return False
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))
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)