 All right. Hello, everyone. Welcome back on board to some Python programming looking at the XML RPC lib module I'm at the documentation right now online and we were looking at it in the last video kind of researching learning more about it I'm going through some I don't know just the documentation and reading and trying to understand what it is We can do and work with this with this module so We were looking at the documentation online for Python of course and then eventually we kind of found this XML RPC how to with the Linux documentation project and It had a lot of kind of cool information and one of the things that was showing us was the common XML RPC interfaces And it was showing us these functions that we could call to explore more of the servers that we're looking at so I want to got to use this video as a Vessel and a way to go about with the demonstration to actually type this code and show you what it does And that sort of thing so I'm gonna fire up idle right now I'm not gonna actually go into a code editor or a text editor for any of this I'm just gonna do it within the Python shell And you can see on this page that I'm at in the XML RPC how to the Linux documentation project We have some Python code presented to us when we're showing ourselves the introspection and discovering the server APIs and Learning more about the server that we're actually working with so here's the Python code right here that we're looking at I'm just gonna go ahead and type this And really execute it so you can watch it and understand what it's doing and that sort of thing So anyway, let's get let's get started here import XML RPC lib By default it is a built-in library. So I mean at least my Python has it. I'm on Windows I'm sure it would have it in Linux and I don't know. I don't know. It's just built in Okay, get back to the code The next line is actually setting a server object or a variable to kind of maintain the connection that we've got with this server Name here and what I'm gonna do is I'm gonna copy this because I don't know I want to really want to type it but this is live. This is working. This is just an example One that we can use in our code and actually experiment and play with so what I'm gonna do is actually set a Variable name for this server name and equal this and that's set for us. Yeah, okay Now in the last tutorial in the last video, we were looking at the server Kind of call and function class that what's what's created there and it left us a note that server is actually Kind of old it's deprecated. It's it's it's left for backwards compatibility But now they're using server proxy. So we'll go ahead and use that in our code I'll say server can equal XML RPC lib dot server Proxy capital P and capital S of course for server and we'll pass in It says a URI These other options that we can pass but I'm not gonna go into too much of that We'll pass in our server name and now we've got our server. We can see it's a server proxy object For this location and this is the server XML RPC server that we're looking at so For introspection and for discovering server APIs the documentation in the the Python centered library Which telling us that there is a reserved attribute server dot system The dot system is the keyword there that actually contains all of the methods that we can look at all at least Looking at list methods and method help on that sort of thing So let's build this loop that they're showing us here and we'll say for a method in server dot system list methods and We'll say print method We'll do print server dot system method help Pass in the method Now method is a string Because we're looping through a list of strings here and method help takes a string You can see up here Out of the top of this kind of guide. It's telling us that yeah, this is gonna return a list or an array method help we'll return a string and it takes a string and Then we'll just print out a new line So now we hit enter and hey, okay now it goes through connects the server and looks at everything we can do there is a sample dot ad and this will add two numbers and These are things that are kind of unique to this server the thing that we're connected to the XML RPC Location that we're calling these other ones like system list methods and system method help and system method signature like we've seen are just Kind of introspection and discovering server API stuff. That's part of the server These other ones sample dot ad sample sum and difference are Methods and functions that have been given to the server that are offered and we can call and use so we use them by server and the dot selector to get to a new a new thing here and This method how it's written here is how we're gonna end up using it So sample will exist and if I use control space here You see that nothing is gonna show up in my idle like environment because it's not able to read What it has we're getting this information online from the server So idle is not to be able to parse through it and find the possible Code completion stuff for the functions and variables that are part of the package because we don't know what's part of the package yet That's why we were able to look through it with list methods So if I did server dot sample dot ad it adds two numbers So I'm gonna have to assume that it takes two arguments. So if I said one and two This isn't gonna return anything for us or at least it might yeah, okay, cool so it just returns three if I were to print this out, it'll do the same thing and Hmm not found is my server still on System To Nope, okay, let's head back here connect one more time Hmm. Oh Of course, I'm typing server system ad. I'm sorry. I'm an idiot. This kind of shows why it's important and crucial to use the actual name even if it has a kind of a subclass to it sample and Debug here system is reserved for of course list methods method help and method signature But I've been typing server dot system. I should have been typing server dot sample and now that works for us fantastic So that's really kind of how it all pieces together What we can do is we can look through server simple. Sorry server dot system List methods to see what is available to us and then we call them from the server and Let's see. There's another one some and difference. Let's do some and difference and Say three and eight Now it's returned to us to dictionary a Python dict The sum is 11 and the difference is negative five. Of course, we can say. Oh, yeah, this is just going to be our result And we can use results indexed with some Get the sum and Difference to get negative five the difference This works exactly like a Python dick and it's been returned to us through this XML RPC server that we connected to and That's all that we did we've created a server proxy object With the server name that we specify We look through the lists we look through a list of the methods and the things that it can do because of our introspection discovering the server APIs and functions and then we can call them just by knowing their name This method help function can give us a description of what it does and That's hopefully how we can learn more about it like the arguments that it takes and that sort of thing so That's the way that it goes XML RPC client just connecting to it by calling a server proxy object passing in the server name and Finding the functions you want to use and call and then calling them so super simple super cool. Hope you enjoyed this Sorry about my little mess up with a System and sample. That's my own fault But just to reiterate know the names of the functions you're calling so thanks for watching guys Hope you enjoyed this if you are liking these videos. Maybe like maybe like the video Maybe leave a comment. Maybe subscribe. I mean it's up to you. All right. See you in the next tutorial guys. All right