HTTPRequest Plugin - v0.1.0

Questions and comments specific to a particular plugin should go here.
Mastiff
Experienced User
Posts: 865
Joined: Thu May 03, 2012 10:43 am

Re: HTTPRequest Plugin - v0.1.0

Post by Mastiff » Sun Jan 28, 2018 9:08 pm

Actually I've already spent an hour going over my full setup of Girder that sends to EG and fixed all those calls. So now I send like I showed over, and it comes up as I wanted to, thanks! :mrgreen: Do I have to redo that when the next beta comes out, or will the "Payload0 Payload1 Payload2" format still work?

As for the answer to the original question, it worked! Thanks! :mrgreen:

User avatar
kgschlosser
Site Admin
Posts: 4179
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: HTTPRequest Plugin - v0.1.0

Post by kgschlosser » Sun Jan 28, 2018 9:11 pm

if you look up standard HTTP responses you will find that 200 means OK/Successful. This is a good means to make sure the transmit was good before carrying out any operations on the returned content. if it failed the content will not be what you code is going to expect. it also gives you a nice mechanism to allow your script to keep on running without throwing a exception that will make it come to a grinding halt. it's a nice mechanism to also stop the macro and exit the script.

Code: Select all

foo=eg.plugins.HTTPRequest.sendRequest(u'192.168.0.1:56565', uri=u'/devices')

if foo != 200:
    eg.StopMacro()
    eg.Exit()
    
    
content = foo.content

print content
If you like the work I have been doing then feel free to Image

Mastiff
Experienced User
Posts: 865
Joined: Thu May 03, 2012 10:43 am

Re: HTTPRequest Plugin - v0.1.0

Post by Mastiff » Sun Jan 28, 2018 9:16 pm

Thanks, I actually said that on the previous page, "But the return is nothing but 200 (wich means that the request went through without errors)", badly worded, but that's what I meant. A 200 is a successful call. I was thinking of something like that to break it, yeah. But thanks for showing me the best way of doing it! :mrgreen:

User avatar
kgschlosser
Site Admin
Posts: 4179
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: HTTPRequest Plugin - v0.1.0

Post by kgschlosser » Sun Jan 28, 2018 9:18 pm

I am going to try and make a mechanism that will parse the command line string that will allow for both ways to work properly. I am not sure if others agree with me on having the ability to key in a specific data set when triggering an event. I also want to include the availability of parsing global variable names as payload data as well. This would ake it a more centralized management for the user. they can house the actual data in a global.


place python code containing the following code example in autostart

Code: Select all


class RemoteCodes:
    direction_up = 'Some remote code here'
    
eg.globals.remote_codes = RemoteCodes

and the cli for triggering the event would be something as follows

Code: Select all


eventghost -event Send.RemoteCode eg.globals.remote_codes.direction_up

and the event would be shown as follows.

Send.RemoteCode "Some remote code here"
If you like the work I have been doing then feel free to Image

Mastiff
Experienced User
Posts: 865
Joined: Thu May 03, 2012 10:43 am

Re: HTTPRequest Plugin - v0.1.0

Post by Mastiff » Sun Jan 28, 2018 9:22 pm

I'm glad if it can take both types of payload. But I'm afraid I didn't really understand much of the rest... :oops: I'm a lousy prorammer, more like a copycat, really. I find stuff that does what I need and tweak it. And I have had a lot of help getting my system up to where it is now. I'll never bee a good coder. :mrgreen:

User avatar
kgschlosser
Site Admin
Posts: 4179
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: HTTPRequest Plugin - v0.1.0

Post by kgschlosser » Sun Jan 28, 2018 9:25 pm

Yeha Yeah I got ya on the 200 thing. I wanted you to look at the standard codes. because this is a real nice way to execute some standard troubleshooting/repair procedures if the transmission has failed. like rebooting whatever it is that you are supposed to be connecting to. or if what you are connecting to is not local you could have EG reboot your router. to try and make the connection work properly for ya. have it handle the first steps that get taken when something doesn't connect properly. then if it still fails you know the first steps have been done so you don't have to waste the time messing around. you can go right into the meat and potatoes of trying to get to the root of the problem.
If you like the work I have been doing then feel free to Image

Mastiff
Experienced User
Posts: 865
Joined: Thu May 03, 2012 10:43 am

Re: HTTPRequest Plugin - v0.1.0

Post by Mastiff » Sun Jan 28, 2018 9:35 pm

Yessir, I can get to it! So I consider that as another time I've been helped here! Thanks again! :mrgreen:

User avatar
kgschlosser
Site Admin
Posts: 4179
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: HTTPRequest Plugin - v0.1.0

Post by kgschlosser » Sun Jan 28, 2018 9:40 pm

Mastiff wrote:
Sun Jan 28, 2018 9:22 pm
But I'm afraid I didn't really understand much of the rest
in a word. Google. in another word Boolean. search for it. learn how to use google to narrow what you are looking for. You can ask me anything you like (programming related, all other questions meh... possibly I will answer). I do not have that "programmer god complex" I started exactly the same as you. and in fact I am still a lousy programmer. but that does not stop me.

My thoughts on this are (this is not directed at you this is if someone else was criticizing my work)."if you don't like it don't use it. if you can make it better. then make it better. share the wealth of knowledge that you have with me so I to can make exceptional pieces of software. And if you do not want to do that.. then ^#@& off!"

if you have an android device. download this little application called Learn Python. Its very kindergartenish but for some really odd reason it's highly addictive. and you will learn a heap load from it.
Mastiff wrote:
Sun Jan 28, 2018 9:22 pm
I'm a lousy prorammer, more like a copycat, really. I find stuff that does what I need and tweak it.
that is how every programmer gets started. you learn by reading, using and modifying. you learn how things work that way. I have spend thousands of hours doing this. and in fact I still do it. Why reinvent the wheel? if someone has already key up some code that works and they posted it on the internet. then use it! if you do not understand how it works then tinker around a bit and figure it out. But why spend time writing and debugging when someone else has done this already??? You may need to modify it to add you coding style to it but use what works.
Mastiff wrote:
Sun Jan 28, 2018 9:22 pm
And I have had a lot of help getting my system up to where it is now.
who hasn't?
Mastiff wrote:
Sun Jan 28, 2018 9:22 pm
I'll never bee a good coder.
there is only one thing i can say to this.

BULLSHIT

sorry for the language but that's about the only word that fits that statement.

you are stopping before you have even started. stated you lost the race but never even ran it. I have only been programming for maybe 2.5 years tops. That's all.I am 100% self taught No schools or teachers. hell i really didn't even have anyone to ask (except google). you have the only tool that is ever needed to do anything.. you know how to read!
If you like the work I have been doing then feel free to Image

Mastiff
Experienced User
Posts: 865
Joined: Thu May 03, 2012 10:43 am

Re: HTTPRequest Plugin - v0.1.0

Post by Mastiff » Sun Jan 28, 2018 9:54 pm

Thanks for the vote of confidence! :) And I understand exactly what you mean. I can admit that I'm good at making code do what I want, and I'm great at asking people nicely to help me out! Which is maybe the best skill there is for stuff like this. So I have a house and a cabin running a smart home system all of my own making, with lots of help, and I keep expanding it. I have had lots of people saying "why don't you use HomeSeer" or stuff like that, but I started with Girder and LUA maybe 15 years ago, and then expanded to Python about 4-5 years ago. And I always manage to get the stuff working in the end, by perserverence. So I think I'm a decent coder. I don't really aspire to be a very good/great coder (and I don't have that much time with a busy translation job), but I do want to be able to do what I want to do practically (like controling audio, video, lights, heat and so on), and I do manage to do it, bit by bit. :mrgreen:

coup
Posts: 1
Joined: Thu Apr 05, 2018 2:12 am

Re: HTTPRequest Plugin - v0.1.0

Post by coup » Thu Apr 05, 2018 2:14 am

I'm getting the following error when I try to use the plugin. Not sure if I'm doing something wrong or missing something.
Error in Action: "HTTPRequest: Send HTTP request"
Traceback (most recent call last) (1722):
File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
return self(*args)
File "C:\Program Files (x86)\EventGhost\plugins\HTTPRequest\__init__.py", line 54, in __call__
"{}://{}{}".format("https" if ssl else "http", host, uri),
ValueError: zero length field name in format
Any help would be appreciated.

User avatar
kgschlosser
Site Admin
Posts: 4179
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: HTTPRequest Plugin - v0.1.0

Post by kgschlosser » Fri Apr 06, 2018 1:48 am

this plugin only works on EG 0.5 or higher
If you like the work I have been doing then feel free to Image

Post Reply