def msgpack_client(): # メッセージバックによるRPC実装のクライアント from msgpackrpc import Client, Address client = Client(Address("localhost", 6789)) # サーバーに接続 num = 8 result = client.call('double', num) # double をリモート呼び出し print("Double %s is %s" % (num, result))
def order_info(increment_id): client = xmlrpc.client.ServerProxy(secrets.magento_api_xmlrpc_url) session = client.login(secrets.magento_api_user, secrets.magento_api_pass) response = client.call(session, 'sales_order.info', [increment_id]) return response
def deluge(self, path, torrent_path, torrent, local_path, remote_path, client, meta): client = DelugeRPCClient(client['deluge_url'], int(client['deluge_port']), client['deluge_user'], client['deluge_pass']) # client = LocalDelugeRPCClient() client.connect() if client.connected == True: print("Deluge connected") isdir = os.path.isdir(path) #Remote path mount if local_path in path and local_path != remote_path: path = path.replace(local_path, remote_path) path = path.replace(os.sep, '/') # if isdir == False: else: path = os.path.dirname(path) client.call('core.add_torrent_file', torrent_path, base64.b64encode(torrent.dump()), {'download_location' : path, 'seed_mode' : True}) if meta['debug']: cprint(f"Path: {path}", 'cyan') else: cprint("Unable to connect to deluge", 'grey', 'on_red')
def product_info(product_id_or_sku): client = xmlrpc.client.ServerProxy(secrets.magento_api_xmlrpc_url) session = client.login(secrets.magento_api_user, secrets.magento_api_pass) try: response = client.call(session, 'catalog_product.info', [product_id_or_sku]) return response except xmlrpc.client.Fault as f: logging.warning( "error while retrieving product info for {0}. {1}".format( product_id_or_sku, f.faultString)) return None
def products_list(updated_at_days_ago): start_date_delta_load = ( datetime.today() - timedelta(days=updated_at_days_ago)).strftime("%Y-%m-%d 00:00:00") client = xmlrpc.client.ServerProxy(secrets.magento_api_xmlrpc_url) session = client.login(secrets.magento_api_user, secrets.magento_api_pass) response = client.call(session, 'catalog_product.list', [{ 'updated_at': { 'from': start_date_delta_load } }]) logging.debug("retrieved {0} products".format(len(response))) return response