I am trying to call a method with no input arguements which is as follows :
[1]
[1]: https://i.stack.imgur.com/tGFe9.png
So far I have tried this :
method=client.get_node("ns=5;s=Demo.StateMachines.Program01.Reset")
parent=client.get_node("ns=5;s=Demo.StateMachines.Program01")
output=parent.call_method(method)
but it given me this BadNotExecutable error:
"The executable attribute does not allow the execution of the method."(BadNotExecutable)
The server is telling you this method cannot be executed.
There doesn't appear to be anything wrong with your client, check the server configuration.
Related
Im trying to make a script that sent an email with python using smtp.smtplib , almost of examples i found while googling shows how to call this function with only smtpserver and port parameters.
i want to added other paramaters : domain and binding IP
i tried this : server = smtplib.SMTP(smtpserver, 25,'mydomain.com',5,'myServerIP')
I got this as error : TypeError: init() takes at most 5 arguments (6 given)
Can you suggest a way to do this?
This error is likely because the parameters are invalid (there is one too many). Try looking at the smtplib docs to see what parameters are valid
I am currently testing a Click CLI application and get result.exit_code == 2. Why does that happen?
This appears to indicate a usage error:
An internal exception that signals a usage error. This typically aborts any further handling.
This is consistent with Click's own tests, e.g.
https://github.com/pallets/click/blob/123dd717439d8620d8d6be5574d2c9f007952326/tests/test_arguments.py#L82
https://github.com/pallets/click/blob/123dd717439d8620d8d6be5574d2c9f007952326/tests/test_arguments.py#L190
https://github.com/pallets/click/blob/123dd717439d8620d8d6be5574d2c9f007952326/tests/test_arguments.py#L201
https://github.com/pallets/click/blob/123dd717439d8620d8d6be5574d2c9f007952326/tests/test_formatting.py#L157
https://github.com/pallets/click/blob/123dd717439d8620d8d6be5574d2c9f007952326/tests/test_formatting.py#L177
https://github.com/pallets/click/blob/123dd717439d8620d8d6be5574d2c9f007952326/tests/test_formatting.py#L193
I ran
result = runner.invoke(cli, ['sync'])
instead of
result = runner.invoke(cli, ['--debug', 'sync'])
So you need to specify the flag as entered via CLI, not only pass the parameters consumed by the function if you use #click.option.
Additionally, the I made a typo for one of the flags.
How to debug
Look at the parameters you pass to runner.invoke (simplest: print it)
Execute it via CLI (e.g. cli(['--debug', 'sync']))
In my case this gave me the message
Error: no such option: --sync Did you mean --syncs?
I'm new to Cloud 9, and have made a script. I want the code to appear at the url https://python-william1835.c9.io and I receive the following message:
Important: use os.getenv(PORT, 8080) as the port and os.getenv(IP,0.0.0.0) as the host in your scripts!
when I run it.
So I put it in the script (along with import os of course). And when I run it again, it says:
File "/home/ubuntu/workspace/Python Projects/Python Enigma Program/main.py", line 14
os.getenv(IP, 0.0.0.0)
^
SyntaxError: invalid syntax
Can you tell me why it does this?
You get a SyntaxError because the literal 0.0.0.0 is syntactically invalid.
The message you're receiving is a bit misleading in this specific case. Additionally, the documentation page for os.getenv is unfortunately not as verbose as one would want.
But, if you look at the source code for getenv you'll see that all arguments must be of type str:
def getenv(key, default=None):
"""Get an environment variable, return None if it doesn't exist.
The optional second argument can specify an alternate default.
key, default and the result are str."""
return environ.get(key, default)
Changing your calls to:
os.getenv("PORT", "8080")
os.getenv("IP", "0.0.0.0")
Should work and you should have no problem using them.
I am trying to use webbrowser.open to send an email using the default mail client. My code looks like this:
mailto = "mailto:me#bla.com?subject=blabla&body=blabla"
webbrowser.open(mailto)
Although the mail client (Outlook) opens normally, I keep getting the following TypeError:
TypeError: open() takes at least 1 argument (0 given)
I tried to use something like webbrowser.open(mailto,1) but the result is still the same.
Why could this happen?
Its not the webbrowser.open, mailto is 1 argument no matter what value it is. So you need to check again where the troublesome open invoking belongs to.
I am new to python and just downloaded it today. I am using it to work on a web spider, so to test it out and make sure everything was working, I downloaded a sample code. Unfortunately, it does not work and gives me the error:
"AttributeError: 'MyShell' object has no attribute 'loaded' "
I am not sure if the code its self has an error or I failed to do something correctly when installing python. Is there anything you have to do when installing python like adding environmental variables, etc.? And what does that error generally mean?
Here is the sample code I used with imported spider class:
import chilkat
spider = chilkat.CkSpider()
spider.Initialize("www.chilkatsoft.com")
spider.AddUnspidered("http://www.chilkatsoft.com/")
for i in range(0,10):
success = spider.CrawlNext()
if (success == True):
print spider.lastUrl()
else:
if (spider.get_NumUnspidered() == 0):
print "No more URLs to spider"
else:
print spider.lastErrorText()
# Sleep 1 second before spidering the next URL.
spider.SleepMs(1000)
And what does that error generally
mean?
An Attribute in Python is a name belonging to an object - a method or a variable. An AttributeError means that the program tried to use an attribute of an object, but the object did not have the requested attribute.
For instance, string objects have the 'upper' attribute, which is a method that returns the uppercase version of the string. You could write a method that uses it like this:
def get_upper(my_string):
return my_string.upper()
However, note that there's nothing in that method to ensure that you have to give it a string. You could pass in a file object, or a number. Neither of those have the 'upper' attribute, and Python will raise an Attribute Error.
As for why you're seeing it in this instance, you haven't provided enough detail for us to work it out. Add the full error message to your question.
1) Put code in Try ... Except block. get exception details.
2) Could you tell StackTrace details means which line # and method thrown error
And also are you able to run other simple python scripts without any error. Means just try to run some sample script etc.